00001 /*************************************************************************** 00002 SimLeg.h - description 00003 ------------------- 00004 begin : mer jun 25 2003 00005 copyright : (C) 2003 by Yann Le Guyadec, Michel DUBOIS 00006 email : Yann.Le-Guyadec@univ-ubs.fr, Michel.Dubois@univ-ubs.fr 00007 ***************************************************************************/ 00008 00009 /*************************************************************************** 00010 * * 00011 * This program is free software; you can redistribute it and/or modify * 00012 * it under the terms of the GNU General Public License as published by * 00013 * the Free Software Foundation; either version 2 of the License, or * 00014 * (at your option) any later version. * 00015 * * 00016 ***************************************************************************/ 00017 00018 #ifndef SIMLEG_H 00019 #define SIMLEG_H 00020 00021 #include "RigidBody.h" 00022 #include "RigidBodyEntity.h" 00023 #include "SimServoMotor.h" 00024 #include "Matrix22.h" 00025 #include "Vector2.h" 00026 #include "Vector3.h" 00027 #include "SphereGeometry.h" 00028 #include "RigidBodyCollider.h" 00029 #include "CylinderGeometry.h" 00030 #include "LegGeometry.h" 00031 #include "SimAtom.h" 00032 //#include "RayGeometry.h" 00033 #include "SimLinkedLeg.h" 00034 00039 #define CAPPEDCYLINDER 0 00040 #define BOX 1 00041 #define FLATCYLINDER 2 00042 #define COMPLEX 3 00043 00044 class SimAtom; 00045 class SimLinkedLeg; 00046 00047 class SimLeg : public RigidBodyEntity { 00048 friend class SimLink; 00049 #ifdef LEGLINK 00050 friend class SimLinkedLeg; 00051 #endif 00052 friend class SimServoMotor; 00053 00054 protected: 00055 int ID; 00056 SimAtom * simatom; 00057 SimRigidBody * sphere; 00058 SphereGeometry * sphereGeometry; 00059 RigidBodyCollider * sphereCollider; 00060 SimRigidBody * body; 00061 Geometry * bodyGeometry; 00062 RigidBodyCollider * bodyCollider; 00063 SimServoMotor * servo[2]; 00064 #ifdef LEGLINK 00065 SimLinkedLeg * linkedLeg; 00066 #endif 00067 #ifndef LEGLINK 00068 SimLink * slink; 00069 #endif 00070 00071 public: 00072 SimLeg(SimAtom * atom, int aLegID); 00073 ~SimLeg(); 00074 void handleEvent (Event * event); 00075 unsigned int getSimServoMotorCount() const; 00076 SimServoMotor * getSimServoMotor(unsigned int aSimServoMotorID) const; 00077 Vector3 getVector(int Geometry=0) const; 00078 Vector3 getAbsPosSphere() const; 00079 Vector3 getAbsPosBody() const; 00080 Vector3 getAbsPosEnd() const; 00081 Vector3 getAbsPosConnexionDevice(unsigned int device) const; 00082 bool isConnectable(SimLeg * aSimLeg) const; 00083 Vector3 getAxis(unsigned int index,int Geometry=0) const; 00084 Real getRotationAngle(int Geometry=0) const; 00085 Vector3 getColor() const; 00086 void link(SimLeg * aSimLeg); 00087 void unlink(); 00088 bool isLinked(); 00089 virtual void print(); 00090 static std::string legCollision; 00091 }; 00092 00093 #endif