Cube not displaying correctly

Started by
11 comments, last by Bimble Bob 17 years ago
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.
It's not a bug... it's a feature!
Advertisement
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.
Sirob Yes.» - status: Work-O-Rama.
Yeah the world transformation is 0 but only because I want to position it at point 0, with no rotation and no scaling.
It's not a bug... it's a feature!
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
Ring3 Circus - Diary of a programmer, journal of a hacker.
So when I setup my world matrix I should do a check to see if it is all zero and if so turn it into an identity matrix?
It's not a bug... it's a feature!
I'd say always build your matrices with the D3DX functions for now.
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]
It's not a bug... it's a feature!
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.
It's not a bug... it's a feature!
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?
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
It's not a bug... it's a feature!

This topic is closed to new replies.

Advertisement