Updating model worldMatrix

This commit is contained in:
lindaandersson 2014-02-20 11:34:29 +01:00
parent d945eea992
commit bf41bd38d4
3 changed files with 17 additions and 8 deletions

View File

@ -5,7 +5,7 @@ C_Object::C_Object()
world = Oyster::Math::Float4x4::identity; world = Oyster::Math::Float4x4::identity;
position = Oyster::Math::Float3::null; position = Oyster::Math::Float3::null;
rotation = Oyster::Math::Quaternion::identity; rotation = Oyster::Math::Quaternion::identity;
scale = Oyster::Math::Float3::null; scale = Oyster::Math::Float3(1);
id = 0; id = 0;
model = NULL; model = NULL;
@ -89,7 +89,10 @@ int C_Object::GetId() const
} }
void C_Object::Render() void C_Object::Render()
{ {
Oyster::Graphics::API::RenderModel(model); if( this->model )
{
Oyster::Graphics::API::RenderModel(model);
}
} }
void C_Object::Release() void C_Object::Release()
{ {
@ -113,14 +116,16 @@ bool C_Object::InitRB(RBInitData RBInit)
type = RBInit.type; type = RBInit.type;
return true; return true;
} }
void C_Object::updateRBWorld()
{
Oyster::Math3D::Float4x4 translation = Oyster::Math3D::TranslationMatrix(this->position);
Oyster::Math3D::Float4x4 rot = Oyster::Math3D::RotationMatrix(this->rotation);
Oyster::Math3D::Float4x4 scale = Oyster::Math3D::ScalingMatrix(this->scale);
RBworld = translation * rot * scale;
}
Oyster::Math::Float4x4 C_Object::getRBWorld() const Oyster::Math::Float4x4 C_Object::getRBWorld() const
{ {
Oyster::Math3D::Float4x4 translation = Oyster::Math3D::TranslationMatrix(this->RBposition); return RBworld;
Oyster::Math3D::Float4x4 rot = Oyster::Math3D::RotationMatrix(this->RBrotation);
Oyster::Math3D::Float4x4 scale = Oyster::Math3D::ScalingMatrix(this->RBscale);
Oyster::Math3D::Float4x4 world = translation * rot * scale;
return world;
} }
void C_Object::setRBPos(Oyster::Math::Float3 newPos) void C_Object::setRBPos(Oyster::Math::Float3 newPos)
{ {

View File

@ -40,6 +40,7 @@ namespace DanBias
Oyster::Math::Float3 scale; Oyster::Math::Float3 scale;
// RB DEBUG // RB DEBUG
Oyster::Math::Float4x4 RBworld;
Oyster::Math::Float3 RBposition; Oyster::Math::Float3 RBposition;
Oyster::Math::Quaternion RBrotation; Oyster::Math::Quaternion RBrotation;
Oyster::Math::Float3 RBscale; Oyster::Math::Float3 RBscale;
@ -67,6 +68,7 @@ namespace DanBias
Oyster::Math::Float3 getScale() const; Oyster::Math::Float3 getScale() const;
// RB DEBUG // RB DEBUG
void updateRBWorld();
bool InitRB(RBInitData modelInit); bool InitRB(RBInitData modelInit);
Oyster::Math::Float4x4 getRBWorld() const; Oyster::Math::Float4x4 getRBWorld() const;
void setRBPos(Oyster::Math::Float3 newPos); void setRBPos(Oyster::Math::Float3 newPos);

View File

@ -508,9 +508,11 @@ const GameClientState::NetEvent & GameState::DataRecieved( const GameClientState
{ {
object->setPos( position ); object->setPos( position );
object->setRot( rotation ); object->setRot( rotation );
object->updateWorld();
// RB DEBUG // RB DEBUG
object->setRBPos ( position ); object->setRBPos ( position );
object->setRBRot ( rotation ); object->setRBRot ( rotation );
object->updateRBWorld();
// !RB DEBUG // !RB DEBUG
} }
} }