updating world matrix, identity needed?

Started by
14 comments, last by cozzie 10 years, 9 months ago

Thanks, got it in right away.

Strangely there's something weird with the X/Y and Z rotations, when I adapt the function as is, I read:

- Y rotation, Z rotation, X rotation

But I have to pass my rotation values, in this order for:

- X rotation, Y rotation, Z rotation

I have to get into that, and compare the result with before (when I used the separate rotation matrices).

Crealysm game & engine development: http://www.crealysm.com

Looking for a passionate, disciplined and structured producer? PM me

Advertisement

Well, you had before in this order:


mMatRotateX*mMatRotateY*mMatRotateZ

so i assumed it is what you want?


One strange thing though, rotation around Z and Y where switched, yaw and pitch...

I assume pitch = X, yaw = Y and roll = Z

Got it, sorry. Probably messed it up, while changing pitch/yaw/roll to X/Y/Z rot.

Thanks again.

It all looks good now, I see a little difference for a specific rotation of a mesh instance compared to the earlier lot of multiplications with the d3dx functions. I'll get into that and see what causes the difference.

This is now the cleaned up function, to update the world matrix for dynamic mesh instances:


bool CD3dmeshInst::UpdateWorldMatrix()
{
	if(!mDynamic) return false;
	if(!mIsMoved && !mIsRotated && !mIsScaled) return false;
	else
	{
		D3DXMatrixCompose(&mMatWorld, &D3DXVECTOR3(mScale, mScale, mScale), mRot.x, mRot.y, mRot.z, &mWorldPos);
	}

	D3DXMatrixInverse(&mMatWorldInv, NULL, &mMatWorld);
	D3DXMatrixTranspose(&mMatWorldInvTransp, &mMatWorldInv);
	return true;
}

Later on I might remove the inverse transpose part, after changing my pixelshader/ lighting shader.

Crealysm game & engine development: http://www.crealysm.com

Looking for a passionate, disciplined and structured producer? PM me

Got it, stupid!!! I passed radians instead of degrees in the new improved function wacko.png

Crealysm game & engine development: http://www.crealysm.com

Looking for a passionate, disciplined and structured producer? PM me

You should pass radians not degrees, like you did before with D3DXToRadian macro (if your mRot is in degrees):


D3DXMatrixCompose(&mMatWorld, &D3DXVECTOR3(mScale, mScale, mScale), D3DXToRadian(mRot.x), D3DXToRadian(mRot.y), D3DXToRadian(mRot.z), &mWorldPos);

Like Phil_t said, rebuild your matrix every time, there is no point to check if it is "moved".

Got it all up and running now, thanks.

Crealysm game & engine development: http://www.crealysm.com

Looking for a passionate, disciplined and structured producer? PM me

This topic is closed to new replies.

Advertisement