2013-12-09 11:05:47 +01:00
|
|
|
#include "C_Object.h"
|
|
|
|
using namespace DanBias::Client;
|
2014-02-14 15:07:55 +01:00
|
|
|
C_Object::C_Object()
|
|
|
|
{
|
|
|
|
world = Oyster::Math::Float4x4::identity;
|
|
|
|
position = Oyster::Math::Float3::null;
|
|
|
|
rotation = Oyster::Math::Quaternion::identity;
|
2014-02-20 11:34:29 +01:00
|
|
|
scale = Oyster::Math::Float3(1);
|
2014-02-14 15:07:55 +01:00
|
|
|
|
|
|
|
id = 0;
|
|
|
|
model = NULL;
|
2014-02-18 15:07:40 +01:00
|
|
|
|
|
|
|
// RB DEBUG
|
|
|
|
type = RB_Type_None;
|
|
|
|
// !RB DEBUG
|
2014-02-14 15:07:55 +01:00
|
|
|
}
|
|
|
|
C_Object::~C_Object()
|
|
|
|
{
|
2014-02-20 09:20:26 +01:00
|
|
|
if( this->model )
|
|
|
|
this->Release();
|
2014-02-14 15:07:55 +01:00
|
|
|
}
|
2014-02-20 09:20:26 +01:00
|
|
|
|
2014-02-14 15:07:55 +01:00
|
|
|
bool C_Object::Init(ModelInitData modelInit)
|
2014-02-10 14:00:14 +01:00
|
|
|
{
|
|
|
|
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);
|
2014-02-14 15:07:55 +01:00
|
|
|
if(model == NULL)
|
|
|
|
return false;
|
2014-02-11 10:11:38 +01:00
|
|
|
model->Visible = modelInit.visible;
|
2014-02-10 14:00:14 +01:00
|
|
|
updateWorld();
|
2014-02-14 15:07:55 +01:00
|
|
|
return true;
|
2014-02-10 14:00:14 +01:00
|
|
|
}
|
|
|
|
void C_Object::updateWorld()
|
|
|
|
{
|
|
|
|
Oyster::Math3D::Float4x4 translation = Oyster::Math3D::TranslationMatrix(this->position);
|
|
|
|
Oyster::Math3D::Float4x4 rot = Oyster::Math3D::RotationMatrix(this->rotation);
|
2014-02-18 13:31:36 +01:00
|
|
|
Oyster::Math3D::Float4x4 scale = Oyster::Math3D::ScalingMatrix(this->scale);
|
2014-02-10 14:00:14 +01:00
|
|
|
world = translation * rot * scale;
|
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
|
|
|
|
{
|
2014-02-18 13:31:36 +01:00
|
|
|
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);
|
|
|
|
Oyster::Math3D::Float4x4 world = translation * rot * scale;
|
|
|
|
|
2014-02-10 14:00:14 +01:00
|
|
|
return world;
|
|
|
|
}
|
|
|
|
void C_Object::setPos(Oyster::Math::Float3 newPos)
|
|
|
|
{
|
|
|
|
this->position = newPos;
|
|
|
|
}
|
|
|
|
void C_Object::addPos(Oyster::Math::Float3 deltaPos)
|
|
|
|
{
|
|
|
|
this->position += deltaPos;
|
|
|
|
}
|
|
|
|
Oyster::Math::Float3 C_Object::getPos() const
|
|
|
|
{
|
|
|
|
return this->position;
|
|
|
|
}
|
|
|
|
void C_Object::setRot(Oyster::Math::Quaternion newRot)
|
|
|
|
{
|
|
|
|
this->rotation = newRot;
|
|
|
|
}
|
|
|
|
Oyster::Math::Quaternion C_Object::getRotation() const
|
|
|
|
{
|
|
|
|
return this->rotation;
|
|
|
|
}
|
|
|
|
void C_Object::setScale(Oyster::Math::Float3 newScale)
|
|
|
|
{
|
|
|
|
this->scale = newScale;
|
|
|
|
}
|
|
|
|
void C_Object::addScale(Oyster::Math::Float3 deltaScale)
|
|
|
|
{
|
|
|
|
this->scale += deltaScale;
|
|
|
|
}
|
|
|
|
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-20 11:34:29 +01:00
|
|
|
if( this->model )
|
|
|
|
{
|
|
|
|
Oyster::Graphics::API::RenderModel(model);
|
|
|
|
}
|
2014-02-11 10:11:38 +01:00
|
|
|
}
|
|
|
|
void C_Object::Release()
|
|
|
|
{
|
2014-02-17 11:27:43 +01:00
|
|
|
if( this->model )
|
|
|
|
{
|
|
|
|
Oyster::Graphics::API::DeleteModel(model);
|
|
|
|
this->model = nullptr;
|
|
|
|
}
|
2014-02-18 13:31:36 +01:00
|
|
|
}
|
|
|
|
|
2014-02-20 12:07:53 +01:00
|
|
|
Oyster::Math::Float3 C_Object::GetTint()
|
|
|
|
{
|
|
|
|
return model->Tint;
|
|
|
|
}
|
|
|
|
|
|
|
|
Oyster::Math::Float3 C_Object::GetGlowTint()
|
|
|
|
{
|
|
|
|
return model->GlowTint;
|
|
|
|
}
|
|
|
|
|
|
|
|
void C_Object::SetTint(Oyster::Math::Float3 tint)
|
|
|
|
{
|
|
|
|
model->Tint = tint;
|
|
|
|
}
|
|
|
|
|
|
|
|
void C_Object::SetGlowTint(Oyster::Math::Float3 tint)
|
|
|
|
{
|
|
|
|
model->GlowTint = tint;
|
|
|
|
}
|
|
|
|
|
2014-02-25 16:08:45 +01:00
|
|
|
void C_Object::SetVisible(bool visible)
|
|
|
|
{
|
|
|
|
model->Visible = visible;
|
|
|
|
}
|
2014-02-18 13:31:36 +01:00
|
|
|
|
|
|
|
////////////////////////////////////////////////
|
|
|
|
// RB DEBUG
|
|
|
|
////////////////////////////////////////////////
|
|
|
|
bool C_Object::InitRB(RBInitData RBInit)
|
|
|
|
{
|
|
|
|
RBposition = RBInit.position;
|
|
|
|
RBrotation = RBInit.rotation;
|
|
|
|
RBscale = RBInit.scale;
|
2014-02-18 15:07:40 +01:00
|
|
|
type = RBInit.type;
|
2014-02-18 13:31:36 +01:00
|
|
|
return true;
|
|
|
|
}
|
2014-02-20 11:34:29 +01:00
|
|
|
void C_Object::updateRBWorld()
|
|
|
|
{
|
2014-02-20 13:35:51 +01:00
|
|
|
Oyster::Math3D::Float4x4 translation = Oyster::Math3D::TranslationMatrix(this->RBposition);
|
|
|
|
Oyster::Math3D::Float4x4 rot = Oyster::Math3D::RotationMatrix(this->RBrotation);
|
|
|
|
Oyster::Math3D::Float4x4 scale = Oyster::Math3D::ScalingMatrix(this->RBscale);
|
2014-02-20 11:34:29 +01:00
|
|
|
RBworld = translation * rot * scale;
|
|
|
|
}
|
2014-02-18 13:31:36 +01:00
|
|
|
Oyster::Math::Float4x4 C_Object::getRBWorld() const
|
|
|
|
{
|
2014-02-20 11:34:29 +01:00
|
|
|
return RBworld;
|
2014-02-18 13:31:36 +01:00
|
|
|
}
|
|
|
|
void C_Object::setRBPos(Oyster::Math::Float3 newPos)
|
|
|
|
{
|
|
|
|
this->RBposition = newPos;
|
|
|
|
}
|
|
|
|
Oyster::Math::Float3 C_Object::getRBPos() const
|
|
|
|
{
|
|
|
|
return this->RBposition;
|
|
|
|
}
|
|
|
|
void C_Object::setRBRot(Oyster::Math::Quaternion newRot)
|
|
|
|
{
|
|
|
|
this->RBrotation = newRot;
|
|
|
|
}
|
|
|
|
Oyster::Math::Quaternion C_Object::getRBRotation() const
|
|
|
|
{
|
|
|
|
return this->RBrotation;
|
|
|
|
}
|
|
|
|
void C_Object::setRBScale(Oyster::Math::Float3 newScale)
|
|
|
|
{
|
|
|
|
this->RBscale = newScale;
|
|
|
|
}
|
|
|
|
Oyster::Math::Float3 C_Object::getRBScale() const
|
|
|
|
{
|
|
|
|
return this->RBscale;
|
|
|
|
}
|
|
|
|
RB_Type C_Object::getBRtype()const
|
|
|
|
{
|
|
|
|
return this->type;
|
2014-02-18 15:07:40 +01:00
|
|
|
}
|
|
|
|
// !RB DEBUG
|