Back to index

supertuxkart  0.5+dfsg1
moveable.hpp
Go to the documentation of this file.
00001 //  $Id: moveable.hpp 2111 2008-05-31 07:04:30Z cosmosninja $
00002 //
00003 //  SuperTuxKart - a fun racing game with go-kart
00004 //  Copyright (C) 2004-2005 Steve Baker <sjbaker1@airmail.net>
00005 //  Copyright (C) 2006 Joerg Henrichs, Steve Baker
00006 //
00007 //  This program is free software; you can redistribute it and/or
00008 //  modify it under the terms of the GNU General Public License
00009 //  as published by the Free Software Foundation; either version 2
00010 //  of the License, or (at your option) any later version.
00011 //
00012 //  This program is distributed in the hope that it will be useful,
00013 //  but WITHOUT ANY WARRANTY; without even the implied warranty of
00014 //  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00015 //  GNU General Public License for more details.
00016 //
00017 //  You should have received a copy of the GNU General Public License
00018 //  along with this program; if not, write to the Free Software
00019 //  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
00020 
00021 #ifndef HEADER_MOVEABLE_H
00022 #define HEADER_MOVEABLE_H
00023 
00024 #include <plib/ssg.h>
00025 #include "material.hpp"
00026 #include "btBulletDynamicsCommon.h"
00027 #include "user_pointer.hpp"
00028 
00029 /* Limits of Kart performance */
00030 #define CRASH_PITCH          -45.0f
00031 
00032 #define MAX_HERRING_EATEN    20
00033 
00034 
00035 class Moveable 
00036 {
00037 private:
00038     btVector3     m_velocityLC;      /* velocity in kart coordinates                */
00039 protected:
00040     UserPointer   m_user_pointer;
00041     sgCoord       m_reset_pos;       /* Where to start in case of a reset           */
00042     sgCoord       m_curr_pos;        /* current position                            */
00043     sgVec4*       m_normal_hot;      /* plane on which HOT was computed             */
00044     Material*     m_material_hot;    /* Material at HOT                             */
00045     ssgTransform* m_model_transform;            // The transform where the model is under
00046     ssgTransform* m_shadow;
00047     int           m_collided;
00048     int           m_crashed;
00049     sgVec3        m_surface_avoidance_vector ;
00050     int           m_first_time ;
00051     sgCoord*      m_history_velocity;
00052     sgCoord*      m_history_position;
00053     btRigidBody*          m_body;
00054     btDefaultMotionState* m_motion_state;
00055     btTransform   m_transform;
00056 
00057 public:
00058 
00059     Moveable (bool bHasHistory=false);
00060     virtual ~Moveable();
00061 
00062     ssgTransform* getModelTransform()          {return m_model_transform;          }
00063     virtual const btVector3 &getVelocity() const {return m_body->getLinearVelocity();}
00064     const btVector3 &getVelocityLC() const     {return m_velocityLC;               }
00065     virtual void  setVelocity(const btVector3& v) {m_body->setLinearVelocity(v);   }
00066     sgCoord*      getCoord     ()              {return &m_curr_pos;                }
00067     const btVector3 getPos     ()  const       {return m_transform.getOrigin();    }
00068     const sgCoord* getCoord    ()  const       {return &m_curr_pos;                }
00069     const sgVec4* getNormalHOT ()  const       {return m_normal_hot;               }
00070     void          setCoord     (sgCoord* pos)  {sgCopyCoord ( &m_curr_pos,pos);    }
00071     virtual void  placeModel   ();
00072     virtual void  handleZipper ()              {};
00073     virtual void  reset        ();
00074     virtual void  update       (float dt) ;
00075     void          WriteHistory (char* s, int kartNumber, int indx);
00076     void          ReadHistory  (char* s, int kartNumber, int indx);
00077     btRigidBody*  getBody   () const {return m_body; }
00078     void          createBody(float mass, btTransform& trans, 
00079                              btCollisionShape *shape);
00080     const btTransform&  getTrans() const {return m_transform;}
00081     void          setTrans  (btTransform& t){m_transform=t;m_motion_state->setWorldTransform(t);}
00082 }
00083 ;   // class Moveable
00084 
00085 #endif