X File loading

Started by
3 comments, last by David_Kay 22 years, 5 months ago
Hello everyone, I created a CXMesh class that loads a X-File. The problem is, when I go through the render process, and apply the textures for the different segments, my Mesh is basically inside out so to speak. As an example, I loaded the tiger.x file that comes with the DirectX SDK and placed the tiger.bmp file into the same directory ( so it will apply this texture (only texture for the tiger.x )). When I render, you see through the body, legs, tail, head until it hits the other side of the leg, body, tail and it renders the texture to that face ... given my mesh a some what ''Indent'' apperance. I''m not sure if this has to do with face normals or any of the such. If anyone knows what is wrong please help me. David
Huh... oh I see..
Advertisement
Ensure that you have the backface-culling mode correctly set. i.e. are the faces/triangles specified in clockwise or counter-clockwise order? Set the culling mode accordingly.
Not exactly sure, using the D3DXLoadMeshFromX helper function so I'm going to assume it is clockwise. VERY weird. I turned off backface culling and well ... the image is correct now. Can anyone explain? I figured if it was on, it wouldn't draw the part it was (which was the other side of the image... Maybe it was drawing over the first part? ... any input please


Example of what I'm talking about:

(top view)

left side of body-->( ) <---right side of body
Camera ---> X

if camera was positioned at X looking at the left side of the body - it would draw the right inside and vice versa - I wouldn't see the outter rib cage of the tiger but rather the opp side that the camera was pointing to ...


Edited by - David_Kay on October 19, 2001 4:56:45 AM

Edited by - David_Kay on October 19, 2001 4:57:39 AM
Huh... oh I see..
With backface culling turned off DirectX renders both sides of a polygon, so the tiger would look fine, but there''s some unecessary rendering taking place, because the insides of the tiger will also be rendered, so if you position the camera inside the tiger you should see the "skin" around you.

If backface culling is on, only one side of each polygon will be rendered, and the polygon would be invisible if viewed from the other side.

In your case the backface-culling mode was set to the opposite of what it should have been, so the polygon-sides that should have been "front sides" (the outside of the tiger), were treated as "back sides" by DirectX (and were therefore not rendered), consequently the polygon-sides that should have been "back sides" (the ones facing into the tiger) were treated as "front sides", and were being rendered. Just set the cull-mode to the opposite of what it was and it should look right.

Whether the model should be rendered with CW or CCW culling depends on the modelling package used to create it (and how the model was saved). From the little I''ve seen it seems like CCW is the most common (I have no backing what so ever for this statement, just an impression I get). Of course you can always reverse the vertex-order at load-time should the need arise.

I''m not sure this is such a good explanation. If you play around a little with the cull-mode for different models you should get the hang of how it works.
Thank you very much, Dactylos. I understand your explanation. I'm not sure what the tiger.x file was created in, but most likely it was converted to an x file with MS's application, conv3ds file. So I really don't know about the CW or CCW rendering of triangles. I will read up on it today though.


Thanks again!

Edited by - David_Kay on October 19, 2001 8:37:23 AM
Huh... oh I see..

This topic is closed to new replies.

Advertisement