ODE.Import.pas 86 KB

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