bullet.monkey2 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613
  1. Namespace bullet
  2. #Import "<libc>"
  3. #Import "<std>"
  4. #Import "bullet3-2.85.1/src/*.h"
  5. #Import "bullet_glue.cpp"
  6. #Import "bullet_glue.h"
  7. #Import "makefile_linearmath"
  8. #Import "makefile_collision"
  9. #Import "makefile_dynamics"
  10. Using std.geom
  11. Alias btScalar:Float
  12. Extern
  13. Struct btVector3
  14. Field x:btScalar="m_floats[0]"
  15. Field y:btScalar="m_floats[1]"
  16. Field z:btScalar="m_floats[2]"
  17. Method New()
  18. Method New( x:btScalar,y:btScalar,z:btScalar )
  19. End
  20. Struct btVector4
  21. Field x:btScalar="m_floats[0]"
  22. Field y:btScalar="m_floats[1]"
  23. Field z:btScalar="m_floats[2]"
  24. Field w:btScalar="m_floats[3]"
  25. Method New()
  26. Method New( x:btScalar,y:btScalar,z:btScalar,w:btScalar )
  27. End
  28. Struct btMatrix3x3
  29. Method New()
  30. Method New( xx:btScalar,xy:btScalar,xz:btScalar,yx:btScalar,yy:btScalar,yz:btScalar,zx:btScalar,zy:btScalar,zz:btScalar )
  31. Method getRow:btVector3( i:Int )
  32. Method getColumn:btVector3( j:Int )
  33. End
  34. Struct btQuaternion
  35. Field x:btScalar="m_floats[0]"
  36. Field y:btScalar="m_floats[1]"
  37. Field z:btScalar="m_floats[2]"
  38. Field w:btScalar="m_floats[3]"
  39. Method New()
  40. Method New( x:btScalar,y:btScalar,z:btScalar,w:btScalar )
  41. End
  42. Struct btTransform
  43. Method New()
  44. Method New( q:btQuaternion,c:btVector3=New btVector3( 0,0,0 ) )
  45. Method New( b:btMatrix3x3,c:btVector3=New btVector3( 0,0,0 ) )
  46. Method setOrigin( origin:btVector3 )
  47. Method getOrigin:btVector3()
  48. Method setBasis( basis:btMatrix3x3 )
  49. Method getBasis:btMatrix3x3()
  50. Method setFromOpenGLMatrix( m:Float Ptr )
  51. Method getOpenGLMatrix( m:Float Ptr )
  52. Method getOpenGLMatrix2( m:Float Ptr )
  53. Function getIdentity:btTransform()
  54. End
  55. Class btObject Extends Void
  56. Method destroy() Extension="delete"
  57. End
  58. Class btBroadphaseInterface Extends btObject
  59. End
  60. Class btDbvtBroadphase Extends btBroadphaseInterface
  61. End
  62. Class btMultiSapBroadphase Extends btBroadphaseInterface
  63. End
  64. Class btSimpleBroadphase Extends btBroadphaseInterface
  65. End
  66. Class btCollisionConfiguration Extends btObject
  67. End
  68. Class btDefaultCollisionConfiguration Extends btCollisionConfiguration
  69. End
  70. Class btConstraintSolver Extends btObject
  71. End
  72. Class btSequentialImpulseConstraintSolver Extends btConstraintSolver
  73. End
  74. Class btDispatcher Extends btObject
  75. End
  76. Class btCollisionDispatcher Extends btDispatcher
  77. Method New( collisionConfiguration:btCollisionConfiguration )
  78. End
  79. Class btBroadphaseProxy Extends btObject
  80. End
  81. Class btCollisionWorld Extends btObject
  82. Struct LocalShapeInfo
  83. Field m_shapePart:Int
  84. Field m_triangleIndex:int
  85. End
  86. Struct LocalRayResult
  87. Field m_collisionObject:btCollisionObject
  88. Field m_localShapeInfo:LocalShapeInfo Ptr
  89. Field m_hitNormalLocal:btVector3
  90. Field m_hitFraction:btScalar
  91. End
  92. Struct RayResultCallback
  93. Field m_closestHitFraction:btScalar
  94. Field m_collisionObject:btCollisionObject
  95. Field m_collisionFilterGroup:Short
  96. Field m_collisionFilterMask:Short
  97. Field m_flags:UInt
  98. Method hasHit:Bool()
  99. ' Method needsCollision:Bool( proxy0:btBroadphaseProxy ) Virtual
  100. ' Method addSingleResult:btScalar( rayResult:LocalRayResult Ptr,normalInWorldSpace:Bool ) Virtual
  101. End
  102. Struct ClosestRayResultCallback
  103. Field m_closestHitFraction:btScalar
  104. Field m_collisionObject:btCollisionObject
  105. Field m_collisionFilterGroup:Short
  106. Field m_collisionFilterMask:Short
  107. Field m_flags:UInt
  108. Field m_rayFromWorld:btVector3
  109. Field m_rayToWorld:btVector3
  110. Field m_hitNormalWorld:btVector3
  111. Field m_hitPointWorld:btVector3
  112. Method New( rayFromWorld:btVector3,rayToWorld:btVector3 )
  113. Method hasHit:Bool()
  114. End
  115. Struct ConvexResultCallback
  116. Field m_closestHitFraction:btScalar
  117. Field m_collisionFilterGroup:Short
  118. Field m_collisionFilterMask:Short
  119. Method hasHit:Bool()
  120. End
  121. Struct ClosestConvexResultCallback
  122. Field m_closestHitFraction:btScalar
  123. Field m_collisionFilterGroup:Short
  124. Field m_collisionFilterMask:Short
  125. Field m_convexFromWorld:btVector3
  126. Field m_convexToWorld:btVector3
  127. Field m_hitNormalWorld:btVector3
  128. Field m_hitPointWorld:btVector3
  129. Field m_hitCollisionObject:btCollisionObject
  130. Method New( castFrom:btVector3,castTo:btVector3 )
  131. Method hasHit:Bool()
  132. End
  133. Method rayTest( rayFromWorld:btVector3,rayToWorld:btVector3,resultCallback:RayResultCallback Ptr ) Extension="bbBullet::rayTest"
  134. Method convexSweepTest( castShape:btConvexShape,castFrom:btTransform,castTo:btTransform,resultCallback:ConvexResultCallback ptr,allowedCcdPenetration:btScalar=0 ) Extension="bbBullet::convexSweepTest"
  135. Method addCollisionObject( collisionObject:btCollisionObject )
  136. Method removeCollisionObject( collisionObject:btCollisionObject )
  137. End
  138. Class btDynamicsWorld Extends btCollisionWorld
  139. Method setGravity( gravity:btVector3 )
  140. Method getGravity:btVector3()
  141. Method stepSimulation( timeStep:btScalar,maxSubSteps:Int=1,fixedTimeStep:btScalar=1.0/60.0 ) Virtual
  142. Method addRigidBody( body:btRigidBody ) Virtual
  143. Method addRigidBody( body:btRigidBody,group:Short,mask:Short ) Virtual
  144. Method removeRigidBody( body:btRigidBody ) Virtual
  145. Method addConstraint( constraint:btTypedConstraint,disableCollisionsBetweenLinkedBodies:Bool=False )
  146. Method removeConstraint( constraint:btTypedConstraint )
  147. End
  148. Class btDiscreteDynamicsWorld Extends btDynamicsWorld
  149. Method New( dispatcher:btDispatcher,pairCache:btBroadphaseInterface,contraintSolver:btConstraintSolver,collisionConfiguration:btCollisionConfiguration )
  150. End
  151. Class btCollisionShape Extends btObject
  152. Method setLocalScaling( scaling:btVector3 )
  153. Method getLocalScaling:btVector3()
  154. Method setMargin( margin:btScalar )
  155. Method getMargin:btScalar()
  156. Method setUserPointer( p:Void Ptr )
  157. Method getUserPointer:Void Ptr()
  158. Method calculateLocalInertia:btVector3( mass:btScalar ) Extension="bbBullet::calculateLocalInertia"
  159. End
  160. Class btCompoundShape Extends btCollisionShape
  161. Method New( enableDynamicAabbTree:Bool=True,initialChildCapacity:int=0 )
  162. Method addChildShape( localTransform:btTransform,shape:btCollisionShape )
  163. End
  164. Class btConcaveShape Extends btCollisionShape
  165. End
  166. Class btConvexShape Extends btCollisionShape
  167. End
  168. Class btConvexInternalShape Extends btConvexShape
  169. End
  170. Class btPolyhedralConvexShape Extends btConvexInternalShape
  171. End
  172. Class btEmptyShape Extends btConcaveShape
  173. End
  174. Class btBoxShape Extends btPolyhedralConvexShape
  175. Method New( boxHalfExtents:btVector3 )
  176. End
  177. Class btStaticPlaneShape Extends btConcaveShape
  178. Method New( planeNormal:btVector3,planeConstant:btScalar )
  179. End
  180. Class btSphereShape Extends btConvexShape
  181. Method New( radius:btScalar )
  182. End
  183. Class btCapsuleShape Extends btConvexShape
  184. Method New( radius:btScalar,height:btScalar )
  185. End
  186. Class btCapsuleShapeX Extends btCapsuleShape
  187. Method New( radius:btScalar,height:btScalar )
  188. End
  189. Class btCapsuleShapeZ Extends btCapsuleShape
  190. Method New( radius:btScalar,height:btScalar )
  191. End
  192. Class btCylinderShape Extends btConvexShape
  193. Method New( halfExtents:btVector3 )
  194. End
  195. Class btCylinderShapeX Extends btCylinderShape
  196. Method New( halfExtents:btVector3 )
  197. End
  198. Class btCylinderShapeZ Extends btCylinderShape
  199. Method New( halfExtents:btVector3 )
  200. End
  201. Class btConeShape Extends btConvexShape
  202. Method New( radius:btScalar,height:btScalar )
  203. End
  204. Class btConeShapeX Extends btConeShape
  205. Method New( radius:btScalar,height:btScalar )
  206. End
  207. Class btConeShapeZ Extends btConeShape
  208. Method New( radius:btScalar,height:btScalar )
  209. End
  210. Class btConvexHullShape Extends btConvexShape
  211. Method New( points:btScalar Ptr,numPoints:Int,stride:Int )
  212. ' Method addPoint( point:btVector3,recalculateLocalAabb:Bool=True )
  213. End
  214. Enum PHY_ScalarType
  215. End
  216. Const PHY_FLOAT:PHY_ScalarType
  217. Const PHY_DOUBLE:PHY_ScalarType
  218. Const PHY_INTEGER:PHY_ScalarType
  219. Const PHY_SHORT:PHY_ScalarType
  220. Const PHY_FIXEPOINT88:PHY_ScalarType
  221. Const PHY_UCHAR:PHY_ScalarType
  222. Class btHeightfieldTerrainShape Extends btConcaveShape
  223. Method New( heightStickWidth:Int,heightStickLength:Int,heightfieldData:Void Ptr,heightScale:btScalar,minHeight:btScalar,maxHeight:btScalar,upAxis:Int,heightDataType:PHY_ScalarType,flipQuadEdges:Bool )
  224. Method setUseDiamondSubdivision( useDiamondSubdivision:Bool=True )
  225. Method setUseZigzagSubdivision( useZigZagSubdivision:Bool=True )
  226. End
  227. Class btTriangleMeshShape Extends btConcaveShape
  228. Field m_convexEpsilon:btScalar
  229. Field m_planarEpsilon:btScalar
  230. Field m_equalVertexThreshold:btScalar
  231. Field m_edgeDistanceThreshold:btScalar
  232. Field m_maxEdgeAngleThreshold:btScalar
  233. Field m_zeroAreaThreshold:btScalar
  234. End
  235. Class btBvhTriangleMeshShape Extends btTriangleMeshShape
  236. Method New( meshInterface:btStridingMeshInterface,useQuantizedAabbCompression:Bool,buildBvh:Bool=True )
  237. End
  238. Class btStridingMeshInterface Extends btObject
  239. End
  240. Class btTriangleIndexVertexArray Extends btStridingMeshInterface
  241. Method New( numTriangles:Int,triangleIndexBase:Int Ptr,triangleIndexStride:Int,numVertices:Int,vertexBase:btScalar Ptr,vertexStride:Int )
  242. End
  243. Class btMotionState Extends btObject="bbBullet::MotionState"
  244. Method setWorldTransform( worldTrans:btTransform Ptr ) Virtual
  245. Method getWorldTransform( worldTrans:btTransform Ptr ) Virtual
  246. End
  247. Class btDefaultMotionState Extends btMotionState="bbBullet::DefaultMotionState"
  248. Field m_graphicsWorldTrans:btTransform
  249. Field m_centerOfMassOffset:btTransform
  250. Field m_startWorldTrans:btTransform
  251. Field m_userPointer:Void Ptr
  252. Method New()
  253. Method New( startTrans:btTransform=btTransform.getIdentity(),centerOfMassOffset:btTransform=btTransform.getIdentity() )
  254. End
  255. Const ACTIVE_TAG:Int
  256. Const ISLAND_SLEEPING:Int
  257. Const WANTS_DEACTIVATION:Int
  258. Const DISABLE_DEACTIVATION:Int
  259. Const DISABLE_SIMULATION:Int
  260. Class btCollisionObject Extends btObject
  261. Const CF_STATIC_OBJECT:Int="btCollisionObject::CF_STATIC_OBJECT"
  262. Const CF_KINEMATIC_OBJECT:Int="btCollisionObject::CF_KINEMATIC_OBJECT"
  263. Const CF_NO_CONTACT_RESPONSE:Int="btCollisionObject::CF_NO_CONTACT_RESPONSE"
  264. Const CF_CUSTOM_MATERIAL_CALLBACK:Int="btCollisionObject::CF_CUSTOM_MATERIAL_CALLBACK"
  265. Const CF_CHARACTER_OBJECT:Int="btCollisionObject::CF_CHARACTER_OBJECT"
  266. Const CF_DISABLE_VISUALIZE_OBJECT:Int="btCollisionObject::CF_DISABLE_VISUALIZE_OBJECT"
  267. Const CF_DISABLE_SPU_COLLISION_PROCESSING:Int="btCollisionObject::CF_DISABLE_SPU_COLLISION_PROCESSING"
  268. Method isStaticObject:Bool()
  269. Method isKinematicObject:Bool()
  270. Method isStaticOrKinematicObject:Bool()
  271. Method hasContactResponse:Bool()
  272. Method setCollisionShape( collisionShape:btCollisionShape )
  273. Method getCollisionShape:btCollisionShape()
  274. Method setWorldTransform( transform:btTransform )
  275. Method getWorldTransform:btTransform()
  276. Method setRestitution( restitution:btScalar )
  277. Method getRestitution:btScalar()
  278. Method setFriction( friction:btScalar )
  279. Method getFriction:btScalar()
  280. Method setRollingFriction( friction:btScalar )
  281. Method getRollingFriction:btScalar()
  282. Method setSpinningFriction( friction:btScalar )
  283. Method getSpinningFriction:btScalar()
  284. Method setContactStiffnessAndDamping( stiffness:btScalar,damping:btScalar )
  285. Method getContactStiffness:btScalar()
  286. Method getContactDamping:btScalar()
  287. Method setCcdSweptSphereRadius( radius:btScalar )
  288. Method getCcdSweptSphereRadius:btScalar()
  289. Method setCcdMotionThreshold( ccdMotionTheshold:btScalar )
  290. Method getCcdMotionThreshold:btScalar()
  291. Method setCollisionFlags( flags:Int )
  292. Method getCollisionFlags:Int()
  293. Method setActivationState( newState:Int )
  294. Method forceActivationState( newState:Int )
  295. Method getActivationState:Int()
  296. Method setUserPointer( p:Void Ptr )
  297. Method getUserPointer:void ptr()
  298. End
  299. Struct btRigidBodyConstructionInfo
  300. Field m_mass:btScalar
  301. Field m_motionState:btMotionState
  302. Field m_startWorldTransform:btTransform
  303. Field m_collisionShape:btCollisionShape
  304. Field m_localInertia:btVector3
  305. Field m_linearDamping:btScalar
  306. Field m_angularDamping:btScalar
  307. Field m_friction:btScalar
  308. Field m_rollingFriction:btScalar
  309. Field m_restitution:btScalar
  310. Field m_linearSleepingThreshold:btScalar
  311. Field m_angularSleepingThreshold:btScalar
  312. Field m_additionalDamping:Bool
  313. Field m_additionalDampingFactor:btScalar
  314. Field m_additionalLinearDampingThresholdSqr:btScalar
  315. Field m_additionalAngularDampingThresholdSqr:btScalar
  316. Field m_additionalAngularDampingFactor:btScalar
  317. Method New( mass:btScalar,motionState:btMotionState,collisionShape:btCollisionShape,localInertia:btVector3=New btVector3( 0,0,0 ) )
  318. End
  319. Class btRigidBody Extends btCollisionObject
  320. Method New( constructionInfo:btRigidBodyConstructionInfo )
  321. Method New( mass:btScalar,motionState:btMotionState,collisionShape:btCollisionShape,localInertia:btVector3=New btVector3( 0,0,0 ) )
  322. Method clearForces()
  323. Method setMassProps( mass:btScalar,inertia:btVector3 )
  324. Method updateInertiaTensor()
  325. Method getInvMass:btScalar()
  326. Method setGravity( acceleration:btVector3 )
  327. Method getGravity:btVector3()
  328. Method proceedToTransform( newTrans:btTransform )
  329. Method setLinearVelocity( lin_vel:btVector3 )
  330. Method getLinearVelocity:btVector3()
  331. Method setAngularVelocity( ang_vel:btVector3 )
  332. Method getAngularVelocity:btVector3()
  333. Method applyForce( force:btVector3,rel_pos:btVector3 )
  334. Method applyCentralForce( force:btVector3 )
  335. Method applyImpulse( impulse:btVector3,rel_pos:btVector3 )
  336. Method applyCentralImpulse( impulse:btVector3 )
  337. Method applyTorque( torque:btVector3 )
  338. Method applyTorqueImpulse( torque:btVector3 )
  339. Method setDamping( lin_damping:btScalar,ang_damping:btScalar )
  340. Method getLinearDamping:btScalar()
  341. Method getAngularDamping:btScalar()
  342. Method getLinearFactor:btVector3()
  343. Method setLinearFactor( factor:btVector3 )
  344. Method getAngularFactor:btVector3()
  345. Method setAngularFactor( factor:btVector3 )
  346. End
  347. Const BT_CONSTRAINT_ERP:Int
  348. Const BT_CONSTRAINT_STOP_ERP:Int
  349. Const BT_CONSTRAINT_CFM:Int
  350. Const BT_CONSTRAINT_STOP_CFM:Int
  351. Class btTypedConstraint Extends btObject
  352. Method setParam( num:Int,value:btScalar,axis:Int=-1 )
  353. Method getParam:btScalar( num:Int,axis:Int=-1 )
  354. End
  355. Class btPoint2PointConstraint Extends btTypedConstraint="bbBullet::Point2PointConstraint"
  356. Method New( rbA:btRigidBody,rbB:btRigidBody,pivotInA:btVector3,pivotInB:btVector3 )
  357. Method New( rbA:btRigidBody,pivotInA:btVector3 )
  358. Method setPivotA( pivotA:btVector3 )
  359. Method setPivotB( pivotB:btVector3 )
  360. Method getPivotA:btVector3()
  361. Method getPivotB:btVector3()
  362. End