home *** CD-ROM | disk | FTP | other *** search
- #include "GameObject.h"
-
- #include <stdio.h>
- #include <math.h>
-
- GameObject::GameObject(){
- vectorInit3d(0.0, 0.0, 0.0, pos);
- vectorInit3d(0.0, 0.0, 1.0, dir);
- vectorInit3d(0.0, 1.0, 0.0, up);
- vectorInit3d(1.0, 0.0, 0.0, left);
- vectorInit3d(0.0, 0.0, 0.0, vel);
- yaw=0.0f;
- pitch=PI*0.5f;
- turnSpeed=0.0f;
- moveSpeed=0.0f;
-
- attachedDlpcs.clear();
- }
-
- GameObject::~GameObject(){
- // list<DynamicLightParticleCluster*>::iterator iter = attachedDlpcs.begin();
- while( !attachedDlpcs.empty() ){
- Renderer::particleSystem.unlinkParticleCluster( attachedDlpcs.front() );
- delete attachedDlpcs.front(); // this will result in a call to detachDLPC() and remove the item
- }
- }
-
- void GameObject::reconstructVectors(){
- vectorCrossP3d(up, dir, left);
- vectorCrossP3d(dir, left, up);
-
- vectorNormalize3d(dir, dir);
- vectorNormalize3d(up, up);
- vectorNormalize3d(left, left);
- }
-
- void GameObject::vectorsFromAngles(){
- vectorInit3d((float)(cos(yaw)*sin(pitch)), (float)(cos(pitch)), (float)(sin(yaw)*sin(pitch)), dir);
- float upPitch=pitch - PI*0.5f;
- vectorInit3d((float)(cos(yaw)*sin(upPitch)), (float)(cos(upPitch)), (float)(sin(yaw)*sin(upPitch)), up);
- vectorCrossP3d(up, dir, left);
- }
-
- void GameObject::anglesFromVectors(){
- pitch = (float)acos( dir[1] );
- // yaw = vectorAngle3d( left
- if( left[0] < 0.0f ){
- yaw = PI + (float)acos(left[2]);
- }else{
- yaw = /*PI*0.5f + */(float)acos(-left[2]);
- }
- }
-
-
- /*
- void GameObject::move(float deltaT){
- if(vectorLengthSquared3d(vel)<0.0001f)
- return;
-
- vectorNormalize3d(vel, vel);
- vectorScale3d(deltaT*moveSpeed, vel, vel);
- if(noclip || collisionDetection(vel)) // check if move is save
- vectorAdd3d(pos, vel, pos); // ...and move
- }
- */
-
-
- void GameObject::attachDynamicLightParticleCluster(DynamicLightParticleCluster* dlpc){
- attachedDlpcs.push_back(dlpc);
- }
-
- void GameObject::detachDynamicLightParticleCluster(DynamicLightParticleCluster* dlpc){
- attachedDlpcs.remove(dlpc);
- }
-