Flickering problem with world matrix

Posted by gnomgrol on Game Development See other posts from Game Development or by gnomgrol
Published on 2012-07-05T16:43:23Z Indexed on 2012/07/05 21:25 UTC
Read the original article Hit count: 238

Filed under:
|
|

I do have a pretty wierd problem today. As soon as I try to change my translation- or rotationmatrix for an object to something else than (0,0,0), the object starts to flicker (scaling works fine). It rapid and randomly switches between the spot it should be in and a crippled something. I first thought that the problem would be z-fighting, but now Im pretty sure it isn't.

I have now clue at all what it could be, here are two screenshots of the two states the plant is switching between.

http://imageshack.us/photo/my-images/819/73395561.png/

http://imageshack.us/photo/my-images/31/faildt.png/

I already used PIX, but could find anything of use (Im not a very good debugger anyway) I would appreciate any help, thanks a lot!

Important code:

D3DXMatrixIdentity(&World);
D3DXVECTOR3 rotaxisX = D3DXVECTOR3(1.0f, 0.0f, 0.0f);
D3DXVECTOR3 rotaxisY = D3DXVECTOR3(0.0f, 1.0f, 0.0f);
D3DXVECTOR3 rotaxisZ = D3DXVECTOR3(0.0f, 0.0f, 1.0f);

D3DXMATRIX temprot1, temprot2, temprot3;
D3DXMatrixRotationAxis(&temprot1, &rotaxisX, 0);
D3DXMatrixRotationAxis(&temprot2, &rotaxisY, 0);
D3DXMatrixRotationAxis(&temprot3, &rotaxisZ, 0);

Rotation = temprot1 *temprot2 * temprot3;


D3DXMatrixTranslation(&Translation, 0.0f, 10.0f, 0.0f);
D3DXMatrixScaling(&Scale, 0.02f, 0.02f, 0.02f);
//Set objs world space using the transformations
World = Translation * Rotation * Scale;

shader:

cbuffer cbPerObject
{
matrix worldMatrix;
matrix viewMatrix;
matrix projectionMatrix;
};

// Change the position vector to be 4 units for proper matrix calculations.
input.position.w = 1.0f;

// Calculate the position of the vertex against the world, view, and projection         matrices.
output.position = mul(input.position, worldMatrix);
output.position = mul(output.position, viewMatrix);
output.position = mul(output.position, projectionMatrix);

© Game Development or respective owner

Related posts about c++

Related posts about directx