box2d.bmx 133 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190
  1. ' Copyright (c) 2008-2022 Bruce A Henderson
  2. '
  3. ' Permission is hereby granted, free of charge, to any person obtaining a copy
  4. ' of this software and associated documentation files (the "Software"), to deal
  5. ' in the Software without restriction, including without limitation the rights
  6. ' to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  7. ' copies of the Software, and to permit persons to whom the Software is
  8. ' furnished to do so, subject to the following conditions:
  9. '
  10. ' The above copyright notice and this permission notice shall be included in
  11. ' all copies or substantial portions of the Software.
  12. '
  13. ' THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  14. ' IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  15. ' FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  16. ' AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  17. ' LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  18. ' OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  19. ' THE SOFTWARE.
  20. '
  21. SuperStrict
  22. Rem
  23. bbdoc: Box2D
  24. End Rem
  25. Module Physics.Box2D
  26. ModuleInfo "Version: 1.07"
  27. ModuleInfo "License: MIT"
  28. ModuleInfo "Copyright: Box2D (c) 2006-2016 Erin Catto http://www.gphysics.com"
  29. ModuleInfo "Copyright: BlitzMax port - 2008-2022 Bruce A Henderson"
  30. ModuleInfo "History: 1.07"
  31. ModuleInfo "History: Fixed for macOS build."
  32. ModuleInfo "History: Refactored to use some more structs."
  33. ModuleInfo "History: 1.06"
  34. ModuleInfo "History: Refactored to use structs where appropriate."
  35. ModuleInfo "History: 1.05"
  36. ModuleInfo "History: Updated for NG"
  37. ModuleInfo "History: 1.04"
  38. ModuleInfo "History: Updated to box2d svn (rev 207)"
  39. ModuleInfo "History: Added b2LineJoint type."
  40. ModuleInfo "History: Added b2ShapeDef.SetUserData() method."
  41. ModuleInfo "History: Added b2Mat22.GetAngle() method."
  42. ModuleInfo "History: Added b2Mat22 Create... methods, and others."
  43. ModuleInfo "History: Added shape SetFriction() and SetRestitution() methods."
  44. ModuleInfo "History: Fixed contact filter example and docs."
  45. ModuleInfo "History: Added b2EdgeShape type."
  46. ModuleInfo "History: Added staticedges, dynamicedges, pyramidstaticedges and buoyancy examples."
  47. ModuleInfo "History: Added buoyancy types + methods."
  48. ModuleInfo "History: Added b2Body SetMass() method."
  49. ModuleInfo "History: Added b2BodyDef GetMassData() method."
  50. ModuleInfo "History: Converted bool handling in glue to use ints instead."
  51. ModuleInfo "History: Added b2Vec2 SetX() and SetY() methods."
  52. ModuleInfo "History: 1.03"
  53. ModuleInfo "History: Updated to box2d svn (rev 172)"
  54. ModuleInfo "History: Added b2CircleShape and b2PolygonShape types."
  55. ModuleInfo "History: Added b2OBB type."
  56. ModuleInfo "History: Added b2Segment type."
  57. ModuleInfo "History: Added b2World Raycast(), RaycastOne() and InRange() methods."
  58. ModuleInfo "History: Added b2Body.GetWorld() method."
  59. ModuleInfo "History: Added raycast example."
  60. ModuleInfo "History: 1.02"
  61. ModuleInfo "History: Updated to box2d svn (rev 169)"
  62. ModuleInfo "History: API CHANGES : DoStep() - changed iteration parameters"
  63. ModuleInfo "History: API CHANGES : joints - GetReactionForce() And GetReactionTorque() added 'dt' parameter."
  64. ModuleInfo "History: Added car example."
  65. ModuleInfo "History: Added revolute example."
  66. ModuleInfo "History: Added b2ShapeDef - SetIsSensor and IsSensor methods."
  67. ModuleInfo "History: Fixed typo in b2ContactListener - Remove()."
  68. ModuleInfo "History: Added b2World.Refilter() and several missing b2Shape methods."
  69. ModuleInfo "History: Updated Documentation."
  70. ModuleInfo "History: 1.01"
  71. ModuleInfo "History: Fixed filterdata problem. Fixed collisionfiltering example."
  72. ModuleInfo "History: Added Theo Jansen example."
  73. ModuleInfo "History: 1.00 Initial Release"
  74. Import "common.bmx"
  75. ' NOTES :
  76. ' b2Controller.h - Added userData fields/methods.
  77. '
  78. ' b2Math.h - added __APPLE__ test for isfinite() use.
  79. '
  80. Rem
  81. bbdoc: The world type manages all physics entities, dynamic simulation, and asynchronous queries.
  82. about: The world also contains efficient memory management facilities.
  83. End Rem
  84. Type b2World
  85. Field b2ObjectPtr:Byte Ptr
  86. Field filter:b2ContactFilter
  87. Field contactListener:b2ContactListener
  88. Field boundaryListener:b2BoundaryListener
  89. Field destructionListener:b2DestructionListener
  90. Field groundBody:b2Body
  91. Function _create:b2World(b2ObjectPtr:Byte Ptr)
  92. If b2ObjectPtr Then
  93. Local this:b2World = New b2World
  94. this.b2ObjectPtr = b2ObjectPtr
  95. Return this
  96. End If
  97. End Function
  98. Rem
  99. bbdoc: Construct a world object.
  100. End Rem
  101. Function CreateWorld:b2World(worldAABB:b2AABB, gravity:b2Vec2, doSleep:Int)
  102. Return New b2World.Create(worldAABB, gravity, doSleep)
  103. End Function
  104. Rem
  105. bbdoc: Construct a world object.
  106. End Rem
  107. Method Create:b2World(worldAABB:b2AABB, gravity:b2Vec2, doSleep:Int)
  108. b2ObjectPtr = bmx_b2world_create(worldAABB, gravity, doSleep)
  109. ' setup default destruction listener
  110. SetDestructionListener(New b2DestructionListener)
  111. Return Self
  112. End Method
  113. Method Free()
  114. If b2ObjectPtr Then
  115. bmx_b2world_free(b2ObjectPtr)
  116. b2ObjectPtr = Null
  117. End If
  118. End Method
  119. Method Delete()
  120. Free()
  121. End Method
  122. Rem
  123. bbdoc: Register a destruction listener.
  124. End Rem
  125. Method SetDestructionListener(listener:b2DestructionListener)
  126. destructionListener = listener
  127. bmx_b2world_setdestructionlistener(b2ObjectPtr, listener.b2ObjectPtr)
  128. End Method
  129. Rem
  130. bbdoc: Register a broad-phase boundary listener.
  131. End Rem
  132. Method SetBoundaryListener(listener:b2BoundaryListener)
  133. boundaryListener = listener
  134. bmx_b2world_setboundarylistener(b2ObjectPtr, listener.b2ObjectPtr)
  135. End Method
  136. Rem
  137. bbdoc: Register a contact filter to provide specific control over collision.
  138. about: Otherwise the default filter is used.
  139. End Rem
  140. Method SetFilter(_filter:b2ContactFilter)
  141. filter = _filter
  142. bmx_b2world_setfilter(b2ObjectPtr, filter.b2ObjectPtr)
  143. End Method
  144. Rem
  145. bbdoc: Register a contact event listener
  146. End Rem
  147. Method SetContactListener(listener:b2ContactListener)
  148. contactListener = listener
  149. bmx_b2world_setcontactlistener(b2ObjectPtr, listener.b2ObjectPtr)
  150. End Method
  151. Rem
  152. bbdoc: Register a routine for debug drawing.
  153. about: The debug draw functions are called inside the b2World::DoStep method, so make sure your renderer is ready to
  154. consume draw commands when you call DoStep().
  155. End Rem
  156. Method SetDebugDraw(debugDraw:b2DebugDraw)
  157. bmx_b2world_setdebugDraw(b2ObjectPtr, debugDraw.b2ObjectPtr)
  158. End Method
  159. Rem
  160. bbdoc: Create a rigid body given a definition
  161. about: No reference to the definition is retained.
  162. <p>
  163. Warning: This method is locked during callbacks.
  164. </p>
  165. End Rem
  166. Method CreateBody:b2Body(def:b2BodyDef)
  167. Local body:b2Body = New b2Body
  168. body.userData = def.userData ' copy the userData
  169. body.b2ObjectPtr = bmx_b2world_createbody(b2ObjectPtr, def.b2ObjectPtr, body)
  170. Return body
  171. End Method
  172. Rem
  173. bbdoc: Destroy a rigid body given a definition.
  174. about: No reference to the definition is retained.
  175. <p>
  176. Warning: This automatically deletes all associated shapes and joints.
  177. </p>
  178. <p>
  179. Warning: This method is locked during callbacks.
  180. </p>
  181. End Rem
  182. Method DestroyBody(body:b2Body)
  183. bmx_b2world_destroybody(b2ObjectPtr, body.b2ObjectPtr)
  184. End Method
  185. Rem
  186. bbdoc: Create a joint to constrain bodies together.
  187. about: No reference to the definition is retained. This may cause the connected bodies to cease
  188. colliding.
  189. <p>
  190. Warning: This method is locked during callbacks.
  191. </p>
  192. End Rem
  193. Method CreateJoint:b2Joint(def:b2JointDef)
  194. Local joint:b2Joint = b2Joint._create(bmx_b2world_createjoint(b2ObjectPtr, def.b2ObjectPtr))
  195. joint.userData = def.userData ' copy the userData
  196. Return joint
  197. End Method
  198. '
  199. Function _createJoint:b2Joint(jointType:Int) { nomangle }
  200. Local joint:b2Joint
  201. Select jointType
  202. Case e_unknownJoint
  203. joint = New b2Joint
  204. Case e_revoluteJoint
  205. joint = New b2RevoluteJoint
  206. Case e_prismaticJoint
  207. joint = New b2PrismaticJoint
  208. Case e_distanceJoint
  209. joint = New b2DistanceJoint
  210. Case e_pulleyJoint
  211. joint = New b2PulleyJoint
  212. Case e_mouseJoint
  213. joint = New b2MouseJoint
  214. Case e_gearJoint
  215. joint = New b2GearJoint
  216. Case e_lineJoint
  217. joint = New b2LineJoint
  218. Default
  219. DebugLog "Warning, joint type '" + jointType + "' is not defined in module."
  220. joint = New b2Joint
  221. End Select
  222. Return joint
  223. End Function
  224. Rem
  225. bbdoc: Destroy a joint.
  226. about: This may cause the connected bodies to begin colliding.
  227. <p>
  228. Warning: This method is locked during callbacks.
  229. </p>
  230. End Rem
  231. Method DestroyJoint(joint:b2Joint)
  232. bmx_b2world_destroyjoint(b2ObjectPtr, joint.b2ObjectPtr)
  233. End Method
  234. Rem
  235. bbdoc: Add a controller to the world.
  236. End Rem
  237. Method CreateController:b2Controller(def:b2ControllerDef)
  238. Local controller:b2Controller = b2Controller._create(bmx_b2world_createcontroller(b2ObjectPtr, def.b2ObjectPtr, def._type))
  239. controller.userData = def.userData ' copy the userData
  240. Return controller
  241. End Method
  242. '
  243. Function __createController:b2Controller(controllerType:Int) { nomangle }
  244. Local controller:b2Controller
  245. Select controllerType
  246. Case e_buoyancyController
  247. controller = New b2BuoyancyController
  248. Case e_constantAccelController
  249. controller = New b2ConstantAccelController
  250. Case e_tensorDampingController
  251. controller = New b2TensorDampingController
  252. Case e_gravityController
  253. controller = New b2GravityController
  254. Case e_constantForceController
  255. controller = New b2ConstantForceController
  256. Default
  257. DebugLog "Warning, controller type '" + controllerType + "' is not defined in module."
  258. controller = New b2Controller
  259. End Select
  260. Return controller
  261. End Function
  262. Rem
  263. bbdoc: Removes a controller from the world.
  264. End Rem
  265. Method DestroyController(controller:b2Controller)
  266. bmx_b2world_destroycontroller(b2ObjectPtr, controller.b2ObjectPtr)
  267. End Method
  268. Rem
  269. bbdoc: The world provides a single static ground body with no collision shapes.
  270. about: You can use this to simplify the creation of joints and static shapes.
  271. End Rem
  272. Method GetGroundBody:b2Body()
  273. If Not groundBody Then
  274. groundBody = b2Body._create(bmx_b2world_getgroundbody(b2ObjectPtr))
  275. End If
  276. Return groundBody
  277. End Method
  278. Rem
  279. bbdoc: Take a time Step.
  280. about: This performs collision detection, integration, and constraint solution.
  281. <p>Parameters:
  282. <ul>
  283. <li><b> timeStep </b> : the amount of time To simulate, this should Not vary. </li>
  284. <li><b> velocityIterations </b> : for the velocity constraint solver.</li>
  285. <li><b> positionIterations </b> : for the position constraint solver.</li>
  286. </ul>
  287. </p>
  288. End Rem
  289. Method DoStep(timeStep:Float, velocityIterations:Int, positionIterations:Int)
  290. bmx_b2world_dostep(b2ObjectPtr, timeStep, velocityIterations, positionIterations)
  291. End Method
  292. Rem
  293. bbdoc: Get the world body list.
  294. returns: The head of the world body list.
  295. about: With the returned body, use b2Body::GetNext to get the next body in the world list. A NULL body indicates
  296. the end of the list.
  297. End Rem
  298. Method GetBodyList:b2Body()
  299. Return b2Body._create(bmx_b2world_getbodylist(b2ObjectPtr))
  300. End Method
  301. Rem
  302. bbdoc: Get the world joint list.
  303. returns: The head of the world joint list.
  304. about: With the returned joint, use b2Joint::GetNext to get the next joint in the world list. A NULL joint indicates
  305. the end of the list.
  306. End Rem
  307. Method GetJointList:b2Joint()
  308. Return b2Joint._create(bmx_b2world_getjointlist(b2ObjectPtr))
  309. End Method
  310. Rem
  311. bbdoc: Enable/disable warm starting. For testing.
  312. End Rem
  313. Method SetWarmStarting(flag:Int)
  314. bmx_b2world_setwarmstarting(b2ObjectPtr, flag)
  315. End Method
  316. Rem
  317. bbdoc: Enable/disable continuous physics. For testing.
  318. End Rem
  319. Method SetContinuousPhysics(flag:Int)
  320. bmx_b2world_setcontinuousphysics(b2ObjectPtr, flag)
  321. End Method
  322. Rem
  323. bbdoc: Perform validation of internal data structures.
  324. End Rem
  325. Method Validate()
  326. bmx_b2world_validate(b2ObjectPtr)
  327. End Method
  328. Rem
  329. bbdoc: Change the global gravity vector.
  330. End Rem
  331. Method SetGravity(gravity:b2Vec2)
  332. bmx_b2world_setgravity(b2ObjectPtr, gravity)
  333. End Method
  334. Rem
  335. bbdoc: Get the number of broad-phase proxies.
  336. End Rem
  337. Method GetProxyCount:Int()
  338. Return bmx_b2world_getproxycount(b2ObjectPtr)
  339. End Method
  340. Rem
  341. bbdoc: Get the number of broad-phase pairs.
  342. End Rem
  343. Method GetPairCount:Int()
  344. Return bmx_b2world_getpaircount(b2ObjectPtr)
  345. End Method
  346. Rem
  347. bbdoc: Get the number of bodies.
  348. End Rem
  349. Method GetBodyCount:Int()
  350. Return bmx_b2world_getbodycount(b2ObjectPtr)
  351. End Method
  352. Rem
  353. bbdoc: Get the number joints.
  354. End Rem
  355. Method GetJointCount:Int()
  356. Return bmx_b2world_getjointcount(b2ObjectPtr)
  357. End Method
  358. Rem
  359. bbdoc: Query the world for all shapes that potentially overlap the provided AABB.
  360. returns: The number of shapes found in aabb.
  361. about: You provide a shape array for populating. The number of shapes found is returned.
  362. End Rem
  363. Method Query:Int(aabb:b2AABB, shapes:b2Shape[])
  364. Return bmx_b2world_query(b2ObjectPtr, aabb, shapes)
  365. End Method
  366. Rem
  367. bbdoc: Re-filter a shape.
  368. about: This re-runs contact filtering on a shape.
  369. End Rem
  370. Method Refilter(shape:b2Shape)
  371. bmx_b2world_refilter(b2ObjectPtr, shape.b2ObjectPtr)
  372. End Method
  373. Rem
  374. bbdoc: Query the world for all shapes that intersect a given segment.
  375. about: You provide a shape array of an appropriate size. The number of shapes found is returned, and the array
  376. is filled in order of intersection.
  377. End Rem
  378. Method Raycast:Int(segment:b2Segment Var, shapes:b2Shape[], solidShapes:Int)
  379. Return bmx_b2world_raycast(b2ObjectPtr, segment, shapes, solidShapes)
  380. End Method
  381. Rem
  382. bbdoc: Performs a raycast as with Raycast, finding the first intersecting shape.
  383. End Rem
  384. Method RaycastOne:b2Shape(segment:b2Segment Var, lambda:Float Var, normal:b2Vec2 Var, solidShapes:Int)
  385. Return b2Shape._create(bmx_b2world_raycastone(b2ObjectPtr, segment, Varptr lambda, normal, solidShapes))
  386. End Method
  387. Rem
  388. bbdoc: Check if the AABB is within the broadphase limits.
  389. End Rem
  390. Method InRange:Int(aabb:b2AABB)
  391. Return bmx_b2world_inrange(b2ObjectPtr, aabb)
  392. End Method
  393. Function _setShape(shapes:b2Shape[], index:Int, shape:Byte Ptr) { nomangle }
  394. shapes[index] = b2Shape._create(shape)
  395. End Function
  396. End Type
  397. Rem
  398. bbdoc: An axis aligned bounding box.
  399. End Rem
  400. Struct b2AABB
  401. Field lowerBound:b2Vec2
  402. Field upperBound:b2Vec2
  403. Method Create:b2AABB()
  404. Return Self
  405. End Method
  406. Rem
  407. bbdoc: Creates a new AABB
  408. End Rem
  409. Function CreateAABB:b2AABB(lowerBound:b2Vec2, upperBound:b2Vec2)
  410. Return New b2AABB.Create(lowerBound, upperBound)
  411. End Function
  412. Rem
  413. bbdoc: Creates a new AABB
  414. End Rem
  415. Method Create:b2AABB(lowerBound:b2Vec2, upperBound:b2Vec2)
  416. Self.lowerBound = lowerBound
  417. Self.upperBound = upperBound
  418. Return Self
  419. End Method
  420. Rem
  421. bbdoc: Sets the lower vertex.
  422. End Rem
  423. Method SetLowerBound(lowerBound:b2Vec2)
  424. Self.lowerBound = lowerBound
  425. End Method
  426. Rem
  427. bbdoc: Sets the upper vertex.
  428. End Rem
  429. Method SetUpperBound(upperBound:b2Vec2)
  430. Self.upperBound = upperBound
  431. End Method
  432. Rem
  433. bbdoc: Verify that the bounds are sorted.
  434. End Rem
  435. Method IsValid:Int()
  436. Return bmx_b2abb_isvalid(Self)
  437. End Method
  438. End Struct
  439. Rem
  440. bbdoc: A 2D column vector.
  441. End Rem
  442. Struct b2Vec2
  443. Field x:Float
  444. Field y:Float
  445. Method New()
  446. End Method
  447. Method New(x:Float, y:Float)
  448. Self.x = x
  449. Self.y = y
  450. End Method
  451. Rem
  452. bbdoc: Creates a new vector with the given coordinates.
  453. End Rem
  454. Function CreateVec2:b2Vec2(x:Float = 0, y:Float = 0)
  455. Return New b2Vec2.Create(x, y)
  456. End Function
  457. Rem
  458. bbdoc: Creates a new vector with the given coordinates.
  459. End Rem
  460. Method Create:b2Vec2(x:Float = 0, y:Float = 0)
  461. Self.x = x
  462. Self.y = y
  463. Return Self
  464. End Method
  465. Rem
  466. bbdoc: Returns the X coordinate.
  467. about: Synonym for X().
  468. End Rem
  469. Method GetX:Float()
  470. Return x
  471. End Method
  472. Rem
  473. bbdoc: Returns the Y coordinate.
  474. about: Synonym for Y().
  475. End Rem
  476. Method GetY:Float()
  477. Return y
  478. End Method
  479. Rem
  480. bbdoc: Adds @vec to this vector.
  481. End Rem
  482. Method Add(vec:b2Vec2)
  483. x :+ vec.x
  484. y :+ vec.y
  485. End Method
  486. Rem
  487. bbdoc: Adds @vec to this vector, returning the a new b2Vec2.
  488. about: This object is not modified.
  489. End Rem
  490. Method Plus:b2Vec2(vec:b2Vec2)
  491. Return New b2Vec2(x + vec.x, y + vec.y)
  492. End Method
  493. Rem
  494. bbdoc: Multiplies the vector by @value.
  495. End Rem
  496. Method Multiply:b2Vec2(value:Float)
  497. x :* value
  498. y :* value
  499. Return Self
  500. End Method
  501. Rem
  502. bbdoc: Divides the vector by @value.
  503. End Rem
  504. Method Divide:b2Vec2(value:Float)
  505. Local v:Float = 1.0 / value
  506. x :* v
  507. y :* v
  508. Return Self
  509. End Method
  510. Rem
  511. bbdoc: Copies @vec into this object.
  512. End Rem
  513. Method Copy(vec:b2Vec2)
  514. x = vec.x
  515. y = vec.y
  516. End Method
  517. Rem
  518. bbdoc: Subtracts @vec from this object, returning a new b2Vec2.
  519. about: This object is not modified.
  520. End Rem
  521. Method Subtract:b2Vec2(vec:b2Vec2)
  522. Return New b2Vec2(x - vec.x, y - vec.y)
  523. End Method
  524. Rem
  525. bbdoc: Sets the x and y parts.
  526. End Rem
  527. Method Set(x:Float, y:Float)
  528. Self.x = x
  529. Self.y = y
  530. End Method
  531. Rem
  532. bbdoc: Sets the x part.
  533. End Rem
  534. Method SetX(x:Float)
  535. Self.x = x
  536. End Method
  537. Rem
  538. bbdoc: Sets the y part.
  539. End Rem
  540. Method SetY(y:Float)
  541. Self.y = y
  542. End Method
  543. Rem
  544. bbdoc: Returns the length of this vector.
  545. End Rem
  546. Method Length:Float()
  547. Return bmx_b2vec2_length(Self)
  548. End Method
  549. Rem
  550. bbdoc: Convert this vector into a unit vector.
  551. returns: The length.
  552. End Rem
  553. Method Normalize:Float()
  554. Return bmx_b2vec2_normalize(Self)
  555. End Method
  556. Rem
  557. bbdoc: Get the length squared.
  558. about: For performance, use this instead of b2Vec2::Length (if possible).
  559. End Rem
  560. Method LengthSquared:Float()
  561. Return bmx_b2vec2_lengthsquared(Self)
  562. End Method
  563. Function _newVecArray:b2Vec2[](count:Int) { nomangle }
  564. Return New b2Vec2[count]
  565. End Function
  566. Rem
  567. bbdoc: A zero vector (0,0)
  568. End Rem
  569. Global ZERO:b2Vec2 = New b2Vec2
  570. End Struct
  571. Rem
  572. bbdoc: Convenience function for creating a b2Vec2 object.
  573. End Rem
  574. Function Vec2:b2Vec2(x:Float, y:Float)
  575. Return New b2Vec2(x, y)
  576. End Function
  577. Rem
  578. bbdoc: Joints and shapes are destroyed when their associated body is destroyed.
  579. about: Implement this listener so that you may nullify references to these joints and shapes.
  580. End Rem
  581. Type b2DestructionListener
  582. Field b2ObjectPtr:Byte Ptr
  583. Method New()
  584. b2ObjectPtr = bmx_b2destructionlistener_new(Self)
  585. End Method
  586. Rem
  587. bbdoc: Called when any joint is about to be destroyed due to the destruction of one of its attached bodies.
  588. End Rem
  589. Method SayGoodbyeJoint(joint:b2Joint)
  590. End Method
  591. Function _SayGoodbyeJoint(listener:b2DestructionListener, joint:Byte Ptr) { nomangle }
  592. listener.SayGoodbyeJoint(b2Joint._create(joint))
  593. End Function
  594. Rem
  595. bbdoc: Called when any shape is about to be destroyed due to the destruction of its parent body.
  596. End Rem
  597. Method SayGoodbyeShape(shape:b2Shape)
  598. End Method
  599. Function _SayGoodbyeShape(listener:b2DestructionListener, shape:Byte Ptr) { nomangle }
  600. listener.SayGoodbyeShape(b2Shape._create(shape))
  601. End Function
  602. Method Delete()
  603. If b2ObjectPtr Then
  604. bmx_b2destructionlistener_delete(b2ObjectPtr)
  605. b2ObjectPtr = Null
  606. End If
  607. End Method
  608. End Type
  609. Rem
  610. bbdoc: Use this type for when a body's shape passes outside of the world boundary.
  611. about: Override Violation().
  612. End Rem
  613. Type b2BoundaryListener
  614. Field b2ObjectPtr:Byte Ptr
  615. Method New()
  616. b2ObjectPtr = bmx_b2boundarylistener_new(Self)
  617. End Method
  618. Rem
  619. bbdoc: This is called for each body that leaves the world boundary.
  620. about: Warning: you can't modify the world inside this callback.
  621. End Rem
  622. Method Violation(body:b2Body)
  623. End Method
  624. Function _Violation(listener:b2BoundaryListener, body:Byte Ptr) { nomangle }
  625. listener.Violation(b2Body._create(body))
  626. End Function
  627. Method Delete()
  628. If b2ObjectPtr Then
  629. bmx_b2boundarylistener_delete(b2ObjectPtr)
  630. b2ObjectPtr = Null
  631. End If
  632. End Method
  633. End Type
  634. Rem
  635. bbdoc: Implement this type to get collision results.
  636. about: You can use these results for things like sounds and game logic. You can also get contact results by traversing
  637. the contact lists after the time step. However, you might miss some contacts because continuous physics leads to
  638. sub-stepping. Additionally you may receive multiple callbacks for the same contact in a single time step.
  639. You should strive to make your callbacks efficient because there may be many callbacks per time step.
  640. End Rem
  641. Type b2ContactListener
  642. Field b2ObjectPtr:Byte Ptr
  643. Method New()
  644. b2ObjectPtr = bmx_b2contactlistener_new(Self)
  645. End Method
  646. Rem
  647. bbdoc: Called when a contact point is added.
  648. about: This includes the geometry and the forces.
  649. End Rem
  650. Method Add(point:b2ContactPoint)
  651. End Method
  652. Function _Add(listener:b2ContactListener, point:b2ContactPoint) { nomangle }
  653. listener.Add(point)
  654. End Function
  655. Rem
  656. bbdoc: Called when a contact point persists.
  657. about: This includes the geometry and the forces.
  658. End Rem
  659. Method Persist(point:b2ContactPoint)
  660. End Method
  661. Function _Persist(listener:b2ContactListener, point:b2ContactPoint) { nomangle }
  662. listener.Persist(point)
  663. End Function
  664. Rem
  665. bbdoc: Called when a contact point is removed.
  666. about: This includes the last computed geometry and forces.
  667. End Rem
  668. Method Remove(point:b2ContactPoint)
  669. End Method
  670. Function _Remove(listener:b2ContactListener, point:b2ContactPoint) { nomangle }
  671. listener.Remove(point)
  672. End Function
  673. Rem
  674. bbdoc: Called after a contact point is solved.
  675. End Rem
  676. Method Result(result:b2ContactResult)
  677. End Method
  678. Function _Result(listener:b2ContactListener, result:b2ContactResult) { nomangle }
  679. listener.Result(result)
  680. End Function
  681. Method Delete()
  682. If b2ObjectPtr Then
  683. bmx_b2contactlistener_delete(b2ObjectPtr)
  684. b2ObjectPtr = Null
  685. End If
  686. End Method
  687. End Type
  688. Rem
  689. bbdoc: Implement this type and override ShouldCollide() to provide collision filtering.
  690. about: In other words, you can implement this type if you want finer control over contact creation.
  691. End Rem
  692. Type b2ContactFilter
  693. Field b2ObjectPtr:Byte Ptr
  694. Method New()
  695. b2ObjectPtr = bmx_b2contactfilter_new(Self)
  696. End Method
  697. Rem
  698. bbdoc: Return True if contact calculations should be performed between these two shapes.
  699. about: Warning: for performance reasons this is only called when the AABBs begin to overlap.
  700. End Rem
  701. Method ShouldCollide:Int(shape1:b2Shape, shape2:b2Shape)
  702. Return True
  703. End Method
  704. Function _ShouldCollide:Int(filter:b2ContactFilter, shape1:Byte Ptr, shape2:Byte Ptr) { nomangle }
  705. Return filter.ShouldCollide(b2Shape._create(shape1), b2Shape._create(shape2))
  706. End Function
  707. Method Delete()
  708. If b2ObjectPtr Then
  709. bmx_b2contactfilter_delete(b2ObjectPtr)
  710. b2ObjectPtr = Null
  711. End If
  712. End Method
  713. End Type
  714. Rem
  715. bbdoc: This type manages contact between two shapes.
  716. about: A contact exists for each overlapping AABB in the broad-phase (except if filtered). Therefore a contact
  717. object may exist that has no contact points.
  718. End Rem
  719. Type b2Contact
  720. Field b2ObjectPtr:Byte Ptr
  721. Function _create:b2Contact(b2ObjectPtr:Byte Ptr)
  722. If b2ObjectPtr Then
  723. Local contact:b2Contact = New b2Contact
  724. contact.b2ObjectPtr = b2ObjectPtr
  725. Return contact
  726. End If
  727. End Function
  728. Rem
  729. bbdoc: Get the first shape in this contact.
  730. End Rem
  731. Method GetShape1:b2Shape()
  732. Return b2Shape._create(bmx_b2contact_getshape1(b2ObjectPtr))
  733. End Method
  734. Rem
  735. bbdoc: Get the second shape in this contact.
  736. End Rem
  737. Method GetShape2:b2Shape()
  738. Return b2Shape._create(bmx_b2contact_getshape2(b2ObjectPtr))
  739. End Method
  740. Rem
  741. bbdoc: Get the next contact in the world's contact list.
  742. End Rem
  743. Method GetNext:b2Contact()
  744. Return b2Contact._create(bmx_b2contact_getnext(b2ObjectPtr))
  745. End Method
  746. Rem
  747. bbdoc: Is this contact solid?
  748. returns: True if this contact should generate a response.
  749. End Rem
  750. Method IsSolid:Int()
  751. Return bmx_b2contact_issolid(b2ObjectPtr)
  752. End Method
  753. Rem
  754. bbdoc: Get the number of manifolds.
  755. about: This is 0 or 1 between convex shapes.
  756. This may be greater than 1 for convex-vs-concave shapes. Each
  757. manifold holds up to two contact points with a shared contact normal.
  758. End Rem
  759. Method GetManifoldCount:Int()
  760. Return bmx_b2contact_getmanifoldcount(b2ObjectPtr)
  761. End Method
  762. End Type
  763. Rem
  764. bbdoc: This type is used to report contact points.
  765. End Rem
  766. Struct b2ContactPoint
  767. Field shape1:Byte Ptr
  768. Field shape2:Byte Ptr
  769. Field position:b2Vec2
  770. Field velocity:b2Vec2
  771. Field normal:b2Vec2
  772. Field separation:Float
  773. Field friction:Float
  774. Field restitution:Float
  775. Field id:UInt
  776. Rem
  777. bbdoc: Returns the first shape.
  778. End Rem
  779. Method GetShape1:b2Shape()
  780. Return b2Shape._create(shape1)
  781. End Method
  782. Rem
  783. bbdoc: Returns the second shape.
  784. End Rem
  785. Method GetShape2:b2Shape()
  786. Return b2Shape._create(shape2)
  787. End Method
  788. Rem
  789. bbdoc: Returns position in world coordinates.
  790. End Rem
  791. Method GetPosition:b2Vec2()
  792. Return position
  793. End Method
  794. Rem
  795. bbdoc: Returns the velocity of point on body2 relative to point on body1 (pre-solver).
  796. End Rem
  797. Method GetVelocity:b2Vec2()
  798. Return velocity
  799. End Method
  800. Rem
  801. bbdoc: Points from shape1 to shape2.
  802. End Rem
  803. Method GetNormal:b2Vec2()
  804. Return normal
  805. End Method
  806. Rem
  807. bbdoc: The separation is negative when shapes are touching
  808. End Rem
  809. Method GetSeparation:Float()
  810. Return separation
  811. End Method
  812. Rem
  813. bbdoc: Returns the combined friction coefficient.
  814. End Rem
  815. Method GetFriction:Float()
  816. Return friction
  817. End Method
  818. Rem
  819. bbdoc: Returns the combined restitution coefficient.
  820. End Rem
  821. Method GetRestitution:Float()
  822. Return restitution
  823. End Method
  824. End Struct
  825. Rem
  826. bbdoc: This type is used to report contact point results.
  827. End Rem
  828. Struct b2ContactResult
  829. Field shape1:Byte Ptr
  830. Field shape2:Byte Ptr
  831. Field position:b2Vec2
  832. Field normal:b2Vec2
  833. Field normalImpulse:Float
  834. Field tangentImpulse:Float
  835. Field id:UInt
  836. Rem
  837. bbdoc: Returns the first shape.
  838. End Rem
  839. Method GetShape1:b2Shape()
  840. Return b2Shape._create(shape1)
  841. End Method
  842. Rem
  843. bbdoc: Returns the second shape.
  844. End Rem
  845. Method GetShape2:b2Shape()
  846. Return b2Shape._create(shape2)
  847. End Method
  848. Rem
  849. bbdoc: Returns position in world coordinates.
  850. End Rem
  851. Method GetPosition:b2Vec2()
  852. Return position
  853. End Method
  854. Rem
  855. bbdoc: Points from shape1 to shape2.
  856. End Rem
  857. Method GetNormal:b2Vec2()
  858. Return normal
  859. End Method
  860. Rem
  861. bbdoc: Returns the normal impulse applied to body2.
  862. End Rem
  863. Method GetNormalImpulse:Float()
  864. Return normalImpulse
  865. End Method
  866. Rem
  867. bbdoc: Returns the tangent impulse applied to body2.
  868. End Rem
  869. Method GetTangentImpulse:Float()
  870. Return tangentImpulse
  871. End Method
  872. End Struct
  873. Rem
  874. bbdoc: The base joint type.
  875. about: Joints are used to constraint two bodies together in various fashions.
  876. Some joints also feature limits and motors.
  877. End Rem
  878. Type b2Joint
  879. Field b2ObjectPtr:Byte Ptr
  880. Field userData:Object
  881. Function _create:b2Joint(b2ObjectPtr:Byte Ptr)
  882. If b2ObjectPtr Then
  883. Local joint:b2Joint = b2Joint(bmx_b2joint_getmaxjoint(b2ObjectPtr))
  884. If Not joint Then
  885. joint = New b2Joint
  886. joint.b2ObjectPtr = b2ObjectPtr
  887. Else
  888. If Not joint.b2ObjectPtr Then
  889. joint.b2ObjectPtr = b2ObjectPtr
  890. EndIf
  891. End If
  892. Return joint
  893. End If
  894. End Function
  895. Rem
  896. bbdoc: Get the first body attached to this joint.
  897. end rem
  898. Method GetBody1:b2Body()
  899. Return b2Body._create(bmx_b2joint_getbody1(b2ObjectPtr))
  900. End Method
  901. Rem
  902. bbdoc: Get the second body attached to this joint.
  903. end rem
  904. Method GetBody2:b2Body()
  905. Return b2Body._create(bmx_b2joint_getbody2(b2ObjectPtr))
  906. End Method
  907. Rem
  908. bbdoc: Get the next joint the world joint list.
  909. end rem
  910. Method GetNext:b2Joint()
  911. Return b2Joint._create(bmx_b2joint_getnext(b2ObjectPtr))
  912. End Method
  913. Rem
  914. bbdoc: Get the user data pointer that was provided in the joint definition.
  915. End Rem
  916. Method GetUserData:Object()
  917. Return userData
  918. End Method
  919. End Type
  920. Rem
  921. bbdoc: Bodies are the backbone for shapes.
  922. about: Bodies carry shapes and move them around in the world. Bodies are always rigid bodies in Box2D. That
  923. means that two shapes attached to the same rigid body never move relative to each other.
  924. <p>
  925. Bodies have position and velocity. You can apply forces, torques, and impulses to bodies. Bodies can be
  926. static or dynamic. Static bodies never move and don't collide with other static bodies.
  927. </p>
  928. End Rem
  929. Type b2Body
  930. Field b2ObjectPtr:Byte Ptr
  931. Field userData:Object
  932. Function _create:b2Body(b2ObjectPtr:Byte Ptr)
  933. If b2ObjectPtr Then
  934. Local body:b2Body = b2Body(bmx_b2body_getmaxbody(b2ObjectPtr))
  935. If Not body Then
  936. body = New b2Body
  937. body.b2ObjectPtr = b2ObjectPtr
  938. bmx_b2body_setmaxbody(b2ObjectPtr, body)
  939. End If
  940. Return body
  941. End If
  942. End Function
  943. Rem
  944. bbdoc: Creates a shape and attach it to this body.
  945. about: Warning: This method is locked during callbacks.
  946. <p>Parameters:
  947. <ul>
  948. <li><b>def </b> : the shape definition.</li>
  949. </ul>
  950. </p>
  951. End Rem
  952. Method CreateShape:b2Shape(def:b2ShapeDef)
  953. Local shape:b2Shape
  954. shape = b2Shape._create(bmx_b2body_createshape(b2ObjectPtr, def.b2ObjectPtr))
  955. shape.userData = def.userData ' copy the userData
  956. Return shape
  957. End Method
  958. Function _createShape:b2Shape(shapeType:Int) { nomangle }
  959. Local shape:b2Shape
  960. Select shapeType
  961. Case e_unknownShape
  962. shape = New b2Shape
  963. Case e_circleShape
  964. shape = New b2CircleShape
  965. Case e_polygonShape
  966. shape = New b2PolygonShape
  967. Case e_edgeShape
  968. shape = New b2EdgeShape
  969. Default
  970. DebugLog "Warning, shape type '" + shapeType + "' is not defined in module."
  971. shape = New b2Shape
  972. End Select
  973. Return shape
  974. End Function
  975. Rem
  976. bbdoc: Destroy a shape.
  977. about: This removes the shape from the broad-phase and therefore destroys any contacts associated with this shape.
  978. All shapes attached to a body are implicitly destroyed when the body is destroyed.
  979. <p>
  980. Warning: This method is locked during callbacks.
  981. </p>
  982. End Rem
  983. Method DestroyShape(shape:b2Shape)
  984. bmx_b2body_destroyshape(b2ObjectPtr, shape.b2ObjectPtr)
  985. End Method
  986. Rem
  987. bbdoc: Compute the mass properties from the attached shapes.
  988. about: You typically call this after adding all the shapes. If you add or remove shapes later, you may
  989. want to call this again. Note that this changes the center of mass position.
  990. End Rem
  991. Method SetMassFromShapes()
  992. bmx_b2body_setmassfromshapes(b2ObjectPtr)
  993. End Method
  994. Rem
  995. bbdoc: Get the world body origin position.
  996. End Rem
  997. Method GetPosition:b2Vec2()
  998. Return bmx_b2body_getposition(b2ObjectPtr)
  999. End Method
  1000. Rem
  1001. bbdoc: Get the angle in degrees.
  1002. returns: The current world rotation angle in degrees.
  1003. End Rem
  1004. Method GetAngle:Float()
  1005. Return bmx_b2body_getangle(b2ObjectPtr)
  1006. End Method
  1007. Rem
  1008. bbdoc: Get the world position of the center of mass.
  1009. End Rem
  1010. Method GetWorldCenter:b2Vec2()
  1011. Return bmx_b2body_getworldcenter(b2ObjectPtr)
  1012. End Method
  1013. Rem
  1014. bbdoc:Get the Local position of the center of mass.
  1015. End Rem
  1016. Method GetLocalCenter:b2Vec2()
  1017. Return bmx_b2body_getlocalcenter(b2ObjectPtr)
  1018. End Method
  1019. Rem
  1020. bbdoc: Set the linear velocity of the center of mass.
  1021. about: Parameters:
  1022. <ul>
  1023. <li><b>v </b> : the New linear velocity of the center of mass.</li>
  1024. </ul>
  1025. End Rem
  1026. Method SetLinearVelocity(v:b2Vec2)
  1027. bmx_b2body_setlinearvelocity(b2ObjectPtr, v)
  1028. End Method
  1029. Rem
  1030. bbdoc: Get the linear velocity of the center of mass.
  1031. returns: The linear velocity of the center of mass.
  1032. End Rem
  1033. Method GetLinearVelocity:b2Vec2()
  1034. Return bmx_b2body_getlinearvelocity(b2ObjectPtr)
  1035. End Method
  1036. Rem
  1037. bbdoc: Set the angular velocity.
  1038. about: Parameters:
  1039. <ul>
  1040. <li><b>omega </b> : the New angular velocity in degrees/Second.</li>
  1041. </ul>
  1042. End Rem
  1043. Method SetAngularVelocity(omega:Float)
  1044. bmx_b2body_setangularvelocity(b2ObjectPtr, omega)
  1045. End Method
  1046. Rem
  1047. bbdoc: Get the angular velocity.
  1048. returns: The angular velocity in degrees/Second.
  1049. End Rem
  1050. Method GetAngularVelocity:Float()
  1051. Return bmx_b2body_getangularvelocity(b2ObjectPtr)
  1052. End Method
  1053. Rem
  1054. bbdoc: Apply a force at a world point.
  1055. about: If the force is not applied at the center of mass, it will generate a torque and affect the angular velocity.
  1056. This wakes up the body.
  1057. <p>Parameters:
  1058. <ul>
  1059. <li><b>force </b> : the world force vector, usually in Newtons (N).</li>
  1060. <li><b>point </b> : the world position of the point of application.</li>
  1061. </ul>
  1062. </p>
  1063. End Rem
  1064. Method ApplyForce(force:b2Vec2, point:b2Vec2)
  1065. bmx_b2body_applyforce(b2ObjectPtr, force, point)
  1066. End Method
  1067. Rem
  1068. bbdoc: Apply a torque.
  1069. about: This affects the angular velocity without affecting the linear velocity of the center of mass.
  1070. This wakes up the body.
  1071. <p>Parameters:
  1072. <ul>
  1073. <li><b> torque </b> : about the z-axis (out of the screen), usually in N-m.</li>
  1074. </ul>
  1075. </p>
  1076. End Rem
  1077. Method ApplyTorque(torque:Float)
  1078. bmx_b2body_applytorque(b2ObjectPtr, torque)
  1079. End Method
  1080. Rem
  1081. bbdoc: Apply an impulse at a point.
  1082. about: This immediately modifies the velocity.
  1083. It also modifies the angular velocity If the point of application is not at the center of mass. This wakes up the body.
  1084. <p>Parameters:
  1085. <ul>
  1086. <li><b> impulse </b> : the world impulse vector, usually in N-seconds Or kg-m/s.</li>
  1087. <li><b> point </b> : the world position of the point of application.</li>
  1088. </ul>
  1089. </p>
  1090. End Rem
  1091. Method ApplyImpulse(impulse:b2Vec2, point:b2Vec2)
  1092. bmx_b2body_applyimpulse(b2ObjectPtr, impulse, point)
  1093. End Method
  1094. Rem
  1095. bbdoc: Get the total mass of the body.
  1096. returns: The mass, usually in kilograms (kg).
  1097. End Rem
  1098. Method GetMass:Float()
  1099. Return bmx_b2body_getmass(b2ObjectPtr)
  1100. End Method
  1101. Rem
  1102. bbdoc: Get the central rotational inertia of the body.
  1103. returns: The rotational inertia, usually in kg-m^2.
  1104. End Rem
  1105. Method GetInertia:Float()
  1106. Return bmx_b2body_getinertia(b2ObjectPtr)
  1107. End Method
  1108. Rem
  1109. bbdoc: Get the world coordinates of a point given the local coordinates.
  1110. returns: The same point expressed in world coordinates.
  1111. about: Parameters:
  1112. <ul>
  1113. <li><b>localPoint </b> : a point on the body measured relative the the body's origin.</li>
  1114. </ul>
  1115. End Rem
  1116. Method GetWorldPoint:b2Vec2(localPoint:b2Vec2)
  1117. Return bmx_b2body_getworldpoint(b2ObjectPtr, localPoint)
  1118. End Method
  1119. Rem
  1120. bbdoc: Get the world coordinates of a vector given the local coordinates.
  1121. returns: The same vector expressed in world coordinates.
  1122. about: Parameters:
  1123. <ul>
  1124. <li><b>localVector </b> : a vector fixed in the body.</li>
  1125. </ul>
  1126. End Rem
  1127. Method GetWorldVector:b2Vec2(localVector:b2Vec2)
  1128. Return bmx_b2body_getworldvector(b2ObjectPtr, localVector)
  1129. End Method
  1130. Rem
  1131. bbdoc: Gets a local point relative to the body's origin given a world point.
  1132. returns: The corresponding local point relative to the body's origin.
  1133. about: Parameters:
  1134. <ul>
  1135. <li><b>worldPoint </b> : a point in world coordinates.</li>
  1136. </ul>
  1137. End Rem
  1138. Method GetLocalPoint:b2Vec2(worldPoint:b2Vec2)
  1139. Return bmx_b2body_getlocalpoint(b2ObjectPtr, worldPoint)
  1140. End Method
  1141. Rem
  1142. bbdoc: Gets a local vector given a world vector.
  1143. returns: The corresponding local vector.
  1144. about: Parameters:
  1145. <ul>
  1146. <li><b>worldVector </b> : a vector in world coordinates.</li>
  1147. </ul>
  1148. End Rem
  1149. Method GetLocalVector:b2Vec2(worldVector:b2Vec2)
  1150. Return bmx_b2body_getlocalvector(b2ObjectPtr, worldVector)
  1151. End Method
  1152. Rem
  1153. bbdoc: Is this body treated like a bullet for continuous collision detection?
  1154. End Rem
  1155. Method IsBullet:Int()
  1156. Return bmx_b2body_isbullet(b2ObjectPtr)
  1157. End Method
  1158. Rem
  1159. bbdoc: Should this body be treated like a bullet for continuous collision detection?
  1160. End Rem
  1161. Method SetBullet(flag:Int)
  1162. bmx_b2body_setbullet(b2ObjectPtr, flag)
  1163. End Method
  1164. Rem
  1165. bbdoc: Is this body static (immovable)?
  1166. End Rem
  1167. Method IsStatic:Int()
  1168. Return bmx_b2body_isstatic(b2ObjectPtr)
  1169. End Method
  1170. Rem
  1171. bbdoc: Is this body dynamic (movable)?
  1172. End Rem
  1173. Method IsDynamic:Int()
  1174. Return bmx_b2body_isdynamic(b2ObjectPtr)
  1175. End Method
  1176. Rem
  1177. bbdoc: Is this body frozen?
  1178. End Rem
  1179. Method IsFrozen:Int()
  1180. Return bmx_b2body_isfrozen(b2ObjectPtr)
  1181. End Method
  1182. Rem
  1183. bbdoc: Is this body sleeping (not simulating).
  1184. End Rem
  1185. Method IsSleeping:Int()
  1186. Return bmx_b2body_issleeping(b2ObjectPtr)
  1187. End Method
  1188. Rem
  1189. bbdoc: You can disable sleeping on this body.
  1190. End Rem
  1191. Method AllowSleeping(flag:Int)
  1192. bmx_b2body_allowsleeping(b2ObjectPtr, flag)
  1193. End Method
  1194. Rem
  1195. bbdoc: Wake up this body so it will begin simulating.
  1196. End Rem
  1197. Method WakeUp()
  1198. bmx_b2body_wakeup(b2ObjectPtr)
  1199. End Method
  1200. Rem
  1201. bbdoc: Put this body to sleep so it will stop simulating.
  1202. about: This also sets the velocity to zero.
  1203. End Rem
  1204. Method PutToSleep()
  1205. bmx_b2body_puttosleep(b2ObjectPtr)
  1206. End Method
  1207. Rem
  1208. bbdoc: Get the list of all shapes attached to this body.
  1209. End Rem
  1210. Method GetShapeList:b2Shape()
  1211. Return b2Shape._create(bmx_b2body_getshapelist(b2ObjectPtr))
  1212. End Method
  1213. Rem
  1214. bbdoc: Get the list of all joints attached to this body.
  1215. End Rem
  1216. Method GetJointList:b2JointEdge()
  1217. Return New b2JointEdge(bmx_b2body_getjointlist(b2ObjectPtr))
  1218. End Method
  1219. Rem
  1220. bbdoc: Get the next body in the world's body list.
  1221. End Rem
  1222. Method GetNext:b2Body()
  1223. Return _create(bmx_b2body_getnext(b2ObjectPtr))
  1224. End Method
  1225. Rem
  1226. bbdoc: Get the user data pointer that was provided in the body definition.
  1227. End Rem
  1228. Method GetUserData:Object()
  1229. Return userData
  1230. End Method
  1231. Rem
  1232. bbdoc: Get the body transform for the body's origin.
  1233. End Rem
  1234. Method GetXForm:b2XForm()
  1235. Return bmx_b2body_getxform(b2ObjectPtr)
  1236. End Method
  1237. Rem
  1238. bbdoc: Set the position of the body's origin and rotation (degrees).
  1239. about: This breaks any contacts and wakes the other bodies.
  1240. End Rem
  1241. Method SetXForm:Int(position:b2Vec2, angle:Float)
  1242. Return bmx_b2body_setxform(b2ObjectPtr, position, angle)
  1243. End Method
  1244. Rem
  1245. bbdoc: Get the parent world of this body.
  1246. End Rem
  1247. Method GetWorld:b2World()
  1248. Return b2World._create(bmx_b2body_getworld(b2ObjectPtr))
  1249. End Method
  1250. Rem
  1251. bbdoc: Set the mass properties.
  1252. about: Note that this changes the center of mass position.
  1253. <p>
  1254. If you are not sure how to compute mass properties, use SetMassFromShapes.
  1255. </p>
  1256. <p>
  1257. The inertia tensor is assumed to be relative to the center of mass.
  1258. </p>
  1259. End Rem
  1260. Method SetMass(massData:b2MassData)
  1261. bmx_b2body_setmass(b2ObjectPtr, massData.b2ObjectPtr)
  1262. End Method
  1263. End Type
  1264. Rem
  1265. bbdoc: A shape is used for collision detection.
  1266. about: Shapes are created in b2World. You can use shape for collision detection before they are attached to the world.
  1267. <p>
  1268. Warning: You cannot reuse shapes.
  1269. </p>
  1270. End Rem
  1271. Type b2Shape
  1272. Field b2ObjectPtr:Byte Ptr
  1273. Field userData:Object
  1274. Function _create:b2Shape(b2ObjectPtr:Byte Ptr)
  1275. If b2ObjectPtr Then
  1276. Local shape:b2Shape = b2Shape(bmx_b2shape_getmaxshape(b2ObjectPtr))
  1277. If Not shape Then
  1278. shape = New b2Shape
  1279. shape.b2ObjectPtr = b2ObjectPtr
  1280. bmx_b2shape_setmaxshape(b2ObjectPtr, shape)
  1281. Else
  1282. If Not shape.b2ObjectPtr Then
  1283. shape.b2ObjectPtr = b2ObjectPtr
  1284. EndIf
  1285. End If
  1286. Return shape
  1287. End If
  1288. End Function
  1289. Rem
  1290. bbdoc: Is this shape a sensor (non-solid)?
  1291. End Rem
  1292. Method IsSensor:Int()
  1293. Return bmx_b2shape_issensor(b2ObjectPtr)
  1294. End Method
  1295. Rem
  1296. bbdoc: Get the parent body of this shape.
  1297. End Rem
  1298. Method GetBody:b2Body()
  1299. Return b2Body._create(bmx_b2shape_getbody(b2ObjectPtr))
  1300. End Method
  1301. Rem
  1302. bbdoc: Get the user data that was assigned in the shape definition.
  1303. End Rem
  1304. Method GetUserData:Object()
  1305. Return userData
  1306. End Method
  1307. Rem
  1308. bbdoc: Sets the user data.
  1309. End Rem
  1310. Method SetUserData(data:Object)
  1311. userData = data
  1312. End Method
  1313. Rem
  1314. bbdoc: Get the next shape in the parent body's shape list.
  1315. End Rem
  1316. Method GetNext:b2Shape()
  1317. Return _create(bmx_b2shape_getnext(b2ObjectPtr))
  1318. End Method
  1319. Rem
  1320. bbdoc: Test a point for containment in this shape.
  1321. about: This only works for convex shapes.
  1322. End Rem
  1323. Method TestPoint:Int(xf:b2XForm, p:b2Vec2)
  1324. Return bmx_b2shape_testpoint(b2ObjectPtr, xf, p)
  1325. End Method
  1326. Rem
  1327. bbdoc: Get the contact filtering data.
  1328. End Rem
  1329. Method GetFilterData:b2FilterData()
  1330. Return bmx_b2shape_getfilterdata(b2ObjectPtr)
  1331. End Method
  1332. Rem
  1333. bbdoc: Set the contact filtering data.
  1334. about: You must call b2World::Refilter to correct existing contacts/non-contacts.
  1335. End Rem
  1336. Method SetFilterData(data:b2FilterData)
  1337. bmx_b2shape_setfilterdata(b2ObjectPtr, data)
  1338. End Method
  1339. Rem
  1340. bbdoc:
  1341. End Rem
  1342. Method TestSegment:Int(xf:b2XForm, lambda:Float Var, normal:b2Vec2 Var, segment:b2Segment, maxLambda:Float)
  1343. End Method
  1344. Rem
  1345. bbdoc: Get the maximum radius about the parent body's center of mass.
  1346. End Rem
  1347. Method GetSweepRadius:Float()
  1348. Return bmx_b2shape_getsweepradius(b2ObjectPtr)
  1349. End Method
  1350. Rem
  1351. bbdoc: Get the coefficient of friction.
  1352. End Rem
  1353. Method GetFriction:Float()
  1354. Return bmx_b2shape_getfriction(b2ObjectPtr)
  1355. End Method
  1356. Rem
  1357. bbdoc: Set the coefficient of friction.
  1358. End Rem
  1359. Method SetFriction(friction:Float)
  1360. bmx_b2shape_setfriction(b2ObjectPtr, friction)
  1361. End Method
  1362. Rem
  1363. bbdoc: Get the coefficient of restitution.
  1364. End Rem
  1365. Method GetRestitution:Float()
  1366. Return bmx_b2shape_getrestitution(b2ObjectPtr)
  1367. End Method
  1368. Rem
  1369. bbdoc: Set the coefficient of restitution.
  1370. End Rem
  1371. Method SetRestitution(restitution:Float)
  1372. bmx_b2shape_setrestitution(b2ObjectPtr, restitution)
  1373. End Method
  1374. Rem
  1375. bbdoc: Given a transform, compute the associated axis aligned bounding box for this shape.
  1376. End Rem
  1377. Method ComputeAABB(aabb:b2AABB, xf:b2XForm)
  1378. bmx_b2shape_computeaabb(b2ObjectPtr, aabb, xf)
  1379. End Method
  1380. Rem
  1381. bbdoc: Given two transforms, compute the associated swept axis aligned bounding box for this shape.
  1382. End Rem
  1383. Method ComputeSweptAABB(aabb:b2AABB, xf1:b2XForm, xf2:b2XForm)
  1384. bmx_b2shape_computesweptaabb(b2ObjectPtr, aabb, xf1, xf2)
  1385. End Method
  1386. Rem
  1387. bbdoc: Compute the mass properties of this shape using its dimensions and density.
  1388. returns: the mass data for this shape.
  1389. about: The inertia tensor is computed about the local origin, not the centroid.
  1390. End Rem
  1391. Method ComputeMass(data:b2MassData)
  1392. bmx_b2shape_computemass(b2ObjectPtr, data.b2ObjectPtr)
  1393. End Method
  1394. End Type
  1395. Rem
  1396. bbdoc: Implement and register this type with a b2World to provide debug drawing of physics entities in your game.
  1397. End Rem
  1398. Type b2DebugDraw
  1399. Field b2ObjectPtr:Byte Ptr
  1400. Const e_shapeBit:Int = $0001 ' draw shapes
  1401. Const e_jointBit:Int = $0002 ' draw joint connections
  1402. Const e_coreShapeBit:Int = $0004 ' draw core (TOI) shapes
  1403. Const e_aabbBit:Int = $0008 ' draw axis aligned bounding boxes
  1404. Const e_obbBit:Int = $0010 ' draw oriented bounding boxes
  1405. Const e_pairBit:Int = $0020 ' draw broad-phase pairs
  1406. Const e_centerOfMassBit:Int = $0040 ' draw center of mass frame
  1407. Const e_controllerBit:Int = $0080
  1408. Method New()
  1409. b2ObjectPtr = bmx_b2debugdraw_create(Self)
  1410. End Method
  1411. Rem
  1412. bbdoc: Set the drawing flags.
  1413. End Rem
  1414. Method SetFlags(flags:Int)
  1415. bmx_b2debugdraw_setflags(b2ObjectPtr, flags)
  1416. End Method
  1417. Rem
  1418. bbdoc: Get the drawing flags.
  1419. End Rem
  1420. Method GetFlags:Int()
  1421. Return bmx_b2debugdraw_getflags(b2ObjectPtr)
  1422. End Method
  1423. Rem
  1424. bbdoc: Append flags to the current flags.
  1425. End Rem
  1426. Method AppendFlags(flags:Int)
  1427. bmx_b2debugdraw_appendflags(b2ObjectPtr, flags)
  1428. End Method
  1429. Rem
  1430. bbdoc: Clear flags from the current flags.
  1431. End Rem
  1432. Method ClearFlags(flags:Int)
  1433. bmx_b2debugdraw_clearflags(b2ObjectPtr, flags)
  1434. End Method
  1435. Rem
  1436. bbdoc: Draw a closed polygon provided in CCW order.
  1437. End Rem
  1438. Method DrawPolygon(vertices:b2Vec2[], color:b2Color) Abstract
  1439. Function _DrawPolygon(obj:b2DebugDraw , vertices:b2Vec2[], r:Int, g:Int, b:Int) { nomangle }
  1440. obj.DrawPolygon(vertices, b2Color.Set(r, g, b))
  1441. End Function
  1442. Rem
  1443. bbdoc: Draw a solid closed polygon provided in CCW order
  1444. End Rem
  1445. Method DrawSolidPolygon(vertices:b2Vec2[], color:b2Color) Abstract
  1446. Function _DrawSolidPolygon(obj:b2DebugDraw , vertices:b2Vec2[], r:Int, g:Int, b:Int) { nomangle }
  1447. obj.DrawSolidPolygon(vertices, b2Color.Set(r, g, b))
  1448. End Function
  1449. Rem
  1450. bbdoc: Draw a circle.
  1451. End Rem
  1452. Method DrawCircle(center:b2Vec2, radius:Float, color:b2Color) Abstract
  1453. Rem
  1454. bbdoc: Draw a solid circle.
  1455. End Rem
  1456. Method DrawSolidCircle(center:b2Vec2, radius:Float, axis:b2Vec2, color:b2Color) Abstract
  1457. Function _DrawSolidCircle(obj:b2DebugDraw, center:b2Vec2, radius:Float, axis:b2Vec2, r:Int, g:Int, b:Int) { nomangle }
  1458. obj.DrawSolidCircle(center, radius, axis, b2Color.Set(r, g, b))
  1459. End Function
  1460. Rem
  1461. bbdoc: Draw a line segment.
  1462. End Rem
  1463. Method DrawSegment(p1:b2Vec2, p2:b2Vec2, color:b2Color) Abstract
  1464. Function _DrawSegment(obj:b2DebugDraw, p1:b2Vec2, p2:b2Vec2, r:Int, g:Int, b:Int) { nomangle }
  1465. obj.DrawSegment(p1, p2, b2Color.Set(r, g, b))
  1466. End Function
  1467. Rem
  1468. bbdoc: Draw a transform. Choose your own length scale.
  1469. /// @param xf a transform.
  1470. End Rem
  1471. Method DrawXForm(xf:b2XForm) Abstract
  1472. End Type
  1473. Rem
  1474. bbdoc: Color for debug drawing.
  1475. about: Each value has the range [0,1].
  1476. End Rem
  1477. Type b2Color
  1478. Field red:Int, green:Int, blue:Int
  1479. Function Set:b2Color(r:Int, g:Int, b:Int)
  1480. Local this:b2Color = New b2Color
  1481. this.red = r
  1482. this.green = g
  1483. this.blue = b
  1484. Return this
  1485. End Function
  1486. End Type
  1487. Rem
  1488. bbdoc: A body definition holds all the data needed to construct a rigid body.
  1489. about: You can safely re-use body definitions.
  1490. End Rem
  1491. Type b2BodyDef
  1492. Field b2ObjectPtr:Byte Ptr
  1493. Field userData:Object
  1494. Method New()
  1495. b2ObjectPtr = bmx_b2bodydef_create()
  1496. End Method
  1497. Rem
  1498. bbdoc: You can use this to initialize the mass properties of the body.
  1499. about: If you prefer, you can set the mass properties after the shapes have been added using b2Body.SetMassFromShapes.
  1500. End Rem
  1501. Method SetMassData(data:b2MassData)
  1502. bmx_b2bodydef_setmassdata(b2ObjectPtr, data.b2ObjectPtr)
  1503. End Method
  1504. Rem
  1505. bbdoc: Returns mass property data.
  1506. End Rem
  1507. Method GetMassData:b2MassData()
  1508. Return b2MassData._create(bmx_b2bodydef_getmassdata(b2ObjectPtr))
  1509. End Method
  1510. Rem
  1511. bbdoc: Use this to store application specific body data.
  1512. End Rem
  1513. Method SetUserData(data:Object)
  1514. userData = data
  1515. End Method
  1516. Rem
  1517. bbdoc: Returns the application specific body data, if any.
  1518. End Rem
  1519. Method GetUserData:Object()
  1520. Return userData
  1521. End Method
  1522. Rem
  1523. bbdoc: The world position of the body.
  1524. about: Avoid creating bodies at the origin since this can lead to many overlapping shapes.
  1525. End Rem
  1526. Method SetPosition(position:b2Vec2)
  1527. bmx_b2bodydef_setposition(b2ObjectPtr, position)
  1528. End Method
  1529. Rem
  1530. bbdoc: The world position of the body.
  1531. about: Avoid creating bodies at the origin since this can lead to many overlapping shapes.
  1532. End Rem
  1533. Method SetPositionXY(x:Float, y:Float)
  1534. bmx_b2bodydef_setpositionxy(b2ObjectPtr, x, y)
  1535. End Method
  1536. Rem
  1537. bbdoc: Returns the world position of the body.
  1538. End Rem
  1539. Method GetPosition:b2Vec2()
  1540. Return bmx_b2bodydef_getposition(b2ObjectPtr)
  1541. End Method
  1542. Rem
  1543. bbdoc: The world angle of the body in degrees.
  1544. End Rem
  1545. Method SetAngle(angle:Float)
  1546. bmx_b2bodydef_setangle(b2ObjectPtr, angle)
  1547. End Method
  1548. Rem
  1549. bbdoc: Returns the world angle of the body in degrees
  1550. End Rem
  1551. Method GetAngle:Float()
  1552. Return bmx_b2bodydef_getangle(b2ObjectPtr)
  1553. End Method
  1554. Rem
  1555. bbdoc: Linear damping is used to reduce the linear velocity.
  1556. about: The damping parameter can be larger than 1.0 but the damping effect becomes sensitive To the
  1557. time Step when the damping parameter is large.
  1558. End Rem
  1559. Method SetLinearDamping(damping:Float)
  1560. bmx_b2bodydef_setlineardamping(b2ObjectPtr, damping)
  1561. End Method
  1562. Rem
  1563. bbdoc: Returns the linear damping.
  1564. End Rem
  1565. Method GetLinearDamping:Float()
  1566. Return bmx_b2bodydef_getlineardamping(b2ObjectPtr)
  1567. End Method
  1568. Rem
  1569. bbdoc: Angular damping is used to reduce the angular velocity.
  1570. about: The damping parameter can be larger than 1.0 but the damping effect becomes sensitive to the
  1571. time Step when the damping parameter is large.
  1572. End Rem
  1573. Method SetAngularDamping(damping:Float)
  1574. bmx_b2bodydef_setangulardamping(b2ObjectPtr, damping)
  1575. End Method
  1576. Rem
  1577. bbdoc: Returns the angular damping.
  1578. End Rem
  1579. Method GetAngularDamping:Float()
  1580. Return bmx_b2bodydef_getangulardamping(b2ObjectPtr)
  1581. End Method
  1582. Rem
  1583. bbdoc: Set this flag to False if this body should never fall asleep.
  1584. about: Note that this increases CPU usage.
  1585. End Rem
  1586. Method SetAllowSleep(allow:Int)
  1587. bmx_b2bodydef_setallowsleep(b2ObjectPtr, allow)
  1588. End Method
  1589. Rem
  1590. bbdoc: Returns true if the body is allowed to sleep.
  1591. End Rem
  1592. Method GetAllowSleep:Int()
  1593. Return bmx_b2bodydef_getallowsleep(b2ObjectPtr)
  1594. End Method
  1595. Rem
  1596. bbdoc: Is this body initially sleeping?
  1597. End Rem
  1598. Method isSleeping:Int()
  1599. Return bmx_b2bodydef_issleeping(b2ObjectPtr)
  1600. End Method
  1601. Rem
  1602. bbdoc: Enables/Disables the sleeping state of the body.
  1603. End Rem
  1604. Method SetIsSleeping(sleeping:Int)
  1605. bmx_b2bodydef_setissleeping(b2ObjectPtr, sleeping)
  1606. End Method
  1607. Rem
  1608. bbdoc: Should this body be prevented from rotating? Useful For characters.
  1609. End Rem
  1610. Method SetFixedRotation(fixed:Int)
  1611. bmx_b2bodydef_setfixedrotation(b2ObjectPtr, fixed)
  1612. End Method
  1613. Rem
  1614. bbdoc: Returns True if rotation is fixed.
  1615. End Rem
  1616. Method GetFixedRotation:Int()
  1617. Return bmx_b2bodydef_getfixedrotation(b2ObjectPtr)
  1618. End Method
  1619. Rem
  1620. bbdoc: Is this a fast moving body that should be prevented from tunneling through other moving bodies?
  1621. about: Note that all bodies are prevented from tunneling through static bodies.
  1622. <p>
  1623. Warning: You should use this flag sparingly since it increases processing time.
  1624. </p>
  1625. End Rem
  1626. Method SetIsBullet(bullet:Int)
  1627. bmx_b2bodydef_setisbullet(b2ObjectPtr, bullet)
  1628. End Method
  1629. Rem
  1630. bbdoc: Returns whether this is a bullet type body.
  1631. End Rem
  1632. Method GetIsBullet:Int()
  1633. Return bmx_b2bodydef_isbullet(b2ObjectPtr)
  1634. End Method
  1635. Method Delete()
  1636. If b2ObjectPtr Then
  1637. bmx_b2bodydef_delete(b2ObjectPtr)
  1638. b2ObjectPtr = Null
  1639. End If
  1640. End Method
  1641. End Type
  1642. Rem
  1643. bbdoc: Joint definitions are used to construct joints.
  1644. End Rem
  1645. Type b2JointDef
  1646. Field b2ObjectPtr:Byte Ptr
  1647. Field userData:Object
  1648. Rem
  1649. bbdoc: The First attached body.
  1650. End Rem
  1651. Method SetBody1(body:b2Body)
  1652. bmx_b2jointdef_setbody1(b2ObjectPtr, body.b2ObjectPtr)
  1653. End Method
  1654. Rem
  1655. bbdoc: Returns the first attached body.
  1656. End Rem
  1657. Method GetBody1:b2Body()
  1658. Return b2Body._create(bmx_b2jointdef_getbody1(b2ObjectPtr))
  1659. End Method
  1660. Rem
  1661. bbdoc: The Second attached body.
  1662. End Rem
  1663. Method SetBody2(body:b2Body)
  1664. bmx_b2jointdef_setbody2(b2ObjectPtr, body.b2ObjectPtr)
  1665. End Method
  1666. Rem
  1667. bbdoc: Returns the second attached body.
  1668. End Rem
  1669. Method GetBody2:b2Body()
  1670. Return b2Body._create(bmx_b2jointdef_getbody2(b2ObjectPtr))
  1671. End Method
  1672. Rem
  1673. bbdoc: Set this flag to True if the attached bodies should collide.
  1674. End Rem
  1675. Method SetCollideConnected(collideConnected:Int)
  1676. bmx_b2jointdef_setcollideconnected(b2ObjectPtr, collideConnected)
  1677. End Method
  1678. Rem
  1679. bbdoc: Returns True if the attached bodies should collide.
  1680. End Rem
  1681. Method GetCollideConnected:Int()
  1682. Return bmx_b2jointdef_getcollideconnected(b2ObjectPtr)
  1683. End Method
  1684. End Type
  1685. Rem
  1686. bbdoc: A joint edge is used to connect bodies and joints together in a joint graph where each body is a node and each joint is an edge.
  1687. about: A joint edge belongs to a doubly linked list maintained in each attached body. Each joint has two
  1688. joint nodes, one for each attached body.
  1689. End Rem
  1690. Struct b2JointEdge
  1691. Field b2ObjectPtr:Byte Ptr
  1692. Method New(b2ObjectPtr:Byte Ptr)
  1693. Self.b2ObjectPtr = b2ObjectPtr
  1694. End Method
  1695. Rem
  1696. bbdoc: Provides quick access to the other body attached.
  1697. End Rem
  1698. Method GetOther:b2Body()
  1699. Return b2Body._create(bmx_b2jointedge_getother(b2ObjectPtr))
  1700. End Method
  1701. Rem
  1702. bbdoc: Returns the joint.
  1703. End Rem
  1704. Method GetJoint:b2Joint()
  1705. Return b2Joint._create(bmx_b2jointedge_getjoint(b2ObjectPtr))
  1706. End Method
  1707. Rem
  1708. bbdoc: Returns the previous joint edge in the body's joint list.
  1709. End Rem
  1710. Method GetPrev:b2JointEdge()
  1711. Return New b2JointEdge(bmx_b2jointedge_getprev(b2ObjectPtr))
  1712. End Method
  1713. Rem
  1714. bbdoc: Returns the next joint edge in the body's joint list.
  1715. End Rem
  1716. Method GetNext:b2JointEdge()
  1717. Return new b2JointEdge(bmx_b2jointedge_getnext(b2ObjectPtr))
  1718. End Method
  1719. End Struct
  1720. Rem
  1721. bbdoc: Holds the mass data computed for a shape.
  1722. End Rem
  1723. Type b2MassData
  1724. Field b2ObjectPtr:Byte Ptr
  1725. Field owner:Int
  1726. Function _create:b2MassData(b2ObjectPtr:Byte Ptr)
  1727. If b2ObjectPtr Then
  1728. Local this:b2MassData = New b2MassData
  1729. bmx_b2massdata_delete(this.b2ObjectPtr)
  1730. this.b2ObjectPtr = b2ObjectPtr
  1731. this.owner = False
  1732. Return this
  1733. End If
  1734. End Function
  1735. Method New()
  1736. b2ObjectPtr = bmx_b2massdata_new()
  1737. owner = True
  1738. End Method
  1739. Method Delete()
  1740. If b2ObjectPtr Then
  1741. If owner Then
  1742. bmx_b2massdata_delete(b2ObjectPtr)
  1743. End If
  1744. b2ObjectPtr = Null
  1745. End If
  1746. End Method
  1747. Rem
  1748. bbdoc: Sets the mass of the shape, usually in kilograms.
  1749. End Rem
  1750. Method SetMass(mass:Float)
  1751. bmx_b2massdata_setmass(b2ObjectPtr, mass)
  1752. End Method
  1753. Rem
  1754. bbdoc: Sets the position of the shape's centroid relative to the shape's origin.
  1755. End Rem
  1756. Method SetCenter(center:b2Vec2)
  1757. bmx_b2massdata_setcenter(b2ObjectPtr, center)
  1758. End Method
  1759. Rem
  1760. bbdoc: Sets the rotational inertia of the shape.
  1761. End Rem
  1762. Method SetRotationalInertia(i:Float)
  1763. bmx_b2massdata_seti(b2ObjectPtr, i)
  1764. End Method
  1765. End Type
  1766. Rem
  1767. bbdoc: A shape definition is used to construct a shape.
  1768. about: You can reuse shape definitions safely.
  1769. End Rem
  1770. Type b2ShapeDef
  1771. Field b2ObjectPtr:Byte Ptr
  1772. Field userData:Object
  1773. Rem
  1774. bbdoc: Sets the shape's friction coefficient, usually in the range [0,1].
  1775. End Rem
  1776. Method SetFriction(friction:Float)
  1777. bmx_b2shapedef_setfriction(b2ObjectPtr, friction)
  1778. End Method
  1779. Rem
  1780. bbdoc: Gets the shape's friction coefficient, usually in the range [0,1].
  1781. End Rem
  1782. Method GetFriction:Float()
  1783. Return bmx_b2shapedef_getfriction(b2ObjectPtr)
  1784. End Method
  1785. Rem
  1786. bbdoc: Sets the shape's restitution (elasticity) usually in the range [0,1].
  1787. End Rem
  1788. Method SetRestitution(restitution:Float)
  1789. bmx_b2shapedef_setrestitution(b2ObjectPtr, restitution)
  1790. End Method
  1791. Rem
  1792. bbdoc: Gets the shape's restitution (elasticity) usually in the range [0,1].
  1793. End Rem
  1794. Method GetRestitution:Float()
  1795. Return bmx_b2shapedef_getrestitution(b2ObjectPtr)
  1796. End Method
  1797. Rem
  1798. bbdoc: Sets the shape's density, usually in kg/m^2.
  1799. End Rem
  1800. Method SetDensity(density:Float)
  1801. bmx_b2shapedef_setdensity(b2ObjectPtr, density)
  1802. End Method
  1803. Rem
  1804. bbdoc: Gets the shape's density, usually in kg/m^2.
  1805. End Rem
  1806. Method GetDensity:Float()
  1807. Return bmx_b2shapedef_getdensity(b2ObjectPtr)
  1808. End Method
  1809. Rem
  1810. bbdoc: Sets the contact filtering data.
  1811. End Rem
  1812. Method SetFilter(filter:b2FilterData)
  1813. bmx_b2shapedef_setfilter(b2ObjectPtr, filter)
  1814. End Method
  1815. Rem
  1816. bbdoc: Sets the contact filtering group index.
  1817. End Rem
  1818. Method SetFilterGroupIndex(groupIndex:Int)
  1819. bmx_b2shapedef_setfilter_groupindex(b2ObjectPtr, groupIndex)
  1820. End Method
  1821. Rem
  1822. bbdoc: Sets the contact filtering category bits.
  1823. End Rem
  1824. Method SetFilterCategoryBits(categoryBits:Short)
  1825. bmx_b2shapedef_setfilter_categorybits(b2ObjectPtr, categoryBits)
  1826. End Method
  1827. Rem
  1828. bbdoc: Sets the contact filtering mask bits.
  1829. End Rem
  1830. Method SetFilterMaskBits(maskBits:Short)
  1831. bmx_b2shapedef_setfilter_maskbits(b2ObjectPtr, maskBits)
  1832. End Method
  1833. Rem
  1834. bbdoc: Returns the contact filtering data.
  1835. about: If you change the field values of the returned #b2FilterData, you will need to call #SetFilter() with the new data.
  1836. End Rem
  1837. Method GetFilter:b2FilterData()
  1838. Return bmx_b2shapedef_getfilter(b2ObjectPtr)
  1839. End Method
  1840. Rem
  1841. bbdoc: A sensor shape collects contact information but never generates a collision response.
  1842. End Rem
  1843. Method SetIsSensor(sensor:Int)
  1844. bmx_b2shapedef_setissensor(b2ObjectPtr, sensor)
  1845. End Method
  1846. Rem
  1847. bbdoc: Returns True if this shape is a sensor.
  1848. about: A sensor shape collects contact information but never generates a collision response.
  1849. End Rem
  1850. Method IsSensor:Int()
  1851. Return bmx_b2shapedef_issensor(b2ObjectPtr)
  1852. End Method
  1853. Rem
  1854. bbdoc: Sets the user data.
  1855. End Rem
  1856. Method SetUserData(data:Object)
  1857. userData = data
  1858. End Method
  1859. End Type
  1860. Rem
  1861. bbdoc: Convex polygon.
  1862. about: Vertices must be in CCW order.
  1863. End Rem
  1864. Type b2PolygonDef Extends b2ShapeDef
  1865. Field _vertices:b2Vec2[]
  1866. Method New()
  1867. b2ObjectPtr = bmx_b2polygondef_create()
  1868. End Method
  1869. Rem
  1870. bbdoc: Build vertices to represent an axis-aligned box.
  1871. about: Parameters:
  1872. <ul>
  1873. <li><b>hx </b> : the half-width.</li>
  1874. <li><b>hy </b> : the half-height. </li>
  1875. </ul>
  1876. End Rem
  1877. Method SetAsBox(hx:Float, hy:Float)
  1878. bmx_b2polygondef_setasbox(b2ObjectPtr, hx, hy)
  1879. End Method
  1880. Rem
  1881. bbdoc: Build vertices to represent an oriented box.
  1882. about: Parameters:
  1883. <ul>
  1884. <li><b>hx </b> : the half-width.</li>
  1885. <li><b>hy </b> : the half-height. </li>
  1886. <li><b>center </b> : the center of the box in local coordinates. </li>
  1887. <li><b>angle </b> : the rotation of the box in local coordinates. </li>
  1888. </ul>
  1889. End Rem
  1890. Method SetAsOrientedBox(hx:Float, hy:Float, center:b2Vec2, angle:Float)
  1891. bmx_b2polygondef_setasorientedbox(b2ObjectPtr, hx, hy, center, angle)
  1892. End Method
  1893. Rem
  1894. bbdoc: Sets the polygon vertices in local coordinates.
  1895. End Rem
  1896. Method SetVertices(vertices:b2Vec2[])
  1897. _vertices = vertices
  1898. bmx_b2polygondef_setvertices(b2ObjectPtr, vertices)
  1899. End Method
  1900. Rem
  1901. bbdoc: Gets the polygon vertices in local coordinates.
  1902. End Rem
  1903. Method GetVertices:b2Vec2[]()
  1904. Return _vertices
  1905. End Method
  1906. Method Delete()
  1907. If b2ObjectPtr Then
  1908. _vertices = Null
  1909. bmx_b2polygondef_delete(b2ObjectPtr)
  1910. b2ObjectPtr = Null
  1911. End If
  1912. End Method
  1913. End Type
  1914. Rem
  1915. bbdoc: A convex polygon.
  1916. End Rem
  1917. Type b2PolygonShape Extends b2Shape
  1918. Rem
  1919. bbdoc: Get the oriented bounding box relative to the parent body.
  1920. End Rem
  1921. Method GetOBB:b2OBB()
  1922. Return b2OBB._create(bmx_b2polygonshape_getobb(b2ObjectPtr))
  1923. End Method
  1924. Rem
  1925. bbdoc: Get local centroid relative to the parent body.
  1926. End Rem
  1927. Method GetCentroid:b2Vec2()
  1928. Return bmx_b2polygonshape_getcentroid(b2ObjectPtr)
  1929. End Method
  1930. Rem
  1931. bbdoc: Get the vertex count.
  1932. End Rem
  1933. Method GetVertexCount:Int()
  1934. Return bmx_b2polygonshape_getvertexcount(b2ObjectPtr)
  1935. End Method
  1936. Rem
  1937. bbdoc: Get the vertices in local coordinates.
  1938. End Rem
  1939. Method GetVertices:b2Vec2[]()
  1940. Return bmx_b2polygonshape_getvertices(b2ObjectPtr)
  1941. End Method
  1942. Rem
  1943. bbdoc: Get the core vertices in local coordinates.
  1944. End Rem
  1945. Method GetCoreVertices:b2Vec2[]()
  1946. Return bmx_b2polygonshape_getcorevertices(b2ObjectPtr)
  1947. End Method
  1948. Rem
  1949. bbdoc: Get the edge normal vectors.
  1950. about: There is one for each vertex.
  1951. End Rem
  1952. Method GetNormals:b2Vec2[]()
  1953. Return bmx_b2polygonshape_getnormals(b2ObjectPtr)
  1954. End Method
  1955. Rem
  1956. bbdoc: Get the first vertex and apply the supplied transform.
  1957. End Rem
  1958. Method GetFirstVertex:b2Vec2(xf:b2XForm)
  1959. Return bmx_b2polygonshape_getfirstvertex(b2ObjectPtr, xf)
  1960. End Method
  1961. Rem
  1962. bbdoc: Get the centroid and apply the supplied transform.
  1963. End Rem
  1964. Method Centroid:b2Vec2(xf:b2XForm)
  1965. Return bmx_b2polygonshape_centroid(b2ObjectPtr, xf)
  1966. End Method
  1967. Rem
  1968. bbdoc: Get the support point in the given world direction.
  1969. End Rem
  1970. Method Support:b2Vec2(xf:b2XForm, d:b2Vec2)
  1971. Return bmx_b2polygonshape_support(b2ObjectPtr, xf, d)
  1972. End Method
  1973. Rem
  1974. bbdoc:
  1975. End Rem
  1976. Method TestSegment:Int(xf:b2XForm, lambda:Float Var, normal:b2Vec2 Var, segment:b2Segment, maxLambda:Float)
  1977. Return bmx_b2shape_testsegment(b2ObjectPtr, xf, lambda, normal, segment, maxLambda)
  1978. End Method
  1979. End Type
  1980. Extern
  1981. Function bmx_b2polygondef_setvertices(handle:Byte Ptr, vertices:b2Vec2[])
  1982. Function bmx_b2world_query:Int(handle:Byte Ptr, aabb:b2AABB Var, shapes:b2Shape[])
  1983. Function bmx_b2world_raycast:Int(handle:Byte Ptr, segment:b2Segment Var, shapes:b2Shape[], solidShapes:Int)
  1984. Function bmx_b2polygonshape_getvertices:b2Vec2[](handle:Byte Ptr)
  1985. Function bmx_b2polygonshape_getcorevertices:b2Vec2[](handle:Byte Ptr)
  1986. Function bmx_b2polygonshape_getnormals:b2Vec2[](handle:Byte Ptr)
  1987. Function bmx_b2edgechaindef_setvertices(handle:Byte Ptr, vertices:b2Vec2[])
  1988. Function bmx_b2shape_testsegment:Int(handle:Byte Ptr, xf:b2XForm Var, lambda:Float Var, normal:b2Vec2 Var, segment:b2Segment Var, maxLambda:Float)
  1989. End Extern
  1990. Rem
  1991. bbdoc: Used to build circle shapes.
  1992. End Rem
  1993. Type b2CircleDef Extends b2ShapeDef
  1994. Method New()
  1995. b2ObjectPtr = bmx_b2circledef_create()
  1996. End Method
  1997. Rem
  1998. bbdoc: Sets the circle radius.
  1999. End Rem
  2000. Method SetRadius(radius:Float)
  2001. bmx_b2circledef_setradius(b2ObjectPtr, radius)
  2002. End Method
  2003. Rem
  2004. bbdoc: Returns the circle radius.
  2005. End Rem
  2006. Method GetRadius:Float()
  2007. Return bmx_b2circledef_getradius(b2ObjectPtr)
  2008. End Method
  2009. Rem
  2010. bbdoc: Sets the local position.
  2011. End Rem
  2012. Method SetLocalPosition(pos:b2Vec2)
  2013. bmx_b2circledef_setlocalposition(b2ObjectPtr, pos)
  2014. End Method
  2015. Rem
  2016. bbdoc: Returns the local position.
  2017. End Rem
  2018. Method GetLocalPosition:b2Vec2()
  2019. Return bmx_b2circledef_getlocalposition(b2ObjectPtr)
  2020. End Method
  2021. Method Delete()
  2022. If b2ObjectPtr Then
  2023. bmx_b2circledef_delete(b2ObjectPtr)
  2024. b2ObjectPtr = Null
  2025. End If
  2026. End Method
  2027. End Type
  2028. Rem
  2029. bbdoc: A circle shape.
  2030. End Rem
  2031. Type b2CircleShape Extends b2Shape
  2032. Rem
  2033. bbdoc: Get the local position of this circle in its parent body.
  2034. End Rem
  2035. Method GetLocalPosition:b2Vec2()
  2036. Return bmx_b2circleshape_getlocalposition(b2ObjectPtr)
  2037. End Method
  2038. Rem
  2039. bbdoc: Get the radius of this circle.
  2040. End Rem
  2041. Method GetRadius:Float()
  2042. Return bmx_b2circleshape_getradius(b2ObjectPtr)
  2043. End Method
  2044. Rem
  2045. bbdoc:
  2046. End Rem
  2047. Method TestSegment:Int(xf:b2XForm, lambda:Float Var, normal:b2Vec2 Var, segment:b2Segment, maxLambda:Float)
  2048. Return bmx_b2shape_testsegment(b2ObjectPtr, xf, lambda, normal, segment, maxLambda)
  2049. End Method
  2050. End Type
  2051. Rem
  2052. bbdoc:
  2053. End Rem
  2054. Type b2EdgeChainDef Extends b2ShapeDef
  2055. Field shapeDefPtr:Byte Ptr
  2056. Field vertices:b2Vec2[]
  2057. Method New()
  2058. shapeDefPtr = bmx_b2edgechaindef_create()
  2059. b2ObjectPtr = bmx_b2edgechaindef_getdef(shapeDefPtr)
  2060. End Method
  2061. Rem
  2062. bbdoc:
  2063. End Rem
  2064. Method SetVertices(vertices:b2Vec2[])
  2065. Self.vertices = vertices
  2066. bmx_b2edgechaindef_setvertices(shapeDefPtr, vertices)
  2067. End Method
  2068. Rem
  2069. bbdoc:
  2070. End Rem
  2071. Method GetVertices:b2Vec2[]()
  2072. Return vertices
  2073. End Method
  2074. Rem
  2075. bbdoc:
  2076. End Rem
  2077. Method isALoop:Int()
  2078. Return bmx_b2edgechaindef_isaloop(shapeDefPtr)
  2079. End Method
  2080. Rem
  2081. bbdoc:
  2082. End Rem
  2083. Method SetIsALoop(value:Int)
  2084. bmx_b2edgechaindef_setisaloop(shapeDefPtr, value)
  2085. End Method
  2086. Method Delete()
  2087. If b2ObjectPtr Then
  2088. vertices = Null
  2089. bmx_b2edgechaindef_delete(shapeDefPtr)
  2090. b2ObjectPtr = Null
  2091. End If
  2092. End Method
  2093. End Type
  2094. Rem
  2095. bbdoc:
  2096. End Rem
  2097. Type b2EdgeShape Extends b2Shape
  2098. Function _create:b2EdgeShape(b2ObjectPtr:Byte Ptr)
  2099. If b2ObjectPtr Then
  2100. Local this:b2EdgeShape = New b2EdgeShape
  2101. this.b2ObjectPtr = b2ObjectPtr
  2102. Return this
  2103. End If
  2104. End Function
  2105. Method GetLength:Float()
  2106. Return bmx_b2edgeshape_getlength(b2ObjectPtr)
  2107. End Method
  2108. ' Local position of vertex in parent body
  2109. Method GetVertex1:b2Vec2()
  2110. Return bmx_b2edgeshape_getvertex1(b2ObjectPtr)
  2111. End Method
  2112. ' Local position of vertex in parent body
  2113. Method GetVertex2:b2Vec2()
  2114. Return bmx_b2edgeshape_getvertex2(b2ObjectPtr)
  2115. End Method
  2116. ' "Core" vertex with TOI slop For b2Distance functions:
  2117. Method GetCoreVertex1:b2Vec2()
  2118. Return bmx_b2edgeshape_getcorevertex1(b2ObjectPtr)
  2119. End Method
  2120. ' "Core" vertex with TOI slop For b2Distance functions:
  2121. Method GetCoreVertex2:b2Vec2()
  2122. Return bmx_b2edgeshape_getcorevertex2(b2ObjectPtr)
  2123. End Method
  2124. ' Perpendicular unit vector point, pointing from the solid side To the empty side:
  2125. Method GetNormalVector:b2Vec2()
  2126. Return bmx_b2edgeshape_getnormalvector(b2ObjectPtr)
  2127. End Method
  2128. ' Parallel unit vector, pointing from vertex1 To vertex2:
  2129. Method GetDirectionVector:b2Vec2()
  2130. Return bmx_b2edgeshape_getdirectionvector(b2ObjectPtr)
  2131. End Method
  2132. Method GetCorner1Vector:b2Vec2()
  2133. Return bmx_b2edgeshape_getcorner1vector(b2ObjectPtr)
  2134. End Method
  2135. Method GetCorner2Vector:b2Vec2()
  2136. Return bmx_b2edgeshape_getcorner2vector(b2ObjectPtr)
  2137. End Method
  2138. Method Corner1IsConvex:Int()
  2139. Return bmx_b2edgeshape_corner1isconvex(b2ObjectPtr)
  2140. End Method
  2141. Method Corner2IsConvex:Int()
  2142. Return bmx_b2edgeshape_corner2isconvex(b2ObjectPtr)
  2143. End Method
  2144. Method GetFirstVertex:b2Vec2(xf:b2XForm)
  2145. Return bmx_b2edgeshape_getfirstvertex(b2ObjectPtr, xf)
  2146. End Method
  2147. Method Support:b2Vec2(xf:b2XForm, d:b2Vec2)
  2148. Return bmx_b2edgeshape_support(b2ObjectPtr, xf, d)
  2149. End Method
  2150. ' Get the Next edge in the chain.
  2151. Method GetNextEdge:b2EdgeShape()
  2152. Return b2EdgeShape._create(bmx_b2edgeshape_getnextedge(b2ObjectPtr))
  2153. End Method
  2154. ' Get the previous edge in the chain.
  2155. Method GetPrevEdge:b2EdgeShape()
  2156. Return b2EdgeShape._create(bmx_b2edgeshape_getprevedge(b2ObjectPtr))
  2157. End Method
  2158. Rem
  2159. bbdoc:
  2160. End Rem
  2161. Method TestSegment:Int(xf:b2XForm, lambda:Float Var, normal:b2Vec2 Var, segment:b2Segment, maxLambda:Float)
  2162. Return bmx_b2shape_testsegment(b2ObjectPtr, xf, lambda, normal, segment, maxLambda)
  2163. End Method
  2164. End Type
  2165. Rem
  2166. bbdoc: Revolute joint definition.
  2167. about: This requires defining an anchor point where the bodies are joined. The definition uses local anchor points
  2168. so that the initial configuration can violate the constraint slightly. You also need to specify the initial
  2169. relative angle for joint limits. This helps when saving and loading a game. The local anchor points are measured
  2170. from the body's origin rather than the center of mass because: 1. you might not know where the center of mass
  2171. will be. 2. if you add/remove shapes from a body and recompute the mass, the joints will be broken.
  2172. End Rem
  2173. Type b2RevoluteJointDef Extends b2JointDef
  2174. Method New()
  2175. b2ObjectPtr = bmx_b2revolutejointdef_create()
  2176. End Method
  2177. Rem
  2178. bbdoc: Initialize the bodies, anchors, and reference angle using the world anchor.
  2179. End Rem
  2180. Method Initialize(body1:b2Body, body2:b2Body, anchor:b2Vec2)
  2181. bmx_b2revolutejointdef_initialize(b2ObjectPtr, body1.b2ObjectPtr, body2.b2ObjectPtr, anchor)
  2182. End Method
  2183. Rem
  2184. bbdoc: The local anchor point relative to body1's origin.
  2185. end rem
  2186. Method GetLocalAnchor1:b2Vec2()
  2187. Return bmx_b2revolutejointdef_getlocalanchor1(b2ObjectPtr)
  2188. End Method
  2189. Rem
  2190. bbdoc: Sets the local anchor point relative to body1's origin.
  2191. End Rem
  2192. Method SetLocalAnchor1(anchor:b2Vec2)
  2193. bmx_b2revolutejointdef_setlocalanchor1(b2ObjectPtr, anchor)
  2194. End Method
  2195. Rem
  2196. bbdoc: The local anchor point relative to body2's origin.
  2197. end rem
  2198. Method GetLocalAnchor2:b2Vec2()
  2199. Return bmx_b2revolutejointdef_getlocalanchor2(b2ObjectPtr)
  2200. End Method
  2201. Rem
  2202. bbdoc: Sets the local anchor point relative to body2's origin.
  2203. End Rem
  2204. Method SetLocalAnchor2(anchor:b2Vec2)
  2205. bmx_b2revolutejointdef_setlocalanchor2(b2ObjectPtr, anchor)
  2206. End Method
  2207. Rem
  2208. bbdoc: The body2 angle minus body1 angle in the reference state (degrees).
  2209. End Rem
  2210. Method GetReferenceAngle:Float()
  2211. Return bmx_b2revolutejointdef_getreferenceangle(b2ObjectPtr)
  2212. End Method
  2213. Rem
  2214. bbdoc: Sets the body2 angle minus body1 angle in the reference state (degrees).
  2215. End Rem
  2216. Method SetReferenceAngle(angle:Float)
  2217. bmx_b2revolutejointdef_setreferenceangle(b2ObjectPtr, angle)
  2218. End Method
  2219. Rem
  2220. bbdoc: A flag to enable joint limits.
  2221. end rem
  2222. Method IsLimitEnabled:Int()
  2223. Return bmx_b2revolutejointdef_islimitenabled(b2ObjectPtr)
  2224. End Method
  2225. Rem
  2226. bbdoc: Enables joint limits.
  2227. End Rem
  2228. Method EnableLimit(limit:Int)
  2229. bmx_b2revolutejointdef_enablelimit(b2ObjectPtr, limit)
  2230. End Method
  2231. Rem
  2232. bbdoc: The lower angle for the joint limit (degrees).
  2233. End Rem
  2234. Method GetLowerAngle:Float()
  2235. Return bmx_b2revolutejointdef_getlowerangle(b2ObjectPtr)
  2236. End Method
  2237. Rem
  2238. bbdoc: Sets the lower angle for the joint limit (degrees).
  2239. End Rem
  2240. Method SetLowerAngle(angle:Float)
  2241. bmx_b2revolutejointdef_setlowerangle(b2ObjectPtr, angle)
  2242. End Method
  2243. Rem
  2244. bbdoc: The upper angle for the joint limit (degrees).
  2245. End Rem
  2246. Method GetUpperAngle:Float()
  2247. Return bmx_b2revolutejointdef_getupperangle(b2ObjectPtr)
  2248. End Method
  2249. Rem
  2250. bbdoc: Sets the upper angle for the joint limit (degrees).
  2251. End Rem
  2252. Method SetUpperAngle(angle:Float)
  2253. bmx_b2revolutejointdef_setupperangle(b2ObjectPtr, angle)
  2254. End Method
  2255. Rem
  2256. bbdoc: A flag to enable the joint motor.
  2257. end rem
  2258. Method IsMotorEnabled:Int()
  2259. Return bmx_b2revolutejointdef_ismotorenabled(b2ObjectPtr)
  2260. End Method
  2261. Rem
  2262. bbdoc: Enables the joint motor.
  2263. End Rem
  2264. Method EnableMotor(value:Int)
  2265. bmx_b2revolutejointdef_enablemotor(b2ObjectPtr, value)
  2266. End Method
  2267. Rem
  2268. bbdoc: The desired motor speed, usually in degrees per second.
  2269. End Rem
  2270. Method GetMotorSpeed:Float()
  2271. Return bmx_b2revolutejointdef_getmotorspeed(b2ObjectPtr)
  2272. End Method
  2273. Rem
  2274. bbdoc: Sets the desired motor speed, usually in degrees per second.
  2275. End Rem
  2276. Method SetMotorSpeed(speed:Float)
  2277. bmx_b2revolutejointdef_setmotorspeed(b2ObjectPtr, speed)
  2278. End Method
  2279. Rem
  2280. bbdoc: The maximum motor torque used to achieve the desired motor speed, usually in N-m.
  2281. End Rem
  2282. Method GetMaxMotorTorque:Float()
  2283. Return bmx_b2revolutejointdef_getmaxmotortorque(b2ObjectPtr)
  2284. End Method
  2285. Rem
  2286. bbdoc: Sets the maximum motor torque used to achieve the desired motor speed, usually in N-m.
  2287. End Rem
  2288. Method SetMaxMotorTorque(torque:Float)
  2289. bmx_b2revolutejointdef_setmaxmotortorque(b2ObjectPtr, torque)
  2290. End Method
  2291. Method Delete()
  2292. If b2ObjectPtr Then
  2293. bmx_b2revolutejointdef_delete(b2ObjectPtr)
  2294. b2ObjectPtr = Null
  2295. End If
  2296. End Method
  2297. End Type
  2298. Rem
  2299. bbdoc:Pulley joint definition.
  2300. about: This requires two ground anchors, two dynamic body anchor points, max lengths for each side, and a pulley ratio.
  2301. End Rem
  2302. Type b2PulleyJointDef Extends b2JointDef
  2303. Method New()
  2304. b2ObjectPtr = bmx_b2pulleyjointdef_create()
  2305. End Method
  2306. Rem
  2307. bbdoc: Initialize the bodies, anchors, lengths, max lengths, and ratio using the world anchors.
  2308. End Rem
  2309. Method Initialize(body1:b2Body, body2:b2Body, groundAnchor1:b2Vec2, groundAnchor2:b2Vec2, ..
  2310. anchor1:b2Vec2, anchor2:b2Vec2, ratio:Float)
  2311. bmx_b2pulleyjointdef_initialize(b2ObjectPtr, body1.b2ObjectPtr, body2.b2ObjectPtr, groundAnchor1, ..
  2312. groundAnchor2, anchor1, anchor2, ratio)
  2313. End Method
  2314. Rem
  2315. bbdoc: The first ground anchor in world coordinates. This point never moves.
  2316. end rem
  2317. Method SetGroundAnchor1(anchor:b2Vec2)
  2318. bmx_b2pulleyjointdef_setgroundanchor1(b2ObjectPtr, anchor)
  2319. End Method
  2320. Rem
  2321. bbdoc: Returns the first ground anchor, in world coordinates.
  2322. End Rem
  2323. Method GetGroundAnchor1:b2Vec2()
  2324. Return bmx_b2pulleyjointdef_getgroundanchor1(b2ObjectPtr)
  2325. End Method
  2326. Rem
  2327. bbdoc: The second ground anchor in world coordinates. This point never moves.
  2328. end rem
  2329. Method SetGroundAnchor2(anchor:b2Vec2)
  2330. bmx_b2pulleyjointdef_setgroundanchor2(b2ObjectPtr, anchor)
  2331. End Method
  2332. Rem
  2333. bbdoc: Returns the second ground anchor, in world coordinates.
  2334. End Rem
  2335. Method GetGroundAnchor2:b2Vec2()
  2336. Return bmx_b2pulleyjointdef_getgroundanchor2(b2ObjectPtr)
  2337. End Method
  2338. Rem
  2339. bbdoc: The local anchor point relative to body1's origin.
  2340. end rem
  2341. Method SetLocalAnchor1(anchor:b2Vec2)
  2342. bmx_b2pulleyjointdef_setlocalanchor1(b2ObjectPtr, anchor)
  2343. End Method
  2344. Rem
  2345. bbdoc: Returns the local anchor point.
  2346. End Rem
  2347. Method GetLocalAnchor1:b2Vec2()
  2348. Return bmx_b2pulleyjointdef_getlocalanchor1(b2ObjectPtr)
  2349. End Method
  2350. Rem
  2351. bbdoc: The local anchor point relative to body2's origin.
  2352. end rem
  2353. Method SetLocalAnchor2(anchor:b2Vec2)
  2354. bmx_b2pulleyjointdef_setlocalanchor2(b2ObjectPtr, anchor)
  2355. End Method
  2356. Rem
  2357. bbdoc: Returns the local anchor point.
  2358. End Rem
  2359. Method GetLocalAnchor2:b2Vec2()
  2360. Return bmx_b2pulleyjointdef_getlocalanchor2(b2ObjectPtr)
  2361. End Method
  2362. Rem
  2363. bbdoc: The a reference length for the segment attached to body1.
  2364. end rem
  2365. Method SetLength1(length:Float)
  2366. bmx_b2pulleyjointdef_setlength1(b2ObjectPtr, length)
  2367. End Method
  2368. Rem
  2369. bbdoc: Returns the reference length for the segment attached to body1.
  2370. End Rem
  2371. Method GetLength1:Float()
  2372. Return bmx_b2pulleyjointdef_getlength1(b2ObjectPtr)
  2373. End Method
  2374. Rem
  2375. bbdoc: The maximum length of the segment attached to body1.
  2376. end rem
  2377. Method SetMaxLength1(maxLength:Float)
  2378. bmx_b2pulleyjointdef_setmaxlength1(b2ObjectPtr, maxLength)
  2379. End Method
  2380. Rem
  2381. bbdoc: Returns the maximum length of the segment attached to body1.
  2382. End Rem
  2383. Method GetMaxLength1:Float()
  2384. Return bmx_b2pulleyjointdef_getmaxlength1(b2ObjectPtr)
  2385. End Method
  2386. Rem
  2387. bbdoc: The a reference length for the segment attached to body2.
  2388. end rem
  2389. Method SetLength2(length:Float)
  2390. bmx_b2pulleyjointdef_setlength2(b2ObjectPtr, length)
  2391. End Method
  2392. Rem
  2393. bbdoc: Returns the reference length for the segment attached to body2.
  2394. End Rem
  2395. Method GetLength2:Float()
  2396. Return bmx_b2pulleyjointdef_getlength2(b2ObjectPtr)
  2397. End Method
  2398. Rem
  2399. bbdoc: The maximum length of the segment attached to body2.
  2400. end rem
  2401. Method SetMaxLength2(maxLength:Float)
  2402. bmx_b2pulleyjointdef_setmaxlength2(b2ObjectPtr, maxLength)
  2403. End Method
  2404. Rem
  2405. bbdoc: Returns the maximum length of the segment attached to body2.
  2406. End Rem
  2407. Method GetMaxLength2:Float()
  2408. Return bmx_b2pulleyjointdef_getmaxlength2(b2ObjectPtr)
  2409. End Method
  2410. Rem
  2411. bbdoc: The pulley ratio, used to simulate a block-and-tackle.
  2412. end rem
  2413. Method SetRatio(ratio:Float)
  2414. bmx_b2pulleyjointdef_setratio(b2ObjectPtr, ratio)
  2415. End Method
  2416. Rem
  2417. bbdoc: Returns the pulley ratio.
  2418. End Rem
  2419. Method GetRatio:Float()
  2420. Return bmx_b2pulleyjointdef_getratio(b2ObjectPtr)
  2421. End Method
  2422. Method Delete()
  2423. If b2ObjectPtr Then
  2424. bmx_b2pulleyjointdef_delete(b2ObjectPtr)
  2425. b2ObjectPtr = Null
  2426. End If
  2427. End Method
  2428. End Type
  2429. Rem
  2430. bbdoc: Prismatic joint definition.
  2431. about: This requires defining a line of motion using an axis and an anchor point. The definition uses local
  2432. anchor points and a local axis so that the initial configuration can violate the constraint slightly. The
  2433. joint translation is zero when the local anchor points coincide in world space. Using local anchors and a
  2434. local axis helps when saving and loading a game.
  2435. End Rem
  2436. Type b2PrismaticJointDef Extends b2JointDef
  2437. Method New()
  2438. b2ObjectPtr = bmx_b2prismaticjointdef_create()
  2439. End Method
  2440. Rem
  2441. bbdoc: Initialize the bodies, anchors, axis, and reference angle using the world anchor and world axis.
  2442. End Rem
  2443. Method Initialize(body1:b2Body, body2:b2Body, anchor:b2Vec2, axis:b2Vec2)
  2444. bmx_b2prismaticjointdef_initialize(b2ObjectPtr, body1.b2ObjectPtr, body2.b2ObjectPtr, ..
  2445. anchor, axis)
  2446. End Method
  2447. Rem
  2448. bbdoc: The local anchor point relative to body1's origin.
  2449. End Rem
  2450. Method SetLocalAnchor1(anchor:b2Vec2)
  2451. bmx_b2prismaticjointdef_setlocalanchor1(b2ObjectPtr, anchor)
  2452. End Method
  2453. Rem
  2454. bbdoc: Returns the local anchor point.
  2455. End Rem
  2456. Method GetLocalAnchor1:b2Vec2()
  2457. Return bmx_b2prismaticjointdef_getlocalanchor1(b2ObjectPtr)
  2458. End Method
  2459. Rem
  2460. bbdoc: The local anchor point relative to body2's origin.
  2461. End Rem
  2462. Method SetLocalAnchor2(anchor:b2Vec2)
  2463. bmx_b2prismaticjointdef_setlocalanchor2(b2ObjectPtr, anchor)
  2464. End Method
  2465. Rem
  2466. bbdoc: Returns the local anchor point.
  2467. End Rem
  2468. Method GetLocalAnchor2:b2Vec2()
  2469. Return bmx_b2prismaticjointdef_getlocalanchor2(b2ObjectPtr)
  2470. End Method
  2471. Rem
  2472. bbdoc: The local translation axis in body1.
  2473. End Rem
  2474. Method SetLocalAxis1(axis:b2Vec2)
  2475. bmx_b2prismaticjointdef_setlocalaxis1(b2ObjectPtr, axis)
  2476. End Method
  2477. Rem
  2478. bbdoc: Returns the local translation axis in body1.
  2479. End Rem
  2480. Method GetLocalAxis1:b2Vec2()
  2481. Return bmx_b2prismaticjointdef_getlocalaxis1(b2ObjectPtr)
  2482. End Method
  2483. Rem
  2484. bbdoc: The constrained angle between the bodies: body2_angle - body1_angle.
  2485. End Rem
  2486. Method SetReferenceAngle(angle:Float)
  2487. bmx_b2prismaticjointdef_setreferenceangle(b2ObjectPtr, angle)
  2488. End Method
  2489. Rem
  2490. bbdoc: Returns the constrained angle between the bodies.
  2491. End Rem
  2492. Method GetReferenceAngle:Float()
  2493. Return bmx_b2prismaticjointdef_getreferenceangle(b2ObjectPtr)
  2494. End Method
  2495. Rem
  2496. bbdoc: Enable/disable the joint limit.
  2497. End Rem
  2498. Method EnableLimit(value:Int)
  2499. bmx_b2prismaticjointdef_enablelimit(b2ObjectPtr, value)
  2500. End Method
  2501. Rem
  2502. bbdoc: Returns True if the joint limit is enabled.
  2503. End Rem
  2504. Method IsLimitEnabled:Int()
  2505. Return bmx_b2prismaticjointdef_islimitenabled(b2ObjectPtr)
  2506. End Method
  2507. Rem
  2508. bbdoc: The lower translation limit, usually in meters.
  2509. End Rem
  2510. Method SetLowerTranslation(Translation:Float)
  2511. bmx_b2prismaticjointdef_setlowertranslation(b2ObjectPtr, Translation)
  2512. End Method
  2513. Rem
  2514. bbdoc: Returns the lower translation limit.
  2515. End Rem
  2516. Method GetLowerTranslation:Float()
  2517. Return bmx_b2prismaticjointdef_getlowertranslation(b2ObjectPtr)
  2518. End Method
  2519. Rem
  2520. bbdoc: The upper translation limit, usually in meters.
  2521. End Rem
  2522. Method SetUpperTranslation(Translation:Float)
  2523. bmx_b2prismaticjointdef_setuppertranslation(b2ObjectPtr, Translation)
  2524. End Method
  2525. Rem
  2526. bbdoc: Returns the upper translation limit.
  2527. End Rem
  2528. Method GetUpperTranslation:Float()
  2529. Return bmx_b2prismaticjointdef_getuppertranslation(b2ObjectPtr)
  2530. End Method
  2531. Rem
  2532. bbdoc: Enable/disable the joint motor.
  2533. end rem
  2534. Method EnableMotor(value:Int)
  2535. bmx_b2prismaticjointdef_enablemotor(b2ObjectPtr, value)
  2536. End Method
  2537. Rem
  2538. bbdoc: Returns true if the joint motor is enabled.
  2539. End Rem
  2540. Method IsMotorEnabled:Int()
  2541. Return bmx_b2prismaticjointdef_ismotorenabled(b2ObjectPtr)
  2542. End Method
  2543. Rem
  2544. bbdoc: The maximum motor torque, usually in N-m.
  2545. end rem
  2546. Method SetMaxMotorForce(force:Float)
  2547. bmx_b2prismaticjointdef_setmaxmotorforce(b2ObjectPtr, force)
  2548. End Method
  2549. Rem
  2550. bbdoc: Returns the maximum motor torque.
  2551. End Rem
  2552. Method GetMaxMotorForce:Float()
  2553. Return bmx_b2prismaticjointdef_getmaxmotorforce(b2ObjectPtr)
  2554. End Method
  2555. Rem
  2556. bbdoc: The desired motor speed in degrees per second.
  2557. End Rem
  2558. Method SetMotorSpeed(speed:Float)
  2559. bmx_b2prismaticjointdef_setmotorspeed(b2ObjectPtr, speed)
  2560. End Method
  2561. Rem
  2562. bbdoc: The motorspeed, in degrees per second.
  2563. End Rem
  2564. Method GetMotorSpeed:Float()
  2565. Return bmx_b2prismaticjointdef_getmotorspeed(b2ObjectPtr)
  2566. End Method
  2567. Method Delete()
  2568. If b2ObjectPtr Then
  2569. bmx_b2prismaticjointdef_delete(b2ObjectPtr)
  2570. b2ObjectPtr = Null
  2571. End If
  2572. End Method
  2573. End Type
  2574. Rem
  2575. bbdoc: Mouse joint definition.
  2576. about: This requires a world target point, tuning parameters, and the time step.
  2577. End Rem
  2578. Type b2MouseJointDef Extends b2JointDef
  2579. Method New()
  2580. b2ObjectPtr = bmx_b2mousejointdef_new()
  2581. End Method
  2582. Rem
  2583. bbdoc: The initial world target point.
  2584. about: This is assumed to coincide with the body anchor initially.
  2585. End Rem
  2586. Method SetTarget(target:b2Vec2)
  2587. bmx_b2mousejointdef_settarget(b2ObjectPtr, target)
  2588. End Method
  2589. Rem
  2590. bbdoc: Returns the initial world target point.
  2591. End Rem
  2592. Method GetTarget:b2Vec2()
  2593. Return bmx_b2mousejointdef_gettarget(b2ObjectPtr)
  2594. End Method
  2595. Rem
  2596. bbdoc: The maximum constraint force that can be exerted to move the candidate body.
  2597. about: Usually you will express as some multiple of the weight (multiplier * mass * gravity).
  2598. End Rem
  2599. Method SetMaxForce(maxForce:Float)
  2600. bmx_b2mousejointdef_setmaxforce(b2ObjectPtr, maxForce)
  2601. End Method
  2602. Rem
  2603. bbdoc: Returns the maximum constraint force that can be exerted to move the candidate body.
  2604. End Rem
  2605. Method GetMaxForce:Float()
  2606. Return bmx_b2mousejointdef_getmaxforce(b2ObjectPtr)
  2607. End Method
  2608. Rem
  2609. bbdoc: The response speed.
  2610. end rem
  2611. Method SetFrequencyHz(frequency:Float)
  2612. bmx_b2mousejointdef_setfrequencyhz(b2ObjectPtr, frequency)
  2613. End Method
  2614. Rem
  2615. bbdoc: Returns the response speed.
  2616. End Rem
  2617. Method GetFrequencyHz:Float()
  2618. Return bmx_b2mousejointdef_getfrequencyhz(b2ObjectPtr)
  2619. End Method
  2620. Rem
  2621. bbdoc: The damping ratio.
  2622. about: 0 = no damping, 1 = critical damping.
  2623. End Rem
  2624. Method SetDampingRatio(ratio:Float)
  2625. bmx_b2mousejointdef_setdampingration(b2ObjectPtr, ratio)
  2626. End Method
  2627. Rem
  2628. bbdoc: Returns the damping ratio.
  2629. End Rem
  2630. Method GetDampingRatio:Float()
  2631. Return bmx_b2mousejointdef_getdampingratio(b2ObjectPtr)
  2632. End Method
  2633. Method Delete()
  2634. If b2ObjectPtr Then
  2635. bmx_b2mousejointdef_delete(b2ObjectPtr)
  2636. b2ObjectPtr = Null
  2637. End If
  2638. End Method
  2639. End Type
  2640. Rem
  2641. bbdoc: Gear joint definition.
  2642. about: This definition requires two existing revolute or prismatic joints (any combination will work). The provided
  2643. joints must attach a dynamic body to a static body.
  2644. End Rem
  2645. Type b2GearJointDef Extends b2JointDef
  2646. Method New()
  2647. b2ObjectPtr = bmx_b2gearjointdef_new()
  2648. End Method
  2649. Rem
  2650. bbdoc: Sets the first revolute/prismatic joint attached to the gear joint.
  2651. End Rem
  2652. Method SetJoint1(joint:b2Joint)
  2653. bmx_b2gearjointdef_setjoint1(b2ObjectPtr, joint.b2ObjectPtr)
  2654. End Method
  2655. Rem
  2656. bbdoc: Sets the second revolute/prismatic joint attached to the gear joint.
  2657. End Rem
  2658. Method SetJoint2(joint:b2Joint)
  2659. bmx_b2gearjointdef_setjoint2(b2ObjectPtr, joint.b2ObjectPtr)
  2660. End Method
  2661. Rem
  2662. bbdoc: Sets the gear ratio.
  2663. End Rem
  2664. Method SetRatio(ratio:Float)
  2665. bmx_b2gearjointdef_setratio(b2ObjectPtr, ratio)
  2666. End Method
  2667. Method Delete()
  2668. If b2ObjectPtr Then
  2669. bmx_b2gearjointdef_delete(b2ObjectPtr)
  2670. b2ObjectPtr = Null
  2671. End If
  2672. End Method
  2673. End Type
  2674. Rem
  2675. bbdoc: Line joint definition.
  2676. about: This requires defining a line of motion using an axis and an anchor point. The definition uses local
  2677. anchor points and a local axis so that the initial configuration can violate the constraint slightly. The joint translation is zero
  2678. when the local anchor points coincide in world space. Using local anchors and a local axis helps when saving and loading a game.
  2679. End Rem
  2680. Type b2LineJointDef Extends b2JointDef
  2681. Method New()
  2682. b2ObjectPtr = bmx_b2linejointdef_create()
  2683. End Method
  2684. Rem
  2685. bbdoc: Initialize the bodies, anchors, axis, and reference angle using the world anchor and world axis.
  2686. End Rem
  2687. Method Initialize(body1:b2Body, body2:b2Body, anchor:b2Vec2, axis:b2Vec2)
  2688. bmx_b2linejointdef_initialize(b2ObjectPtr, body1.b2ObjectPtr, body2.b2ObjectPtr, ..
  2689. anchor, axis)
  2690. End Method
  2691. Rem
  2692. bbdoc: Sets the local anchor point relative to body1's origin.
  2693. End Rem
  2694. Method SetLocalAnchor1(anchor:b2Vec2)
  2695. bmx_b2linejointdef_setlocalanchor1(b2ObjectPtr, anchor)
  2696. End Method
  2697. Rem
  2698. bbdoc: Returns the local anchor point relative to body1's origin.
  2699. End Rem
  2700. Method GetLocalAnchor1:b2Vec2()
  2701. Return bmx_b2linejointdef_getlocalanchor1(b2ObjectPtr)
  2702. End Method
  2703. Rem
  2704. bbdoc: Sets the Local anchor point relative to body2's origin.
  2705. End Rem
  2706. Method SetLocalAnchor2(anchor:b2Vec2)
  2707. bmx_b2linejointdef_setlocalanchor2(b2ObjectPtr, anchor)
  2708. End Method
  2709. Rem
  2710. bbdoc: Returns the Local anchor point relative to body2's origin.
  2711. End Rem
  2712. Method GetLocalAnchor2:b2Vec2()
  2713. Return bmx_b2linejointdef_getlocalanchor2(b2ObjectPtr)
  2714. End Method
  2715. Rem
  2716. bbdoc: Sets the local translation axis in body1.
  2717. End Rem
  2718. Method SetLocalAxis1(axis:b2Vec2)
  2719. bmx_b2linejointdef_setlocalaxis1(b2ObjectPtr, axis)
  2720. End Method
  2721. Rem
  2722. bbdoc: Returns the local translation axis in body1.
  2723. End Rem
  2724. Method GetLocalAxis1:b2Vec2()
  2725. Return bmx_b2linejointdef_getlocalaxis1(b2ObjectPtr)
  2726. End Method
  2727. Rem
  2728. bbdoc: Enables/disables the joint limit.
  2729. End Rem
  2730. Method EnableLimit(limit:Int)
  2731. bmx_b2linejointdef_enablelimit(b2ObjectPtr, limit)
  2732. End Method
  2733. Rem
  2734. bbdoc: Returns the joint limit.
  2735. End Rem
  2736. Method GetLimit:Int()
  2737. Return bmx_b2linejointdef_getlimit(b2ObjectPtr)
  2738. End Method
  2739. Rem
  2740. bbdoc: Sets the lower translation limit, usually in meters.
  2741. End Rem
  2742. Method SetLowerTranslation(Translation:Float)
  2743. bmx_b2linejointdef_setlowertranslation(b2ObjectPtr, Translation)
  2744. End Method
  2745. Rem
  2746. bbdoc: Gets the lower translation limit, usually in meters.
  2747. End Rem
  2748. Method GetLowerTranslation:Float()
  2749. Return bmx_b2linejointdef_getlowertranslation(b2ObjectPtr)
  2750. End Method
  2751. Rem
  2752. bbdoc: Sets the upper translation limit, usually in meters.
  2753. End Rem
  2754. Method SetUpperTranslation(Translation:Float)
  2755. bmx_b2linejointdef_setuppertranslation(b2ObjectPtr, Translation)
  2756. End Method
  2757. Rem
  2758. bbdoc: Gets the upper translation limit, usually in meters.
  2759. End Rem
  2760. Method GetUpperTranslation:Float()
  2761. Return bmx_b2linejointdef_getuppertranslation(b2ObjectPtr)
  2762. End Method
  2763. Rem
  2764. bbdoc: Enables/disables the joint motor.
  2765. End Rem
  2766. Method EnableMotor(enable:Int)
  2767. bmx_b2linejointdef_enablemotor(b2ObjectPtr, enable)
  2768. End Method
  2769. Rem
  2770. bbdoc: Is the motor enabled?
  2771. End Rem
  2772. Method IsMotorEnabled:Int()
  2773. Return bmx_b2linejointdef_ismotorenabled(b2ObjectPtr)
  2774. End Method
  2775. Rem
  2776. bbdoc: Sets the maximum motor torque, usually in N-m.
  2777. End Rem
  2778. Method SetMaxMotorForce(maxForce:Float)
  2779. bmx_b2linejointdef_setmaxmotorforce(b2ObjectPtr, maxForce)
  2780. End Method
  2781. Rem
  2782. bbdoc: Returns the maximum motor torque, usually in N-m.
  2783. End Rem
  2784. Method GetMaxMotorForce:Float()
  2785. Return bmx_b2linejointdef_getmaxmotorforce(b2ObjectPtr)
  2786. End Method
  2787. Rem
  2788. bbdoc: Sets the desired motor speed, in degrees per second.
  2789. End Rem
  2790. Method SetMotorSpeed(speed:Float)
  2791. bmx_b2linejointdef_setmotorspeed(b2ObjectPtr, speed)
  2792. End Method
  2793. Rem
  2794. bbdoc: Returns the desired motor speed, in degrees per second.
  2795. End Rem
  2796. Method GetMotorSpeed:Float()
  2797. Return bmx_b2linejointdef_getmotorspeed(b2ObjectPtr)
  2798. End Method
  2799. Method Delete()
  2800. If b2ObjectPtr Then
  2801. bmx_b2linejointdef_delete(b2ObjectPtr)
  2802. b2ObjectPtr = Null
  2803. End If
  2804. End Method
  2805. End Type
  2806. Rem
  2807. bbdoc: A line joint.
  2808. about: This joint provides one degree of freedom: translation along an axis fixed in body1. You can use a joint limit to restrict
  2809. the range of motion and a joint motor to drive the motion or to model joint friction.
  2810. End Rem
  2811. Type b2LineJoint Extends b2Joint
  2812. Rem
  2813. bbdoc:
  2814. End Rem
  2815. Method GetAnchor1:b2Vec2()
  2816. Return bmx_b2linejoint_getanchor1(b2ObjectPtr)
  2817. End Method
  2818. Rem
  2819. bbdoc:
  2820. End Rem
  2821. Method GetAnchor2:b2Vec2()
  2822. Return bmx_b2linejoint_getanchor2(b2ObjectPtr)
  2823. End Method
  2824. Rem
  2825. bbdoc:
  2826. End Rem
  2827. Method GetReactionForce:b2Vec2(inv_dt:Float)
  2828. Return bmx_b2linejoint_getreactionforce(b2ObjectPtr, inv_dt)
  2829. End Method
  2830. Rem
  2831. bbdoc:
  2832. End Rem
  2833. Method GetReactionTorque:Float(inv_dt:Float)
  2834. Return bmx_b2linejoint_getreactiontorque(b2ObjectPtr, inv_dt)
  2835. End Method
  2836. Rem
  2837. bbdoc: Get the current joint translation, usually in meters.
  2838. End Rem
  2839. Method GetJointTranslation:Float()
  2840. Return bmx_b2linejoint_getjointtranslation(b2ObjectPtr)
  2841. End Method
  2842. Rem
  2843. bbdoc: Get the current joint translation speed, usually in meters per second.
  2844. End Rem
  2845. Method GetJointSpeed:Float()
  2846. Return bmx_b2linejoint_getjointspeed(b2ObjectPtr)
  2847. End Method
  2848. Rem
  2849. bbdoc: Is the joint limit enabled?
  2850. End Rem
  2851. Method IsLimitEnabled:Int()
  2852. Return bmx_b2linejoint_islimitenabled(b2ObjectPtr)
  2853. End Method
  2854. Rem
  2855. bbdoc: Enable/disable the joint limit.
  2856. End Rem
  2857. Method EnableLimit(flag:Int)
  2858. bmx_b2linejoint_enablelimit(b2ObjectPtr, flag)
  2859. End Method
  2860. Rem
  2861. bbdoc: Get the lower joint limit, usually in meters.
  2862. End Rem
  2863. Method GetLowerLimit:Float()
  2864. Return bmx_b2linejoint_getlowerlimit(b2ObjectPtr)
  2865. End Method
  2866. Rem
  2867. bbdoc: Get the upper joint limit, usually in meters.
  2868. End Rem
  2869. Method GetUpperLimit:Float()
  2870. Return bmx_b2linejoint_getupperlimit(b2ObjectPtr)
  2871. End Method
  2872. Rem
  2873. bbdoc: Set the joint limits, usually in meters.
  2874. End Rem
  2875. Method SetLimits(_lower:Float, _upper:Float)
  2876. bmx_b2linejoint_setlimits(b2ObjectPtr, _lower, _upper)
  2877. End Method
  2878. Rem
  2879. bbdoc: Is the joint motor enabled?
  2880. End Rem
  2881. Method IsMotorEnabled:Int()
  2882. Return bmx_b2linejoint_ismotorenabled(b2ObjectPtr)
  2883. End Method
  2884. Rem
  2885. bbdoc: Enable/disable the joint motor.
  2886. End Rem
  2887. Method EnableMotor(flag:Int)
  2888. bmx_b2linejoint_enablemotor(b2ObjectPtr, flag)
  2889. End Method
  2890. Rem
  2891. bbdoc: Set the motor speed, usually in meters per second.
  2892. End Rem
  2893. Method SetMotorSpeed(speed:Float)
  2894. bmx_b2linejoint_setmotorspeed(b2ObjectPtr, speed)
  2895. End Method
  2896. Rem
  2897. bbdoc: Get the motor speed, usually in meters per second.
  2898. End Rem
  2899. Method GetMotorSpeed:Float()
  2900. Return bmx_b2linejoint_getmotorspeed(b2ObjectPtr)
  2901. End Method
  2902. Rem
  2903. bbdoc: Set the maximum motor force, usually in N.
  2904. End Rem
  2905. Method SetMaxMotorForce(force:Float)
  2906. bmx_b2linejoint_setmaxmotorforce(b2ObjectPtr, force)
  2907. End Method
  2908. Rem
  2909. bbdoc: Get the current motor force, usually in N.
  2910. End Rem
  2911. Method GetMotorForce:Float()
  2912. Return bmx_b2linejoint_getmotorforce(b2ObjectPtr)
  2913. End Method
  2914. End Type
  2915. Rem
  2916. bbdoc: Distance joint definition.
  2917. about: This requires defining an anchor point on both bodies and the non-zero length of the
  2918. distance joint. The definition uses local anchor points so that the initial configuration can violate the
  2919. constraint slightly. This helps when saving and loading a game.
  2920. <p>
  2921. Warning: Do not use a zero or short length.
  2922. </p>
  2923. End Rem
  2924. Type b2DistanceJointDef Extends b2JointDef
  2925. Method New()
  2926. b2ObjectPtr = bmx_b2distancejointdef_new()
  2927. End Method
  2928. Rem
  2929. bbdoc: Initialize the bodies, anchors, and length using the world anchors.
  2930. End Rem
  2931. Method Initialize(body1:b2Body, body2:b2Body, anchor1:b2Vec2, anchor2:b2Vec2)
  2932. bmx_b2distancejointdef_initialize(b2ObjectPtr, body1.b2ObjectPtr, body2.b2ObjectPtr, anchor1, anchor2)
  2933. End Method
  2934. Rem
  2935. bbdoc: Sets the local anchor point relative to body1's origin.
  2936. End Rem
  2937. Method SetLocalAnchor1(anchor:b2Vec2)
  2938. bmx_b2distancejointdef_setlocalanchor1(b2ObjectPtr, anchor)
  2939. End Method
  2940. Rem
  2941. bbdoc: Returns the local anchor point relative to body1's origin.
  2942. End Rem
  2943. Method GetLocalAnchor1:b2Vec2()
  2944. Return bmx_b2distancejointdef_getlocalanchor1(b2ObjectPtr)
  2945. End Method
  2946. Rem
  2947. bbdoc: Sets the Local anchor point relative to body2's origin.
  2948. End Rem
  2949. Method SetLocalAnchor2(anchor:b2Vec2)
  2950. bmx_b2distancejointdef_setlocalanchor2(b2ObjectPtr, anchor)
  2951. End Method
  2952. Rem
  2953. bbdoc: Returns the Local anchor point relative to body2's origin.
  2954. End Rem
  2955. Method GetLocalAnchor2:b2Vec2()
  2956. Return bmx_b2distancejointdef_getlocalanchor2(b2ObjectPtr)
  2957. End Method
  2958. Rem
  2959. bbdoc: Sets the equilibrium length between the anchor points.
  2960. End Rem
  2961. Method SetLength(length:Float)
  2962. bmx_b2distancejointdef_setlength(b2ObjectPtr, length)
  2963. End Method
  2964. Rem
  2965. bbdoc: Returns the equilibrium length between the anchor points.
  2966. End Rem
  2967. Method GetLength:Float()
  2968. Return bmx_b2distancejointdef_getlength(b2ObjectPtr)
  2969. End Method
  2970. Rem
  2971. bbdoc: Sets the response speed.
  2972. End Rem
  2973. Method SetFrequencyHz(freq:Float)
  2974. bmx_b2distancejointdef_setfrequencyhz(b2ObjectPtr, freq)
  2975. End Method
  2976. Rem
  2977. bbdoc: Sets the damping ratio. 0 = no damping, 1 = critical damping.
  2978. End Rem
  2979. Method SetDampingRatio(ratio:Float)
  2980. bmx_b2distancejointdef_setdampingratio(b2ObjectPtr, ratio)
  2981. End Method
  2982. Method Delete()
  2983. If b2ObjectPtr Then
  2984. bmx_b2distancejointdef_delete(b2ObjectPtr)
  2985. b2ObjectPtr = Null
  2986. End If
  2987. End Method
  2988. End Type
  2989. Rem
  2990. bbdoc: A distance joint constrains two points on two bodies to remain at a fixed distance from each other.
  2991. about: You can view this as a massless, rigid rod.
  2992. End Rem
  2993. Type b2DistanceJoint Extends b2Joint
  2994. Rem
  2995. bbdoc: Get the anchor point on body1 in world coordinates.
  2996. End Rem
  2997. Method GetAnchor1:b2Vec2()
  2998. Return bmx_b2distancejoint_getanchor1(b2ObjectPtr)
  2999. End Method
  3000. Rem
  3001. bbdoc: Get the anchor point on body2 in world coordinates.
  3002. End Rem
  3003. Method GetAnchor2:b2Vec2()
  3004. Return bmx_b2distancejoint_getanchor2(b2ObjectPtr)
  3005. End Method
  3006. Rem
  3007. bbdoc: Get the reaction force on body2 at the joint anchor.
  3008. End Rem
  3009. Method GetReactionForce:b2Vec2(inv_dt:Float)
  3010. Return bmx_b2distancejoint_getreactionforce(b2ObjectPtr, inv_dt)
  3011. End Method
  3012. Rem
  3013. bbdoc: Get the reaction torque on body2.
  3014. End Rem
  3015. Method GetReactionTorque:Float(inv_dt:Float)
  3016. Return bmx_b2distancejoint_getreactiontorque(b2ObjectPtr, inv_dt)
  3017. End Method
  3018. End Type
  3019. Rem
  3020. bbdoc: A revolute joint constrains to bodies to share a common point while they are free to rotate about the point.
  3021. about: The relative rotation about the shared point is the joint angle. You can limit the relative rotation
  3022. with a joint limit that specifies a lower and upper angle. You can use a motor to drive the relative rotation
  3023. about the shared point. A maximum motor torque is provided so that infinite forces are not generated.
  3024. End Rem
  3025. Type b2RevoluteJoint Extends b2Joint
  3026. Rem
  3027. bbdoc: Get the anchor point on body1 in world coordinates.
  3028. End Rem
  3029. Method GetAnchor1:b2Vec2()
  3030. Return bmx_b2revolutejoint_getanchor1(b2ObjectPtr)
  3031. End Method
  3032. Rem
  3033. bbdoc: Get the anchor point on body2 in world coordinates.
  3034. End Rem
  3035. Method GetAnchor2:b2Vec2()
  3036. Return bmx_b2revolutejoint_getanchor2(b2ObjectPtr)
  3037. End Method
  3038. Rem
  3039. bbdoc: Get the reaction force on body2 at the joint anchor.
  3040. End Rem
  3041. Method GetReactionForce:b2Vec2(inv_dt:Float)
  3042. Return bmx_b2revolutejoint_getreactionforce(b2ObjectPtr, inv_dt)
  3043. End Method
  3044. Rem
  3045. bbdoc: Get the reaction torque on body2.
  3046. End Rem
  3047. Method GetReactionTorque:Float(inv_dt:Float)
  3048. Return bmx_b2revolutejoint_getreactiontorque(b2ObjectPtr, inv_dt)
  3049. End Method
  3050. Rem
  3051. bbdoc: Get the current joint angle in degrees.
  3052. End Rem
  3053. Method GetJointAngle:Float()
  3054. Return bmx_b2revolutejoint_getjointangle(b2ObjectPtr)
  3055. End Method
  3056. Rem
  3057. bbdoc: Get the current joint angle speed in degrees per second.
  3058. End Rem
  3059. Method GetJointSpeed:Float()
  3060. Return bmx_b2revolutejoint_getjointspeed(b2ObjectPtr)
  3061. End Method
  3062. Rem
  3063. bbdoc: Is the joint limit enabled?
  3064. end rem
  3065. Method IsLimitEnabled:Int()
  3066. Return bmx_b2revolutejoint_islimitenabled(b2ObjectPtr)
  3067. End Method
  3068. Rem
  3069. bbdoc: Enable/disable the joint limit.
  3070. end rem
  3071. Method EnableLimit(flag:Int)
  3072. bmx_b2revolutejoint_enablelimit(b2ObjectPtr, flag)
  3073. End Method
  3074. Rem
  3075. bbdoc: Get the lower joint limit in degrees.
  3076. End Rem
  3077. Method GetLowerLimit:Float()
  3078. Return bmx_b2revolutejoint_getlowerlimit(b2ObjectPtr)
  3079. End Method
  3080. Rem
  3081. bbdoc: Get the upper joint limit in degrees.
  3082. End Rem
  3083. Method GetUpperLimit:Float()
  3084. Return bmx_b2revolutejoint_getupperlimit(b2ObjectPtr)
  3085. End Method
  3086. Rem
  3087. bbdoc: Set the joint limits in degrees.
  3088. End Rem
  3089. Method SetLimits(lowerLimit:Float, upperLimit:Float)
  3090. bmx_b2revolutejoint_setlimits(b2ObjectPtr, lowerLimit, upperLimit)
  3091. End Method
  3092. Rem
  3093. bbdoc: Is the joint motor enabled?
  3094. end rem
  3095. Method IsMotorEnabled:Int()
  3096. Return bmx_b2revolutejoint_ismotorenabled(b2ObjectPtr)
  3097. End Method
  3098. Rem
  3099. bbdoc: Enable/disable the joint motor.
  3100. end rem
  3101. Method EnableMotor(flag:Int)
  3102. bmx_b2revolutejoint_enablemotor(b2ObjectPtr, flag)
  3103. End Method
  3104. Rem
  3105. bbdoc: Set the motor speed in radians per second.
  3106. end rem
  3107. Method SetMotorSpeed(speed:Float)
  3108. bmx_b2revolutejoint_setmotorspeed(b2ObjectPtr, speed)
  3109. End Method
  3110. Rem
  3111. bbdoc: Get the motor speed in radians per second.
  3112. end rem
  3113. Method GetMotorSpeed:Float()
  3114. Return bmx_b2revolutejoint_getmotorspeed(b2ObjectPtr)
  3115. End Method
  3116. Rem
  3117. bbdoc: Set the maximum motor torque, usually in N-m.
  3118. end rem
  3119. Method SetMaxMotorTorque(torque:Float)
  3120. bmx_b2revolutejoint_setmaxmotortorque(b2ObjectPtr, torque)
  3121. End Method
  3122. Rem
  3123. bbdoc: Get the current motor torque, usually in N-m.
  3124. end rem
  3125. Method GetMotorTorque:Float()
  3126. Return bmx_b2revolutejoint_getmotortorque(b2ObjectPtr)
  3127. End Method
  3128. End Type
  3129. Rem
  3130. bbdoc:
  3131. End Rem
  3132. Type b2PrismaticJoint Extends b2Joint
  3133. Rem
  3134. bbdoc: Get the anchor point on body1 in world coordinates.
  3135. End Rem
  3136. Method GetAnchor1:b2Vec2()
  3137. Return bmx_b2prismaticjoint_getanchor1(b2ObjectPtr)
  3138. End Method
  3139. Rem
  3140. bbdoc: Get the anchor point on body2 in world coordinates.
  3141. End Rem
  3142. Method GetAnchor2:b2Vec2()
  3143. Return bmx_b2prismaticjoint_getanchor2(b2ObjectPtr)
  3144. End Method
  3145. Rem
  3146. bbdoc: Get the reaction force on body2 at the joint anchor.
  3147. End Rem
  3148. Method GetReactionForce:b2Vec2(inv_dt:Float)
  3149. Return bmx_b2prismaticjoint_getreactionforce(b2ObjectPtr, inv_dt)
  3150. End Method
  3151. Rem
  3152. bbdoc: Get the reaction torque on body2.
  3153. End Rem
  3154. Method GetReactionTorque:Float(inv_dt:Float)
  3155. Return bmx_b2prismaticjoint_getreactiontorque(b2ObjectPtr, inv_dt)
  3156. End Method
  3157. Rem
  3158. bbdoc: Get the current joint translation, usually in meters.
  3159. End Rem
  3160. Method GetJointTranslation:Float()
  3161. Return bmx_b2prismaticjoint_getjointtranslation(b2ObjectPtr)
  3162. End Method
  3163. Rem
  3164. bbdoc: Get the current joint translation speed, usually in meters per second.
  3165. end rem
  3166. Method GetJointSpeed:Float()
  3167. Return bmx_b2prismaticjoint_getjointspeed(b2ObjectPtr)
  3168. End Method
  3169. Rem
  3170. bbdoc: Is the joint limit enabled?
  3171. end rem
  3172. Method IsLimitEnabled:Int()
  3173. Return bmx_b2prismaticjoint_islimitenabled(b2ObjectPtr)
  3174. End Method
  3175. Rem
  3176. bbdoc: Enable/disable the joint limit.
  3177. end rem
  3178. Method EnableLimit(flag:Int)
  3179. bmx_b2prismaticjoint_enablelimit(b2ObjectPtr, flag)
  3180. End Method
  3181. Rem
  3182. bbdoc: Get the lower joint limit, usually in meters.
  3183. end rem
  3184. Method GetLowerLimit:Float()
  3185. Return bmx_b2prismaticjoint_getlowerlimit(b2ObjectPtr)
  3186. End Method
  3187. Rem
  3188. bbdoc: Get the upper joint limit, usually in meters.
  3189. end rem
  3190. Method GetUpperLimit:Float()
  3191. Return bmx_b2prismaticjoint_getupperlimit(b2ObjectPtr)
  3192. End Method
  3193. Rem
  3194. bbdoc: Set the joint limits, usually in meters.
  3195. end rem
  3196. Method SetLimits(lowerLimit:Float, upperLimit:Float)
  3197. bmx_b2prismaticjoint_setlimits(b2ObjectPtr, lowerLimit, upperLimit)
  3198. End Method
  3199. Rem
  3200. bbdoc: Is the joint motor enabled?
  3201. end rem
  3202. Method IsMotorEnabled:Int()
  3203. Return bmx_b2prismaticjoint_ismotorenabled(b2ObjectPtr)
  3204. End Method
  3205. Rem
  3206. bbdoc: Enable/disable the joint motor.
  3207. end rem
  3208. Method EnableMotor(flag:Int)
  3209. bmx_b2prismaticjoint_enablemotor(b2ObjectPtr, flag)
  3210. End Method
  3211. Rem
  3212. bbdoc: Set the motor speed, usually in meters per second.
  3213. end rem
  3214. Method SetMotorSpeed(speed:Float)
  3215. bmx_b2prismaticjoint_setmotorspeed(b2ObjectPtr, speed)
  3216. End Method
  3217. Rem
  3218. bbdoc: Get the motor speed, usually in meters per second.
  3219. end rem
  3220. Method GetMotorSpeed:Float()
  3221. Return bmx_b2prismaticjoint_getmotorspeed(b2ObjectPtr)
  3222. End Method
  3223. Rem
  3224. bbdoc: Set the maximum motor force, usually in N.
  3225. end rem
  3226. Method SetMaxMotorForce(force:Float)
  3227. bmx_b2prismaticjoint_setmaxmotorforce(b2ObjectPtr, force)
  3228. End Method
  3229. Rem
  3230. bbdoc: Get the current motor force, usually in N.
  3231. end rem
  3232. Method GetMotorForce:Float()
  3233. Return bmx_b2prismaticjoint_getmotorforce(b2ObjectPtr)
  3234. End Method
  3235. End Type
  3236. Rem
  3237. bbdoc: The pulley joint is connected to two bodies and two fixed ground points.
  3238. about: The pulley supports a ratio such that:
  3239. <pre>
  3240. length1 + ratio * length2 <= constant
  3241. </pre>
  3242. Yes, the force transmitted is scaled by the ratio. The pulley also enforces a maximum length limit on both sides.
  3243. This is useful to prevent one side of the pulley hitting the top.
  3244. End Rem
  3245. Type b2PulleyJoint Extends b2Joint
  3246. Rem
  3247. bbdoc: Get the anchor point on body1 in world coordinates.
  3248. End Rem
  3249. Method GetAnchor1:b2Vec2()
  3250. Return bmx_b2pulleyjoint_getanchor1(b2ObjectPtr)
  3251. End Method
  3252. Rem
  3253. bbdoc: Get the anchor point on body2 in world coordinates.
  3254. End Rem
  3255. Method GetAnchor2:b2Vec2()
  3256. Return bmx_b2pulleyjoint_getanchor2(b2ObjectPtr)
  3257. End Method
  3258. Rem
  3259. bbdoc: Get the reaction force on body2 at the joint anchor.
  3260. End Rem
  3261. Method GetReactionForce:b2Vec2(inv_dt:Float)
  3262. Return bmx_b2pulleyjoint_getreactionforce(b2ObjectPtr, inv_dt)
  3263. End Method
  3264. Rem
  3265. bbdoc: Get the reaction torque on body2.
  3266. End Rem
  3267. Method GetReactionTorque:Float(inv_dt:Float)
  3268. Return bmx_b2pulleyjoint_getreactiontorque(b2ObjectPtr, inv_dt)
  3269. End Method
  3270. Rem
  3271. bbdoc: Get the first ground anchor.
  3272. End Rem
  3273. Method GetGroundAnchor1:b2Vec2()
  3274. Return bmx_b2pulleyjoint_getgroundanchor1(b2ObjectPtr)
  3275. End Method
  3276. Rem
  3277. bbdoc: Get the second ground anchor.
  3278. end rem
  3279. Method GetGroundAnchor2:b2Vec2()
  3280. Return bmx_b2pulleyjoint_getgroundanchor2(b2ObjectPtr)
  3281. End Method
  3282. Rem
  3283. bbdoc: Get the current length of the segment attached to body1.
  3284. end rem
  3285. Method GetLength1:Float()
  3286. Return bmx_b2pulleyjoint_getlength1(b2ObjectPtr)
  3287. End Method
  3288. Rem
  3289. bbdoc: Get the current length of the segment attached to body2.
  3290. end rem
  3291. Method GetLength2:Float()
  3292. Return bmx_b2pulleyjoint_getlength2(b2ObjectPtr)
  3293. End Method
  3294. Rem
  3295. bbdoc: Get the pulley ratio.
  3296. end rem
  3297. Method GetRatio:Float()
  3298. Return bmx_b2pulleyjoint_getratio(b2ObjectPtr)
  3299. End Method
  3300. End Type
  3301. Rem
  3302. bbdoc: A mouse joint is used to make a point on a body track a specified world point.
  3303. about: This a soft constraint with a maximum force. This allows the constraint to stretch and without applying huge forces.
  3304. End Rem
  3305. Type b2MouseJoint Extends b2Joint
  3306. Rem
  3307. bbdoc: Get the anchor point on body1 in world coordinates.
  3308. End Rem
  3309. Method GetAnchor1:b2Vec2()
  3310. Return bmx_b2mousejoint_getanchor1(b2ObjectPtr)
  3311. End Method
  3312. Rem
  3313. bbdoc: Get the anchor point on body2 in world coordinates.
  3314. End Rem
  3315. Method GetAnchor2:b2Vec2()
  3316. Return bmx_b2mousejoint_getanchor2(b2ObjectPtr)
  3317. End Method
  3318. Rem
  3319. bbdoc: Get the reaction force on body2 at the joint anchor.
  3320. End Rem
  3321. Method GetReactionForce:b2Vec2(inv_dt:Float)
  3322. Return bmx_b2mousejoint_getreactionforce(b2ObjectPtr, inv_dt)
  3323. End Method
  3324. Rem
  3325. bbdoc: Get the reaction torque on body2.
  3326. End Rem
  3327. Method GetReactionTorque:Float(inv_dt:Float)
  3328. Return bmx_b2mousejoint_getreactiontorque(b2ObjectPtr, inv_dt)
  3329. End Method
  3330. Rem
  3331. bbdoc: Use this to update the target point.
  3332. End Rem
  3333. Method SetTarget(target:b2Vec2)
  3334. bmx_b2mousejoint_settarget(b2ObjectPtr, target)
  3335. End Method
  3336. Rem
  3337. bbdoc: Returns the target point.
  3338. End Rem
  3339. Method GetTarget:b2Vec2()
  3340. Return bmx_b2mousejoint_gettarget(b2ObjectPtr)
  3341. End Method
  3342. Rem
  3343. bbdoc: Returns the local anchor.
  3344. End Rem
  3345. Method GetLocalAnchor:b2Vec2()
  3346. Return bmx_b2mousejoint_getlocalanchor(b2ObjectPtr)
  3347. End Method
  3348. End Type
  3349. Rem
  3350. bbdoc: A gear joint is used to connect two joints together.
  3351. about: Either joint can be a revolute or prismatic joint. You specify a gear ratio to bind the motions
  3352. together:
  3353. <pre>
  3354. coordinate1 + ratio * coordinate2 = constant
  3355. </pre>
  3356. The ratio can be negative or positive. If one joint is a revolute joint and the other joint is a prismatic
  3357. joint, then the ratio will have units of length or units of 1/length.
  3358. <p>
  3359. Warning: The revolute and prismatic joints must be attached to fixed bodies (which must be body1 on those
  3360. joints).
  3361. </p>
  3362. End Rem
  3363. Type b2GearJoint Extends b2Joint
  3364. Rem
  3365. bbdoc: Get the anchor point on body1 in world coordinates.
  3366. End Rem
  3367. Method GetAnchor1:b2Vec2()
  3368. Return bmx_b2gearjoint_getanchor1(b2ObjectPtr)
  3369. End Method
  3370. Rem
  3371. bbdoc: Get the anchor point on body2 in world coordinates.
  3372. End Rem
  3373. Method GetAnchor2:b2Vec2()
  3374. Return bmx_b2gearjoint_getanchor2(b2ObjectPtr)
  3375. End Method
  3376. Rem
  3377. bbdoc: Get the reaction force on body2 at the joint anchor.
  3378. End Rem
  3379. Method GetReactionForce:b2Vec2(inv_dt:Float)
  3380. Return bmx_b2gearjoint_getreactionforce(b2ObjectPtr, inv_dt)
  3381. End Method
  3382. Rem
  3383. bbdoc: Get the reaction torque on body2.
  3384. End Rem
  3385. Method GetReactionTorque:Float(inv_dt:Float)
  3386. Return bmx_b2gearjoint_getreactiontorque(b2ObjectPtr, inv_dt)
  3387. End Method
  3388. Rem
  3389. bbdoc: Get the gear ratio.
  3390. End Rem
  3391. Method GetRatio:Float()
  3392. Return bmx_b2gearjoint_getratio(b2ObjectPtr)
  3393. End Method
  3394. End Type
  3395. Rem
  3396. bbdoc: A transform contains translation and rotation.
  3397. about: It is used to represent the position and orientation of rigid frames.
  3398. End Rem
  3399. Struct b2XForm
  3400. Field position:b2Vec2
  3401. Field R:b2Mat22
  3402. Rem
  3403. bbdoc:
  3404. End Rem
  3405. Method Create:b2XForm()
  3406. Return Self
  3407. End Method
  3408. Rem
  3409. bbdoc:
  3410. End Rem
  3411. Method GetPosition:b2Vec2()
  3412. Return position
  3413. End Method
  3414. Rem
  3415. bbdoc:
  3416. End Rem
  3417. Method SetPosition(pos:b2Vec2)
  3418. position = pos
  3419. End Method
  3420. Rem
  3421. bbdoc:
  3422. End Rem
  3423. Method SetR(r:b2Mat22)
  3424. Self.R = r
  3425. 'bmx_b2xform_setr(b2ObjectPtr, r.b2ObjectPtr)
  3426. End Method
  3427. End Struct
  3428. Rem
  3429. bbdoc: A 2-by-2 matrix.
  3430. about: Stored in column-major order.
  3431. End Rem
  3432. Struct b2Mat22
  3433. Field col1:b2Vec2
  3434. Field col2:b2Vec2
  3435. Rem
  3436. bbdoc: Constructs the matrix using scalars.
  3437. End Rem
  3438. Method Create:b2Mat22(a11:Float = 0, a12:Float = 0, a21:Float = 0, a22:Float = 0)
  3439. col1.x = a11
  3440. col1.y = a21
  3441. col2.x = a12
  3442. col2.y = a22
  3443. Return Self
  3444. End Method
  3445. Rem
  3446. bbdoc: Constructs the matrix using columns.
  3447. End Rem
  3448. Method CreateVec:b2Mat22(c1:b2Vec2, c2:b2Vec2)
  3449. col1 = c1
  3450. col2 = c2
  3451. Return Self
  3452. End Method
  3453. Rem
  3454. bbdoc: Constructs the matrix using an angle.
  3455. about: This matrix becomes an orthonormal rotation matrix.
  3456. End Rem
  3457. Method CreateAngle:b2Mat22(angle:Float)
  3458. bmx_b2mat22_createangle(Self, angle)
  3459. Return Self
  3460. End Method
  3461. Rem
  3462. bbdoc: Initialize this matrix using an angle.
  3463. about: This matrix becomes an orthonormal rotation matrix.
  3464. End Rem
  3465. Method SetAngle(angle:Float)
  3466. bmx_b2mat22_setangle(Self, angle)
  3467. End Method
  3468. Rem
  3469. bbdoc: Returns the angle.
  3470. End Rem
  3471. Method GetAngle:Float()
  3472. Return bmx_b2mat22_getangle(Self)
  3473. End Method
  3474. Rem
  3475. bbdoc: Set this to the identity matrix.
  3476. End Rem
  3477. Method SetIdentity()
  3478. col1.x = 1.0
  3479. col2.x = 0.0
  3480. col1.y = 0.0
  3481. col2.y = 1.0
  3482. End Method
  3483. Rem
  3484. bbdoc: Set this matrix to all zeros.
  3485. End Rem
  3486. Method SetZero()
  3487. col1.x = 0.0
  3488. col2.x = 0.0
  3489. col1.y = 0.0
  3490. col2.y = 0.0
  3491. End Method
  3492. Rem
  3493. bbdoc: Computes the inverse of this matrix, such that inv(A) * A = identity.
  3494. End Rem
  3495. Method GetInverse:b2Mat22()
  3496. Return bmx_b2mat22_getinverse(Self)
  3497. End Method
  3498. End Struct
  3499. Rem
  3500. bbdoc: An oriented bounding box.
  3501. End Rem
  3502. Type b2OBB
  3503. Field b2ObjectPtr:Byte Ptr
  3504. Function _create:b2OBB(b2ObjectPtr:Byte Ptr)
  3505. If b2ObjectPtr Then
  3506. Local this:b2OBB = New b2OBB
  3507. this.b2ObjectPtr = b2ObjectPtr
  3508. Return this
  3509. End If
  3510. End Function
  3511. Rem
  3512. bbdoc: Returns the rotation matrix.
  3513. End Rem
  3514. Method GetRotationMatrix:b2Mat22()
  3515. Return bmx_b2obb_getrotationmatrix(b2ObjectPtr)
  3516. End Method
  3517. Rem
  3518. bbdoc: Returns the local centroid.
  3519. End Rem
  3520. Method GetCenter:b2Vec2()
  3521. Return bmx_b2obb_getcenter(b2ObjectPtr)
  3522. End Method
  3523. Rem
  3524. bbdoc: Returns the half-widths.
  3525. End Rem
  3526. Method GetExtents:b2Vec2()
  3527. Return bmx_b2obb_getextents(b2ObjectPtr)
  3528. End Method
  3529. End Type
  3530. Rem
  3531. bbdoc: A line segment.
  3532. End Rem
  3533. Struct b2Segment
  3534. Field p1:b2Vec2
  3535. Field p2:b2Vec2
  3536. Rem
  3537. bbdoc: Creates a new b2Segment object.
  3538. End Rem
  3539. Method CreateXY:b2Segment(x1:Float, y1:Float, x2:Float, y2:Float)
  3540. p1.x = x1
  3541. p1.y = y1
  3542. p2.x = x2
  3543. p2.y = y2
  3544. Return Self
  3545. End Method
  3546. Method Create:b2Segment()
  3547. Return Self
  3548. End Method
  3549. Rem
  3550. bbdoc: Creates a new b2Segment object.
  3551. End Rem
  3552. Method Create:b2Segment(p1:b2Vec2, p2:b2Vec2)
  3553. Self.p1 = p1
  3554. Self.p2 = p2
  3555. Return Self
  3556. End Method
  3557. Rem
  3558. bbdoc: Returns the start point of this segment.
  3559. End Rem
  3560. Method GetStartPoint:b2Vec2()
  3561. Return p1
  3562. End Method
  3563. Rem
  3564. bbdoc: Returns the end point of this segment.
  3565. End Rem
  3566. Method GetEndPoint:b2Vec2()
  3567. Return p2
  3568. End Method
  3569. Rem
  3570. bbdoc: Sets the start point of this segment.
  3571. End Rem
  3572. Method SetStartPoint(point:b2Vec2)
  3573. p1 = point
  3574. End Method
  3575. Rem
  3576. bbdoc: Sets the end point of this segment.
  3577. End Rem
  3578. Method SetEndPoint(point:b2Vec2)
  3579. p2 = point
  3580. End Method
  3581. End Struct
  3582. Rem
  3583. bbdoc: A controller edge is used to connect bodies and controllers together in a bipartite graph.
  3584. End Rem
  3585. Type b2ControllerEdge
  3586. Field b2ObjectPtr:Byte Ptr
  3587. Function _create:b2ControllerEdge(b2ObjectPtr:Byte Ptr)
  3588. If b2ObjectPtr Then
  3589. Local this:b2ControllerEdge = New b2ControllerEdge
  3590. this.b2ObjectPtr = b2ObjectPtr
  3591. Return this
  3592. End If
  3593. End Function
  3594. Rem
  3595. bbdoc: Provides quick access to other end of this edge.
  3596. End Rem
  3597. Method GetController:b2Controller()
  3598. Return b2Controller._create(bmx_b2controlleredge_getcontroller(b2ObjectPtr))
  3599. End Method
  3600. Rem
  3601. bbdoc: Returns the body.
  3602. End Rem
  3603. Method GetBody:b2Body()
  3604. Return b2Body._create(bmx_b2controlleredge_getbody(b2ObjectPtr))
  3605. End Method
  3606. Rem
  3607. bbdoc: Returns the previous controller edge in the controllers's joint list.
  3608. End Rem
  3609. Method GetPrevBody:b2ControllerEdge()
  3610. Return b2ControllerEdge._create(bmx_b2controlleredge_getprevbody(b2ObjectPtr))
  3611. End Method
  3612. Rem
  3613. bbdoc: Returns the next controller edge in the controllers's joint list.
  3614. End Rem
  3615. Method GetNexBody:b2ControllerEdge()
  3616. Return b2ControllerEdge._create(bmx_b2controlleredge_getnextbody(b2ObjectPtr))
  3617. End Method
  3618. Rem
  3619. bbdoc: Returns the previous controller edge in the body's joint list.
  3620. End Rem
  3621. Method GetPrevController:b2ControllerEdge()
  3622. Return b2ControllerEdge._create(bmx_b2controlleredge_getprevcontroller(b2ObjectPtr))
  3623. End Method
  3624. Rem
  3625. bbdoc: Returns the next controller edge in the body's joint list.
  3626. End Rem
  3627. Method GetNextController:b2ControllerEdge()
  3628. Return b2ControllerEdge._create(bmx_b2controlleredge_getnextcontroller(b2ObjectPtr))
  3629. End Method
  3630. End Type
  3631. Type b2ControllerDef
  3632. Field b2ObjectPtr:Byte Ptr
  3633. Field userData:Object
  3634. Field _type:Int
  3635. End Type
  3636. Rem
  3637. bbdoc: Used to build buoyancy controllers
  3638. End Rem
  3639. Type b2BuoyancyControllerDef Extends b2ControllerDef
  3640. Method New()
  3641. b2ObjectPtr = bmx_b2buoyancycontrollerdef_create()
  3642. _type = e_buoyancyController
  3643. End Method
  3644. Rem
  3645. bbdoc: Returns the outer surface normal.
  3646. End Rem
  3647. Method GetNormal:b2Vec2()
  3648. Return bmx_b2buoyancycontrollerdef_getnormal(b2ObjectPtr)
  3649. End Method
  3650. Rem
  3651. bbdoc: Sets the outer surface normal.
  3652. End Rem
  3653. Method SetNormal(normal:b2Vec2)
  3654. bmx_b2buoyancycontrollerdef_setnormal(b2ObjectPtr, normal)
  3655. End Method
  3656. Rem
  3657. bbdoc: Returns the height of the fluid surface along the normal.
  3658. End Rem
  3659. Method GetOffset:Float()
  3660. Return bmx_b2buoyancycontrollerdef_getoffset(b2ObjectPtr)
  3661. End Method
  3662. Rem
  3663. bbdoc: Sets the height of the fluid surface along the normal.
  3664. End Rem
  3665. Method SetOffset(offset:Float)
  3666. bmx_b2buoyancycontrollerdef_setoffset(b2ObjectPtr, offset)
  3667. End Method
  3668. Rem
  3669. bbdoc: Returns the fluid density.
  3670. End Rem
  3671. Method GetDensity:Float()
  3672. Return bmx_b2buoyancycontrollerdef_getdensity(b2ObjectPtr)
  3673. End Method
  3674. Rem
  3675. bbdoc: Sets the fluid density.
  3676. End Rem
  3677. Method SetDensity(density:Float)
  3678. bmx_b2buoyancycontrollerdef_setdensity(b2ObjectPtr, density)
  3679. End Method
  3680. Rem
  3681. bbdoc: Returns the fluid velocity, for drag calculations.
  3682. End Rem
  3683. Method GetVelocity:b2Vec2()
  3684. Return bmx_b2buoyancycontrollerdef_getvelocity(b2ObjectPtr)
  3685. End Method
  3686. Rem
  3687. bbdoc: Sets the fluid velocity, for drag calculations.
  3688. End Rem
  3689. Method SetVelocity(velocity:b2Vec2)
  3690. bmx_b2buoyancycontrollerdef_setvelocity(b2ObjectPtr, velocity)
  3691. End Method
  3692. Rem
  3693. bbdoc: Returns the linear drag co-efficient.
  3694. End Rem
  3695. Method GetLinearDrag:Float()
  3696. Return bmx_b2buoyancycontrollerdef_getlineardrag(b2ObjectPtr)
  3697. End Method
  3698. Rem
  3699. bbdoc: Sets the linear drag co-efficient.
  3700. End Rem
  3701. Method SetLinearDrag(drag:Float)
  3702. bmx_b2buoyancycontrollerdef_setlineardrag(b2ObjectPtr, drag)
  3703. End Method
  3704. Rem
  3705. bbdoc: Returns the angular drag co-efficient.
  3706. End Rem
  3707. Method GetAngularDrag:Float()
  3708. Return bmx_b2buoyancycontrollerdef_getangulardrag(b2ObjectPtr)
  3709. End Method
  3710. Rem
  3711. bbdoc: Sets the angular drag co-efficient.
  3712. End Rem
  3713. Method SetAngularDrag(drag:Float)
  3714. bmx_b2buoyancycontrollerdef_setangulardrag(b2ObjectPtr, drag)
  3715. End Method
  3716. Rem
  3717. bbdoc: Returns False if bodies are assumed to be uniformly dense, otherwise use the shapes densities.
  3718. End Rem
  3719. Method UsesDensity:Int()
  3720. Return bmx_b2buoyancycontrollerdef_usesdensity(b2ObjectPtr)
  3721. End Method
  3722. Rem
  3723. bbdoc: Set to False, if bodies are assumed to be uniformly dense, otherwise use the shapes densities.
  3724. End Rem
  3725. Method SetUsesDensity(value:Int)
  3726. bmx_b2buoyancycontrollerdef_setusesdensity(b2ObjectPtr, value)
  3727. End Method
  3728. Rem
  3729. bbdoc: Returns True, if gravity is taken from the world instead of the gravity parameter.
  3730. End Rem
  3731. Method UsesWorldGravity:Int()
  3732. Return bmx_b2buoyancycontrollerdef_usesworldgravity(b2ObjectPtr)
  3733. End Method
  3734. Rem
  3735. bbdoc: Set to True, if gravity is to be taken from the world instead of the gravity parameter.
  3736. End Rem
  3737. Method SetUsesWorldGravity(value:Int)
  3738. bmx_b2buoyancycontrollerdef_setusesworldgravity(b2ObjectPtr, value)
  3739. End Method
  3740. Rem
  3741. bbdoc: Returns the gravity vector, if the world's gravity is not used.
  3742. End Rem
  3743. Method GetGravity:b2Vec2()
  3744. Return bmx_b2buoyancycontrollerdef_getgravity(b2ObjectPtr)
  3745. End Method
  3746. Rem
  3747. bbdoc: Returns the gravity vector, if the world's gravity is not used.
  3748. End Rem
  3749. Method SetGravity(gravity:b2Vec2)
  3750. bmx_b2buoyancycontrollerdef_setgravity(b2ObjectPtr, gravity)
  3751. End Method
  3752. Method Delete()
  3753. If b2ObjectPtr Then
  3754. bmx_b2buoyancycontrollerdef_delete(b2ObjectPtr)
  3755. b2ObjectPtr = Null
  3756. End If
  3757. End Method
  3758. End Type
  3759. Rem
  3760. bbdoc: Used to build tensor damping controllers.
  3761. End Rem
  3762. Type b2TensorDampingControllerDef Extends b2ControllerDef
  3763. Method New()
  3764. b2ObjectPtr = bmx_b2tensordampingcontrollerdef_create()
  3765. _type = e_tensorDampingController
  3766. End Method
  3767. Rem
  3768. bbdoc: Returns the tensor to use in damping model.
  3769. End Rem
  3770. Method GetTensor:b2Mat22()
  3771. Return bmx_b2tensordampingcontrollerdef_gettensor(b2ObjectPtr)
  3772. End Method
  3773. Rem
  3774. bbdoc: Sets the tensor to use in damping model.
  3775. about: Some examples (matrixes in format (row1; row2) )
  3776. <table>
  3777. <th><td>Matrix</td><td>Description</td></th>
  3778. <tr><td>(-a 0;0 -a)</td><td>Standard isotropic damping with strength a</td></tr>
  3779. <tr><td>(0 a;-a 0)</td><td>Electron in fixed field - a force at right angles to velocity with proportional magnitude</td></tr>
  3780. <tr><td>(-a 0;0 -b)</td><td>Differing x and y damping. Useful e.g. for top-down wheels.</td></tr>
  3781. </table>
  3782. <p>
  3783. By the way, tensor in this case just means matrix, don't let the terminology get you down.
  3784. </p>
  3785. End Rem
  3786. Method SetTensor(tensor:b2Mat22)
  3787. bmx_b2tensordampingcontrollerdef_settensor(b2ObjectPtr, tensor)
  3788. End Method
  3789. Rem
  3790. bbdoc: Returns the maximum amount of damping.
  3791. End Rem
  3792. Method GetMaxTimestep:Float()
  3793. Return bmx_b2tensordampingcontrollerdef_getmaxtimestep(b2ObjectPtr)
  3794. End Method
  3795. Rem
  3796. bbdoc: Set this to a positive number to clamp the maximum amount of damping done.
  3797. End Rem
  3798. Method SetMaxTimestep(timestep:Float)
  3799. bmx_b2tensordampingcontrollerdef_setmaxtimestep(b2ObjectPtr, timestep)
  3800. End Method
  3801. Rem
  3802. bbdoc: Sets damping independently along the x and y axes.
  3803. End Rem
  3804. Method SetAxisAligned(xDamping:Float, yDamping:Float)
  3805. bmx_b2tensordampingcontrollerdef_setaxisaligned(b2ObjectPtr, xDamping, yDamping)
  3806. End Method
  3807. Method Delete()
  3808. If b2ObjectPtr Then
  3809. bmx_b2tensordampingcontrollerdef_delete(b2ObjectPtr)
  3810. b2ObjectPtr = Null
  3811. End If
  3812. End Method
  3813. End Type
  3814. Rem
  3815. bbdoc: Used to build gravity controllers.
  3816. End Rem
  3817. Type b2GravityControllerDef Extends b2ControllerDef
  3818. Method New()
  3819. b2ObjectPtr = bmx_b2gravitycontrollerdef_create()
  3820. _type = e_gravityController
  3821. End Method
  3822. Rem
  3823. bbdoc: Returns the strength of the gravitiation force.
  3824. End Rem
  3825. Method GetForce:Float()
  3826. Return bmx_b2gravitycontrollerdef_getforce(b2ObjectPtr)
  3827. End Method
  3828. Rem
  3829. bbdoc: Sets the strength of the gravitiation force.
  3830. End Rem
  3831. Method SetForce(force:Float)
  3832. bmx_b2gravitycontrollerdef_setforce(b2ObjectPtr, force)
  3833. End Method
  3834. Rem
  3835. bbdoc: Returns whether gravity is proportional to r^-2 (True), otherwise r^-1 (False).
  3836. End Rem
  3837. Method IsInvSqr:Int()
  3838. Return bmx_b2gravitycontrollerdef_isinvsqr(b2ObjectPtr)
  3839. End Method
  3840. Rem
  3841. bbdoc: Sets whether gravity is proportional to r^-2 (True), otherwise r^-1 (False).
  3842. End Rem
  3843. Method SetIsInvSqr(value:Int)
  3844. bmx_b2gravitycontrollerdef_setisinvsqr(b2ObjectPtr, value)
  3845. End Method
  3846. Method Delete()
  3847. If b2ObjectPtr Then
  3848. bmx_b2gravitycontrollerdef_delete(b2ObjectPtr)
  3849. b2ObjectPtr = Null
  3850. End If
  3851. End Method
  3852. End Type
  3853. Rem
  3854. bbdoc: Used to build constant force controllers.
  3855. End Rem
  3856. Type b2ConstantForceControllerDef Extends b2ControllerDef
  3857. Method New()
  3858. b2ObjectPtr = bmx_b2constantforcecontrollerdef_create()
  3859. _type = e_constantForceController
  3860. End Method
  3861. Rem
  3862. bbdoc: Returns the force to apply.
  3863. End Rem
  3864. Method GetForce:b2Vec2()
  3865. Return bmx_b2constantforcecontrollerdef_getforce(b2ObjectPtr)
  3866. End Method
  3867. Rem
  3868. bbdoc: Sets the force to apply.
  3869. End Rem
  3870. Method SetForce(force:b2Vec2)
  3871. bmx_b2constantforcecontrollerdef_setforce(b2ObjectPtr, force)
  3872. End Method
  3873. Method Delete()
  3874. If b2ObjectPtr Then
  3875. bmx_b2constantforcecontrollerdef_delete(b2ObjectPtr)
  3876. b2ObjectPtr = Null
  3877. End If
  3878. End Method
  3879. End Type
  3880. Rem
  3881. bbdoc: Used to build constant acceleration controllers.
  3882. End Rem
  3883. Type b2ConstantAccelControllerDef Extends b2ControllerDef
  3884. Method New()
  3885. b2ObjectPtr = bmx_b2constantaccelcontrollerdef_create()
  3886. _type = e_constantAccelController
  3887. End Method
  3888. Rem
  3889. bbdoc: Returns the force to apply.
  3890. End Rem
  3891. Method GetForce:b2Vec2()
  3892. Return bmx_b2constantaccelcontrollerdef_getforce(b2ObjectPtr)
  3893. End Method
  3894. Rem
  3895. bbdoc: Sets the force to apply.
  3896. End Rem
  3897. Method SetForce(force:b2Vec2)
  3898. bmx_b2constantaccelcontrollerdef_setforce(b2ObjectPtr, force)
  3899. End Method
  3900. Method Delete()
  3901. If b2ObjectPtr Then
  3902. bmx_b2constantaccelcontrollerdef_delete(b2ObjectPtr)
  3903. b2ObjectPtr = Null
  3904. End If
  3905. End Method
  3906. End Type
  3907. Rem
  3908. bbdoc: Base type for controllers.
  3909. about: Controllers are a convience for encapsulating common per-step functionality.
  3910. End Rem
  3911. Type b2Controller
  3912. Field b2ObjectPtr:Byte Ptr
  3913. Field userData:Object
  3914. Function _create:b2Controller(b2ObjectPtr:Byte Ptr)
  3915. If b2ObjectPtr Then
  3916. Local controller:b2Controller = b2Controller(bmx_b2controller_getmaxcontroller(b2ObjectPtr))
  3917. If Not controller Then
  3918. controller = New b2Controller
  3919. controller.b2ObjectPtr = b2ObjectPtr
  3920. Else
  3921. If Not controller.b2ObjectPtr Then
  3922. controller.b2ObjectPtr = b2ObjectPtr
  3923. EndIf
  3924. End If
  3925. Return controller
  3926. End If
  3927. End Function
  3928. Rem
  3929. bbdoc: Adds a body to the controller list.
  3930. End Rem
  3931. Method AddBody(body:b2Body)
  3932. bmx_b2controller_addbody(b2ObjectPtr, body.b2ObjectPtr)
  3933. End Method
  3934. Rem
  3935. bbdoc: Removes a body from the controller list.
  3936. End Rem
  3937. Method RemoveBody(body:b2Body)
  3938. bmx_b2controller_removebody(b2ObjectPtr, body.b2ObjectPtr)
  3939. End Method
  3940. Rem
  3941. bbdoc: Removes all bodies from the controller list.
  3942. End Rem
  3943. Method Clear()
  3944. bmx_b2controller_clear(b2ObjectPtr)
  3945. End Method
  3946. Rem
  3947. bbdoc: Get the next controller in the world's body list.
  3948. End Rem
  3949. Method GetNext:b2Controller()
  3950. Return b2Controller._create(bmx_b2controller_getnext(b2ObjectPtr))
  3951. End Method
  3952. Rem
  3953. bbdoc: Get the parent world of this body.
  3954. End Rem
  3955. Method GetWorld:b2World()
  3956. Return b2World._create(bmx_b2controller_getworld(b2ObjectPtr))
  3957. End Method
  3958. Rem
  3959. bbdoc: Get the attached body list.
  3960. End Rem
  3961. Method GetBodyList:b2ControllerEdge()
  3962. Return b2ControllerEdge._create(bmx_b2controller_getbodylist(b2ObjectPtr))
  3963. End Method
  3964. Rem
  3965. bbdoc: Get the user data that was provided in the controller definition.
  3966. End Rem
  3967. Method GetUserData:Object()
  3968. Return userData
  3969. End Method
  3970. End Type
  3971. Rem
  3972. bbdoc: Applies a force every frame
  3973. End Rem
  3974. Type b2ConstantAccelController Extends b2Controller
  3975. Rem
  3976. bbdoc: Returns the force to apply.
  3977. End Rem
  3978. Method GetForce:b2Vec2()
  3979. Return bmx_b2constantaccelcontroller_getforce(b2ObjectPtr)
  3980. End Method
  3981. Rem
  3982. bbdoc: Sets the force to apply.
  3983. End Rem
  3984. Method SetForce(force:b2Vec2)
  3985. bmx_b2constantaccelcontroller_setforce(b2ObjectPtr, force)
  3986. End Method
  3987. End Type
  3988. Rem
  3989. bbdoc: Calculates buoyancy forces for fluids in the form of a half plane.
  3990. End Rem
  3991. Type b2BuoyancyController Extends b2Controller
  3992. Rem
  3993. bbdoc: Returns the outer surface normal.
  3994. End Rem
  3995. Method GetNormal:b2Vec2()
  3996. Return bmx_b2buoyancycontroller_getnormal(b2ObjectPtr)
  3997. End Method
  3998. Rem
  3999. bbdoc: Sets the outer surface normal.
  4000. End Rem
  4001. Method SetNormal(normal:b2Vec2)
  4002. bmx_b2buoyancycontroller_setnormal(b2ObjectPtr, normal)
  4003. End Method
  4004. Rem
  4005. bbdoc: Returns the height of the fluid surface along the normal.
  4006. End Rem
  4007. Method GetOffset:Float()
  4008. Return bmx_b2buoyancycontroller_getoffset(b2ObjectPtr)
  4009. End Method
  4010. Rem
  4011. bbdoc: Sets the height of the fluid surface along the normal.
  4012. End Rem
  4013. Method SetOffset(offset:Float)
  4014. bmx_b2buoyancycontroller_setoffset(b2ObjectPtr, offset)
  4015. End Method
  4016. Rem
  4017. bbdoc: Returns the fluid density.
  4018. End Rem
  4019. Method GetDensity:Float()
  4020. Return bmx_b2buoyancycontroller_getdensity(b2ObjectPtr)
  4021. End Method
  4022. Rem
  4023. bbdoc: Sets the fluid density.
  4024. End Rem
  4025. Method SetDensity(density:Float)
  4026. bmx_b2buoyancycontroller_setdensity(b2ObjectPtr, density)
  4027. End Method
  4028. Rem
  4029. bbdoc: Returns the fluid velocity, for drag calculations.
  4030. End Rem
  4031. Method GetVelocity:b2Vec2()
  4032. Return bmx_b2buoyancycontroller_getvelocity(b2ObjectPtr)
  4033. End Method
  4034. Rem
  4035. bbdoc: Sets the fluid velocity, for drag calculations.
  4036. End Rem
  4037. Method SetVelocity(velocity:b2Vec2)
  4038. bmx_b2buoyancycontroller_setvelocity(b2ObjectPtr, velocity)
  4039. End Method
  4040. Rem
  4041. bbdoc: Returns the linear drag co-efficient.
  4042. End Rem
  4043. Method GetLinearDrag:Float()
  4044. Return bmx_b2buoyancycontroller_getlineardrag(b2ObjectPtr)
  4045. End Method
  4046. Rem
  4047. bbdoc: Sets the linear drag co-efficient.
  4048. End Rem
  4049. Method SetLinearDrag(drag:Float)
  4050. bmx_b2buoyancycontroller_setlineardrag(b2ObjectPtr, drag)
  4051. End Method
  4052. Rem
  4053. bbdoc: Returns the angular drag co-efficient.
  4054. End Rem
  4055. Method GetAngularDrag:Float()
  4056. Return bmx_b2buoyancycontroller_getangulardrag(b2ObjectPtr)
  4057. End Method
  4058. Rem
  4059. bbdoc: Sets the angular drag co-efficient.
  4060. End Rem
  4061. Method SetAngularDrag(drag:Float)
  4062. bmx_b2buoyancycontroller_setangulardrag(b2ObjectPtr, drag)
  4063. End Method
  4064. Rem
  4065. bbdoc: Returns False if bodies are assumed to be uniformly dense, otherwise use the shapes densities.
  4066. End Rem
  4067. Method UsesDensity:Int()
  4068. Return bmx_b2buoyancycontroller_usesdensity(b2ObjectPtr)
  4069. End Method
  4070. Rem
  4071. bbdoc: Set to False, if bodies are assumed to be uniformly dense, otherwise use the shapes densities.
  4072. End Rem
  4073. Method SetUsesDensity(value:Int)
  4074. bmx_b2buoyancycontroller_setusesdensity(b2ObjectPtr, value)
  4075. End Method
  4076. Rem
  4077. bbdoc: Returns True, if gravity is taken from the world instead of the gravity parameter.
  4078. End Rem
  4079. Method UsesWorldGravity:Int()
  4080. Return bmx_b2buoyancycontroller_usesworldgravity(b2ObjectPtr)
  4081. End Method
  4082. Rem
  4083. bbdoc: Set to True, if gravity is to be taken from the world instead of the gravity parameter.
  4084. End Rem
  4085. Method SetUsesWorldGravity(value:Int)
  4086. bmx_b2buoyancycontroller_setusesworldgravity(b2ObjectPtr, value)
  4087. End Method
  4088. Rem
  4089. bbdoc: Returns the gravity vector, if the world's gravity is not used.
  4090. End Rem
  4091. Method GetGravity:b2Vec2()
  4092. Return bmx_b2buoyancycontroller_getgravity(b2ObjectPtr)
  4093. End Method
  4094. Rem
  4095. bbdoc: Returns the gravity vector, if the world's gravity is not used.
  4096. End Rem
  4097. Method SetGravity(gravity:b2Vec2)
  4098. bmx_b2buoyancycontroller_setgravity(b2ObjectPtr, gravity)
  4099. End Method
  4100. End Type
  4101. Rem
  4102. bbdoc: Applies a force every frame.
  4103. End Rem
  4104. Type b2ConstantForceController Extends b2Controller
  4105. Rem
  4106. bbdoc: Returns the force to apply.
  4107. End Rem
  4108. Method GetForce:b2Vec2()
  4109. Return bmx_b2constantaccelcontroller_getforce(b2ObjectPtr)
  4110. End Method
  4111. Rem
  4112. bbdoc: Sets the force to apply.
  4113. End Rem
  4114. Method SetForce(force:b2Vec2)
  4115. bmx_b2constantaccelcontroller_setforce(b2ObjectPtr, force)
  4116. End Method
  4117. End Type
  4118. Rem
  4119. bbdoc: Applies simplified gravity between every pair of bodies.
  4120. End Rem
  4121. Type b2GravityController Extends b2Controller
  4122. Rem
  4123. bbdoc: Returns the strength of the gravitiation force.
  4124. End Rem
  4125. Method GetForce:Float()
  4126. Return bmx_b2gravitycontroller_getforce(b2ObjectPtr)
  4127. End Method
  4128. Rem
  4129. bbdoc: Sets the strength of the gravitiation force.
  4130. End Rem
  4131. Method SetForce(force:Float)
  4132. bmx_b2gravitycontroller_setforce(b2ObjectPtr, force)
  4133. End Method
  4134. Rem
  4135. bbdoc: Returns whether gravity is proportional to r^-2 (True), otherwise r^-1 (False).
  4136. End Rem
  4137. Method IsInvSqr:Int()
  4138. Return bmx_b2gravitycontroller_isinvsqr(b2ObjectPtr)
  4139. End Method
  4140. Rem
  4141. bbdoc: Sets whether gravity is proportional to r^-2 (True), otherwise r^-1 (False).
  4142. End Rem
  4143. Method SetIsInvSqr(value:Int)
  4144. bmx_b2gravitycontroller_setisinvsqr(b2ObjectPtr, value)
  4145. End Method
  4146. End Type
  4147. Rem
  4148. bbdoc: Applies top down linear damping to the controlled bodies
  4149. about: The damping is calculated by multiplying velocity by a matrix in local co-ordinates.
  4150. End Rem
  4151. Type b2TensorDampingController Extends b2Controller
  4152. Rem
  4153. bbdoc: Returns the tensor to use in damping model.
  4154. End Rem
  4155. Method GetTensor:b2Mat22()
  4156. Return bmx_b2tensordampingcontroller_gettensor(b2ObjectPtr)
  4157. End Method
  4158. Rem
  4159. bbdoc: Sets the tensor to use in damping model.
  4160. about: Some examples (matrixes in format (row1; row2) )
  4161. <table>
  4162. <th><td>Matrix</td><td>Description</td></th>
  4163. <tr><td>(-a 0;0 -a)</td><td>Standard isotropic damping with strength a</td></tr>
  4164. <tr><td>(0 a;-a 0)</td><td>Electron in fixed field - a force at right angles to velocity with proportional magnitude</td></tr>
  4165. <tr><td>(-a 0;0 -b)</td><td>Differing x and y damping. Useful e.g. for top-down wheels.</td></tr>
  4166. </table>
  4167. <p>
  4168. By the way, tensor in this case just means matrix, don't let the terminology get you down.
  4169. </p>
  4170. End Rem
  4171. Method SetTensor(tensor:b2Mat22)
  4172. bmx_b2tensordampingcontroller_settensor(b2ObjectPtr, tensor)
  4173. End Method
  4174. Rem
  4175. bbdoc: Returns the maximum amount of damping.
  4176. End Rem
  4177. Method GetMaxTimestep:Float()
  4178. Return bmx_b2tensordampingcontroller_getmaxtimestep(b2ObjectPtr)
  4179. End Method
  4180. Rem
  4181. bbdoc: Set this to a positive number to clamp the maximum amount of damping done.
  4182. End Rem
  4183. Method SetMaxTimestep(timestep:Float)
  4184. bmx_b2tensordampingcontroller_setmaxtimestep(b2ObjectPtr, timestep)
  4185. End Method
  4186. End Type
  4187. Rem
  4188. bbdoc: Perform the cross product on a vector and a scalar.
  4189. about: In 2D this produces a vector.
  4190. End Rem
  4191. Function b2Cross:b2Vec2(a:b2Vec2, s:Float)
  4192. Return bmx_b2cross(a, s)
  4193. End Function
  4194. Rem
  4195. bbdoc: Perform the cross product on a scalar and a vector.
  4196. about: In 2D this produces a vector.
  4197. End Rem
  4198. Function b2CrossF:b2Vec2(s:Float, a:b2Vec2)
  4199. Return bmx_b2crossf(s, a)
  4200. End Function
  4201. Rem
  4202. bbdoc: Peform the dot product on two vectors.
  4203. End Rem
  4204. Function b2Dot:Float(a:b2Vec2, b:b2Vec2)
  4205. Return bmx_b2dot(a, b)
  4206. End Function
  4207. Rem
  4208. bbdoc: Multiply a matrix times a vector.
  4209. about: If a rotation matrix is provided, then this transforms the vector from one frame to another.
  4210. End Rem
  4211. Function b2Mul:b2Vec2(A:b2Mat22, v:b2Vec2)
  4212. Return bmx_b2mul(A, v)
  4213. End Function
  4214. Rem
  4215. bbdoc: Multiply a matrix transpose times a vector.
  4216. about: If a rotation matrix is provided, then this transforms the vector from one frame to another
  4217. (inverse transform).
  4218. End Rem
  4219. Function b2MulT:b2Vec2(A:b2Mat22, v:b2Vec2)
  4220. Return bmx_b2mult(A, v)
  4221. End Function
  4222. Rem
  4223. bbdoc:
  4224. end rem
  4225. Function b2MulF:b2Vec2(T:b2XForm, v:b2Vec2)
  4226. Return bmx_b2mulf(T, v)
  4227. End Function
  4228. Rem
  4229. bbdoc:
  4230. end rem
  4231. Function b2MulTF:b2Vec2(T:b2XForm, v:b2Vec2)
  4232. Return bmx_b2multf(T, v)
  4233. End Function
  4234. Extern
  4235. Function bmx_b2world_create:Byte Ptr(worldAABB:b2AABB Var, gravity:b2Vec2 Var, doSleep:Int)
  4236. Function bmx_b2world_setgravity(handle:Byte Ptr, gravity:b2Vec2 Var)
  4237. Function bmx_b2world_raycastone:Byte Ptr(handle:Byte Ptr, segment:b2Segment Var, lambda:Float Ptr, normal:b2Vec2 Var, solidShapes:Int)
  4238. Function bmx_b2world_inrange:Int(handle:Byte Ptr, aabb:b2AABB Var)
  4239. Function bmx_b2abb_isvalid:Int(handle:b2AABB Var)
  4240. Function bmx_b2vec2_add(v:b2Vec2 Var, vec:b2Vec2 Var)
  4241. Function bmx_b2vec2_copy(v:b2Vec2 Var, vec:b2Vec2 Var)
  4242. Function bmx_b2vec2_set(v:b2Vec2 Var, x:Float, y:Float)
  4243. Function bmx_b2vec2_subtract:b2Vec2(v:b2Vec2 Var, vec:b2Vec2 Var)
  4244. Function bmx_b2vec2_length:Float(v:b2Vec2 Var)
  4245. Function bmx_b2vec2_multiply(v:b2Vec2 Var, value:Float)
  4246. Function bmx_b2vec2_plus:b2Vec2(v:b2Vec2 Var, vec:b2Vec2 Var)
  4247. Function bmx_b2vec2_normalize:Float(v:b2Vec2 Var)
  4248. Function bmx_b2vec2_lengthsquared:Float(v:b2Vec2 Var)
  4249. Function bmx_b2mat22_createangle(handle:b2Mat22 Var, angle:Float)
  4250. Function bmx_b2mat22_setangle(handle:b2Mat22 Var, angle:Float)
  4251. Function bmx_b2mat22_getangle:Float(handle:b2Mat22 Var)
  4252. Function bmx_b2mat22_getinverse:b2Mat22(handle:b2Mat22 Var)
  4253. Function bmx_b2obb_getrotationmatrix:b2Mat22(handle:Byte Ptr)
  4254. Function bmx_b2obb_getcenter:b2Vec2(handle:Byte Ptr)
  4255. Function bmx_b2obb_getextents:b2Vec2(handle:Byte Ptr)
  4256. Function bmx_b2revolutejointdef_initialize(handle:Byte Ptr, body1:Byte Ptr, body2:Byte Ptr, anchor:b2Vec2 Var)
  4257. Function bmx_b2revolutejointdef_setlocalanchor1(handle:Byte Ptr, anchor:b2Vec2 Var)
  4258. Function bmx_b2revolutejointdef_setlocalanchor2(handle:Byte Ptr, anchor:b2Vec2 Var)
  4259. Function bmx_b2revolutejointdef_getlocalanchor1:b2Vec2(handle:Byte Ptr)
  4260. Function bmx_b2revolutejointdef_getlocalanchor2:b2Vec2(handle:Byte Ptr)
  4261. Function bmx_b2cross:b2Vec2(a:b2Vec2 Var, s:Float)
  4262. Function bmx_b2crossf:b2Vec2(s:Float, a:b2Vec2 Var)
  4263. Function bmx_b2mul:b2Vec2(A:b2Mat22 Var, v:b2Vec2 Var)
  4264. Function bmx_b2mult:b2Vec2(A:b2Mat22 Var, v:b2Vec2 Var)
  4265. Function bmx_b2mulf:b2Vec2(T:b2XForm Var, v:b2Vec2 Var)
  4266. Function bmx_b2multf:b2Vec2(T:b2XForm Var, v:b2Vec2 Var)
  4267. Function bmx_b2dot:Float(a:b2Vec2 Var, b:b2Vec2 Var)
  4268. Function bmx_b2body_setlinearvelocity(handle:Byte Ptr, v:b2Vec2 Var)
  4269. Function bmx_b2body_getlinearvelocity:b2Vec2(handle:Byte Ptr)
  4270. Function bmx_b2body_applyforce(handle:Byte Ptr, force:b2Vec2 Var, point:b2Vec2 Var)
  4271. Function bmx_b2body_applyimpulse(handle:Byte Ptr, impulse:b2Vec2 Var, point:b2Vec2 Var)
  4272. Function bmx_b2body_getworldpoint:b2Vec2(handle:Byte Ptr, localPoint:b2Vec2 Var)
  4273. Function bmx_b2body_getworldvector:b2Vec2(handle:Byte Ptr, localVector:b2Vec2 Var)
  4274. Function bmx_b2body_getlocalpoint:b2Vec2(handle:Byte Ptr, worldPoint:b2Vec2 Var)
  4275. Function bmx_b2body_getlocalvector:b2Vec2(handle:Byte Ptr, worldVector:b2Vec2 Var)
  4276. Function bmx_b2body_setxform:Int(handle:Byte Ptr, position:b2Vec2 Var, angle:Float)
  4277. Function bmx_b2body_getxform:b2XForm(handle:Byte Ptr)
  4278. Function bmx_b2body_getposition:b2Vec2(handle:Byte Ptr)
  4279. Function bmx_b2body_getworldcenter:b2Vec2(handle:Byte Ptr)
  4280. Function bmx_b2body_getlocalcenter:b2Vec2(handle:Byte Ptr)
  4281. Function bmx_b2shape_testpoint:Int(handle:Byte Ptr, xf:b2XForm Var, p:b2Vec2 Var)
  4282. Function bmx_b2shape_computeaabb(handle:Byte Ptr, aabb:b2AABB Var, xf:b2XForm Var)
  4283. Function bmx_b2shape_computesweptaabb(handle:Byte Ptr, aabb:b2AABB Var, xf1:b2XForm Var, xf2:b2XForm Var)
  4284. Function bmx_b2bodydef_setposition(handle:Byte Ptr, position:b2Vec2 Var)
  4285. Function bmx_b2bodydef_getposition:b2Vec2(handle:Byte Ptr)
  4286. Function bmx_b2massdata_setcenter(handle:Byte Ptr, center:b2Vec2 Var)
  4287. Function bmx_b2polygondef_setasorientedbox(handle:Byte Ptr, hx:Float, hy:Float, center:b2Vec2 Var, angle:Float)
  4288. Function bmx_b2polygonshape_getcentroid:b2Vec2(handle:Byte Ptr)
  4289. Function bmx_b2polygonshape_getfirstvertex:b2Vec2(handle:Byte Ptr, xf:b2XForm Var)
  4290. Function bmx_b2polygonshape_centroid:b2Vec2(handle:Byte Ptr, xf:b2XForm Var)
  4291. Function bmx_b2polygonshape_support:b2Vec2(handle:Byte Ptr, xf:b2XForm Var, d:b2Vec2 Var)
  4292. Function bmx_b2circledef_setlocalposition(handle:Byte Ptr, pos:b2Vec2 Var)
  4293. Function bmx_b2circledef_getlocalposition:b2Vec2(handle:Byte Ptr)
  4294. Function bmx_b2circleshape_getlocalposition:b2Vec2(handle:Byte Ptr)
  4295. Function bmx_b2distancejointdef_initialize(handle:Byte Ptr, body1:Byte Ptr, body2:Byte Ptr, anchor1:b2Vec2 Var, anchor2:b2Vec2 Var)
  4296. Function bmx_b2distancejointdef_setlocalanchor1(handle:Byte Ptr, anchor:b2Vec2 Var)
  4297. Function bmx_b2distancejointdef_getlocalanchor1:b2Vec2(handle:Byte Ptr)
  4298. Function bmx_b2distancejointdef_setlocalanchor2(handle:Byte Ptr, anchor:b2Vec2 Var)
  4299. Function bmx_b2distancejointdef_getlocalanchor2:b2Vec2(handle:Byte Ptr)
  4300. Function bmx_b2edgeshape_getvertex1:b2Vec2(handle:Byte Ptr)
  4301. Function bmx_b2edgeshape_getvertex2:b2Vec2(handle:Byte Ptr)
  4302. Function bmx_b2edgeshape_getcorevertex1:b2Vec2(handle:Byte Ptr)
  4303. Function bmx_b2edgeshape_getcorevertex2:b2Vec2(handle:Byte Ptr)
  4304. Function bmx_b2edgeshape_getnormalvector:b2Vec2(handle:Byte Ptr)
  4305. Function bmx_b2edgeshape_getdirectionvector:b2Vec2(handle:Byte Ptr)
  4306. Function bmx_b2edgeshape_getcorner1vector:b2Vec2(handle:Byte Ptr)
  4307. Function bmx_b2edgeshape_getcorner2vector:b2Vec2(handle:Byte Ptr)
  4308. Function bmx_b2edgeshape_getfirstvertex:b2Vec2(handle:Byte Ptr, xf:b2XForm Var)
  4309. Function bmx_b2edgeshape_support:b2Vec2(handle:Byte Ptr, xf:b2XForm Var, d:b2Vec2 Var)
  4310. Function bmx_b2pulleyjointdef_initialize(handle:Byte Ptr, body1:Byte Ptr, body2:Byte Ptr, groundAnchor1:b2Vec2 Var, ..
  4311. groundAnchor2:b2Vec2 Var, anchor1:b2Vec2 Var, anchor2:b2Vec2 Var, ratio:Float)
  4312. Function bmx_b2pulleyjointdef_setgroundanchor1(handle:Byte Ptr, anchor:b2Vec2 Var)
  4313. Function bmx_b2pulleyjointdef_getgroundanchor1:b2Vec2(handle:Byte Ptr)
  4314. Function bmx_b2pulleyjointdef_setgroundanchor2(handle:Byte Ptr, anchor:b2Vec2 Var)
  4315. Function bmx_b2pulleyjointdef_getgroundanchor2:b2Vec2(handle:Byte Ptr)
  4316. Function bmx_b2pulleyjointdef_setlocalanchor1(handle:Byte Ptr, anchor:b2Vec2 Var)
  4317. Function bmx_b2pulleyjointdef_getlocalanchor1:b2Vec2(handle:Byte Ptr)
  4318. Function bmx_b2pulleyjointdef_setlocalanchor2(handle:Byte Ptr, anchor:b2Vec2 Var)
  4319. Function bmx_b2pulleyjointdef_getlocalanchor2:b2Vec2(handle:Byte Ptr)
  4320. Function bmx_b2prismaticjointdef_initialize(handle:Byte Ptr, body1:Byte Ptr, body2:Byte Ptr, ..
  4321. anchor:b2Vec2 Var, axis:b2Vec2 Var)
  4322. Function bmx_b2prismaticjointdef_setlocalanchor1(handle:Byte Ptr, anchor:b2Vec2 Var)
  4323. Function bmx_b2prismaticjointdef_getlocalanchor1:b2Vec2(handle:Byte Ptr)
  4324. Function bmx_b2prismaticjointdef_setlocalanchor2(handle:Byte Ptr, anchor:b2Vec2 Var)
  4325. Function bmx_b2prismaticjointdef_getlocalanchor2:b2Vec2(handle:Byte Ptr)
  4326. Function bmx_b2prismaticjointdef_setlocalaxis1(handle:Byte Ptr, axis:b2Vec2 Var)
  4327. Function bmx_b2prismaticjointdef_getlocalaxis1:b2Vec2(handle:Byte Ptr)
  4328. Function bmx_b2mousejointdef_settarget(handle:Byte Ptr, target:b2Vec2 Var)
  4329. Function bmx_b2mousejointdef_gettarget:b2Vec2(handle:Byte Ptr)
  4330. Function bmx_b2linejointdef_initialize(handle:Byte Ptr, body1:Byte Ptr, body2:Byte Ptr, anchor:b2Vec2 Var, axis:b2Vec2 Var)
  4331. Function bmx_b2linejointdef_setlocalanchor1(handle:Byte Ptr, anchor:b2Vec2 Var)
  4332. Function bmx_b2linejointdef_getlocalanchor1:b2Vec2(handle:Byte Ptr)
  4333. Function bmx_b2linejointdef_setlocalanchor2(handle:Byte Ptr, anchor:b2Vec2 Var)
  4334. Function bmx_b2linejointdef_getlocalanchor2:b2Vec2(handle:Byte Ptr)
  4335. Function bmx_b2linejointdef_setlocalaxis1(handle:Byte Ptr, axis:b2Vec2 Var)
  4336. Function bmx_b2linejointdef_getlocalaxis1:b2Vec2(handle:Byte Ptr)
  4337. Function bmx_b2linejoint_getanchor1:b2Vec2(handle:Byte Ptr)
  4338. Function bmx_b2linejoint_getanchor2:b2Vec2(handle:Byte Ptr)
  4339. Function bmx_b2linejoint_getreactionforce:b2Vec2(handle:Byte Ptr, inv_dt:Float)
  4340. Function bmx_b2distancejoint_getanchor1:b2Vec2(handle:Byte Ptr)
  4341. Function bmx_b2distancejoint_getanchor2:b2Vec2(handle:Byte Ptr)
  4342. Function bmx_b2distancejoint_getreactionforce:b2Vec2(handle:Byte Ptr, inv_dt:Float)
  4343. Function bmx_b2revolutejoint_getanchor1:b2Vec2(handle:Byte Ptr)
  4344. Function bmx_b2revolutejoint_getanchor2:b2Vec2(handle:Byte Ptr)
  4345. Function bmx_b2revolutejoint_getreactionforce:b2Vec2(handle:Byte Ptr, inv_dt:Float)
  4346. Function bmx_b2prismaticjoint_getanchor1:b2Vec2(handle:Byte Ptr)
  4347. Function bmx_b2prismaticjoint_getanchor2:b2Vec2(handle:Byte Ptr)
  4348. Function bmx_b2prismaticjoint_getreactionforce:b2Vec2(handle:Byte Ptr, inv_dt:Float)
  4349. Function bmx_b2gearjoint_getanchor1:b2Vec2(handle:Byte Ptr)
  4350. Function bmx_b2gearjoint_getanchor2:b2Vec2(handle:Byte Ptr)
  4351. Function bmx_b2gearjoint_getreactionforce:b2Vec2(handle:Byte Ptr, inv_dt:Float)
  4352. Function bmx_b2mousejoint_getanchor1:b2Vec2(handle:Byte Ptr)
  4353. Function bmx_b2mousejoint_getanchor2:b2Vec2(handle:Byte Ptr)
  4354. Function bmx_b2mousejoint_getreactionforce:b2Vec2(handle:Byte Ptr, inv_dt:Float)
  4355. Function bmx_b2mousejoint_getlocalanchor:b2Vec2(handle:Byte Ptr)
  4356. Function bmx_b2mousejoint_settarget(handle:Byte Ptr, target:b2Vec2 Var)
  4357. Function bmx_b2mousejoint_gettarget:b2Vec2(handle:Byte Ptr)
  4358. Function bmx_b2pulleyjoint_getanchor1:b2Vec2(handle:Byte Ptr)
  4359. Function bmx_b2pulleyjoint_getanchor2:b2Vec2(handle:Byte Ptr)
  4360. Function bmx_b2pulleyjoint_getreactionforce:b2Vec2(handle:Byte Ptr, inv_dt:Float)
  4361. Function bmx_b2pulleyjoint_getgroundanchor1:b2Vec2(handle:Byte Ptr)
  4362. Function bmx_b2pulleyjoint_getgroundanchor2:b2Vec2(handle:Byte Ptr)
  4363. Function bmx_b2buoyancycontrollerdef_getnormal:b2Vec2(handle:Byte Ptr)
  4364. Function bmx_b2buoyancycontrollerdef_setnormal(handle:Byte Ptr, normal:b2Vec2 Var)
  4365. Function bmx_b2buoyancycontrollerdef_getvelocity:b2Vec2(handle:Byte Ptr)
  4366. Function bmx_b2buoyancycontrollerdef_setvelocity(handle:Byte Ptr, velocity:b2Vec2 Var)
  4367. Function bmx_b2buoyancycontrollerdef_getgravity:b2Vec2(handle:Byte Ptr)
  4368. Function bmx_b2buoyancycontrollerdef_setgravity(handle:Byte Ptr, gravity:b2Vec2 Var)
  4369. Function bmx_b2tensordampingcontrollerdef_gettensor:b2Mat22(handle:Byte Ptr)
  4370. Function bmx_b2tensordampingcontrollerdef_settensor(handle:Byte Ptr, tensor:b2Mat22 Var)
  4371. Function bmx_b2constantforcecontrollerdef_getforce:b2Vec2(handle:Byte Ptr)
  4372. Function bmx_b2constantforcecontrollerdef_setforce(handle:Byte Ptr, force:b2Vec2 Var)
  4373. Function bmx_b2constantforcecontroller_getforce:b2Vec2(handle:Byte Ptr)
  4374. Function bmx_b2constantforcecontroller_setforce(handle:Byte Ptr, force:b2Vec2 Var)
  4375. Function bmx_b2constantaccelcontrollerdef_getforce:b2Vec2(handle:Byte Ptr)
  4376. Function bmx_b2constantaccelcontrollerdef_setforce(handle:Byte Ptr, force:b2Vec2 Var)
  4377. Function bmx_b2constantaccelcontroller_getforce:b2Vec2(handle:Byte Ptr)
  4378. Function bmx_b2constantaccelcontroller_setforce(handle:Byte Ptr, force:b2Vec2 Var)
  4379. Function bmx_b2buoyancycontroller_getnormal:b2Vec2(handle:Byte Ptr)
  4380. Function bmx_b2buoyancycontroller_setnormal(handle:Byte Ptr, normal:b2Vec2 Var)
  4381. Function bmx_b2buoyancycontroller_getvelocity:b2Vec2(handle:Byte Ptr)
  4382. Function bmx_b2buoyancycontroller_setvelocity(handle:Byte Ptr, velocity:b2Vec2 Var)
  4383. Function bmx_b2buoyancycontroller_getgravity:b2Vec2(handle:Byte Ptr)
  4384. Function bmx_b2buoyancycontroller_setgravity(handle:Byte Ptr, gravity:b2Vec2 Var)
  4385. Function bmx_b2tensordampingcontroller_gettensor:b2Mat22(handle:Byte Ptr)
  4386. Function bmx_b2tensordampingcontroller_settensor(handle:Byte Ptr, tensor:b2Mat22 Var)
  4387. End Extern