Why my model displays abnormally ?

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

Recommended Posts

Hi all I use DirectX SDK 9.0C. And my model is .x file. This is the snapshot link : http://tinypic.com/bijyvb.jpg The terrain is a .x file. I made the terrain a rectangle, but now it seems a trapezoid. This is my set:
myDevice.Transform.View = Matrix.LookAtLH(New Vector3(40, 40, -40), New Vector3(0.0F, 0.0F, 0.0F), New Vector3(0.0F, 1.0F, 0.0F))
myDevice.Transform.Projection = Matrix.OrthoLH(800, 600, -2000, 2000)

How could I fix it? Thanks for replies.

Share on other sites
I think what is happening is you are using an ortho view. That is basically a 2D mode; it eliminates any depth from the scene. When drawing models in that mode you can picture drawing the model like normal then flattening it against the screen. I'm guessing this line is the culprit:
myDevice.Transform.Projection = Matrix.OrthoLH(800, 600, -2000, 2000)

Is there something like this that you can use instead?
myDevice.Transform.Projection = Matrix.ProjectionLH(...)

Good luck!
Matt Hughson

Share on other sites
Good tip!
That's really useful.(I tried.)

But there's a problem, I need an orthogonal projection.
Can I solve the display problem if I use Matrix.OrthoLH(...)?

Thanks.

Share on other sites
You could enable ortho only when you draw sprites. Like this:

myDevice.Transform.Projection = Matrix.OrthoLH(...);drawSprites();myDevice.Transform.Projection = Matrix.PerspectiveFovLH(...);draw3DStuff();

Share on other sites
That's a good suggestion. But...

Actually, I want to display every model's real size - no matter it's Z-Value.

Could this request be satisfied?

Thank you.

Share on other sites
Quote:
 Original post by iannanActually, I want to display every model's real size - no matter it's Z-Value.

Do you mean that objects further away get smaller? If so, use perspective matrix for rendering everything, including sprites. With sprites you need to use billboarding if you want to be able to rotate your camera.

Share on other sites
Quote:
 Original post by iannanThat's a good suggestion. But...Actually, I want to display every model's real size - no matter it's Z-Value.Could this request be satisfied?Thank you.

That's what you are doing now.

Matt Hughson

Share on other sites
Thanks all suggestions above.

Hmm, sorry, I think I did't express good enough.
Let me explain my requests.

I hope that my models will not get smaller when it's further away.
I use Matrix.OrthoLH(...) to create my projection matrix.
And it works.

But, the new problem is my terrain displays abnormally.
(This terrain is a .x model.)
I made the terrain a rectangle, but it now seems a trapezoid.

I ask a solution for fix the display problem.

Thanks.

Share on other sites
It is a rectangle, you're just looking at it from a angle and from slightly above. Picture holding a book in front of you with it's cover paralelle with the floor, then rotating the book by 45 degrees (while still keeping it paralelle with the floor): that's what you have here (I belive). Now the ortho matrix is making that tougher to see because it is removing any depth from the rendering, so that the top left corner seems to be at the same distance as bottom right corner, making this rectangle seem like a trapazoid that is perpendicular with the floor.

Hope that makes sense. If not, maybe I can draw some pictures or something.

Can I ask too why you want to render the model in ortho mode? Just looking at what you going happening in the screen, I don't know if that is the best approach for what you are trying to accomplish (seems like you are 3/4 perspective game aka isometric).

Matt Hughson

Share on other sites
Ooh, I get it.
Thanks.

Quote:
 Original post by matthughsonCan I ask too why you want to render the model in ortho mode? Just looking at what you going happening in the screen, I don't know if that is the best approach for what you are trying to accomplish (seems like you are 3/4 perspective game aka isometric).Matt Hughson

Do you know Ragnarok Online(RO)? That's a Korea online game.
This is the snapshot link : http://tinypic.com/dfw18h.jpg
I need a view like RO.

Thank you very much, anyway.