[.net] My models are depth perception handicapped!

Started by
13 comments, last by Swamii 18 years, 7 months ago
For my own learning experience, I'm writing my own Managed DirectX 9 game engine. Things are going pretty well, the only problem is all the models I render are "inverted" or look like cut-out models. Any ideas on why this would be? The models I'm seeing as inverted are both external .x files, as well as DirectX primitives, such as Mesh.Sphere(...). I'd appreciate any insight on this! [Edited by - Swamii on September 4, 2005 10:35:03 PM]
------Tech, life, family, faith: Give me a visit.
Advertisement
Sounds like a problem with normals to me.
You didn't change the Cull mode, did you?
Turring Machines are better than C++ any day ^_~
I didn't change the cull mode. Do I need to?

My gut reaction was that the normals of the models were wrong, but how could they be wrong when the models are created via Managed DirectX's own methods (the Mesh.Box, Mesh.Cylinder, etc.)?

Is there something with my camera/viewport settings I need to do? Currently, when I go to "render" the camera, I do the following

device.Transform.Projection = Matrix.PerspectiveFovLH(fieldOfView, device.Viewport.Width / device.Viewport.Height, frontClipping, backClipping);device.Transform.View = Matrix.LookAtLH(camPosition, camOrientation, camOrientationUp);


If it'd help, I can post screenshots or post my actual project.
------Tech, life, family, faith: Give me a visit.
Ok, after more investigation (after playing with the cull mode), I've realized that what I'm seeing is not inverted models. So ignore the post title. :-)

Instead, what I'm seeing is depth problems: Model A is in front of Model B. Yet when rendered, I see model B rendered as though it is in front of the other model.

Here is a screenshot of what I'm seeing:

------Tech, life, family, faith: Give me a visit.
ya gots no depth buffering, my friend. I bets that model A is render in order after model B.

[Formerly "capn_midnight". See some of my projects. Find me on twitter tumblr G+ Github.]

Can you explain that a bit further? What do I need to do to get depth buffering working correctly? Currently, I just draw all models in the scene, not in any particular order...
------Tech, life, family, faith: Give me a visit.
for depth buffering all you need is the following in your PresentParameters before you create your device. That should take care of it.

presentParams.AutoDepthStencilFormat = DepthFormat.D16;presentParams.EnableAutoDepthFormatStencil = true;
My JournalComputer science education cannot make anybody an expert programmer any more than studying brushes and pigment can make somebody an expert painter. (Eric Raymond)"C makes it easy to shoot yourself in the foot. C++ makes itharder, but when you do, it blows away your whole leg."-- Bjarne Stroustrup
You also need device.depthtest (or something like that) set to true.
Excellent, I'll try this out soon as I get home from work. Thanks guys!
------Tech, life, family, faith: Give me a visit.

This topic is closed to new replies.

Advertisement