Archived

This topic is now archived and is closed to further replies.

Best

Problem with .x models

Recommended Posts

First, i have to apologised for my bad english.... i´m using VB5 and directx 8.1 Here is my problem: First, i intialice everything(d3d,z-buffer,etc).Then I load two meshes to the memory (a car and a circuit race). I apply the respectives matrix maths for each of them and then render. When i run the program and move the car, it seems to don´t have a depth, like there isn´t any z-buffer. I move the car down, but it looks like it´s ALWAYS on the circuit race, when it´s behind it. I hope you could undertund it, and help me... thanks to all

Share this post


Link to post
Share on other sites
Hmmm...I can only think of 2 things.

1. You don''t have a depth buffer (I often forget to do do that and then get really scared ), or you turned off the Z_ENABLE render state, or you arent clearing your depth buffer.

2. You have only one matrix for both the car and the track, so when you move the car, the track moves with it. Try applying an identity matrix before rendering the track.

If I misunderstood anything, sorry :\

Share this post


Link to post
Share on other sites
quote:
Original post by Sheep
Hmmm...I can only think of 2 things.

1. You don''t have a depth buffer (I often forget to do do that and then get really scared ), or you turned off the Z_ENABLE render state, or you arent clearing your depth buffer.

2. You have only one matrix for both the car and the track, so when you move the car, the track moves with it. Try applying an identity matrix before rendering the track.

If I misunderstood anything, sorry :\


1. Yes i have a z-buffer, it´s on and i clear it every frame.
2. I apply a different matrix for each thing, the car and the matrix.

One thing that can be wrong is that after rendering i put Settransform to apply de matrix to the car and after rendering the track i put Settransform again, ís it wrong?

Share this post


Link to post
Share on other sites
Are you applying the world matrices for each obect after rendering? You should actually apply the matrices before rendering. It should actually look something like this (psuedo-code):


      
transform(car_matrix); // rotation*translation or however

car->render();

set_to_indentity(track_matrix);
tranform(track_matrix);
track->render();


Apply the transformation matrices before rendering.

[edited by - Sheep on September 3, 2002 4:46:49 PM]

[edited by - Sheep on September 3, 2002 8:01:34 PM]

Share this post


Link to post
Share on other sites
Yes, i am applying each matrix for each object after rendering.


  
SetupMatrices

Settransform matCar
render Car
Settransform matTrack ''or MultiplyTransform?
render Track

Share this post


Link to post
Share on other sites
Actually, you are applying the matrices before rendering the models. Could you maybe post some screenshots? Maybe I am not visualizing this correctly.

Share this post


Link to post
Share on other sites
See if Direct3DDevice8.GetDepthStencilSurface() actually returns a surface just to make sure that you really do have the Z buffer working. If so, try moving your car really far back - this may sound silly but are you sure that your cars wheels are actually touching the ground? A small car floating in the air would give the illusion shown in the screenshots.

Share this post


Link to post
Share on other sites
quote:
Original post by bazee
See if Direct3DDevice8.GetDepthStencilSurface() actually returns a surface just to make sure that you really do have the Z buffer working. If so, try moving your car really far back - this may sound silly but are you sure that your cars wheels are actually touching the ground? A small car floating in the air would give the illusion shown in the screenshots.


Yes it returns a surface, and the screenshot aren´t a ilusion, anywhere you see, you see the car first and then de track...

Share this post


Link to post
Share on other sites
Fair enough, it''s just that caught me out once when I made a similar program, my cars wheels weren''t touching the ground because the car was too small. I can''t really think of anything else, sorry

Share this post


Link to post
Share on other sites
A point that could be important:
If i first render the track, you see first the track and then the car. If i first render the car, you see first the car.





[edited by - Best on September 5, 2002 6:53:33 PM]

Share this post


Link to post
Share on other sites
Sorry man, I don''t know what else to say :/

Those truly are the wierdest screenshots I have ever seen

Share this post


Link to post
Share on other sites
I had a similar problem.

Turned out that I did not have the view matrix set. Make sure you have both a world and view transform active. From what you have shown it seems you have done that, but might want to double check.

Strangest thing, when I did not have the D3DTS_VIEW set, and just the D3DTS_WORLD set, it seemed my models were rendering inside out.

Share this post


Link to post
Share on other sites
The problem has been solved. The problem was in the projection matrix. I put 0 in the Max distance, i changed it and walla!
thanks to all.

Share this post


Link to post
Share on other sites