TargetLife.h

Go to the documentation of this file.
00001 ////////////////////////////////////////////////////////////////////////////////
00002 //    Scorched3D (c) 2000-2009
00003 //
00004 //    This file is part of Scorched3D.
00005 //
00006 //    Scorched3D is free software; you can redistribute it and/or modify
00007 //    it under the terms of the GNU General Public License as published by
00008 //    the Free Software Foundation; either version 2 of the License, or
00009 //    (at your option) any later version.
00010 //
00011 //    Scorched3D is distributed in the hope that it will be useful,
00012 //    but WITHOUT ANY WARRANTY; without even the implied warranty of
00013 //    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014 //    GNU General Public License for more details.
00015 //
00016 //    You should have received a copy of the GNU General Public License
00017 //    along with Scorched3D; if not, write to the Free Software
00018 //    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00019 ////////////////////////////////////////////////////////////////////////////////
00020 
00021 #if !defined(__INCLUDE_TargetLifeh_INCLUDE__)
00022 #define __INCLUDE_TargetLifeh_INCLUDE__
00023 
00024 #include <engine/ScorchedCollisionIds.h>
00025 #include <target/TargetSpaceContainment.h>
00026 #include <net/NetBuffer.h>
00027 #include <common/FixedVector4.h>
00028 
00029 class ScorchedContext;
00030 class Target;
00031 class TargetLife
00032 {
00033 public:
00034         TargetLife(ScorchedContext &context, unsigned int playerId);
00035         virtual ~TargetLife();
00036 
00037         void newGame();
00038 
00039         // Position
00040         void setTargetPositionAndRotation(FixedVector &position, fixed rotation);
00041         void setTargetPosition(FixedVector &position);
00042         FixedVector &getTargetPosition() { return targetPosition_; }
00043         FixedVector &getCenterPosition();
00044         void setSize(FixedVector &size);
00045         FixedVector &getSize() { return size_; }
00046         FixedVector4 &getQuaternion() { return quaternion_; }
00047         FixedVector &getAabbSize() { return aabbSize_; }
00048         void setRotation(fixed rotation);
00049         FixedVector &getVelocity() { return velocity_; }
00050         void setVelocity(FixedVector &velocity) { velocity_ = velocity; }
00051 
00052         void setTarget(Target *target) { target_ = target; }
00053         void setBoundingSphere(bool sphereGeom);
00054         bool getBoundingSphere() { return sphereGeom_; }
00055         TargetSpaceContainment &getSpaceContainment() { return spaceContainment_; }
00056 
00057         // Client only performance functions
00058         Vector &getFloatPosition() { return floatPosition_; }
00059         Vector &getFloatAabbSize() { return floatAabbSize_; }
00060         float *getFloatRotMatrix() { return floatRotMatrix_; }
00061         float getFloatBoundingSize() { return floatBoundingSize_; }
00062         Vector &getFloatCenterPosition();
00063 
00064         // Collision
00065         fixed collisionDistance(FixedVector &position);
00066         bool collision(FixedVector &position);
00067 
00068         // Tank Life / Health
00069         fixed getLife() { return life_; }
00070         void setLife(fixed life);
00071         fixed getMaxLife() { return maxLife_; }
00072         void setMaxLife(fixed life) { maxLife_ = life; }
00073 
00074         // Serialize the tank
00075         bool writeMessage(NetBuffer &buffer);
00076         bool readMessage(NetBufferReader &reader);
00077 
00078 protected:
00079         ScorchedContext &context_;
00080         TargetSpaceContainment spaceContainment_;
00081         Target *target_;
00082         FixedVector4 quaternion_;
00083         FixedVector targetPosition_;
00084         FixedVector velocity_;
00085         FixedVector aabbSize_;
00086         FixedVector size_;
00087         Vector floatPosition_;
00088         Vector floatAabbSize_;
00089         float floatRotMatrix_[16], floatBoundingSize_;
00090         fixed life_;
00091         fixed maxLife_;
00092         bool sphereGeom_;
00093 
00094         void updateSpace();
00095         void updateAABB();
00096 
00097 };
00098 
00099 #endif // __INCLUDE_TargetLifeh_INCLUDE__
00100 

Generated on Mon Feb 16 15:14:52 2009 for Scorched3D by  doxygen 1.5.3