Hi,
I've ran into a challenge with the following:
- my weapon is rendered/ positioned using the viewIdentityMatrix (*projection matrix)
- to do this I have a local space World matrix for the weapon
- my point lights are in worldspace and therefor not affecting my weapon, since the world matrix used/ sent to the shader is in local space
My question;
- I have a local space World matrix / orientation of the gun
- I have a world space position of the camera, and yaw/roll/pitch angles (rotation)
How do I combine both to get a resulting World Matrix?
I've tried the following, which goes in the direction but is definately not OK:
D3DXMATRIXA16 WorldWorldspace;
D3DXVECTOR3 CamRot = pCam.GetRot();
D3DXVECTOR3 MeshRot = pD3dscene.mWeaponMeshInst[mInst].GetRot();
float scale = pD3dscene.mWeaponMeshInst[mInst].GetScale();
ComposeD3DXWorldMatrix(&WorldWorldspace, D3DXVECTOR3(scale, scale, scale), CamRot.x - MeshRot.x, CamRot.y - MeshRot.y, CamRot.z - MeshRot.z, pCam.GetPosition() + pD3dscene.mWeaponMeshInst[mInst].GetWorldPos());
I know my compose matrix function is working fine, it's used for positioning all mesh instances in the scene.
(the goal is to sent both the local space world matrix to the shader, for positioning, as the world space world matrix, for lighting in the pixel shader).
I also tried this:
D3DXMATRIXA16 WorldWorldSpace = pCam.GetViewMatrix() * pD3dscene.mWeaponMeshInst[mInst].GetWorldMatrix();
Any ideas/ hints?