Advertisement Jump to content
Sign in to follow this  
Zwingling

DX11 [DX11] Tex.Coord problem with MD2 Format!

This topic is 2835 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I just finished my MD2 Loader and when i tested the Model with its skin it fails a bit :lol: hrr3-1.jpg

I can 't figure out whats wrong. Quake use a other Coord-System so i changed the x<->y Coord to i also need to change the TexCoord :S

Here is some code from my Loader:




Save tex Vertex Data to a vector:

XMFLOAT3 NewVertex;
XMFLOAT3 NewNormal;



for(int Frame=0;Frame<m_Header.num_frames;Frame++) {
MeshFrame NewFrame;
NewFrame.Normals =new vector<XMFLOAT3>();
NewFrame.Vertices =new vector<XMFLOAT3>();

for(int i=0;i<m_Header.num_vertices;i++) {
NewVertex.x= ( m_Frames.at(Frame).Scale.x * m_Frames.at(Frame).VertexData.at(i).v[0]) + m_Frames.at(Frame).Translate.x;
NewVertex.z= ( m_Frames.at(Frame).Scale.y * m_Frames.at(Frame).VertexData.at(i).v[1]) + m_Frames.at(Frame).Translate.y;
NewVertex.y= ( m_Frames.at(Frame).Scale.z * m_Frames.at(Frame).VertexData.at(i).v[2]) + m_Frames.at(Frame).Translate.z;

NewNormal.x=Normals[m_Frames.at(Frame).VertexData.at(i).normalIndex][0];
NewNormal.z=Normals[m_Frames.at(Frame).VertexData.at(i).normalIndex][1];
NewNormal.y=Normals[m_Frames.at(Frame).VertexData.at(i).normalIndex][2];

NewFrame.Vertices->push_back(NewVertex);
NewFrame.Normals->push_back(NewNormal);
}

m_Mesh.Frame.push_back(NewFrame);
}


Save the Tex. Data to a vectore<>:

m_Mesh.TextureCoord = new vector<XMFLOAT2>();
XMFLOAT2 NewTexturCoord;


for(int i=0;i<m_Header.num_tris;i++) {
NewTexturCoord.x=(float)m_Texture.at(m_Trinagles.at(i).st[0]).s/m_Header.skinwidth;
NewTexturCoord.y=(float)m_Texture.at(m_Trinagles.at(i).st[0]).t/m_Header.skinheight;
m_Mesh.TextureCoord->push_back(NewTexturCoord);

NewTexturCoord.x=(float)m_Texture.at(m_Trinagles.at(i).st[1]).s/m_Header.skinwidth;
NewTexturCoord.y=(float)m_Texture.at(m_Trinagles.at(i).st[1]).t/m_Header.skinheight;
m_Mesh.TextureCoord->push_back(NewTexturCoord);

NewTexturCoord.x=(float)m_Texture.at(m_Trinagles.at(i).st[2]).s/m_Header.skinwidth;
NewTexturCoord.y=(float)m_Texture.at(m_Trinagles.at(i).st[2]).t/m_Header.skinheight;
m_Mesh.TextureCoord->push_back(NewTexturCoord);
}


I hope anyone can give me a advice =)

Share this post


Link to post
Share on other sites
Advertisement
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!