Import.ODE.pas 87 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858
  1. //
  2. // This unit is part of the GLScene Engine, http://glscene.org
  3. //
  4. unit Import.ODE;
  5. (*************************************************************************
  6. * *
  7. * Open Dynamics Engine, Copyright (C) 2001,2020 Russell L. Smith. *
  8. * All rights reserved. Web: www.ode.org *
  9. * *
  10. * This library is free software; you can redistribute it and/or *
  11. * modify it under the terms of EITHER: *
  12. * (1) The GNU Lesser General Public License as published by the Free *
  13. * Software Foundation; either version 2.1 of the License, or (at *
  14. * your option) any later version. The text of the GNU Lesser *
  15. * General Public License is included with this library in the *
  16. * file LICENSE.TXT. *
  17. * (2) The BSD-style license that is included with this library in *
  18. * the file LICENSE-BSD.TXT. *
  19. * *
  20. * This library is distributed in the hope that it will be useful, *
  21. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  22. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the files *
  23. * LICENSE.TXT and LICENSE-BSD.TXT for more details. *
  24. * *
  25. *************************************************************************)
  26. (*************************************************************************
  27. Some notes;
  28. Sometimes it's easier and faster to refer to the members of the objects
  29. directly, like Body.Pos, Geom.Data or Body.Mass, instead of calling the built
  30. in routines. Be very careful if you do this, because some of the built in
  31. routines alter states when called.
  32. Examples
  33. bGeomSetBody(Geom, Body); // This method must be used so
  34. Geom.Body := Body; // DON'T DO THIS
  35. Setting the mass of a body is another example. Typically, reading members is
  36. fine, but before writing directly to member fields yourself, you should check
  37. the c source and see what the function/procedure does. The source can be found
  38. at http://www.q12.org/ode/
  39. *************************************************************************)
  40. interface
  41. // remove . from line below if you are using a generic ODE DLL
  42. {$DEFINE VanillaODE}
  43. {$IFNDEF VanillaODE}
  44. {$DEFINE PARODE}
  45. {$ENDIF}
  46. uses
  47. System.Classes,
  48. GLS.ModuleLoader;
  49. const
  50. // ********************************************************************
  51. //
  52. // ODE precision:
  53. //
  54. // ODE can be run in Single or Double precision, Single is less precise,
  55. // but requires less memory.
  56. //
  57. // If you choose to run in Single mode, you must deploy the single precision
  58. // dll (this is default)
  59. //
  60. // If you choose to run in Double mode, you must deploy the double precision
  61. // dll (named ode_double.dll and located in the dll directory)
  62. {$define cSINGLE} //Insert . before "$" to make ODEImport double based
  63. {$IFDEF WIN32}
  64. {$IFDEF cSINGLE}
  65. ODEDLL = 'ode32s.dll';
  66. {$ELSE}
  67. ODEDLL = 'ode32d.dll';
  68. {$ENDIF}
  69. {$ENDIF}
  70. {$IFDEF WIN64}
  71. {$IFDEF cSINGLE}
  72. ODEDLL = 'ode64s.dll';
  73. {$ELSE}
  74. ODEDLL = 'ode64d.dll';
  75. {$ENDIF}
  76. {$ENDIF}
  77. {$IFDEF UNIX}
  78. ODEDLL = 'libode.so';
  79. {$ENDIF}
  80. {$IFDEF MACOS}
  81. ODEDLL = 'libode.dylib';
  82. {$ENDIF}
  83. {$IFDEF DARWIN} // MacOS X
  84. ODEDLL = 'libode.dylib';
  85. {$ENDIF}
  86. const
  87. // enum (* TRIMESH_FACE_NORMALS, TRIMESH_LAST_TRANSFORMATION ; *)
  88. TRIMESH_FACE_NORMALS = 0;
  89. TRIMESH_LAST_TRANSFORMATION = 1;
  90. // Just generate any contacts (disables any contact refining).
  91. CONTACTS_UNIMPORTANT = $80000000;
  92. // Change: New Type added, syntax enforcement
  93. type TJointFlag = Integer;
  94. // These consts now have defined types
  95. const
  96. // if this flag is set, the joint was allocated in a joint group
  97. dJOINT_INGROUP: TJointFlag = 1;
  98. (* if this flag is set, the joint was attached with arguments (0,body).
  99. our convention is to treat all attaches as (body,0), i.e. so node[0].body
  100. is always nonzero, so this flag records the fact that the arguments were swapped *)
  101. dJOINT_REVERSE: TJointFlag = 2;
  102. (* if this flag is set, the joint can not have just one body attached to it,
  103. it must have either zero or two bodies attached *)
  104. dJOINT_TWOBODIES: TJointFlag = 4;
  105. // Change: New Type added, syntax enforcement
  106. type TdContactType = Integer;
  107. // These consts now have defined types
  108. const
  109. dContactMu2: TdContactType = $0001;
  110. dContactFDir1: TdContactType = $0002;
  111. dContactBounce: TdContactType = $0004;
  112. dContactSoftERP: TdContactType = $0008;
  113. dContactSoftCFM: TdContactType = $0010;
  114. dContactMotion1: TdContactType = $0020;
  115. dContactMotion2: TdContactType = $0040;
  116. dContactMotionN: TdContactType = $0080;
  117. dContactSlip1: TdContactType = $0100;
  118. dContactSlip2: TdContactType = $0200;
  119. dContactApprox0: TdContactType = $0000;
  120. dContactApprox1_1: TdContactType = $1000;
  121. dContactApprox1_2: TdContactType = $2000;
  122. dContactApprox1: TdContactType = $3000;
  123. // Change: New Type added, syntax enforcement
  124. type TBodyFlags = Integer;
  125. // These consts now have defined types
  126. const
  127. dxBodyFlagFiniteRotation: TBodyFlags = 1; // use finite rotations
  128. dxBodyFlagFiniteRotationAxis: TBodyFlags = 2; // use finite rotations only along axis
  129. dxBodyDisabled: TBodyFlags = 4; // body is disabled
  130. dxBodyNoGravity: TBodyFlags = 8; // body is not influenced by gravity
  131. type
  132. {$ifdef cSINGLE}
  133. TdReal = single;
  134. {$else}
  135. TdReal = double;
  136. {$endif}
  137. PdReal = ^TdReal;
  138. {define cODEDebugEnabled} // Debug mode
  139. (* Pointers to internal ODE structures to reproduce C++ classes in Delphi *)
  140. PdxJointGroup = ^TdxJointGroup;
  141. TdJointGroupID = PdxJointGroup;
  142. TdxJointGroup = record
  143. num : integer;
  144. stack : pointer;
  145. end;
  146. PdxJointLimitMotor = ^TdxJointLimitMotor;
  147. TdxJointLimitMotor = record
  148. vel,fmax : TdReal; // powered joint: velocity, max force
  149. lostop,histop : TdReal; // joint limits, relative to initial position
  150. fudge_factor : TdReal; // when powering away from joint limits
  151. normal_cfm : TdReal; // cfm to use when not at a stop
  152. stop_erp,stop_sfm : TdReal; // erp and cfm for when at joint limit
  153. bounce : TdReal; // restitution factor
  154. // variables used between getInfo1() and getInfo2()
  155. limit : integer; // 0=free, 1=at lo limit, 2=at hi limit
  156. limit_err : TdReal; // if at limit, amount over limit
  157. end;
  158. TdRealArray = array[0..15] of TdReal;
  159. PdRealArray = ^TdRealArray;
  160. // typedef dReal dVector33[4];
  161. TdVector3 = array[0..3] of TdReal;//Q: Why isn't TdVector3 = array[0..2] of TdReal? A: Because of SIMD alignment.
  162. PdVector3 = ^TdVector3;
  163. Pd3Axis = ^Td3Axis;
  164. Td3Axis = array[0..2] of TdVector3;
  165. PdInteger3 = ^TdInteger3;
  166. TdInteger3 = array[0..2] of integer;
  167. PdxJointLimitMotor3 = ^TdxJointLimitMotor3;
  168. TdxJointLimitMotor3 = array[0..2] of TdxJointLimitMotor;
  169. // typedef dReal dVector4[4];
  170. TdVector4 = array[0..3] of TdReal;
  171. PdVector4 = ^TdVector4;
  172. // typedef dReal dMatrix3[4*3];
  173. TdMatrix3 = array[0..4*3-1] of TdReal;
  174. PdMatrix3 = ^TdMatrix3;
  175. TdMatrix3_As3x4 = array[0..2, 0..3] of TdReal;
  176. PdMatrix3_As3x4 = ^TdMatrix3_As3x4;
  177. // typedef dReal dMatrix4[4*4];
  178. TdMatrix4 = array[0..4*4-1] of TdReal;
  179. PdMatrix4 = ^TdMatrix4;
  180. // typedef dReal dMatrix6[8*6];
  181. TdMatrix6 = array[0..8*6-1] of TdReal;
  182. PdMatrix6 = ^TdMatrix6;
  183. // typedef dReal dQuaternion[4];
  184. TdQuaternion = TdVector4;//array[0..3] of TdReal;
  185. PdQuaternion = ^TdQuaternion;
  186. // No typedef for AABB
  187. TdAABB = array[0..5] of TdReal;
  188. TdMass = record
  189. mass : TdReal; // total mass of the rigid body
  190. c : TdVector4; // center of gravity position in body frame (x,y,z)
  191. I : TdMatrix3; // 3x3 inertia tensor in body frame, about POR
  192. end;
  193. PdMass = ^TdMass;
  194. TdxAutoDisable = record
  195. idle_time : TdReal; // time the body needs to be idle to auto-disable it
  196. idle_steps : integer; // steps the body needs to be idle to auto-disable it
  197. linear_average_threashold : TdReal; // linear (squared) average velocity threshold
  198. angular_average_threashold : TdReal; // angular (squared) average velocity threshold
  199. average_samples : longword; // size of the average_lvel and average_avel buffers
  200. end;
  201. TdxDampingParameters = record
  202. linear_scale : TdReal; // multiply the linear velocity by (1 - scale)
  203. angular_scale : TdReal; // multiply the angular velocity by (1 - scale)
  204. linear_threahold : TdReal; // linear (squared) average speed threshold
  205. angular_threashold : TdReal; // angular (squared) average speed threshold
  206. end;
  207. TdxContactParameters = record
  208. max_vel : TdReal; // maximum correcting velocity
  209. min_depth : TdReal; // thickness of 'surface layer'
  210. end;
  211. TdxQuickStepParameters = record
  212. num_iterations : integer; // number of SOR iterations to perform
  213. w : TdReal; // the SOR over-relaxation parameter
  214. end;
  215. PdxGeom = ^TdxGeom;
  216. PPdxGeom = ^PdxGeom;
  217. // Whenever a body has its position or rotation changed during the
  218. // timestep, the callback will be called (with body as the argument).
  219. // Use it to know which body may need an update in an external
  220. // structure (like a 3D engine).
  221. TdMovedCallback = procedure(o1: PdxGeom); cdecl;
  222. // Per triangle callback. Allows the user to say if he wants a collision with
  223. // a particular triangle.
  224. TdTriCallback = function(TriMesh,RefObject : PdxGeom; TriangleIndex : integer) : integer;
  225. // Per object callback. Allows the user to get the list of triangles in 1
  226. // shot. Maybe we should remove this one.
  227. TdTriArrayCallback = procedure(TriMesh,RefObject : PdxGeom; TriIndices:PIntegerArray; TriCount : integer);
  228. // Allows the user to say if a ray collides with a triangle on barycentric
  229. // coords. The user can for example sample a texture with alpha transparency
  230. // to determine if a collision should occur.
  231. TdTriRayCallback = function(TriMesh,Ray : PdxGeom; TriangleIndex : integer; u,v:TdReal) : integer;
  232. PdxWorld = ^TdxWorld;
  233. PdObject = ^TdObject;
  234. PPdObject = ^PdObject;
  235. TdObject = record
  236. World : PdxWorld; // world this object is in
  237. next : PdObject; // next object of this type in list
  238. tome : PPdObject; // pointer to previous object's next ptr
  239. userdata : pointer; // user settable data
  240. tag : integer; // used by dynamics algorithms
  241. end;
  242. PdxBody = ^TdxBody;
  243. PdxJoint= ^TdxJoint;
  244. TdJointID = PdxJoint;
  245. {$IFDEF PARODE}
  246. TdJointBreakCallback = procedure(joint: TdJointID); cdecl;
  247. TJointBreakMode = Integer;
  248. PdxJointBreakInfo = ^TdxJointBreakInfo;
  249. TdxJointBreakInfo = record
  250. flags : integer;
  251. b1MaxF:TdVector3; // maximum force on body 1
  252. b1MaxT:TdVector3; // maximum torque on body 1
  253. b2MaxF:TdVector3; // maximum force on body 2
  254. b2MaxT:TdVector3; // maximum torque on body 2
  255. callback:TdJointBreakCallback; // function that is called when this joint breaks
  256. end;
  257. {$ENDIF}
  258. PdxJointNode = ^TdxJointNode;
  259. TdxJointNode = record
  260. joint : PdxJoint; // pointer to enclosing dxJoint object
  261. body : PdxBody; // *other* body this joint is connected to
  262. next : PdxJointNode; // next node in body's list of connected joints
  263. end;
  264. // info returned by getInfo1 function. the constraint dimension is m (<=6).
  265. // i.e. that is the total number of rows in the jacobian. `nub' is the
  266. // number of unbounded variables (which have lo,hi = -/+ infinity).
  267. TJointInfo1 = record
  268. m,nub : integer;
  269. end;
  270. // info returned by getInfo2 function
  271. TJointInfo2 = record
  272. // integrator parameters: frames per second (1/stepsize), default error
  273. // reduction parameter (0..1).
  274. fps,erp : TdReal;
  275. // for the first and second body, pointers to two (linear and angular)
  276. // n*3 jacobian sub matrices, stored by rows. these matrices will have
  277. // been initialized to 0 on entry. if the second body is zero then the
  278. // J2xx pointers may be 0.
  279. J1l,J1a,J2l,J2a : pdReal;
  280. // elements to jump from one row to the next in J's
  281. rowskip : integer;
  282. // right hand sides of the equation J*v = c + cfm * lambda. cfm is the
  283. // "constraint force mixing" vector. c is set to zero on entry, cfm is
  284. // set to a constant value (typically very small or zero) value on entry.
  285. c,cfm : pdReal;
  286. // lo and hi limits for variables (set to -/+ infinity on entry).
  287. lo,hi : pdReal;
  288. // findex vector for variables. see the LCP solver interface for a
  289. // description of what this does. this is set to -1 on entry.
  290. // note that the returned indexes are relative to the first index of
  291. // the constraint.
  292. findex : pinteger;
  293. end;
  294. TdxJoint = record
  295. baseObject : TdObject;
  296. Info1 : TJointInfo1;
  297. Info2 : TJointInfo2;
  298. end;
  299. TdxJointNull = TdxJoint;
  300. PdxJointBall = ^TdxJointBall;
  301. TdxJointBall = record
  302. BaseJoint : TdxJoint;
  303. anchor1 : TdVector3;// anchor w.r.t first body
  304. anchor2 : TdVector3;// anchor w.r.t second body
  305. erp : TdReal; // error reduction
  306. cfm : TdReal; // constraint force mix in
  307. end;
  308. PdxJointHinge = ^TdxJointHinge;
  309. TdxJointHinge = record
  310. BaseJoint : TdxJoint;
  311. anchor1 : TdVector3; // anchor w.r.t first body
  312. anchor2 : TdVector3; // anchor w.r.t second body
  313. axis1 : TdVector3; // axis w.r.t first body
  314. axis2 : TdVector3; // axis w.r.t second body
  315. qrel : tdQuaternion; // initial relative rotation body1 -> body2
  316. limot : TdxJointLimitMotor; // limit and motor information
  317. end;
  318. PdxJointUniversial = ^TdxJointUniversial;
  319. TdxJointUniversial = record
  320. BaseJoint : TdxJoint;
  321. anchor1 : TdVector3; // anchor w.r.t first body
  322. anchor2 : TdVector3; // anchor w.r.t second body
  323. axis1 : TdVector3; // axis w.r.t first body
  324. axis2 : TdVector3; // axis w.r.t second body
  325. qrel1 : tdQuaternion; // initial relative rotation body1 -> virtual cross piece
  326. qrel2 : tdQuaternion; // initial relative rotation virtual cross piece -> body2
  327. limot1 : TdxJointLimitMotor; // limit and motor information for axis1
  328. limot2 : TdxJointLimitMotor;// limit and motor information for axis2
  329. end;
  330. PdxJointPR = ^TdxJointPR;
  331. TdxJointPR = record
  332. BaseJoint : TdxJoint;
  333. anchor2:TdVector3; ///< @brief Position of the rotoide articulation
  334. ///< w.r.t second body.
  335. ///< @note Position of body 2 in world frame +
  336. ///< anchor2 in world frame give the position
  337. ///< of the rotoide articulation
  338. axisR1:TdVector3 ; ///< axis of the rotoide articulation w.r.t first body.
  339. ///< @note This is considered as axis1 from the parameter
  340. ///< view.
  341. axisR2:TdVector3 ; ///< axis of the rotoide articulation w.r.t second body.
  342. ///< @note This is considered also as axis1 from the
  343. ///< parameter view
  344. axisP1:TdVector3; ///< axis for the prismatic articulation w.r.t first body.
  345. ///< @note This is considered as axis2 in from the parameter
  346. ///< view
  347. qrel:TdQuaternion; ///< initial relative rotation body1 -> body2.
  348. offset:TdVector3; ///< @brief vector between the body1 and the rotoide
  349. ///< articulation.
  350. ///<
  351. ///< Going from the first to the second in the frame
  352. ///< of body1.
  353. ///< That should be aligned with body1 center along axisP
  354. ///< This is calculated when the axis are set.
  355. limotR:TdxJointLimitMotor; ///< limit and motor information for the rotoide articulation.
  356. limotP:TdxJointLimitMotor; ///< limit and motor information for the prismatic articulation.
  357. end;
  358. PdxJointPiston = ^TdxJointPiston;
  359. TdxJointPiston = record
  360. BaseJoint : TdxJoint;
  361. axis1:TdVector3; ///< Axis of the prismatic and rotoide w.r.t first body
  362. axis2:TdVector3; ///< Axis of the prismatic and rotoide w.r.t second body
  363. qrel:TdQuaternion; ///< Initial relative rotation body1 -> body2
  364. /// Anchor w.r.t first body.
  365. /// This is the same as the offset for the Slider joint
  366. /// @note To find the position of the anchor when the body 1 has moved
  367. /// you must add the position of the prismatic joint
  368. /// i.e anchor = R1 * anchor1 + dJointGetPistonPosition() * (R1 * axis1)
  369. anchor1:TdVector3;
  370. anchor2:TdVector3; //< anchor w.r.t second body
  371. /// limit and motor information for the prismatic
  372. /// part of the joint
  373. limotP:TdxJointLimitMotor;
  374. /// limit and motor information for the rotoide
  375. /// part of the joint
  376. limotR:TdxJointLimitMotor;
  377. end;
  378. PdxJointSlider = ^TdxJointSlider;
  379. TdxJointSlider = record
  380. BaseJoint : TdxJoint;
  381. axis1:TdVector3; // axis w.r.t first body
  382. qrel:TdQuaternion; // initial relative rotation body1 -> body2
  383. offset:TdVector3; // point relative to body2 that should be
  384. // aligned with body1 center along axis1
  385. limot:TdxJointLimitMotor; // limit and motor information
  386. end;
  387. PdxJointHinge2 = ^TdxJointHinge2;
  388. TdxJointHinge2 = record
  389. BaseJoint : TdxJoint;
  390. anchor1:TdVector3 ; // anchor w.r.t first body
  391. anchor2:TdVector3 ; // anchor w.r.t second body
  392. axis1:TdVector3; // axis 1 w.r.t first body
  393. axis2:TdVector3; // axis 2 w.r.t second body
  394. c0,s0:TdReal; // cos,sin of desired angle between axis 1,2
  395. v1,v2:TdVector3; // angle ref vectors embedded in first body
  396. limot1:TdxJointLimitMotor; // limit+motor info for axis 1
  397. limot2:TdxJointLimitMotor; // limit+motor info for axis 2
  398. susp_erp,susp_cfm:TdReal; // suspension parameters (erp,cfm)
  399. end;
  400. TdxJointAMotor = record
  401. BaseJoint : TdxJoint;
  402. num:integer; // number of axes (0..3)
  403. mode:integer; // a dAMotorXXX constant
  404. rel:TdInteger3; // what the axes are relative to (global,b1,b2)
  405. axis:Td3Axis; // three axes
  406. limot:TdxJointLimitMotor3; // limit+motor info for axes
  407. angle:TdVector3; // user-supplied angles for axes
  408. // these vectors are used for calculating euler angles
  409. reference1:TdVector3; // original axis[2], relative to body 1
  410. reference2:TdVector3; // original axis[0], relative to body 2
  411. end;
  412. TdxJointLMotor = record
  413. BaseJoint : TdxJoint;
  414. num: integer;
  415. rel:TdInteger3;
  416. axis:Td3Axis; // three axes
  417. limot:TdxJointLimitMotor3; // limit+motor info for axes
  418. end;
  419. TdxJointPlane2D = record
  420. BaseJoint : TdxJoint;
  421. row_motor_x:integer;
  422. row_motor_y:integer;
  423. row_motor_angle:integer;
  424. motor_x:TdxJointLimitMotor;
  425. motor_y:TdxJointLimitMotor;
  426. motor_angle:TdxJointLimitMotor;
  427. end;
  428. TdxJointFixed = record
  429. BaseJoint : TdxJoint;
  430. qrel:TdQuaternion; // initial relative rotation body1 -> body2
  431. offset:TdVector3; // relative offset between the bodies
  432. erp:TdReal; // error reduction parameter
  433. cfm:TdReal; // constraint force mix-in
  434. end;
  435. // position vector and rotation matrix for geometry objects that are not
  436. // connected to bodies.
  437. PdxPosR = ^TdxPosR;
  438. TdxPosR = record
  439. pos : TdVector3;
  440. R : TdMatrix3;
  441. end;
  442. TdxBody = record
  443. BaseObject : TdObject;
  444. {$ifdef cSINGLE}
  445. Padding : byte;
  446. {$endif}
  447. firstjoint : TdJointID; // list of attached joints
  448. flags : integer; // some dxBodyFlagXXX flags
  449. geom : PdxGeom; // first collision geom associated with body
  450. mass : TdMass; // mass parameters about POR
  451. invI : TdMatrix3 ; // inverse of mass.I
  452. invMass : TdReal; // 1 / mass.mass
  453. posr : TdxPosR; // position and orientation of point of reference
  454. q : TdQuaternion; // orientation quaternion
  455. lvel,avel : TdVector3; // linear and angular velocity of POR
  456. facc,tacc : TdVector3 ; // force and torque accululators
  457. finite_rot_axis : TdVector3 ; // finite rotation axis, unit length or 0=none
  458. adis : TdxAutoDisable; // auto-disable parameters
  459. adis_timeleft : TdReal; // time left to be idle
  460. adis_stepsleft : integer; // steps left to be idle
  461. average_lvel_buffer : pdVector3; // buffer for the linear average velocity calculation
  462. average_avel_buffer : pdVector3; // buffer for the angular average velocity calculation
  463. average_counter : longword; // counter/index to fill the average-buffers
  464. average_ready : integer; // indicates ( with = 1 ), if the Body's buffers are ready for average-calculations
  465. moved_callback : TdMovedCallback; // let the user know the body moved
  466. dampingp : TdxDampingParameters; // damping parameters, depends on flags
  467. max_angular_speed : TdReal; // limit the angular velocity to this magnitude
  468. end;
  469. TBodyList = class(TList)
  470. private
  471. function GetItems(i: integer): PdxBody;
  472. procedure SetItems(i: integer; const Value: PdxBody);
  473. public
  474. property Items[i : integer] : PdxBody read GetItems write SetItems; default;
  475. procedure DeleteAllBodies;
  476. end;
  477. (*struct dxWorld : public dBase {
  478. dxBody *firstbody; // body linked list
  479. dxJoint *firstjoint; // joint linked list
  480. int nb,nj; // number of bodies and joints in lists
  481. dVector3 gravity; // gravity vector (m/s/s)
  482. dReal global_erp; // global error reduction parameter
  483. dReal global_cfm; // global costraint force mixing parameter
  484. };*)
  485. TdxWorld = record //(TdBase)
  486. firstbody : PdxBody; // body linked list
  487. firstjoint : PdxJoint; // joint linked list
  488. nb,nj : integer; // number of bodies and joints in lists
  489. gravity : TdVector3; // gravity vector (m/s/s)
  490. global_erp : TdReal; // global error reduction parameter
  491. global_cfm : TdReal; // global costraint force mixing parameter
  492. adis : TdxAutoDisable;
  493. body_flags : integer;
  494. qs : TdxQuickStepParameters;
  495. contactp : TdxContactParameters;
  496. dampingp : TdxDampingParameters;
  497. max_angular_speed : TdReal;
  498. end;
  499. TdJointFeedback = record
  500. f1 : TdVector3; // force that joint applies to body 1
  501. t1 : TdVector3; // torque that joint applies to body 1
  502. f2 : TdVector3; // force that joint applies to body 2
  503. t2 : TdVector3; // torque that joint applies to body 2
  504. end;
  505. PTdJointFeedback = ^TdJointFeedback;
  506. TdErrorType =
  507. (d_ERR_UNKNOWN, // unknown error
  508. d_ERR_IASSERT, // user assertion failed */
  509. d_ERR_UASSERT, // user assertion failed */
  510. d_ERR_LCP);
  511. TdJointTypeNumbers =
  512. (dJointTypeNone, // or "unknown"
  513. dJointTypeBall,
  514. dJointTypeHinge,
  515. dJointTypeSlider,
  516. dJointTypeContact,
  517. dJointTypeUniversal,
  518. dJointTypeHinge2,
  519. dJointTypeFixed,
  520. dJointTypeNull,
  521. dJointTypeAMotor,
  522. dJointTypeLMotor,
  523. dJointTypePlane2D,
  524. dJointTypePR,
  525. dJointTypePU,
  526. dJointTypePiston
  527. );
  528. TdAngularMotorModeNumbers =
  529. (dAMotorUser,
  530. dAMotorEuler);
  531. TdSurfaceParameters = record
  532. // must always be defined
  533. mode : integer;
  534. mu : TdReal;
  535. // only defined if the corresponding flag is set in mode
  536. mu2,
  537. bounce,
  538. bounce_vel,
  539. soft_erp,
  540. soft_cfm,
  541. motion1,motion2,motionN,
  542. slip1,slip2 : TdReal
  543. end;
  544. TdContactGeom = record
  545. pos : TdVector3;
  546. normal : TdVector3;
  547. depth : TdReal;
  548. g1,g2 : PdxGeom;
  549. side1,side2 : integer;
  550. end;
  551. PdContactGeom = ^TdContactGeom;
  552. TdContact = record
  553. surface : TdSurfaceParameters;
  554. geom : TdContactGeom;
  555. fdir1 : TdVector3;
  556. end;
  557. PdContact = ^TdContact;
  558. // Collission callback structure
  559. TdNearCallback = procedure(data : pointer; o1, o2 : PdxGeom); cdecl;
  560. TdColliderFn = function(o1, o2 : PdxGeom; flags : Integer;
  561. contact : PdContactGeom; skip : Integer) : Integer; cdecl;
  562. TdGetColliderFnFn = function(num : Integer) : TdColliderFn; cdecl;
  563. TdGetAABBFn = procedure(g : PdxGeom; var aabb : TdAABB); cdecl;
  564. TdGeomDtorFn = procedure(o : PdxGeom); cdecl;
  565. TdAABBTestFn = function(o1, o2 : PdxGeom; const aabb2 : TdAABB) : Integer; cdecl;
  566. (*typedef struct dGeomClass {
  567. int bytes;
  568. dGetColliderFnFn *collider;
  569. dGetAABBFn *aabb;
  570. dAABBTestFn *aabb_test;
  571. dGeomDtorFn *dtor;
  572. } dGeomClass;*)
  573. TdGeomClass = record
  574. bytes : integer; // extra storage size
  575. collider : TdGetColliderFnFn; // collider function
  576. aabb : TdGetAABBFn; // bounding box function
  577. aabb_test : TdAABBTestFn; // aabb tester, can be 0 for none
  578. dtor : TdGeomDtorFn; // destructor, can be 0 for none
  579. end;
  580. PdGeomClass = ^TdGeomClass;
  581. (*struct dxSpace : public dBase {
  582. int type; // don't want to use RTTI
  583. virtual void destroy()=0;
  584. virtual void add (dGeomID)=0;
  585. virtual void remove (dGeomID)=0;
  586. virtual void collide (void *data, dNearCallback *callback)=0;
  587. virtual int query (dGeomID)=0;
  588. };*)
  589. PdxSpace = ^TdxSpace;
  590. TdRealHugeArray = array[0..65535] of TdReal;
  591. PdRealHugeArray = ^TdRealHugeArray;
  592. // Tri-list collider
  593. TdIntegerArray = array[0..65535] of Integer;
  594. PdIntegerArray = ^TdIntegerArray;
  595. TdVector3Array = array[0..65535] of TdVector3;
  596. PdVector3Array = ^TdVector3Array;
  597. (*struct dxTriMeshData{
  598. Model BVTree;
  599. MeshInterface Mesh;
  600. dxTriMeshData();
  601. ~dxTriMeshData();
  602. void Build(const void* Vertices, int VertexStide, int VertexCount,
  603. const void* Indices, int IndexCount, int TriStride,
  604. const void* Normals,
  605. bool Single);
  606. /* aabb in model space */
  607. dVector3 AABBCenter;
  608. dVector3 AABBExtents;
  609. /* data for use in collison resolution */
  610. const void* Normals;
  611. Matrix4x4 last_trans;
  612. };*)
  613. TdxTriMeshData = record
  614. unknown : byte; //
  615. end;
  616. PdxTriMeshData = ^TdxTriMeshData;
  617. TdxHeightfieldData = record
  618. m_fWidth : TdReal;
  619. m_fDepth : TdReal;
  620. m_fSampleWidth : TdReal;
  621. m_fSampleDepth : TdReal;
  622. m_fInvSampleWidth : TdReal;
  623. m_fInvSampleDepth : TdReal;
  624. m_fHalfWidth : TdReal;
  625. m_fHalfDepth : TdReal;
  626. m_fMinHeight : TdReal;
  627. m_fMaxHeight : TdReal;
  628. m_fThickness : TdReal;
  629. m_fScale : TdReal;
  630. m_fOffset : TdReal;
  631. m_nWidthSamples : integer;
  632. m_nDepthSamples : integer;
  633. m_bCopyHeightData : integer;
  634. m_bWrapMode : integer;
  635. m_nGetHeightMode : integer;
  636. m_pHeightData : pointer;
  637. m_pUserData : pointer;
  638. m_contacts : PdContactGeom;
  639. end;
  640. PdxHeightfieldData = ^TdxHeightfieldData;
  641. (*//simple space - reports all n^2 object intersections
  642. struct dxSimpleSpace : public dxSpace {
  643. dGeomID first;
  644. void destroy();
  645. void add (dGeomID);
  646. void remove (dGeomID);
  647. void collide (void *data, dNearCallback *callback);
  648. int query (dGeomID);
  649. };*)
  650. PdxSimpleSpace = ^TdxSimpleSpace;
  651. (*//currently the space 'container' is just a list of the geoms in the space.
  652. struct dxHashSpace : public dxSpace {
  653. dxGeom *first;
  654. int global_minlevel; // smallest hash table level to put AABBs in
  655. int global_maxlevel; // objects that need a level larger than this will be
  656. // put in a "big objects" list instead of a hash table
  657. void destroy();
  658. void add (dGeomID);
  659. void remove (dGeomID);
  660. void collide (void *data, dNearCallback *callback);
  661. int query (dGeomID);
  662. };*)
  663. PdxHashSpace = ^TdxHashSpace;
  664. (*typedef struct dGeomSpaceData {
  665. dGeomID next;
  666. } dGeomSpaceData; *)
  667. TdGeomSpaceData = record
  668. next : PdxGeom;
  669. end;
  670. (*// common data for all geometry objects. the class-specific data area follows
  671. // this structure. pos and R will either point to a separately allocated
  672. // buffer (if body is 0 - pos points to the dxPosR object) or to the pos and
  673. // R of the body (if body nonzero).
  674. struct dxGeom { // a dGeomID is a pointer to this
  675. dxGeomClass *_class; // class of this object
  676. void *data; // user data pointer
  677. dBodyID body; // dynamics body associated with this object (if any)
  678. dReal *pos; // pointer to object's position vector
  679. dReal *R; // pointer to object's rotation matrix
  680. dSpaceID spaceid; // the space this object is in
  681. dGeomSpaceData space; // reserved for use by space this object is in
  682. dReal *space_aabb; // ptr to aabb array held by dSpaceCollide() fn
  683. // class-specific data follows here, with proper alignment.
  684. };*)
  685. TdxGeom = record // a dGeomID is a pointer to this
  686. _type : integer; // class of this object
  687. {$ifdef cSINGLE}
  688. Padding : byte;
  689. {$endif}
  690. gflags : integer;
  691. data : pointer; // user data pointer
  692. Body : PdxBody ; // dynamics body associated with this object (if any)
  693. body_next : PdxGeom; // next geom in body's linked list of associated geoms
  694. final_posr : PdxPosR; // final position of the geom in world coordinates
  695. offset_posr : PdxPosR; // offset from body in local coordinates
  696. next : PdxGeom;
  697. tome : PPdxGeom;
  698. parent_space : Pdxspace;
  699. aabb : TdAABB;
  700. category_bits,collide_bits : longword;
  701. end;
  702. TGeomList = class(TList)
  703. private
  704. function GetItems(i: integer): PdxGeom;
  705. procedure SetItems(i: integer; const Value: PdxGeom);
  706. public
  707. property Items[i : integer] : PdxGeom read GetItems write SetItems; default;
  708. procedure DeleteAllGeoms(DeleteDataAsObject : boolean=false);
  709. end;
  710. TdxSpace = record
  711. baseGeom : TdxGeom;
  712. count : integer;
  713. first : PdxGeom;
  714. cleanup : integer;
  715. current_index : integer;
  716. current_geom : PdxGeom;
  717. lock_count : integer;
  718. end;
  719. // Copies settings from TdxSpace, beacause pascal doeasn't do inheritance
  720. // for records
  721. TdxSimpleSpace = TdxSpace;
  722. // Copies settings from TdxSpace, beacause pascal doeasn't do inheritance
  723. // for records
  724. TdxHashSpace = record
  725. BaseSpace : TdxSpace;
  726. global_minlevel : integer;
  727. global_maxlevel : integer;
  728. end;
  729. TdxQuadTreeSpace = record
  730. BaseSpace : TdxSpace;
  731. Blocks : pointer;
  732. DirtyList : pointer;
  733. end;
  734. // TJointParams = (
  735. // parameters for limits and motors
  736. // Change: New Type added, sintax enforcement
  737. TJointParams = Integer;
  738. // These consts now have defined types
  739. {$IFDEF PARODE}
  740. const
  741. dJOINT_BREAK_UNKNOWN:TJointBreakMode = $0000;
  742. dJOINT_BROKEN:TJointBreakMode = $0001;
  743. dJOINT_DELETE_ON_BREAK:TJointBreakMode = $0002;
  744. dJOINT_BREAK_AT_B1_FORCE:TJointBreakMode = $0004;
  745. dJOINT_BREAK_AT_B1_TORQUE:TJointBreakMode = $0008;
  746. dJOINT_BREAK_AT_B2_FORCE:TJointBreakMode = $0010;
  747. dJOINT_BREAK_AT_B2_TORQUE:TJointBreakMode = $0020;
  748. {$ENDIF}
  749. const
  750. _priv_dParamLoStop = $000;
  751. _priv_dParamLoStop2 = $100;
  752. _priv_dParamLoStop3 = $200;
  753. const
  754. dParamLoStop: TJointParams = _priv_dParamLoStop;
  755. dParamHiStop: TJointParams = _priv_dParamLoStop + 1;
  756. dParamVel: TJointParams = _priv_dParamLoStop + 2;
  757. dParamFMax: TJointParams = _priv_dParamLoStop + 3;
  758. dParamFudgeFactor: TJointParams = _priv_dParamLoStop + 4;
  759. dParamBounce: TJointParams = _priv_dParamLoStop + 5;
  760. dParamCFM: TJointParams = _priv_dParamLoStop + 6;
  761. dParamStopERP: TJointParams = _priv_dParamLoStop + 7;
  762. dParamStopCFM: TJointParams = _priv_dParamLoStop + 8;
  763. // parameters for suspension
  764. dParamSuspensionERP: TJointParams = _priv_dParamLoStop + 9;
  765. dParamSuspensionCFM: TJointParams = _priv_dParamLoStop + 10;
  766. dParamERP: TJointParams = _priv_dParamLoStop + 11;
  767. dParamGroup1: TJointParams = $000;
  768. dParamLoStop1: TJointParams = _priv_dParamLoStop;
  769. dParamHiStop1: TJointParams = _priv_dParamLoStop + 1;
  770. dParamVel1: TJointParams = _priv_dParamLoStop + 2;
  771. dParamFMax1: TJointParams = _priv_dParamLoStop + 3;
  772. dParamFudgeFactor1: TJointParams = _priv_dParamLoStop + 4;
  773. dParamBounce1: TJointParams = _priv_dParamLoStop + 5;
  774. dParamCFM1: TJointParams = _priv_dParamLoStop + 6;
  775. dParamStopERP1: TJointParams = _priv_dParamLoStop + 7;
  776. dParamStopCFM1: TJointParams = _priv_dParamLoStop + 8;
  777. // parameters for suspension
  778. dParamSuspensionERP1: TJointParams = _priv_dParamLoStop + 9;
  779. dParamSuspensionCFM1: TJointParams = _priv_dParamLoStop + 10;
  780. dParamERP1: TJointParams = _priv_dParamLoStop + 11;
  781. // SECOND AXEL
  782. // parameters for limits and motors
  783. dParamGroup2: TJointParams = $100;
  784. dParamLoStop2: TJointParams = _priv_dParamLoStop2;
  785. dParamHiStop2: TJointParams = _priv_dParamLoStop2 + 1;
  786. dParamVel2: TJointParams = _priv_dParamLoStop2 + 2;
  787. dParamFMax2: TJointParams = _priv_dParamLoStop2 + 3;
  788. dParamFudgeFactor2: TJointParams = _priv_dParamLoStop2 + 4;
  789. dParamBounce2: TJointParams = _priv_dParamLoStop2 + 5;
  790. dParamCFM2: TJointParams = _priv_dParamLoStop2 + 6;
  791. dParamStopERP2: TJointParams = _priv_dParamLoStop2 + 7;
  792. dParamStopCFM2: TJointParams = _priv_dParamLoStop2 + 8;
  793. // parameters for suspension
  794. dParamSuspensionERP2: TJointParams = _priv_dParamLoStop2 + 9;
  795. dParamSuspensionCFM2: TJointParams = _priv_dParamLoStop2 + 10;
  796. dParamERP2: TJointParams = _priv_dParamLoStop2 + 11;
  797. // THIRD AXEL
  798. // parameters for limits and motors
  799. dParamGroup3: TJointParams = $200;
  800. dParamLoStop3: TJointParams = _priv_dParamLoStop3;
  801. dParamHiStop3: TJointParams = _priv_dParamLoStop3 + 1;
  802. dParamVel3: TJointParams = _priv_dParamLoStop3 + 2;
  803. dParamFMax3: TJointParams = _priv_dParamLoStop3 + 3;
  804. dParamFudgeFactor3: TJointParams = _priv_dParamLoStop3 + 4;
  805. dParamBounce3: TJointParams = _priv_dParamLoStop3 + 5;
  806. dParamCFM3: TJointParams = _priv_dParamLoStop3 + 6;
  807. dParamStopERP3: TJointParams = _priv_dParamLoStop3 + 7;
  808. dParamStopCFM3: TJointParams = _priv_dParamLoStop3 + 8;
  809. // parameters for suspension
  810. dParamSuspensionERP3: TJointParams = _priv_dParamLoStop3 + 9;
  811. dParamSuspensionCFM3: TJointParams = _priv_dParamLoStop3 + 10;
  812. dParamERP3: TJointParams = _priv_dParamLoStop3 + 11;
  813. dParamGroup: TJointParams = $100;
  814. // added by PAR
  815. {$IFDEF PARODE}
  816. function dSphereGetClass: integer; cdecl; external ODEDLL;
  817. function dBoxGetClass: integer; cdecl; external ODEDLL;
  818. function dCylinderGetClass: integer; cdecl; external ODEDLL;
  819. function dCapsuleGetClass: integer; cdecl; external ODEDLL;
  820. function dRayGetClass: integer; cdecl; external ODEDLL;
  821. function dPlaneGetClass: integer; cdecl; external ODEDLL;
  822. function dConvexGetClass: integer; cdecl; external ODEDLL;
  823. function dTriMeshGetClass: integer; cdecl; external ODEDLL;
  824. function dHeightfieldGetClass: integer; cdecl; external ODEDLL;
  825. function dGeomTransformGetClass: integer; cdecl; external ODEDLL;
  826. {$ENDIF}
  827. procedure dInitODE; cdecl; external ODEDLL;
  828. function dInitODE2(uiInitFlags: longword): integer; cdecl; external ODEDLL;
  829. procedure dCloseODE; cdecl; external ODEDLL;
  830. //----- dWorld -----
  831. function dWorldCreate: PdxWorld; cdecl; external ODEDLL;
  832. procedure dWorldDestroy(const World: PdxWorld); cdecl; external ODEDLL;
  833. function dWorldGetCFM(const World: PdxWorld): TdReal; cdecl; external ODEDLL;
  834. function dWorldGetERP(const World: PdxWorld): TdReal; cdecl; external ODEDLL;
  835. procedure dWorldGetGravity(const World: PdxWorld; var gravity: TdVector3); cdecl; external ODEDLL;
  836. procedure dWorldImpulseToForce(const World: PdxWorld; const stepsize, ix, iy, iz: TdReal; var force: TdVector3); cdecl; external ODEDLL;
  837. procedure dWorldSetCFM(const World: PdxWorld; cfm: TdReal); cdecl; external ODEDLL;
  838. procedure dWorldSetERP(const World: PdxWorld; erp: TdReal); cdecl; external ODEDLL;
  839. procedure dWorldSetGravity(const World: PdxWorld; const x, y, z: TdReal); cdecl; external ODEDLL;
  840. procedure dWorldSetContactMaxCorrectingVel(const World: PdxWorld; const vel: TdReal); cdecl; external ODEDLL;
  841. function dWorldGetContactMaxCorrectingVel(const World: PdxWorld): TdReal; cdecl; external ODEDLL;
  842. procedure dWorldSetContactSurfaceLayer(const World: PdxWorld; const depth: TdReal); cdecl; external ODEDLL;
  843. function dWorldGetContactSurfaceLayer(const World: PdxWorld): TdReal; cdecl; external ODEDLL;
  844. procedure dWorldExportDIF(const World: PdxWorld; fileHandle: cardinal; const world_name:PAnsiChar); cdecl; external ODEDLL;
  845. // Damping
  846. function dWorldGetLinearDampingThreshold(const World: PdxWorld): TdReal; cdecl; external ODEDLL;
  847. procedure dWorldSetLinearDampingThreshold(const World: PdxWorld; const threshold: TdReal); cdecl; external ODEDLL;
  848. function dWorldGetAngularDampingThreshold(const World: PdxWorld): TdReal; cdecl; external ODEDLL;
  849. procedure dWorldSetAngularDampingThreshold(const World: PdxWorld; const threshold: TdReal); cdecl; external ODEDLL;
  850. function dWorldGetLinearDamping(const World: PdxWorld): TdReal; cdecl; external ODEDLL;
  851. procedure dWorldSetLinearDamping(const World: PdxWorld; const scale: TdReal); cdecl; external ODEDLL;
  852. function dWorldGetAngularDamping(const World: PdxWorld): TdReal; cdecl; external ODEDLL;
  853. procedure dWorldSetAngularDamping(const World: PdxWorld; const scale: TdReal); cdecl; external ODEDLL;
  854. procedure dWorldSetDamping(const World: PdxWorld; const linear_scale,angular_scale: TdReal); cdecl; external ODEDLL;
  855. function dWorldGetMaxAngularSpeed(const World: PdxWorld): TdReal; cdecl; external ODEDLL;
  856. procedure dWorldSetMaxAngularSpeed(const World: PdxWorld; const max_speed: TdReal); cdecl; external ODEDLL;
  857. // Step
  858. procedure dWorldStep(const World: PdxWorld; const stepsize: TdReal); cdecl; external ODEDLL;
  859. // QuickStep
  860. procedure dWorldQuickStep(const World: PdxWorld; const stepsize: TdReal); cdecl; external ODEDLL;
  861. procedure dWorldSetQuickStepNumIterations(const World: PdxWorld; const num: integer); cdecl; external ODEDLL;
  862. function dWorldGetQuickStepNumIterations(const World: PdxWorld): integer; cdecl; external ODEDLL;
  863. procedure dWorldSetQuickStepW(const World: PdxWorld; const param: TdReal); cdecl; external ODEDLL;
  864. function dWorldGetQuickStepW(const World: PdxWorld): TdReal; cdecl; external ODEDLL;
  865. // Auto-disable functions
  866. function dWorldGetAutoDisableLinearAverageThreshold(const World: PdxWorld): TdReal; cdecl; external ODEDLL;
  867. procedure dWorldSetAutoDisableLinearAverageThreshold(const World: PdxWorld; linear_average_threshold: TdReal); cdecl; external ODEDLL;
  868. function dWorldGetAutoDisableAngularAverageThreshold(const World: PdxWorld): TdReal; cdecl; external ODEDLL;
  869. procedure dWorldSetAutoDisableAngularAverageThreshold(const World: PdxWorld; linear_average_threshold: TdReal); cdecl; external ODEDLL;
  870. function dWorldGetAutoDisableAverageSamplesCount(const World: PdxWorld): TdReal; cdecl; external ODEDLL;
  871. procedure dWorldSetAutoDisableAverageSamplesCount(const World: PdxWorld; linear_average_threshold: TdReal); cdecl; external ODEDLL;
  872. function dWorldGetAutoDisableLinearThreshold(const World: PdxWorld): TdReal; cdecl; external ODEDLL;
  873. procedure dWorldSetAutoDisableLinearThreshold(const World: PdxWorld; linThreshold: TdReal); cdecl; external ODEDLL;
  874. function dWorldGetAutoDisableAngularThreshold(const World: PdxWorld): TdReal; cdecl; external ODEDLL;
  875. procedure dWorldSetAutoDisableAngularThreshold(const World: PdxWorld; angThreshold: TdReal); cdecl; external ODEDLL;
  876. function dWorldGetAutoDisableSteps(const World: PdxWorld): Integer; cdecl; external ODEDLL;
  877. procedure dWorldSetAutoDisableSteps(const World: PdxWorld; steps: Integer); cdecl; external ODEDLL;
  878. function dWorldGetAutoDisableTime(const World: PdxWorld): TdReal; cdecl; external ODEDLL;
  879. procedure dWorldSetAutoDisableTime(const World: PdxWorld; time: TdReal); cdecl; external ODEDLL;
  880. function dWorldGetAutoDisableFlag(const World: PdxWorld): Integer; cdecl; external ODEDLL;
  881. procedure dWorldSetAutoDisableFlag(const World: PdxWorld; do_auto_disable: Integer); cdecl; external ODEDLL;
  882. //----- dBody -----
  883. procedure dBodyAddForce(const Body: PdxBody; const fx, fy, fz: TdReal); cdecl; external ODEDLL;
  884. procedure dBodyAddForceAtPos(const Body: PdxBody; const fx, fy, fz, px, py, pz: TdReal); cdecl; external ODEDLL;
  885. procedure dBodyAddForceAtRelPos(const Body: PdxBody; const fx, fy, fz, px, py, pz: TdReal); cdecl; external ODEDLL;
  886. procedure dBodyAddRelForce(const Body: PdxBody; const fx, fy, fz: TdReal); cdecl; external ODEDLL;
  887. procedure dBodyAddRelForceAtPos(const Body: PdxBody; const fx, fy, fz, px, py, pz: TdReal); cdecl; external ODEDLL;
  888. procedure dBodyAddRelForceAtRelPos(const Body: PdxBody; const fx, fy, fz, px, py, pz: TdReal); cdecl; external ODEDLL;
  889. procedure dBodyAddRelTorque(const Body: PdxBody; const fx, fy, fz: TdReal); cdecl; external ODEDLL;
  890. procedure dBodyAddTorque(const Body: PdxBody; const fx, fy, fz: TdReal); cdecl; external ODEDLL;
  891. function dBodyCreate(const World: PdxWorld): PdxBody; cdecl; external ODEDLL;
  892. procedure dBodyDestroy(const Body: PdxBody); cdecl; external ODEDLL;
  893. procedure dBodyDisable(const Body: PdxBody); cdecl; external ODEDLL;
  894. procedure dBodyEnable(const Body: PdxBody); cdecl; external ODEDLL;
  895. function dBodyGetAngularVel(const Body: PdxBody): PdVector3; cdecl; external ODEDLL;
  896. procedure dBodyGetFiniteRotationAxis(const Body: PdxBody; var result: TdVector3); cdecl; external ODEDLL;
  897. function dBodyGetFiniteRotationMode(const Body: PdxBody): Integer; cdecl; external ODEDLL;
  898. function dBodyGetForce(const Body: PdxBody): PdVector3; cdecl; external ODEDLL;
  899. function dBodyGetGravityMode(const Body: PdxBody): Integer; cdecl; external ODEDLL;
  900. function dBodyGetJoint(const Body: PdxBody; const index: Integer): TdJointID; cdecl; external ODEDLL;
  901. function dBodyGetLinearVel(const Body: PdxBody): PdVector3; cdecl; external ODEDLL;
  902. procedure dBodyGetMass(const Body: PdxBody; var mass: TdMass); cdecl; external ODEDLL;
  903. function dBodyGetNumJoints(const Body: PdxBody): Integer; cdecl; external ODEDLL;
  904. procedure dBodyGetPointVel(const Body: PdxBody; const px, py, pz: TdReal; var result: TdVector3); cdecl; external ODEDLL;
  905. procedure dBodyGetPosRelPoint(const Body: PdxBody; const px, py, pz: TdReal; var result: TdVector3); cdecl; external ODEDLL;
  906. function dBodyGetPosition(const Body: PdxBody): PdVector3; cdecl; external ODEDLL;
  907. function dBodyGetQuaternion(const Body: PdxBody): PdQuaternion; cdecl; external ODEDLL;
  908. procedure dBodyGetRelPointPos(const Body: PdxBody; const px, py, pz: TdReal; var result: TdVector3); cdecl; external ODEDLL;
  909. procedure dBodyGetRelPointVel(const Body: PdxBody; const px, py, pz: TdReal; var result: TdVector3); cdecl; external ODEDLL;
  910. function dBodyGetRotation(const Body: PdxBody): PdMatrix3; cdecl; external ODEDLL;
  911. function dBodyGetTorque(const Body: PdxBody): PdVector3; cdecl; external ODEDLL;
  912. function dBodyIsEnabled(const Body: PdxBody): Integer; cdecl; external ODEDLL;
  913. procedure dBodySetAngularVel(const Body: PdxBody; const x, y, z: TdReal); cdecl; external ODEDLL;
  914. procedure dBodySetFiniteRotationAxis(const Body: PdxBody; const x, y, z: TdReal); cdecl; external ODEDLL;
  915. procedure dBodySetFiniteRotationMode(const Body: PdxBody; const mode: Integer); cdecl; external ODEDLL;
  916. procedure dBodySetForce(const Body: PdxBody; const x, y, z: TdReal); cdecl; external ODEDLL;
  917. procedure dBodySetGravityMode(const Body: PdxBody; const mode: Integer); cdecl; external ODEDLL;
  918. procedure dBodySetLinearVel(const Body: PdxBody; const x, y, z: TdReal); cdecl; external ODEDLL;
  919. procedure dBodySetMass( const Body: PdxBody; const mass: PdMass); cdecl; external ODEDLL;
  920. procedure dBodySetPosition(const Body: PdxBody; const x, y, z: TdReal); cdecl; external ODEDLL;
  921. procedure dBodySetQuaternion(const Body: PdxBody; const q: TdQuaternion); cdecl; external ODEDLL;
  922. procedure dBodySetRotation(const Body: PdxBody; const R: TdMatrix3); cdecl; external ODEDLL;
  923. procedure dBodySetTorque(const Body: PdxBody; const x, y, z: TdReal); cdecl; external ODEDLL;
  924. procedure dBodyVectorFromWorld(const Body: PdxBody; const px, py, pz: TdReal; var result: TdVector3); cdecl; external ODEDLL;
  925. procedure dBodyVectorToWorld(const Body: PdxBody; const px, py, pz: TdReal; var result: TdVector3); cdecl; external ODEDLL;
  926. procedure dBodySetData (const Body: PdxBody; data : pointer); cdecl; external ODEDLL;
  927. function dBodyGetData (const Body: PdxBody) : pointer; cdecl; external ODEDLL;
  928. procedure dBodySetMovedCallback (const Body: PdxBody; Callback: TdMovedCallback); cdecl; external ODEDLL;
  929. procedure dBodyCopyPosition(const Body: PdxBody; const pos: TdVector3); cdecl; external ODEDLL;
  930. procedure dBodyCopyRotation(const Body: PdxBody; const R: TdMatrix3); cdecl; external ODEDLL;
  931. procedure dBodyCopyQuaternion(const Body: PdxBody; const quat: TdQuaternion); cdecl; external ODEDLL;
  932. // damping functions
  933. procedure dBodySetLinearDamping (const Body: PdxBody; scale: TdReal); cdecl; external ODEDLL;
  934. function dBodyGetLinearDamping (const Body: PdxBody): TdReal; cdecl; external ODEDLL;
  935. procedure dBodySetAngularDamping(const Body: PdxBody; scale : TdReal); cdecl; external ODEDLL;
  936. function dBodyGetAngularDamping(const Body: PdxBody): TdReal; cdecl; external ODEDLL;
  937. procedure dBodySetDamping(const Body: PdxBody; linear_scale, angular_scale: TdReal); cdecl; external ODEDLL;
  938. function dBodyGetLinearDampingThreshold(const Body: PdxBody): TdReal; cdecl; external ODEDLL;
  939. procedure dBodySetLinearDampingThreshold(const Body: PdxBody; threshold: TdReal); cdecl; external ODEDLL;
  940. function dBodyGetAngularDampingThreshold(const Body: PdxBody): TdReal; cdecl; external ODEDLL;
  941. procedure dBodySetAngularDampingThreshold(const Body: PdxBody; threshold: TdReal); cdecl; external ODEDLL;
  942. procedure dBodySetDampingDefaults(const Body: PdxBody; threshold: TdReal); cdecl; external ODEDLL;
  943. procedure dBodySetMaxAngularSpeed(const Body: PdxBody; max_speed: TdReal); cdecl; external ODEDLL;
  944. function dBodyGetMaxAngularSpeed(const Body: PdxBody): TdReal; cdecl; external ODEDLL;
  945. // Auto-disable functions
  946. function dBodyGetAutoDisableLinearThreshold(const Body: PdxBody): TdReal; cdecl; external ODEDLL;
  947. procedure dBodySetAutoDisableLinearThreshold(const Body: PdxBody; linThreshold: TdReal); cdecl; external ODEDLL;
  948. function dBodyGetAutoDisableAngularThreshold(const Body: PdxBody): TdReal; cdecl; external ODEDLL;
  949. procedure dBodySetAutoDisableAngularThreshold(const Body: PdxBody; angThreshold: TdReal); cdecl; external ODEDLL;
  950. function dBodyGetAutoDisableSteps(const Body: PdxBody): Integer; cdecl; external ODEDLL;
  951. procedure dBodySetAutoDisableSteps(const Body: PdxBody; steps: Integer); cdecl; external ODEDLL;
  952. function dBodyGetAutoDisableTime(const Body: PdxBody): TdReal; cdecl; external ODEDLL;
  953. procedure dBodySetAutoDisableTime(const Body: PdxBody; time: TdReal); cdecl; external ODEDLL;
  954. function dBodyGetAutoDisableFlag(const Body: PdxBody): Integer; cdecl; external ODEDLL;
  955. procedure dBodySetAutoDisableFlag(const Body: PdxBody; do_auto_disable: Integer); cdecl; external ODEDLL;
  956. procedure dBodySetAutoDisableDefaults(const Body: PdxBody); cdecl; external ODEDLL;
  957. procedure dBodySetAutoDisableAverageSamplesCount(const Body: PdxBody; average_samples_count: longword); cdecl; external ODEDLL;
  958. //----- dJoint -----
  959. {$IFDEF PARODE}
  960. // breakable joints
  961. procedure dJointSetBreakable (const dJointID: TdJointID; b: integer); cdecl; external ODEDLL;
  962. procedure dJointSetBreakCallback (const dJointID: TdJointID; callbackFunc:TdJointBreakCallback); cdecl; external ODEDLL;
  963. procedure dJointSetBreakMode (const dJointID: TdJointID; mode: integer); cdecl; external ODEDLL;
  964. function dJointGetBreakMode (const dJointID: TdJointID): integer; cdecl; external ODEDLL;
  965. procedure dJointSetBreakForce(const dJointID: TdJointID; body: integer; x, y, z: TdReal); cdecl; external ODEDLL;
  966. procedure dJointSetBreakTorque(const dJointID: TdJointID; body: integer; x, y, z: TdReal); cdecl; external ODEDLL;
  967. function dJointIsBreakable (const dJointID: TdJointID): integer; cdecl; external ODEDLL;
  968. procedure dJointGetBreakForce(const dJointID: TdJointID; body: integer; var force: TdVector3); cdecl; external ODEDLL;
  969. procedure dJointGetBreakTorque(const dJointID: TdJointID; body: integer; var torque: TdVector3); cdecl; external ODEDLL;
  970. {$ENDIF}
  971. // normal joints
  972. procedure dJointGroupDestroy(const dJointGroupID: TdJointGroupID); cdecl; external ODEDLL;
  973. function dJointGroupCreate(const max_size: Integer): TdJointGroupID; cdecl; external ODEDLL;
  974. procedure dJointGroupEmpty(const dJointGroupID: TdJointGroupID); cdecl; external ODEDLL;
  975. procedure dJointAttach(const dJointID: TdJointID; const body1, body2: PdxBody); cdecl; external ODEDLL;
  976. procedure dJointDestroy(const dJointID: TdJointID); cdecl; external ODEDLL;
  977. function dJointGetData (const dJointID: TdJointID): pointer; cdecl; external ODEDLL;
  978. procedure dJointSetData (const dJointID: TdJointID; data: Pointer); cdecl; external ODEDLL;
  979. // callback routines for feedback of joints
  980. procedure dJointSetFeedback (const dJointID: TdJointID; Feedback: PTdJointFeedback); cdecl; external ODEDLL;
  981. function dJointGetFeedback (const dJointID: TdJointID): PTdJointFeedback; cdecl; external ODEDLL;
  982. function dJointGetType(const dJointID: TdJointID): Integer; cdecl; external ODEDLL;
  983. function dJointGetBody(const dJointID: TdJointID; const index: Integer): PdxBody; cdecl; external ODEDLL;
  984. //Contact
  985. function dJointCreateContact(const World: PdxWorld; dJointGroupID: TdJointGroupID; const dContact: PdContact): TdJointID; cdecl; external ODEDLL;
  986. //AMotor
  987. function dJointCreateAMotor(const World: PdxWorld; dJointGroupID: TdJointGroupID): TdJointID; cdecl; external ODEDLL;
  988. procedure dJointSetAMotorAngle(const dJointID: TdJointID; const anum: Integer; const angle: TdReal); cdecl; external ODEDLL;
  989. function dJointGetAMotorAngle(const dJointID: TdJointID; const anum: Integer): TdReal; cdecl; external ODEDLL;
  990. procedure dJointSetAMotorAxis(const dJointID: TdJointID; const anum, rel: Integer; const x, y, z: TdReal); cdecl; external ODEDLL;
  991. procedure dJointGetAMotorAxis(const dJointID: TdJointID; const anum: Integer; var result: TdVector3); cdecl; external ODEDLL;
  992. procedure dJointSetAMotorNumAxes(const dJointID: TdJointID; const num: Integer); cdecl; external ODEDLL;
  993. function dJointGetAMotorNumAxes(const dJointID: TdJointID): Integer; cdecl; external ODEDLL;
  994. procedure dJointSetAMotorParam(const dJointID: TdJointID; const parameter: TJointParams; const value: TdReal); cdecl; external ODEDLL;
  995. function dJointGetAMotorParam(const dJointID: TdJointID; const parameter: TJointParams): TdReal; cdecl; external ODEDLL;
  996. procedure dJointSetAMotorMode(const dJointID: TdJointID; const mode: TdAngularMotorModeNumbers); cdecl; external ODEDLL;
  997. function dJointGetAMotorMode(const dJointID: TdJointID): Integer; cdecl; external ODEDLL;
  998. procedure dJointAddAMotorTorques (const dJointID: TdJointID; torque1, torque2, torque3: TdReal); cdecl; external ODEDLL;
  999. function dJointGetAMotorAngleRate(const dJointID: TdJointID; const anum: Integer): TdReal; cdecl; external ODEDLL;
  1000. function dJointGetAMotorAxisRel(const dJointID: TdJointID; const anum: Integer): Integer; cdecl; external ODEDLL;
  1001. //LMotor
  1002. function dJointCreateLMotor(const World: PdxWorld; dJointGroupID : TdJointGroupID): TdJointID; cdecl; external ODEDLL;
  1003. procedure dJointSetLMotorAxis(const dJointID: TdJointID; const anum, rel: Integer; const x, y, z: TdReal); cdecl; external ODEDLL;
  1004. procedure dJointGetLMotorAxis(const dJointID: TdJointID; const anum: Integer; var result: TdVector3); cdecl; external ODEDLL;
  1005. procedure dJointSetLMotorNumAxes(const dJointID: TdJointID; const num: Integer); cdecl; external ODEDLL;
  1006. function dJointGetLMotorNumAxes(const dJointID: TdJointID): Integer; cdecl; external ODEDLL;
  1007. procedure dJointSetLMotorParam(const dJointID: TdJointID; const parameter: TJointParams; const value: TdReal); cdecl; external ODEDLL;
  1008. function dJointGetLMotorParam(const dJointID: TdJointID; const parameter: TJointParams): TdReal; cdecl; external ODEDLL;
  1009. //Ball
  1010. function dJointCreateBall(const World: PdxWorld; dJointGroupID : TdJointGroupID): TdJointID; cdecl; external ODEDLL;
  1011. procedure dJointSetBallAnchor(const dJointID: TdJointID; const x, y, z: TdReal); cdecl; external ODEDLL;
  1012. procedure dJointGetBallAnchor(const dJointID: TdJointID; var result: TdVector3); cdecl; external ODEDLL;
  1013. procedure dJointGetBallAnchor2(const dJointID: TdJointID; var result: TdVector3); cdecl; external ODEDLL;
  1014. //Hinge
  1015. function dJointCreateHinge(const World: PdxWorld; dJointGroupID : TdJointGroupID): TdJointID; cdecl; external ODEDLL;
  1016. procedure dJointSetHingeAnchor(const dJointID: TdJointID; const x, y, z: TdReal); cdecl; external ODEDLL;
  1017. procedure dJointGetHingeAnchor(const dJointID: TdJointID; var result: TdVector3); cdecl; external ODEDLL;
  1018. procedure dJointGetHingeAnchor2(const dJointID: TdJointID; var result: TdVector3); cdecl; external ODEDLL;
  1019. procedure dJointSetHingeAxis(const dJointID: TdJointID; const x, y, z: TdReal); cdecl; external ODEDLL;
  1020. procedure dJointGetHingeAxis(const dJointID: TdJointID; var result: TdVector3); cdecl; external ODEDLL;
  1021. procedure dJointSetHingeParam(const dJointID: TdJointID; const parameter: TJointParams; const value: TdReal); cdecl; external ODEDLL;
  1022. function dJointGetHingeParam(const dJointID: TdJointID; const parameter: TJointParams): TdReal; cdecl; external ODEDLL;
  1023. function dJointGetHingeAngle(const dJointID: TdJointID): TdReal; cdecl; external ODEDLL;
  1024. function dJointGetHingeAngleRate(const dJointID: TdJointID): TdReal; cdecl; external ODEDLL;
  1025. procedure dJointAddHingeTorque (const dJointID: TdJointID; torque: TdReal); cdecl; external ODEDLL;
  1026. //Hinge2
  1027. function dJointCreateHinge2(const World: PdxWorld; dJointGroupID : TdJointGroupID): TdJointID; cdecl; external ODEDLL;
  1028. procedure dJointSetHinge2Anchor(const dJointID: TdJointID; const x, y, z: TdReal); cdecl; external ODEDLL;
  1029. procedure dJointGetHinge2Anchor(const dJointID: TdJointID; var result: TdVector3); cdecl; external ODEDLL;
  1030. procedure dJointGetHinge2Anchor2(const dJointID: TdJointID; var result: TdVector3); cdecl; external ODEDLL;
  1031. procedure dJointSetHinge2Axis1(const dJointID: TdJointID; const x, y, z: TdReal); cdecl; external ODEDLL;
  1032. procedure dJointGetHinge2Axis1(const dJointID: TdJointID; var result: TdVector3); cdecl; external ODEDLL;
  1033. procedure dJointSetHinge2Axis2(const dJointID: TdJointID; const x, y, z: TdReal); cdecl; external ODEDLL;
  1034. procedure dJointGetHinge2Axis2(const dJointID: TdJointID; var result: TdVector3); cdecl; external ODEDLL;
  1035. procedure dJointSetHinge2Param(const dJointID: TdJointID; const parameter: TJointParams; const value: TdReal); cdecl; external ODEDLL;
  1036. function dJointGetHinge2Param(const dJointID: TdJointID; const parameter: TJointParams): TdReal; cdecl; external ODEDLL;
  1037. function dJointGetHinge2Angle1(const dJointID: TdJointID): TdReal; cdecl; external ODEDLL;
  1038. function dJointGetHinge2Angle1Rate(const dJointID: TdJointID): TdReal; cdecl; external ODEDLL;
  1039. function dJointGetHinge2Angle2Rate(const dJointID: TdJointID): TdReal; cdecl; external ODEDLL;
  1040. procedure dJointAddHinge2Torques (const dJointID: TdJointID; torque1, torque2: TdReal); cdecl; external ODEDLL;
  1041. procedure dJointCorrectHinge2(const dJointID: TdJointID); cdecl; external ODEDLL;
  1042. //Slider
  1043. function dJointCreateSlider(const World: PdxWorld; dJointGroupID : TdJointGroupID): TdJointID; cdecl; external ODEDLL;
  1044. procedure dJointSetSliderAxis(const dJointID: TdJointID; const x, y, z: TdReal); cdecl; external ODEDLL;
  1045. procedure dJointGetSliderAxis(const dJointID: TdJointID; var result: TdVector3); cdecl; external ODEDLL;
  1046. procedure dJointSetSliderParam(const dJointID: TdJointID; const parameter: TJointParams; const value: TdReal); cdecl; external ODEDLL;
  1047. function dJointGetSliderParam(const dJointID: TdJointID; const parameter: TJointParams): TdReal; cdecl; external ODEDLL;
  1048. function dJointGetSliderPosition(const dJointID: TdJointID): TdReal; cdecl; external ODEDLL;
  1049. function dJointGetSliderPositionRate(const dJointID: TdJointID): TdReal; cdecl; external ODEDLL;
  1050. procedure dJointAddSliderForce (const dJointID: TdJointID; force: TdReal); cdecl; external ODEDLL;
  1051. //Universal
  1052. function dJointCreateUniversal(const World: PdxWorld; dJointGroupID : TdJointGroupID): TdJointID; cdecl; external ODEDLL;
  1053. procedure dJointGetUniversalAnchor(const dJointID: TdJointID; var result: TdVector3); cdecl; external ODEDLL;
  1054. procedure dJointGetUniversalAnchor2(const dJointID: TdJointID; var result: TdVector3); cdecl; external ODEDLL;
  1055. procedure dJointSetUniversalAxis1(const dJointID: TdJointID; const x, y, z: TdReal); cdecl; external ODEDLL;
  1056. procedure dJointGetUniversalAxis1(const dJointID: TdJointID; var result: TdVector3); cdecl; external ODEDLL;
  1057. procedure dJointSetUniversalAxis2(const dJointID: TdJointID; const x, y, z: TdReal); cdecl; external ODEDLL;
  1058. procedure dJointGetUniversalAxis2(const dJointID: TdJointID; var result: TdVector3); cdecl; external ODEDLL;
  1059. procedure dJointSetUniversalParam(const dJointID: TdJointID; const parameter: TJointParams; const value: TdReal); cdecl; external ODEDLL;
  1060. function dJointGetUniversalParam(const dJointID: TdJointID; const parameter: TJointParams): TdReal; cdecl; external ODEDLL;
  1061. function dJointGetUniversalAngle1(const dJointID: TdJointID): TdReal; cdecl; external ODEDLL;
  1062. function dJointGetUniversalAngle2(const dJointID: TdJointID): TdReal; cdecl; external ODEDLL;
  1063. function dJointGetUniversalAngle1Rate(const dJointID: TdJointID): TdReal; cdecl; external ODEDLL;
  1064. function dJointGetUniversalAngle2Rate(const dJointID: TdJointID): TdReal; cdecl; external ODEDLL;
  1065. procedure dJointSetUniversalAnchor(const dJointID: TdJointID; const x, y, z: TdReal); cdecl; external ODEDLL;
  1066. procedure dJointAddUniversalTorques (const dJointID: TdJointID; torque1, torque2: TdReal); cdecl; external ODEDLL;
  1067. //Fixed
  1068. function dJointCreateFixed(const World: PdxWorld; dJointGroupID : TdJointGroupID): TdJointID; cdecl; external ODEDLL;
  1069. procedure dJointSetFixed(const dJointID: TdJointID); cdecl; external ODEDLL;
  1070. //Plane2D
  1071. function dJointCreatePlane2D(const World: PdxWorld; dJointGroupID : TdJointGroupID): TdJointID; cdecl; external ODEDLL;
  1072. procedure dJointSetPlane2DXParam(const dJointID: TdJointID; const parameter: Integer; const value: TdReal); cdecl; external ODEDLL;
  1073. procedure dJointSetPlane2DYParam(const dJointID: TdJointID; const parameter: Integer; const value: TdReal); cdecl; external ODEDLL;
  1074. procedure dJointSetPlane2DAngleParam(const dJointID: TdJointID; const parameter: Integer; const value: TdReal); cdecl; external ODEDLL;
  1075. //PR
  1076. function dJointCreatePR(const World: PdxWorld; dJointGroupID : TdJointGroupID): TdJointID; cdecl; external ODEDLL;
  1077. procedure dJointSetPRAnchor(const dJointID: TdJointID; const x, y, z: TdReal); cdecl; external ODEDLL;
  1078. procedure dJointSetPRAxis1(const dJointID: TdJointID; const x, y, z: TdReal); cdecl; external ODEDLL;
  1079. procedure dJointGetPRAxis1(const dJointID: TdJointID; var result: TdVector3); cdecl; external ODEDLL;
  1080. procedure dJointSetPRAxis2(const dJointID: TdJointID; const x, y, z: TdReal); cdecl; external ODEDLL;
  1081. procedure dJointGetPRAxis2(const dJointID: TdJointID; var result: TdVector3); cdecl; external ODEDLL;
  1082. procedure dJointSetPRParam(const dJointID: TdJointID; const parameter: TJointParams; const value: TdReal); cdecl; external ODEDLL;
  1083. function dJointGetPRParam(const dJointID: TdJointID; parameter: integer): TdReal; cdecl; external ODEDLL;
  1084. procedure dJointAddPRTorque (const dJointID: TdJointID; torque: TdReal); cdecl; external ODEDLL;
  1085. //Piston
  1086. function dJointCreatePiston(const World: PdxWorld; dJointGroupID : TdJointGroupID): TdJointID; cdecl; external ODEDLL;
  1087. procedure dJointSetPistonAnchor(const dJointID: TdJointID; const x, y, z: TdReal); cdecl; external ODEDLL;
  1088. procedure dJointGetPistonAnchor(const dJointID: TdJointID; var result: TdVector3); cdecl; external ODEDLL;
  1089. procedure dJointGetPistonAnchor2(const dJointID: TdJointID; var result: TdVector3); cdecl; external ODEDLL;
  1090. procedure dJointSetPistonAxis(const dJointID: TdJointID; const x, y, z: TdReal); cdecl; external ODEDLL;
  1091. procedure dJointGetPistonAxis(const dJointID: TdJointID; var result: TdVector3); cdecl; external ODEDLL;
  1092. procedure dJointSetPistonParam(const dJointID: TdJointID; const parameter: TJointParams; const value: TdReal); cdecl; external ODEDLL;
  1093. function dJointGetPistonParam(const dJointID: TdJointID; parameter : integer): TdReal; cdecl; external ODEDLL;
  1094. procedure dJointSetPistonAxisDelta(const dJointID: TdJointID; const x, y, z, ax, ay, az: TdReal); cdecl; external ODEDLL;
  1095. procedure dJointAddPistonForce (const dJointID: TdJointID; force: TdReal); cdecl; external ODEDLL;
  1096. function dJointGetPistonPosition(const dJointID: TdJointID): TdReal; cdecl; external ODEDLL;
  1097. function dJointGetPistonAngle(const dJointID: TdJointID): TdReal; cdecl; external ODEDLL;
  1098. function dJointGetPistonAngleRate(const dJointID: TdJointID): TdReal; cdecl; external ODEDLL;
  1099. function dJointGetPistonRate(const dJointID: TdJointID): TdReal; cdecl; external ODEDLL;
  1100. //----- dGeom -----
  1101. function dCreateGeom (classnum: Integer): PdxGeom; cdecl; external ODEDLL;
  1102. procedure dGeomDestroy(const Geom: PdxGeom); cdecl; external ODEDLL;
  1103. function dCreateGeomClass(const classptr: TdGeomClass): Integer; cdecl; external ODEDLL;
  1104. function dGeomGetClass(const Geom: PdxGeom): Integer; cdecl; external ODEDLL;
  1105. function dGeomGetClassData(o: PdxGeom): Pointer; cdecl; external ODEDLL;
  1106. function dGeomGetSpace(const Geom: PdxGeom): PdxSpace; cdecl; external ODEDLL;
  1107. function dGeomIsSpace (const Geom: PdxGeom): integer; cdecl; external ODEDLL;
  1108. procedure dGeomSetBody(const Geom: PdxGeom; Body: PdxBody); cdecl; external ODEDLL;
  1109. function dGeomGetBody(const Geom: PdxGeom): PdxBody; cdecl; external ODEDLL;
  1110. procedure dGeomSetPosition(const Geom: PdxGeom; const x, y, z: TdReal); cdecl; external ODEDLL;
  1111. function dGeomGetPosition(const Geom: PdxGeom): PdVector3; cdecl; external ODEDLL;
  1112. procedure dGeomSetRotation(const Geom: PdxGeom; const R: TdMatrix3); cdecl; external ODEDLL;
  1113. function dGeomGetRotation(const Geom: PdxGeom): PdMatrix3; cdecl; external ODEDLL;
  1114. procedure dGeomSetQuaternion(const Geom: PdxGeom; const TdQuaternion); cdecl; external ODEDLL;
  1115. procedure dGeomGetQuaternion(const Geom: PdxGeom; var result: TdQuaternion); cdecl; external ODEDLL;
  1116. procedure dGeomCopyPosition(const Geom: PdxGeom; const pos: TdVector3); cdecl; external ODEDLL;
  1117. procedure dGeomCopyRotation(const Geom: PdxGeom; const R: TdMatrix3); cdecl; external ODEDLL;
  1118. procedure dGeomCopyQuaternion(const Geom: PdxGeom; const quat: TdQuaternion); cdecl; external ODEDLL;
  1119. procedure dGeomSetData (const Geom: PdxGeom; data : pointer); cdecl; external ODEDLL;
  1120. function dGeomGetData (const Geom: PdxGeom): pointer; cdecl; external ODEDLL;
  1121. procedure dGeomEnable (const Geom: PdxGeom); cdecl; external ODEDLL;
  1122. procedure dGeomDisable (const Geom: PdxGeom); cdecl; external ODEDLL;
  1123. function dGeomIsEnabled (const Geom: PdxGeom): integer; cdecl; external ODEDLL;
  1124. procedure dGeomGetAABB(const Geom: PdxGeom; var aabb: TdAABB); cdecl; external ODEDLL;
  1125. procedure dGeomSetCategoryBits (const Geom: PdxGeom; bits : Cardinal); cdecl; external ODEDLL;
  1126. function dGeomGetCategoryBits (const Geom: PdxGeom): cardinal; cdecl; external ODEDLL;
  1127. procedure dGeomSetCollideBits (const Geom: PdxGeom; bits : Cardinal); cdecl; external ODEDLL;
  1128. function dGeomGetCollideBits (const Geom: PdxGeom): cardinal; cdecl; external ODEDLL;
  1129. procedure dGeomSetOffsetPosition (const Geom: PdxGeom; x,y,z:TdReal); cdecl; external ODEDLL;
  1130. function dGeomGetOffsetPosition(const Geom: PdxGeom): PdVector3; cdecl; external ODEDLL;
  1131. procedure dGeomSetOffsetRotation (const Geom: PdxGeom; R:TdMatrix3); cdecl; external ODEDLL;
  1132. function dGeomGetOffsetRotation(const Geom: PdxGeom): PdVector3; cdecl; external ODEDLL;
  1133. procedure dGeomSetOffsetQuaternion (const Geom: PdxGeom; const Q:TdQuaternion); cdecl; external ODEDLL;
  1134. procedure dGeomGetOffsetQuaternion (const Geom: PdxGeom; var Q:TdQuaternion); cdecl; external ODEDLL;
  1135. procedure dGeomClearOffset (const Geom: PdxGeom); cdecl; external ODEDLL;
  1136. procedure dGeomSetOffsetWorldPosition (const Geom: PdxGeom; x,y,z:TdReal); cdecl; external ODEDLL;
  1137. procedure dGeomSetOffsetWorldRotation (const Geom: PdxGeom; R:TdMatrix3); cdecl; external ODEDLL;
  1138. procedure dGeomSetOffsetWorldQuaternion (const Geom: PdxGeom; const Q:TdQuaternion); cdecl; external ODEDLL;
  1139. procedure dGeomCopyOffsetPosition(const Geom: PdxGeom; var pos: TdVector3); cdecl; external ODEDLL;
  1140. procedure dGeomCopyOffsetRotation(const Geom: PdxGeom; var R: TdMatrix3); cdecl; external ODEDLL;
  1141. procedure dGeomIsOffset(const Geom: PdxGeom); cdecl; external ODEDLL;
  1142. //Transform
  1143. function dCreateGeomTransform(const Space: PdxSpace): PdxGeom; cdecl; external ODEDLL;
  1144. procedure dGeomTransformSetGeom(const Geom, obj: PdxGeom); cdecl; external ODEDLL;
  1145. function dGeomTransformGetGeom(const Geom: PdxGeom): PdxGeom; cdecl; external ODEDLL;
  1146. procedure dGeomTransformSetInfo(const Geom: PdxGeom; mode: integer); cdecl; external ODEDLL;
  1147. function dGeomTransformGetInfo(const Geom: PdxGeom): integer; cdecl; external ODEDLL;
  1148. procedure dGeomTransformSetCleanup(const Geom: PdxGeom; const mode: Integer); cdecl; external ODEDLL;
  1149. function dGeomTransformGetCleanup(const Geom: PdxGeom): Integer; cdecl; external ODEDLL;
  1150. //Box
  1151. function dCreateBox(const Space: PdxSpace; const lx, ly, lz: TdReal): PdxGeom; cdecl; external ODEDLL;
  1152. procedure dGeomBoxGetLengths(const Geom: PdxGeom; var result: TdVector3); cdecl; external ODEDLL;
  1153. procedure dGeomBoxSetLengths(const Geom: PdxGeom; const lx, ly, lz: TdReal); cdecl; external ODEDLL;
  1154. function dGeomBoxPointDepth(const Geom: PdxGeom; const x,y,z: TdReal): TdReal; cdecl; external ODEDLL;
  1155. // dCylinder (not a capped cylinder).
  1156. function dCreateCylinder(const Space: PdxSpace; r, lz: TdReal): PdxGeom; cdecl; external ODEDLL;
  1157. procedure dGeomCylinderSetParams(const Geom: PdxGeom; radius, length: TdReal); cdecl; external ODEDLL;
  1158. procedure dGeomCylinderGetParams(const Geom: PdxGeom; var radius, length: TdReal); cdecl; external ODEDLL;
  1159. // dCapsule (a capped cylinder).
  1160. function dCreateCapsule(const Space: PdxSpace; const radius, length: TdReal): PdxGeom; cdecl; external ODEDLL;
  1161. procedure dGeomCapsuleSetParams(const Geom: PdxGeom; const radius, length: TdReal); cdecl; external ODEDLL;
  1162. procedure dGeomCapsuleGetParams(const Geom: PdxGeom; var radius, length: TdReal); cdecl; external ODEDLL;
  1163. function dGeomCapsulePointDepth(const Geom: PdxGeom; const x,y,z: TdReal): TdReal; cdecl; external ODEDLL;
  1164. //Plane
  1165. function dCreatePlane(const Space: PdxSpace; const a, b, c, d: TdReal): PdxGeom; cdecl; external ODEDLL;
  1166. procedure dGeomPlaneSetParams(const Geom: PdxGeom; const a, b, c, d: TdReal); cdecl; external ODEDLL;
  1167. procedure dGeomPlaneGetParams(const Geom: PdxGeom; var result: TdVector4); cdecl; external ODEDLL;
  1168. function dGeomPlanePointDepth(const Geom: PdxGeom; const x,y,z: TdReal): TdReal; cdecl; external ODEDLL;
  1169. //Sphere
  1170. function dCreateSphere(const Space: PdxSpace; const radius: TdReal): PdxGeom; cdecl; external ODEDLL;
  1171. procedure dGeomSphereSetRadius(const Geom: PdxGeom; const radius: TdReal); cdecl; external ODEDLL;
  1172. function dGeomSphereGetRadius(const Geom: PdxGeom): TdReal; cdecl; external ODEDLL;
  1173. function dGeomSpherePointDepth(const Geom: PdxGeom; const x,y,z: TdReal): TdReal; cdecl; external ODEDLL;
  1174. //Convex
  1175. function dCreateConvex(const Space: PdxSpace; _planes: PdReal; _planecount: longword; _points: PdReal; _pointcount: longword; const _polygons:longword): PdxGeom; cdecl; external ODEDLL;
  1176. procedure dGeomSetConvex(const Geom: PdxGeom; _planes: PdReal; _planecount: longword; _points: PdReal; _pointcount: longword; const _polygons:longword); cdecl; external ODEDLL;
  1177. //Heightfield (incomplete)
  1178. function dCreateHeightfield(const Space: PdxSpace; Data: PdxHeightfieldData; bPlaceable:Integer): PdxGeom; cdecl; external ODEDLL;
  1179. function dGeomHeightfieldDataCreate: PdxHeightfieldData; cdecl; external ODEDLL;
  1180. procedure dGeomHeightfieldDataDestroy(Data: PdxHeightfieldData); cdecl; external ODEDLL;
  1181. procedure dGeomHeightfieldSetHeightfieldData(const Geom: PdxGeom; Data: PdxHeightfieldData); cdecl; external ODEDLL;
  1182. function dGeomHeightfieldGetHeightfieldData(const Geom: PdxGeom):PdxHeightfieldData; cdecl; external ODEDLL;
  1183. function dGeomHeightfieldDataSetBounds(Data: PdxHeightfieldData; minHeight, MaxHeight: TdReal) : TdReal; cdecl; external ODEDLL;
  1184. //dRay
  1185. function dCreateRay(const Space: PdxSpace; length: TdReal): PdxGeom; cdecl; external ODEDLL;
  1186. procedure dGeomRaySet(const geom: PdxGeom; px, py, pz, dx, dy, dz: TdReal); cdecl; external ODEDLL;
  1187. procedure dGeomRayGet(const geom: PdxGeom; var start, dir: TdVector3); cdecl; external ODEDLL;
  1188. procedure dGeomRaySetLength(const geom: PdxGeom; length: TdReal); cdecl; external ODEDLL;
  1189. function dGeomRayGetLength(const geom: PdxGeom): TdReal; cdecl; external ODEDLL;
  1190. procedure dGeomRaySetParams(const geom: PdxGeom; FirstContact, BackfacCull: Integer); cdecl; external ODEDLL;
  1191. procedure dGeomRayGetParams(const geom: PdxGeom; var FirstContact, BackfacCull: Integer); cdecl; external ODEDLL;
  1192. procedure dGeomRaySetClosestHit(const geom: PdxGeom; closestHit: Integer); cdecl; external ODEDLL;
  1193. function dGeomRayGetClosestHit(const geom: PdxGeom): Integer; cdecl; external ODEDLL;
  1194. //TriMesh
  1195. function dCreateTriMesh(const Space : PdxSpace; Data: PdxTriMeshData; Callback:TdTriCallback; ArrayCallback:TdTriArrayCallback; RayCallback: TdTriRayCallback): PdxGeom; cdecl; external ODEDLL;
  1196. procedure dGeomTriMeshSetData(g: PdxGeom; Data: PdxTriMeshData); cdecl; external ODEDLL;
  1197. function dGeomTriMeshGetData(g: PdxGeom):PdxTriMeshData; cdecl; external ODEDLL;
  1198. function dGeomTriMeshGetTriMeshDataID(g: PdxGeom): PdxTriMeshData; cdecl; external ODEDLL;
  1199. procedure dGeomTriMeshDataUpdate(g: PdxTriMeshData); cdecl; external ODEDLL;
  1200. function dGeomTriMeshIsTCEnabled(g: PdxGeom; geomClass: Integer): Integer; cdecl; external ODEDLL;
  1201. procedure dGeomTriMeshEnableTC(g: PdxGeom; geomClass, enable: Integer); cdecl; external ODEDLL;
  1202. procedure dGeomTriMeshClearTCCache(g: PdxGeom); cdecl; external ODEDLL;
  1203. function dGeomTriMeshGetTriangleCount(g: PdxGeom) : integer; cdecl; external ODEDLL;
  1204. procedure dGeomTriMeshGetTriangle(g: PdxGeom; Index: Integer; v0, v1, v2: PdVector3); cdecl; external ODEDLL;
  1205. procedure dGeomTriMeshGetPoint(g: PdxGeom; Index: Integer; u, v: TdReal; result: TdVector3); cdecl; external ODEDLL;
  1206. function dGeomTriMeshGetArrayCallback(g: PdxGeom): Pointer; cdecl; external ODEDLL;
  1207. function dGeomTriMeshGetRayCallback(g: PdxGeom): Pointer; cdecl; external ODEDLL;
  1208. procedure dGeomTriMeshSetArrayCallback(g: PdxGeom; ArrayCallback: Pointer); cdecl; external ODEDLL;
  1209. procedure dGeomTriMeshSetRayCallback(g: PdxGeom; RayCallback: Pointer); cdecl; external ODEDLL;
  1210. procedure dGeomTriMeshSetCallback(g: PdxGeom; Callback: Pointer); cdecl; external ODEDLL;
  1211. function dGeomTriMeshGetCallback(g: PdxGeom): Pointer; cdecl; external ODEDLL;
  1212. procedure dGeomTriMeshDataDestroy(g: PdxTriMeshData); cdecl; external ODEDLL;
  1213. function dGeomTriMeshDataCreate: PdxTriMeshData; cdecl; external ODEDLL;
  1214. procedure dGeomTriMeshDataSet(g: PdxTriMeshData; data_id: Integer; data: Pointer); cdecl; external ODEDLL;
  1215. procedure dGeomTriMeshDataBuildSimple(g: PdxTriMeshData; Vertices: PdVector3Array; VertexCount: Integer; Indices: PdIntegerArray; IndexCount: Integer); cdecl; external ODEDLL;
  1216. procedure dGeomTriMeshDataBuildSimple1(g: PdxTriMeshData; Vertices: PdVector3Array; VertexCount: Integer; Indices: PdIntegerArray; IndexCount: Integer; Normals: PdVector3Array); cdecl; external ODEDLL;
  1217. procedure dGeomTriMeshDataBuildDouble(g: PdxTriMeshData; Vertices: PdVector3Array; VertexStride, VertexCount: Integer; Indices: PdIntegerArray; IndexCount, TriStride: Integer); cdecl; external ODEDLL;
  1218. procedure dGeomTriMeshDataBuildDouble1(g: PdxTriMeshData; Vertices: PdVector3Array; VertexStride, VertexCount: Integer; Indices: PdIntegerArray; IndexCount, TriStride: Integer; Normals: PdVector3Array); cdecl; external ODEDLL;
  1219. procedure dGeomTriMeshDataBuildSingle(g: PdxTriMeshData; Vertices: PdVector3Array; VertexStride, VertexCount: Integer; Indices: PdIntegerArray; IndexCount, TriStride: Integer); cdecl; external ODEDLL;
  1220. procedure dGeomTriMeshDataBuildSingle1(g: PdxTriMeshData; Vertices: PdVector3Array; VertexStride, VertexCount: Integer; Indices: PdIntegerArray; IndexCount, TriStride: Integer; Normals: PdVector3Array); cdecl; external ODEDLL;
  1221. procedure dInfiniteAABB(geom: PdxGeom; var aabb: TdAABB); cdecl; external ODEDLL;
  1222. //----- dSpace -----
  1223. procedure dSpaceDestroy(const Space: PdxSpace); cdecl; external ODEDLL;
  1224. function dSimpleSpaceCreate(Space: PdxSpace): PdxSpace; cdecl; external ODEDLL;
  1225. function dHashSpaceCreate(Space: PdxSpace): PdxSpace; cdecl; external ODEDLL;
  1226. function dQuadTreeSpaceCreate(const Space: PdxSpace; const Center, Extents : TdVector3; const Depth : Integer): PdxSpace; cdecl; external ODEDLL;
  1227. procedure dSpaceAdd(const Space: PdxSpace; const Geom: PdxGeom); cdecl; external ODEDLL;
  1228. procedure dSpaceRemove(const Space: PdxSpace; const Geom: PdxGeom); cdecl; external ODEDLL;
  1229. procedure dSpaceClean (const Space: PdxSpace); cdecl; external ODEDLL;
  1230. function dSpaceQuery (const Space: PdxSpace; const Geom: PdxGeom): Integer; cdecl; external ODEDLL;
  1231. function dSpaceGetNumGeoms (const Space: PdxSpace): integer; cdecl; external ODEDLL;
  1232. function dSpaceGetGeom(const Space: PdxSpace; const i: Integer): PdxGeom; cdecl; external ODEDLL;
  1233. procedure dHashSpaceSetLevels(const Space: PdxSpace; const minlevel, maxlevel: Integer); cdecl; external ODEDLL;
  1234. procedure dHashSpaceGetLevels(const Space: PdxSpace; var minlevel, maxlevel: Integer); cdecl; external ODEDLL;
  1235. procedure dSpaceSetCleanup (space: PdxSpace; const mode: integer); cdecl; external ODEDLL;
  1236. function dSpaceGetCleanup(Space: PdxSpace): integer; cdecl; external ODEDLL;
  1237. function dCollide(o1, o2: PdxGeom; flags: integer; var Contact: TdContactGeom; Skip: integer) : integer; cdecl; external ODEDLL;
  1238. procedure dSpaceCollide(const Space : PdxSpace; data: pointer; callback: TdNearCallback); cdecl; external ODEDLL;
  1239. procedure dSpaceCollide2(o1, o2: PdxGeom; data: pointer; callback: TdNearCallback); cdecl; external ODEDLL;
  1240. //----- dMass -----
  1241. procedure dMassSetParameters(var m: TdMass; themass, cgx, cgy, cgz, I11, I22, I33, I12, I13, I23: TdReal); cdecl; external ODEDLL;
  1242. procedure dMassAdd(var a,b: TdMass); cdecl; external ODEDLL;
  1243. procedure dMassAdjust(var m: TdMass; newmass: TdReal); cdecl; external ODEDLL;
  1244. procedure dMassTranslate(var m: TdMass; x, y, z: TdReal); cdecl; external ODEDLL;
  1245. procedure dMassRotate(var m: TdMass; var R: TdMatrix3); cdecl; external ODEDLL;
  1246. procedure dMassSetZero(var m: TdMass); cdecl; external ODEDLL;
  1247. procedure dMassSetBox(var m: TdMass; density, lx, ly, lz: TdReal); cdecl; external ODEDLL;
  1248. procedure dMassSetBoxTotal(var m: TdMass; total_mass, lx, ly, lz: TdReal); cdecl; external ODEDLL;
  1249. procedure dMassSetCylinder(var m: TdMass; density: TdReal; direction: Integer; radius, length: TdReal); cdecl; external ODEDLL;
  1250. procedure dMassSetCylinderTotal(var m: TdMass; total_mass: TdReal; direction: Integer; radius, length: TdReal); cdecl; external ODEDLL;
  1251. procedure dMassSetCapsule(var m: TdMass; density: TdReal; direction: Integer; radius, length: TdReal); cdecl; external ODEDLL;
  1252. procedure dMassSetCapsuleTotal(var m: TdMass; total_mass: TdReal; direction: Integer; radius, length: TdReal); cdecl; external ODEDLL;
  1253. procedure dMassSetSphere(var m: TdMass; density, radius: TdReal); cdecl; external ODEDLL;
  1254. procedure dMassSetSphereTotal(var m: TdMass; total_mass, radius: TdReal); cdecl; external ODEDLL;
  1255. procedure dMassSetTrimesh(var m: TdMass; density: TdReal; trimesh:PdxGeom); cdecl; external ODEDLL;
  1256. procedure dMassSetTrimeshTotal(var m: TdMass; total_mass: TdReal; trimesh:PdxGeom); cdecl; external ODEDLL;
  1257. //----- Rotation.h -----
  1258. procedure dQFromAxisAndAngle (var q: TdQuaternion; const ax, ay ,az, angle: TdReal); cdecl; external ODEDLL;
  1259. procedure dRFromAxisAndAngle (var R: TdMatrix3; const ax, ay ,az, angle: TdReal); cdecl; external ODEDLL;
  1260. procedure dRSetIdentity (var R: TdMatrix3); cdecl; external ODEDLL;
  1261. procedure dQSetIdentity (var Q: TdQuaternion); cdecl; external ODEDLL;
  1262. procedure dRFromEulerAngles (var R : TdMatrix3; const phi, theta, psi: TdReal); cdecl; external ODEDLL;
  1263. procedure dRFrom2Axes (var R: TdMatrix3; const ax, ay, az, bx, by, bz: TdReal); cdecl; external ODEDLL;
  1264. procedure dRFromZAxis (var R: TdMatrix3; const ax, ay, az: TdReal); cdecl; external ODEDLL;
  1265. procedure dMultiply0 (const A: PdReal; const B, C: PdReal; p, q, r: integer); cdecl; external ODEDLL;
  1266. procedure dMultiply1 (const A: PdReal; const B, C: PdReal; p, q, r: integer); cdecl; external ODEDLL;
  1267. procedure dMultiply2 (const A: PdReal; const B, C: PdReal; p, q, r: integer); cdecl; external ODEDLL;
  1268. procedure dQMultiply0 (var qa: TdQuaternion; const qb, qc: TdQuaternion); cdecl; external ODEDLL;
  1269. procedure dQMultiply1 (var qa: TdQuaternion; const qb, qc: TdQuaternion); cdecl; external ODEDLL;
  1270. procedure dQMultiply2 (var qa: TdQuaternion; const qb, qc: TdQuaternion); cdecl; external ODEDLL;
  1271. procedure dQMultiply3 (var qa: TdQuaternion; const qb, qc: TdQuaternion); cdecl; external ODEDLL;
  1272. procedure dRfromQ (var R: TdMatrix3; const q: TdQuaternion); cdecl; external ODEDLL;
  1273. procedure dQfromR (var q: TdQuaternion; const R: TdMatrix3); cdecl; external ODEDLL;
  1274. procedure dDQfromW (var dq: TdVector4; const w: TdVector3; const q: TdQuaternion); cdecl; external ODEDLL;
  1275. //----- Math -----
  1276. procedure dNormalize3 (var a: TdVector3); cdecl; external ODEDLL;
  1277. procedure dNormalize4 (var a: TdVector4); cdecl; external ODEDLL;
  1278. //----- Misc -----
  1279. procedure dClosestLineSegmentPoints (const a1, a2, b1, b2: TdVector3; var cp1, cp2: TdVector3); cdecl; external ODEDLL;
  1280. function dBoxTouchesBox (const _p1: TdVector3; const R1: TdMatrix3; const side1: TdVector3; const _p2: TdVector3; const R2: TdMatrix3; const side2: TdVector3): integer; cdecl; external ODEDLL;
  1281. function dMaxDifference (A, B: PdReal; n, m: integer): TdReal; cdecl; external ODEDLL;
  1282. procedure dMakeRandomVector(var n1: TdVector3; a: integer; f: TdReal); cdecl; external ODEDLL;
  1283. function dAreConnected (a, b: PdxBody): integer; cdecl; external ODEDLL;
  1284. function dAreConnectedExcluding (a, b: PdxBody; joint_type : TdJointTypeNumbers) : integer; cdecl; external ODEDLL;
  1285. procedure dMakeRandomMatrix (A: PdRealArray; n, m: integer; range: TdReal); cdecl; external ODEDLL;
  1286. procedure dClearUpperTriangle (A: PdRealArray; n: integer); cdecl; external ODEDLL;
  1287. function dRandGetSeed: Cardinal; cdecl; external ODEDLL;
  1288. procedure dRandSetSeed (const s: Cardinal); cdecl; external ODEDLL;
  1289. function dRandInt (const n: Integer): Integer; cdecl; external ODEDLL;
  1290. function dRandReal: TdReal; cdecl; external ODEDLL;
  1291. // return 1 if the random number generator is working.
  1292. function dTestRand: Integer; cdecl; external ODEDLL;
  1293. procedure dTestMatrixComparison; cdecl; external ODEDLL;
  1294. procedure dTestSolveLCP; cdecl; external ODEDLL;
  1295. //----- Recreated -----
  1296. function dDot (const a, b: TdVector3): TdReal; overload;
  1297. function dDot (const a, b: PdVector3): TdReal; overload;
  1298. function dDOT14(const a,b: TdRealArray): TdReal; overload;
  1299. function dDOT14(const a,b: PdRealArray): TdReal; overload;
  1300. procedure dMULTIPLY0_333(var A: TdMatrix3; const B,C: TdMatrix3);
  1301. procedure dMULTIPLY0_331(var A: TdVector3; const B: TdMatrix3; const C: TdVector3);
  1302. function Vector3ScalarMul(const a: TdVector3; const Scalar : TdReal): TdVector3;
  1303. function Vector3ADD(const a, b: TdVector3): TdVector3;
  1304. function Vector3SUB(const a, b: TdVector3): TdVector3;
  1305. function Vector3Length(const a : TdVector3): TdReal;
  1306. function Vector3Cross(const V1, V2: TdVector3): TdVector3;
  1307. function Vector3Make(const x,y,z: TdReal): TdVector3;
  1308. procedure VerifyDelphiODE(Body: PdxBody; Geom: PdxGeom);
  1309. {ExportInitODEMarker}
  1310. const MaxUserClasses = 4;
  1311. var
  1312. dSphereClass : integer=0;
  1313. dBoxClass : integer=1;
  1314. dCapsuleClass : integer=2;
  1315. dCylinderClass : integer=3;
  1316. dPlaneClass : integer=4;
  1317. dRayClass : integer=5;
  1318. dConvexClass : integer=6;
  1319. dGeomTransformClass : integer=7;
  1320. dTriMeshClass : integer=8;
  1321. dHeightFieldClass : integer=9;
  1322. dFirstSpaceClass : integer = 10;
  1323. dSimpleSpaceClass : integer = 10;
  1324. dHashSpaceClass : integer = 11;
  1325. dSweepAndPruneSpaceClass : integer = 12;
  1326. dQuadTreeSpaceClass : integer = 13;
  1327. dLastSpaceClass : integer = 13;
  1328. dFirstUserClass : integer = 14;
  1329. dLastUserClass : integer = 17;
  1330. dGeomNumClasses : integer = 18;
  1331. IsODEInitialized : boolean = False;
  1332. DisabledDebugGeom : boolean = False;
  1333. DisabledDebugCollision : boolean = False;
  1334. {$IFDEF cODEDebugEnabled}
  1335. var
  1336. ODEDebugGeomList: TGeomList;
  1337. {$ENDIF}
  1338. {$IFDEF cODEDebugCollisionEnabled}
  1339. var
  1340. ODEDebugCollisionList: array of TdContact;
  1341. {$ENDIF}
  1342. // These are made public in the dynamic version MRQZZZ
  1343. function InitODE(ADllName : PChar) : boolean;
  1344. procedure CloseODE;
  1345. //-----------------------------------------
  1346. implementation
  1347. //-----------------------------------------
  1348. //---------------------
  1349. // TBodyList
  1350. //---------------------
  1351. procedure TBodyList.DeleteAllBodies;
  1352. var i : integer;
  1353. begin
  1354. for i := 0 to Count-1 do dBodyDestroy(Get(i));
  1355. Clear;
  1356. end;
  1357. function TBodyList.GetItems(i: integer): PdxBody;
  1358. begin
  1359. result := Get(i);
  1360. end;
  1361. procedure TBodyList.SetItems(i: integer; const Value: PdxBody);
  1362. begin
  1363. Put(i, Value);
  1364. end;
  1365. //---------------------------
  1366. // TGeomList
  1367. //---------------------------
  1368. procedure TGeomList.DeleteAllGeoms(DeleteDataAsObject : boolean=false);
  1369. var i : integer;
  1370. geom : PdxGeom;
  1371. begin
  1372. for i := 0 to Count-1 do begin
  1373. geom := Get(i);
  1374. if DeleteDataAsObject and (geom.data<>nil) then TObject(geom.data).Free;
  1375. dGeomDestroy(geom);
  1376. end;
  1377. Clear;
  1378. end;
  1379. function TGeomList.GetItems(i: integer): PdxGeom;
  1380. begin
  1381. result := Get(i);
  1382. end;
  1383. procedure TGeomList.SetItems(i: integer; const Value: PdxGeom);
  1384. begin
  1385. Put(i, Value);
  1386. end;
  1387. //----- Recreated -----
  1388. function dDot (const a, b : PdVector3) : TdReal;
  1389. begin
  1390. Assert(Assigned(a),'a not assigned!');
  1391. Assert(Assigned(b),'b not assigned!');
  1392. result := ((a)[0]*(b)[0] + (a)[1]*(b)[1] + (a)[2]*(b)[2]);
  1393. end;
  1394. function dDot (const a, b : TdVector3) : TdReal;
  1395. begin
  1396. result := ((a)[0]*(b)[0] + (a)[1]*(b)[1] + (a)[2]*(b)[2]);
  1397. end;
  1398. // #define dDOT(a,b) ((a)[0]*(b)[0] + (a)[1]*(b)[1] + (a)[2]*(b)[2])
  1399. // #define dDOT14(a,b) ((a)[0]*(b)[0] + (a)[1]*(b)[4] + (a)[2]*(b)[8])
  1400. // #define dDOT41(a,b) ((a)[0]*(b)[0] + (a)[4]*(b)[1] + (a)[8]*(b)[2])
  1401. // #define dDOT44(a,b) ((a)[0]*(b)[0] + (a)[4]*(b)[4] + (a)[8]*(b)[8])
  1402. function dDOT14(const a,b : TdRealArray) : TdReal; overload;
  1403. begin
  1404. result := ((a)[0]*(b)[0] + (a)[1]*(b)[4] + (a)[2]*(b)[8]);
  1405. end;
  1406. function dDOT14(const a,b : PdRealArray) : TdReal; overload;
  1407. begin
  1408. result := ((a)[0]*(b)[0] + (a)[1]*(b)[4] + (a)[2]*(b)[8]);
  1409. end;
  1410. procedure dMULTIPLY0_331(var A : TdVector3; const B : TdMatrix3; const C : TdVector3);
  1411. {var
  1412. v : PdVector3;}
  1413. begin
  1414. // #define dMULTIPLY0_331(A,B,C) dMULTIPLYOP0_331(A,=,B,C)
  1415. // #define dMULTIPLYOP0_331(A,op,B,C) \
  1416. // (A)[0] op dDOT((B),(C)); \
  1417. // (A)[1] op dDOT((B+4),(C)); \
  1418. // (A)[2] op dDOT((B+8),(C));
  1419. A[0] := dDOT(PdVector3(@(B[0]))^, C);
  1420. A[1] := dDOT(PdVector3(@(B[4]))^, C);
  1421. A[2] := dDOT(PdVector3(@(B[8]))^, C);//}
  1422. end;
  1423. procedure dMULTIPLY0_333(var A : TdMatrix3; const B,C : TdMatrix3);
  1424. begin
  1425. // #define dMULTIPLY0_333(A,B,C) dMULTIPLYOP0_333(A,=,B,C)
  1426. // #define dMULTIPLYOP0_333(A,op,B,C) \
  1427. // (A)[0] op dDOT14((B),(C)); \
  1428. // (A)[1] op dDOT14((B),(C+1)); \
  1429. // (A)[2] op dDOT14((B),(C+2)); \
  1430. // (A)[4] op dDOT14((B+4),(C)); \
  1431. // (A)[5] op dDOT14((B+4),(C+1)); \
  1432. // (A)[6] op dDOT14((B+4),(C+2)); \
  1433. // (A)[8] op dDOT14((B+8),(C)); \
  1434. // (A)[9] op dDOT14((B+8),(C+1)); \
  1435. // (A)[10] op dDOT14((B+8),(C+2));
  1436. A[0] := dDOT14(PdRealArray(@(B[0])),PdRealArray(@(C[0])));
  1437. A[1] := dDOT14(PdRealArray(@(B[0])),PdRealArray(@(C[1])));
  1438. A[2] := dDOT14(PdRealArray(@(B[0])),PdRealArray(@(C[2])));
  1439. A[4] := dDOT14(PdRealArray(@(B[4])),PdRealArray(@(C[0])));
  1440. A[5] := dDOT14(PdRealArray(@(B[4])),PdRealArray(@(C[1])));
  1441. A[6] := dDOT14(PdRealArray(@(B[4])),PdRealArray(@(C[2])));
  1442. A[8] := dDOT14(PdRealArray(@(B[8])),PdRealArray(@(C[0])));
  1443. A[9] := dDOT14(PdRealArray(@(B[8])),PdRealArray(@(C[1])));
  1444. A[10] := dDOT14(PdRealArray(@(B[8])),PdRealArray(@(C[2])));
  1445. end;
  1446. function Vector3ScalarMul(const a : TdVector3; const Scalar : TdReal) : TdVector3;
  1447. begin
  1448. result[0] := a[0]*Scalar;
  1449. result[1] := a[1]*Scalar;
  1450. result[2] := a[2]*Scalar;
  1451. end;
  1452. function Vector3ADD(const a, b : TdVector3) : TdVector3;
  1453. begin
  1454. result[0] := a[0]+b[0];
  1455. result[1] := a[1]+b[1];
  1456. result[2] := a[2]+b[2];
  1457. end;
  1458. function Vector3SUB(const a, b : TdVector3) : TdVector3;
  1459. begin
  1460. result[0] := a[0]-b[0];
  1461. result[1] := a[1]-b[1];
  1462. result[2] := a[2]-b[2];
  1463. end;
  1464. function Vector3Length(const a : TdVector3) : TdReal;
  1465. begin
  1466. result := sqrt(sqr(a[0])+sqr(a[1])+sqr(a[2]));
  1467. end;
  1468. function Vector3Cross(const V1, V2 : TdVector3) : TdVector3;
  1469. begin
  1470. Result[0]:=V1[1] * V2[2] - V1[2] * V2[1];
  1471. Result[1]:=V1[2] * V2[0] - V1[0] * V2[2];
  1472. Result[2]:=V1[0] * V2[1] - V1[1] * V2[0];
  1473. end;
  1474. function Vector3Make(const x,y,z : TdReal) : TdVector3;
  1475. begin
  1476. result[0] := x;
  1477. result[1] := y;
  1478. result[2] := z;
  1479. end;
  1480. (*
  1481. procedure DisableStillBodies(World : PdxWorld; Threshold : TdReal=0.0001);
  1482. var
  1483. Body : PdxBody;
  1484. TempList : TList;
  1485. begin
  1486. if not Assigned(WasStillBefore) then
  1487. begin
  1488. WasStillBefore := TList.Create;
  1489. WasStillBeforeOld := TList.Create;
  1490. end;
  1491. Body := World.FirstBody;
  1492. WasStillBefore.Clear;
  1493. // We can't disable bodies just as soon as they're still - that could disable
  1494. // bodies that are just slowed down or titering on an edge. If they've been
  1495. // still for two frames, we consider them truly still.
  1496. while Assigned(Body) do
  1497. begin
  1498. if dBodyIsEnabled(Body)=1 then
  1499. begin
  1500. // Is the body still?
  1501. if (abs(Body.lvel[0])<Threshold) and (abs(Body.lvel[1])<Threshold) and (abs(Body.lvel[2])<Threshold) and
  1502. (abs(Body.avel[0])<Threshold) and (abs(Body.avel[1])<Threshold) and (abs(Body.avel[2])<Threshold) then
  1503. begin
  1504. if WasStillBeforeOld.IndexOf(Body)<>-1 then
  1505. dBodyDisable(Body)
  1506. else
  1507. WasStillBefore.Add(Body);
  1508. end;
  1509. end;
  1510. Body := PdxBody(Body.BaseObject.next);
  1511. end;
  1512. TempList := WasStillBeforeOld;
  1513. WasStillBeforeOld := WasStillBefore;
  1514. WasStillBefore := TempList;
  1515. end; *)
  1516. procedure VerifyDelphiODE(Body : PdxBody; Geom : PdxGeom);
  1517. var
  1518. m : TdMass;
  1519. VerificationPointer : pointer;
  1520. begin
  1521. VerificationPointer := pointer( -1 ); // A known pointer
  1522. // Verify Body
  1523. dBodySetData( Body, VerificationPointer );
  1524. Assert( dBodyGetData( Body ) = VerificationPointer, 'Body test 1 fails' );
  1525. Assert( Body.BaseObject.userdata = VerificationPointer, 'Body test 2 fails' );
  1526. dBodyGetMass(Body, m);
  1527. Assert(Body.mass.mass = m.mass, 'Body test 3 fails');
  1528. // Verify Geom
  1529. dGeomSetData( Geom, VerificationPointer );
  1530. Assert( dGeomGetData( Geom ) = VerificationPointer, 'Geom test 1 fails' );
  1531. Assert(dGeomGetBody(Geom)=Geom.Body, 'Geom test 2 fails');
  1532. Assert( Geom.Data = VerificationPointer, 'Geom test 3 fails' );
  1533. end;
  1534. var
  1535. vODEHandle : TModuleHandle;
  1536. procedure GetODEClassIDs;
  1537. begin
  1538. {$IFDEF PARODE}
  1539. dSphereClass:=dSphereGetClass;
  1540. dBoxClass:=dBoxGetClass;
  1541. dPlaneClass:=dPlaneGetClass;
  1542. dCylinderClass:=dCylinderGetClass;
  1543. dConvexClass:=dConvexGetClass;
  1544. dGeomTransformClass:=dGeomTransformGetClass;
  1545. dRayClass:=dRayGetClass;
  1546. dTriMeshClass:=dTriMeshGetClass;
  1547. dHeightfieldClass:=dHeightfieldGetClass;
  1548. {$ENDIF}
  1549. end;
  1550. function InitODE(ADllName : PChar) : boolean;
  1551. var isODELoaded : boolean;
  1552. begin
  1553. result := IsODEInitialized;
  1554. if IsODEInitialized then exit;
  1555. if ADllName = '' then ADllName := ODEDLL;
  1556. isODELoaded := LoadModule( vODEHandle, ADllName );
  1557. if not isODELoaded then exit;
  1558. if isODELoaded and not IsODEInitialized then begin
  1559. dInitODE2(0);
  1560. GetODEClassIDs;
  1561. IsODEInitialized:=True;
  1562. end;
  1563. result:=IsODEInitialized;
  1564. end;
  1565. procedure CloseODE;
  1566. begin
  1567. if IsODEInitialized then dCloseODE;
  1568. IsODEInitialized := false;
  1569. UnLoadModule( vODEHandle );
  1570. end;
  1571. //---------------------------------------
  1572. initialization
  1573. //---------------------------------------
  1574. InitODE(ODEDLL);
  1575. //---------------------------------------
  1576. finalization
  1577. //---------------------------------------
  1578. CloseODE;
  1579. end.