box2d.bmx 135 KB

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