ODE.Import.pas 86 KB

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