Unit1.cpp 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. //---------------------------------------------------------------------------
  2. #include <vcl.h>
  3. #pragma hdrstop
  4. #include "Unit1.h"
  5. //---------------------------------------------------------------------------
  6. #pragma package(smart_init)
  7. #pragma link "GLBaseClasses"
  8. #pragma link "GLBitmapFont"
  9. #pragma link "GLCadencer"
  10. #pragma link "GLCoordinates"
  11. #pragma link "GLCrossPlatform"
  12. #pragma link "GLHUDObjects"
  13. #pragma link "GLMaterial"
  14. #pragma link "GLObjects"
  15. #pragma link "GLScene"
  16. #pragma link "GLShadowPlane"
  17. #pragma link "GLVectorFileObjects"
  18. #pragma link "GLWin32Viewer"
  19. #pragma link "GLWindowsFont"
  20. #pragma resource "*.dfm"
  21. TfRagDoll *fRagDoll;
  22. //---------------------------------------------------------------------------
  23. __fastcall TfRagDoll::TfRagDoll(TComponent* Owner)
  24. : TForm(Owner)
  25. {
  26. }
  27. //---------------------------------------------------------------------------
  28. __fastcall TWorld_ODE::TWorld_ODE(TObject *AOwner)
  29. {
  30. TdMatrix3 R;
  31. ODEEnable = false;
  32. PhysTime = 0;
  33. //Create physic
  34. World = dWorldCreate();
  35. dWorldSetQuickStepNumIterations(World, 8);
  36. Space = dHashSpaceCreate(NULL);
  37. ///- contactgroup = &dJointGroupCreate(0);
  38. dWorldSetGravity (World, 0, 0, -0.81);
  39. dWorldSetCFM (World, 1e-5);
  40. //Floor
  41. dCreatePlane (Space, 0, 0, 1, 0);
  42. //Box wall limit
  43. dCreatePlane (Space, 0, 1, 0, -50.00);
  44. dCreatePlane (Space, 1, 0, 0, -50.00);
  45. dCreatePlane (Space, 0,-1, 0, -50.00);
  46. dCreatePlane (Space, -1, 0, 0, -50.00);
  47. // Create 1 GLSCube and a box space.
  48. Ground_box = dCreateBox(Space,25,50,50);
  49. dRFromAxisAndAngle (R,0,1,0,0.95);
  50. dGeomSetPosition(Ground_box,32,5,0.5);
  51. dGeomSetRotation(Ground_box,R);
  52. Cube = (TGLCube*)(fRagDoll->ODEScene->AddNewChild(__classid(TGLCube)));
  53. PdxGeom(Ground_box)->data = Cube;
  54. CopyCubeSizeFromBox(Cube, Ground_box);
  55. PositionSceneObject((TGLBaseSceneObject*)(PdxGeom(Ground_box)->data), Ground_box);
  56. // Same Create 1 GLSCube and a box space.
  57. Ground_box2 = dCreateBox (Space,5,10,5);
  58. dRFromAxisAndAngle (R,0,1,0,0);
  59. dGeomSetPosition (Ground_box2,-12,-5,2.5);
  60. dGeomSetRotation (Ground_box2,R);
  61. Cube2 = (TGLCube*)(fRagDoll->ODEScene->AddNewChild(__classid(TGLCube)));
  62. PdxGeom(Ground_box2)->data = Cube2;
  63. CopyCubeSizeFromBox(Cube2, Ground_box2);
  64. PositionSceneObject((TGLBaseSceneObject*)(PdxGeom(Ground_box2)->data), Ground_box2);
  65. // Create now a sphere
  66. Ground_box2 = dCreateSphere (Space,5);
  67. dGeomSetPosition (Ground_box2,0,-15,2.5);
  68. PdxGeom(Ground_box2)->data = (TGLSphere*)(fRagDoll->ODEScene->AddNewChild(__classid(TGLSphere)));
  69. ///- (TGLSphere*)(PdxGeom(Ground_box2)->data)->Radius = 5;
  70. PositionSceneObject((TGLSphere*)(PdxGeom(Ground_box2)->data), Ground_box2);
  71. }