Hey guys, I'm using some of the built in 3D models that were in the Dark Models folder and I'm having trouble getting their center. Is there a function that allows me to obtain the center of a model?
For example I'm using the below code to rotate the camera so I want my FPS model to rotate with it, but the rotation axis is behind the model, not through his center.
Is there a way to find the center of a model in the x,y and z dimensions?
Model Creation
Player::Player()
{
id = 5;
SetCurrentDirectory ( "assets/Player" );
dbLoadObject( "H-Gi-Static.x", id );
dbRotateObject(id,0,180,0);
dbFixObjectPivot(id);
dbScaleObject( id, 5000, 5000, 5000 );
x = 0;
y = 0;
z = 0;
}
Model Rotation Based on Mouse Movement
void FPS::Update()
{
// create a rotation axis based on controller movement
fCameraAngleX = dbWrapValue ( fCameraAngleX + controller->GetVeiwX() );
fCameraAngleY = dbWrapValue ( fCameraAngleY + controller->GetVeiwY() );
// rotate camera
dbXRotateCamera ( fCameraAngleY );
//dbXRotateObject(player->id,fCameraAngleY);
dbYRotateCamera ( fCameraAngleX );
dbYRotateObject(player->id,fCameraAngleX);
}