/*************************************************************************** * Copyright (C) 2004 by Murray Evans * * m.evans@rdg.ac.uk * * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * * This program is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU General Public License for more details. * * * * You should have received a copy of the GNU General Public License * * along with this program; if not, write to the * * Free Software Foundation, Inc., * * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * ***************************************************************************/ #include "Entity.h" /******************************************************************** * Dazzle * * Base entity class * * * * Murray Evans * ********************************************************************/ CEntity::CEntity(void) { } CEntity::~CEntity(void) { } // change the position of the entity void CEntity::SetPos(float in_X_f, float in_Y_f, float in_Z_f) { pos_v4f.SetXYZW(in_X_f, in_Y_f, in_Z_f, 1.0f); return; } // Set the velocity vector using x, y, z void CEntity::SetVelocity(float in_Xvel_f, float in_Yvel_f, float in_Zvel_f) { vel_v4f.SetXYZW(in_Xvel_f, in_Yvel_f, in_Zvel_f, 1.0f); return; } // Set the velocity vector using a vec4f void CEntity::SetPos(CVec4f in_v4f) { vel_v4f = in_v4f; } // Set rotation of entity by axis rotations (x,y,z) in degrees void CEntity::SetRotation(float in_Xrot_f, float in_Yrot_f, float in_Zrot_f) { rot_v3f.SetXYZ(in_Xrot_f, in_Yrot_f, in_Zrot_f); } // return x position float CEntity::X(void) { return pos_v4f.X(); } // return y position float CEntity::Y(void) { return pos_v4f.Y(); } // return z position float CEntity::Z(void) { return pos_v4f.Z(); } // return x rotation float CEntity::XRot(void) { return rot_v3f.X(); } // return y rotation float CEntity::YRot(void) { return rot_v3f.Y(); } // return z rotation float CEntity::ZRot(void) { return rot_v3f.Z(); } void CEntity::Update(void) { pos_v4f = vel_v4f + pos_v4f; pos_v4f.SetW(1); } // put position data into the array pointed to by io_paf. Array should be float[3] for (x,y,z) void CEntity::GetPos(float* io_paf) { io_paf[0] = pos_v4f.X(); io_paf[1] = pos_v4f.Y(); io_paf[2] = pos_v4f.Z(); } CVec4f CEntity::GetPos() { return pos_v4f; } CVec4f CEntity::GetVelocity() { return vel_v4f; } // Rendering function. Mostly it will be more evolved entities which actually have anythin happen here void CEntity::Render(void) { } void CEntity::PrepareForDestruction() { for(int sc_i = 0; sc_i < sub_ents.Size(); sc_i++) { sub_ents[sc_i]->PrepareForDestruction(); } sub_ents.Clear(); } void CEntity::SetRotVel(float in_Xrot_f, float in_Yrot_f, float in_Zrot_f) { rv_v3f.SetXYZ(in_Xrot_f, in_Yrot_f,in_Zrot_f); } CVec3f CEntity::GetRotVel() { return rv_v3f; }