2013-12-09 11:05:47 +01:00
|
|
|
#include "C_Object.h"
|
|
|
|
using namespace DanBias::Client;
|
2014-02-10 14:00:14 +01:00
|
|
|
void C_Object::Init(ModelInitData modelInit)
|
|
|
|
{
|
|
|
|
position = modelInit.position;
|
|
|
|
rotation = modelInit.rotation;
|
|
|
|
scale = modelInit.scale;
|
2014-02-11 10:11:38 +01:00
|
|
|
id = modelInit.id;
|
|
|
|
model = Oyster::Graphics::API::CreateModel(modelInit.modelPath);
|
|
|
|
model->Visible = modelInit.visible;
|
2014-02-10 14:00:14 +01:00
|
|
|
updateWorld();
|
|
|
|
}
|
|
|
|
void C_Object::updateWorld()
|
|
|
|
{
|
|
|
|
Oyster::Math3D::Float4x4 translation = Oyster::Math3D::TranslationMatrix(this->position);
|
|
|
|
Oyster::Math3D::Float4x4 rot = Oyster::Math3D::RotationMatrix(this->rotation);
|
|
|
|
//Oyster::Math3D::Float4x4 scale = Oyster::Math3D::;
|
|
|
|
Oyster::Math3D::Float4x4 scale = Oyster::Math3D::Matrix::identity;
|
|
|
|
scale.v[0].x = this->scale[0];
|
|
|
|
scale.v[1].y = this->scale[1];
|
|
|
|
scale.v[2].z = this->scale[2];
|
|
|
|
world = translation * rot * scale;
|
2014-02-11 10:11:38 +01:00
|
|
|
|
|
|
|
model->WorldMatrix = world;
|
2014-02-10 14:00:14 +01:00
|
|
|
}
|
|
|
|
void C_Object::setWorld(Oyster::Math::Float4x4 world)
|
|
|
|
{
|
2014-02-11 10:11:38 +01:00
|
|
|
model->WorldMatrix = world;
|
2014-02-10 14:00:14 +01:00
|
|
|
}
|
|
|
|
Oyster::Math::Float4x4 C_Object::getWorld() const
|
|
|
|
{
|
|
|
|
return world;
|
|
|
|
}
|
|
|
|
void C_Object::setPos(Oyster::Math::Float3 newPos)
|
|
|
|
{
|
|
|
|
this->position = newPos;
|
|
|
|
updateWorld();
|
|
|
|
}
|
|
|
|
void C_Object::addPos(Oyster::Math::Float3 deltaPos)
|
|
|
|
{
|
|
|
|
this->position += deltaPos;
|
|
|
|
updateWorld();
|
|
|
|
}
|
|
|
|
Oyster::Math::Float3 C_Object::getPos() const
|
|
|
|
{
|
|
|
|
return this->position;
|
|
|
|
}
|
|
|
|
void C_Object::setRot(Oyster::Math::Quaternion newRot)
|
|
|
|
{
|
|
|
|
this->rotation = newRot;
|
|
|
|
updateWorld();
|
|
|
|
}
|
|
|
|
void C_Object::addRot(Oyster::Math::Quaternion deltaRot)
|
|
|
|
{
|
|
|
|
this->rotation += deltaRot;
|
|
|
|
updateWorld();
|
|
|
|
}
|
|
|
|
Oyster::Math::Quaternion C_Object::getRotation() const
|
|
|
|
{
|
|
|
|
return this->rotation;
|
|
|
|
}
|
|
|
|
void C_Object::setScale(Oyster::Math::Float3 newScale)
|
|
|
|
{
|
|
|
|
this->scale = newScale;
|
|
|
|
updateWorld();
|
|
|
|
}
|
|
|
|
void C_Object::addScale(Oyster::Math::Float3 deltaScale)
|
|
|
|
{
|
|
|
|
this->scale += deltaScale;
|
|
|
|
updateWorld();
|
|
|
|
}
|
|
|
|
Oyster::Math::Float3 C_Object::getScale() const
|
|
|
|
{
|
|
|
|
return this->scale;
|
|
|
|
}
|
2014-02-11 10:11:38 +01:00
|
|
|
int C_Object::GetId() const
|
|
|
|
{
|
|
|
|
return id;
|
|
|
|
}
|
|
|
|
void C_Object::Render()
|
|
|
|
{
|
2014-02-11 13:26:51 +01:00
|
|
|
Oyster::Graphics::API::RenderModel(model);
|
2014-02-11 10:11:38 +01:00
|
|
|
}
|
|
|
|
void C_Object::Release()
|
|
|
|
{
|
|
|
|
Oyster::Graphics::API::DeleteModel(model);
|
|
|
|
}
|