Sign in to follow this  
Dom_152

Cube not displaying correctly

Recommended Posts

I am having some weird troubles with getting DirectX to display my cube correctly. I've been examining the data from PIX and look at this: As you can see before the Vertex Shader is applied there is definatly something there... maybe not a cube but something! :D But as soon as the vertex Shader has been applied all the vertices go to the point 0.0 and nothing is rendered. Now seeing as I'm not using my own Vertex Shaders I assume it's referring to the fixed function pipeline which is what I am using. So does anyone know of any common (or uncommon?) problems which would cause this sort of behavior? I haven't posted any code because I'm not sure what I should post. If you can give me any pointers I can post the relevant code.

Share this post


Link to post
Share on other sites
Did you call SetMatrix 3 times? D3DTS_WORLD, D3DTS_VIEW and D3DTS_PROJECTION?

it would seem at least one of those matrices is set to 0, causing a transformation to 0.

Share this post


Link to post
Share on other sites
Quote:
Original post by Dom_152
Yeah the world transformation is 0 but only because I want to position it at point 0, with no rotation and no scaling.

So it should be the identity matrix, not the zero matrix. Like this:
D3DXMatrixIdentity(&matWorld);

Admiral

Share this post


Link to post
Share on other sites
I do except my world one because I can't use the Direct3D API in that part of my code.

OK I added some things to check for an empty matrix and to turn it into an identity matrix if it is but now my cube won't scale, rotate or move.

EDIT: It's because I'm calculating my world matrix wrong s it's always coming out as all zeroes.

[Edited by - Dom_152 on April 9, 2007 12:04:28 PM]

Share this post


Link to post
Share on other sites
OK I'm having trouble constructing a usable world matrix. This is how I'm doing it currently:


scaleMatrix.Scale(m_scale.GetX(), m_scale.GetY(), m_scale.GetZ());
worldMatrix = scaleMatrix;

transMatrix.Translate(m_position.GetX(), m_position.GetY(), m_position.GetZ());
worldMatrix = worldMatrix.Multiply(transMatrix);

rotMatrix.CreateIdentityMatrix();

if(m_rotation.GetX() || m_rotation.GetY() || m_rotation.GetZ())
{
rotMatrix.RotateX(m_rotation.GetX());
tempMatrix = tempMatrix.Multiply(rotMatrix);

rotMatrix.RotateY(m_rotation.GetY());
tempMatrix = tempMatrix.Multiply(rotMatrix);

rotMatrix.RotateZ(m_rotation.GetZ());
tempMatrix = tempMatrix.Multiply(rotMatrix);

worldMatrix = worldMatrix.Multiply(tempMatrix);
}

if(worldMatrix.Empty())
worldMatrix.CreateIdentityMatrix();




Now if I get rid of the rotation stuff translation works fine. But I cannot get rotation working at all because it always seems to end up making the world matrix all zeros when I multiply rotation with it. What should I be doing? I've tried following instructions on the net and in the SDK docs but I can't seem to get it working.

Share this post


Link to post
Share on other sites
Hmm.. What language and what DX version are you using?

Is that a built-in matrix, or is it your own (long time since I used unmanaged which I'm guessing is what you are using)?

Do you ever initialize tempMatrix, and if so, to what? If it's empty from the beginning, it'll end up empty no matter what you multiply it with?

Share this post


Link to post
Share on other sites
It's my own matrix type and I'm using C++ with DirectX 9. All the matrices are empty to begin with. I only use tempMatrix to store all of the rotations, X, Y and Z, in one matrix. I make rotMatrix and identity matrix before doing anything but when I multiply that with the tempMatrix I get nothing :S

Share this post


Link to post
Share on other sites
Quote:
Original post by Dom_152
It's my own matrix type and I'm using C++ with DirectX 9. All the matrices are empty to begin with. I only use tempMatrix to store all of the rotations, X, Y and Z, in one matrix. I make rotMatrix and identity matrix before doing anything but when I multiply that with the tempMatrix I get nothing :S


Have you fully tested your matrix type to make sure that the results you are getting are correct?

TBH - I would still use the D3DX functions since at the lower levels D3DX makes good use of HW (i.e. SIMD).

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this