MD3 model seperates when swapping axes

Started by
4 comments, last by Sfpiano 19 years, 10 months ago

// for each mesh
	for(i=0; i < Header.numMeshes; i++){
		MD3Mesh *m = &Meshes;

		// allocate space and load in the vertices
		fseek(fp, mesh_offset+m->MeshH.vertex_start, SEEK_SET);
		m->Vertices =  new Vertice[m->MeshH.numVertices * m->MeshH.numMeshFrames];
		fread(m->Vertices, sizeof(Vertice), m->MeshH.numMeshFrames*m->MeshH.numVertices, fp);

                // Swap Y and Z axis
		int j;
		for(j=0; j<m->MeshH.numMeshFrames*m->MeshH.numVertices; j++){
			short temp = m->Vertices[j].Vec[2];
			m->Vertices[j].Vec[2] = -m->Vertices[j].Vec[1];
			m->Vertices[j].Vec[1] = temp;
		}
	}
  </pre>  

When I run the above code, everything loads fine, except that the upper and head parts are not connected to the lower part, and instead are resting side by side.   

<SPAN CLASS=editedby>[edited by - Sfpiano on June 6, 2004 1:51:25 PM]</SPAN>   
//------------------------------------------------------------------------------------------------------The great logician Bertrand Russell once claimed that he could prove anything if given that 1+1=1. So one day, some fool asked him, "Ok. Prove that you're the Pope." He thought for a while and proclaimed, "I am one. The Pope is one. Therefore, the Pope and I are one."
Advertisement
you need to multiply the other meshes by the tag matrix that their connected to(when rendering), thatl put them in the right spot

edit: its not a matrix on its own, youll need to turn those 3 verticies into a matrix, which can be done pretty easily...
-Dan

[edited by - Ademan555 on June 6, 2004 3:46:36 PM]
When General Patton died after World War 2 he went to the gates of Heaven to talk to St. Peter. The first thing he asked is if there were any Marines in heaven. St. Peter told him no, Marines are too rowdy for heaven. He then asked why Patton wanted to know. Patton told him he was sick of the Marines overshadowing the Army because they did more with less and were all hard-core sons of bitches. St. Peter reassured him there were no Marines so Patton went into Heaven. As he was checking out his new home he rounded a corner and saw someone in Marine Dress Blues. He ran back to St. Peter and yelled "You lied to me! There are Marines in heaven!" St. Peter said "Who him? That's just God. He wishes he were a Marine."
I''m sorry, I didn''t really follow that...
//------------------------------------------------------------------------------------------------------The great logician Bertrand Russell once claimed that he could prove anything if given that 1+1=1. So one day, some fool asked him, "Ok. Prove that you're the Pope." He thought for a while and proclaimed, "I am one. The Pope is one. Therefore, the Pope and I are one."
Argh, in that code you use "vertice" as the singular of "verticies...." it''s "vertex," man.

And what he''s saying is that you have to load in the matricies from the MD3 and multiply them by the points that are loaded in to form the model.
i explained it poorly, but assuming your aware of the special "tag" verticies (which you should be to load the model) there is a special set of 3 verticies that forms a "tag" which defines the orientation and position of the mesh that gets attached there, and to "attach" it, you simply multiply the mesh to be attached, by a matrix created by using the three verticies (a process which can be done with D3DXMatrixLookAtLh() ... though i personally have never done this, i know it can be done and that that is what needs to happen, if yo udidnt follow what i said, say so, ill try again... im a bad teacher...
-Dan
When General Patton died after World War 2 he went to the gates of Heaven to talk to St. Peter. The first thing he asked is if there were any Marines in heaven. St. Peter told him no, Marines are too rowdy for heaven. He then asked why Patton wanted to know. Patton told him he was sick of the Marines overshadowing the Army because they did more with less and were all hard-core sons of bitches. St. Peter reassured him there were no Marines so Patton went into Heaven. As he was checking out his new home he rounded a corner and saw someone in Marine Dress Blues. He ran back to St. Peter and yelled "You lied to me! There are Marines in heaven!" St. Peter said "Who him? That's just God. He wishes he were a Marine."
I got it thanks, I just swapped the tag axes when I read them in also. Thanks.
//------------------------------------------------------------------------------------------------------The great logician Bertrand Russell once claimed that he could prove anything if given that 1+1=1. So one day, some fool asked him, "Ok. Prove that you're the Pope." He thought for a while and proclaimed, "I am one. The Pope is one. Therefore, the Pope and I are one."

This topic is closed to new replies.

Advertisement