dumbo2007
Crazy about real time sims
Hi,
I am trying to understand how planets are rendered in the D3D9 client code. It seems that all co-ordinates are camera centric.
There is a call to vObject::Update() which seems to get all the distances wrt the global camera position. The distance of the planet from the camera is in cdist:
From http://d3d9client.codeplex.com/SourceControl/latest#trunk/Orbitersdk/D3D9Client/VObject.cpp
Why is D3DMAT_SetInvRotation(&mWorld, &grot) used ? Shouldnt the rotation thats put into the world matrix be wrt the camera as the world matrix itself seems to be based on camera distances ?
Also since the world matrix seems to have all co-ordinates wrt the camera, I am guessing that no multiplication is needed with a view matrix ?
Usually there is a modeling matrix and a view matrix and the object co-ordinates in world space are multiplied with each in that order.
But is there a view matrix needed here ?
I am trying to understand how planets are rendered in the D3D9 client code. It seems that all co-ordinates are camera centric.
There is a call to vObject::Update() which seems to get all the distances wrt the global camera position. The distance of the planet from the camera is in cdist:
From http://d3d9client.codeplex.com/SourceControl/latest#trunk/Orbitersdk/D3D9Client/VObject.cpp
Code:
MATRIX3 grot;
oapiGetRotationMatrix(hObj, &grot);
oapiGetGlobalPos(hObj, &cpos);
cpos -= scn->GetCameraGPos();
// object positions are relative to camera
cdist = length(cpos);
// camera distance
D3DMAT_SetInvRotation(&mWorld, &grot);
D3DMAT_SetTranslation(&mWorld, &cpos);
Why is D3DMAT_SetInvRotation(&mWorld, &grot) used ? Shouldnt the rotation thats put into the world matrix be wrt the camera as the world matrix itself seems to be based on camera distances ?
Also since the world matrix seems to have all co-ordinates wrt the camera, I am guessing that no multiplication is needed with a view matrix ?
Usually there is a modeling matrix and a view matrix and the object co-ordinates in world space are multiplied with each in that order.
But is there a view matrix needed here ?