however is very slow.
I am developing a DLL to load md2 models with ultra speed.
so far so good, the problem is that I am not able to convert the texture coordinates
here is my code
int index=0;
float TX,TY;
for(index;index<m_header.numFrames;index++)
{
PUT<<"M=d3d_model_create();MODEL["<<index<<"]=M;"<<endl<<"d3d_model_primitive_begin(M,4)"<<endl;
for (index=0;index< m_header.numTriangles;index++)
{
v1[0] = m_glVertexData[m_triData[index].vertexIndices[2]].x - m_glVertexData[m_triData[index].vertexIndices[1]].x;
v1[1] = m_glVertexData[m_triData[index].vertexIndices[2]].y - m_glVertexData[m_triData[index].vertexIndices[1]].y;
v1[2] = m_glVertexData[m_triData[index].vertexIndices[2]].z - m_glVertexData[m_triData[index].vertexIndices[1]].z;
v2[0] = m_glVertexData[m_triData[index].vertexIndices[1]].x - m_glVertexData[m_triData[index].vertexIndices[0]].x;
v2[1] = m_glVertexData[m_triData[index].vertexIndices[1]].y - m_glVertexData[m_triData[index].vertexIndices[0]].y;
v2[2] = m_glVertexData[m_triData[index].vertexIndices[1]].z - m_glVertexData[m_triData[index].vertexIndices[0]].z;
// Take the Cross Product of v1 x v2
v3[0] = v1[1]*v2[2] - v1[2]*v2[1];
v3[1] = v1[2]*v2[0] - v1[0]*v2[2];
v3[2] = v1[0]*v2[1] - v1[1]*v2[0];
TX=((float)m_texData[m_triData[index].vertexIndices[2]].t/256);TY=((float)m_texData[m_triData[index].vertexIndices[2]].s/256);//VERTEX COORDINATES
PUT<<"d3d_model_vertex_texture(M,"<<m_glVertexData[m_triData[index].vertexIndices[2]].x<<","<<m_glVertexData[m_triData[index].vertexIndices[2]].y<<","<<m_glVertexData[m_triData[index].vertexIndices[2]].z<<","<<TX<<","<<TY<<")"<<endl;
TX=((float)m_texData[m_triData[index].vertexIndices[1]].t/256);TY=((float)m_texData[m_triData[index].vertexIndices[1]].s/256);//VERTEX COORDINATES
PUT<<"d3d_model_vertex_texture(M,"<<m_glVertexData[m_triData[index].vertexIndices[1]].x<<","<<m_glVertexData[m_triData[index].vertexIndices[1]].y<<","<<m_glVertexData[m_triData[index].vertexIndices[1]].z<<","<<TX<<","<<TY<<")"<<endl;
TX=((float)m_texData[m_triData[index].vertexIndices[0]].t/256);TY=((float)m_texData[m_triData[index].vertexIndices[0]].s/256);//VERTEX COORDINATES
PUT<<"d3d_model_vertex_texture(M,"<<m_glVertexData[m_triData[index].vertexIndices[0]].x<<","<<m_glVertexData[m_triData[index].vertexIndices[0]].y<<","<<m_glVertexData[m_triData[index].vertexIndices[0]].z<<","<<TX<<","<<TY<<")"<<endl;
}
PUT<<"d3d_model_primitive_end(M);"<<endl;
};
Code Cleared
this is the result

this is the texture

Edited by ChaosMaker, 26 April 2012 - 04:31 AM.











