Advertisement
Guest User

GlutDemoApplication

a guest
Dec 27th, 2014
273
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 3.10 KB | None | 0 0
  1.  
  2. class RagdollDemo : public GlutDemoApplication
  3. {
  4.     //keep the collision shapes, for deletion/cleanup
  5.     btAlignedObjectArray<btCollisionShape*> m_collisionShapes;
  6.  
  7.     btBroadphaseInterface * m_broadphase;
  8.     btCollisionDispatcher * m_dispatcher;
  9.     btConstraintSolver    * m_solver;
  10.     btDefaultCollisionConfiguration * m_collisionConfiguration;
  11.  
  12.     // one main body,
  13.     // 4x2 leg segments,
  14.     // one north marker,
  15.     // 4 ball elbows.    
  16.     btCollisionShape  * geom[42];  
  17.     btHingeConstraint * joints[8];
  18.     btFixedConstraint * welds[4];
  19.     btCollisionObject * fixedGround;
  20.  
  21.     int IDs[45];
  22.     bool oneStep;
  23.     bool pause;
  24.     double globaljointA;
  25.     double currjointA[8];  
  26.     unsigned long int simtick; 
  27.    
  28.     double touchsensor[4];
  29.    
  30.  
  31. public:
  32.     btRigidBody       * body[42];
  33.     double weights[4][8];
  34.     bool OPTdrawgraphics;
  35.     bool OPTloadbestweights;
  36.     char OPTbestweightsfile[80];
  37.     int touches[43];
  38.     btVector3 touchPoints[43];
  39.     unsigned long int timeStep;
  40.     int threadID;
  41.     bool position_sane;
  42.  
  43. public:
  44.     void initPhysics();
  45.     void exitPhysics();
  46.  
  47.     virtual ~RagdollDemo()
  48.     {
  49.         exitPhysics();
  50.     }
  51.      
  52.     virtual void clientMoveAndDisplay();
  53.     virtual void displayCallback();
  54.     virtual void keyboardCallback(unsigned char key, int x, int y);
  55.    
  56.     static DemoApplication* Create()
  57.     {
  58.         RagdollDemo* demo = new RagdollDemo();
  59.         demo->myinit();
  60.         demo->initPhysics();
  61.         return demo;
  62.     }
  63.  
  64.      virtual void renderme() {               
  65.         extern GLDebugDrawer gDebugDrawer;
  66.         // Call the parent method.
  67.         GlutDemoApplication::renderme();
  68.      }
  69.  
  70.     void CreateBox(
  71.         int index,
  72.         double x,       double y,       double z,
  73.         double length,  double width,   double height );
  74.  
  75.     void CreateCylinder(
  76.         int index,
  77.         double x,       double y,       double z,
  78.         double length,  double width,   double height,
  79.         double xrot ,   double yrot ,   double zrot );
  80.    
  81.     void CreateSphere(
  82.         int index,
  83.         double x,       double y,       double z,
  84.         double radius );
  85.  
  86.     void BuildWallofCans(void);
  87.  
  88.     void CreateHinge(int index,
  89.                      int body1, int body2,
  90.                      double x, double y, double z,
  91.                      double ax, double ay, double az);
  92.  
  93.     void CreateWeld(int index,
  94.                      int body1, int body2 );
  95.  
  96.     void DeleteObject( int index );
  97.     void DestroyHinge( int index );
  98.     void DestroyWeld(  int index );
  99.  
  100.     void ActuateJoint(  int jointIndex, double desiredAngle,
  101.                         double jointOffset, double timeStep);
  102.  
  103.     void ActuateJoint2( int jointIndex, double desiredAngle,
  104.                         double jointOffset, double timeStep);
  105.  
  106.     btVector3 PointWorldToLocal(int index, btVector3 &p);
  107.     btVector3 AxisWorldToLocal( int index, btVector3 &a);
  108.     double ConvertActuatorToJoint(int index, double actang);
  109.     double RandomJoint(void);
  110.     double RandomWeight(void);
  111.     void ConsoleFloat(double cf);
  112.     void ConsoleTouches(void);
  113.     int GetFileWeights(char * GFWname );
  114.     int SavePosition( btRigidBody * spbody, char * SPname );
  115.     void WeightFileHandler(void);
  116.     double Fitness(void);
  117.     void AssignToCallback(void);
  118.     bool SanityCheck(double maxbound);
  119.     inline bool airborne(void);
  120. };
  121.  
  122. inline bool RagdollDemo::airborne(void)
  123. {
  124.     return( (touches[5]==0) && (touches[6]==0) &&  (touches[7]==0) &&(touches[8]==0)    );
  125. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement