PolycodeLUAWrappers.h 315 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722
  1. #pragma once
  2. #include <Polycode.h>
  3. extern "C" {
  4. #include <stdio.h>
  5. #include "lua.h"
  6. #include "lualib.h"
  7. #include "lauxlib.h"
  8. class LuaEventHandler : public EventHandler {
  9. public:
  10. LuaEventHandler() : EventHandler() {}
  11. ~LuaEventHandler();
  12. void handleEvent(Event *e) {
  13. lua_rawgeti( L, LUA_REGISTRYINDEX, wrapperIndex );
  14. lua_getfield(L, -1, "__handleEvent");
  15. lua_rawgeti( L, LUA_REGISTRYINDEX, wrapperIndex );
  16. lua_pushlightuserdata(L, e);
  17. lua_call(L, 2, 0);
  18. }
  19. int wrapperIndex;
  20. lua_State *L;
  21. };
  22. static int Polycore_OSFILE_get_fileType(lua_State *L) {
  23. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  24. OSFILE *inst = (OSFILE*)lua_topointer(L, 1);
  25. lua_pushinteger(L, inst->fileType);
  26. return 1;
  27. }
  28. static int Polycore_OSFILE_set_fileType(lua_State *L) {
  29. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  30. OSFILE *inst = (OSFILE*)lua_topointer(L, 1);
  31. int param = lua_tointeger(L, 2);
  32. inst->fileType = param;
  33. return 0;
  34. }
  35. static int Polycore_OSFILE(lua_State *L) {
  36. OSFILE *inst = new OSFILE();
  37. lua_pushlightuserdata(L, (void*)inst);
  38. return 1;
  39. }
  40. static int Polycore_OSFILE_debugDump(lua_State *L) {
  41. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  42. OSFILE *inst = (OSFILE*)lua_topointer(L, 1);
  43. inst->debugDump();
  44. return 0;
  45. }
  46. static int Polycore_delete_OSFILE(lua_State *L) {
  47. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  48. OSFILE *inst = (OSFILE*)lua_topointer(L, 1);
  49. delete inst;
  50. return 0;
  51. }
  52. static int Polycore_OSFileEntry_get_name(lua_State *L) {
  53. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  54. OSFileEntry *inst = (OSFileEntry*)lua_topointer(L, 1);
  55. lua_pushstring(L, inst->name.c_str());
  56. return 1;
  57. }
  58. static int Polycore_OSFileEntry_get_extension(lua_State *L) {
  59. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  60. OSFileEntry *inst = (OSFileEntry*)lua_topointer(L, 1);
  61. lua_pushstring(L, inst->extension.c_str());
  62. return 1;
  63. }
  64. static int Polycore_OSFileEntry_get_nameWithoutExtension(lua_State *L) {
  65. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  66. OSFileEntry *inst = (OSFileEntry*)lua_topointer(L, 1);
  67. lua_pushstring(L, inst->nameWithoutExtension.c_str());
  68. return 1;
  69. }
  70. static int Polycore_OSFileEntry_get_basePath(lua_State *L) {
  71. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  72. OSFileEntry *inst = (OSFileEntry*)lua_topointer(L, 1);
  73. lua_pushstring(L, inst->basePath.c_str());
  74. return 1;
  75. }
  76. static int Polycore_OSFileEntry_get_fullPath(lua_State *L) {
  77. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  78. OSFileEntry *inst = (OSFileEntry*)lua_topointer(L, 1);
  79. lua_pushstring(L, inst->fullPath.c_str());
  80. return 1;
  81. }
  82. static int Polycore_OSFileEntry_get_type(lua_State *L) {
  83. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  84. OSFileEntry *inst = (OSFileEntry*)lua_topointer(L, 1);
  85. lua_pushinteger(L, inst->type);
  86. return 1;
  87. }
  88. static int Polycore_OSFileEntry_set_name(lua_State *L) {
  89. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  90. OSFileEntry *inst = (OSFileEntry*)lua_topointer(L, 1);
  91. String param = lua_tostring(L, 2);
  92. inst->name = param;
  93. return 0;
  94. }
  95. static int Polycore_OSFileEntry_set_extension(lua_State *L) {
  96. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  97. OSFileEntry *inst = (OSFileEntry*)lua_topointer(L, 1);
  98. String param = lua_tostring(L, 2);
  99. inst->extension = param;
  100. return 0;
  101. }
  102. static int Polycore_OSFileEntry_set_nameWithoutExtension(lua_State *L) {
  103. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  104. OSFileEntry *inst = (OSFileEntry*)lua_topointer(L, 1);
  105. String param = lua_tostring(L, 2);
  106. inst->nameWithoutExtension = param;
  107. return 0;
  108. }
  109. static int Polycore_OSFileEntry_set_basePath(lua_State *L) {
  110. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  111. OSFileEntry *inst = (OSFileEntry*)lua_topointer(L, 1);
  112. String param = lua_tostring(L, 2);
  113. inst->basePath = param;
  114. return 0;
  115. }
  116. static int Polycore_OSFileEntry_set_fullPath(lua_State *L) {
  117. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  118. OSFileEntry *inst = (OSFileEntry*)lua_topointer(L, 1);
  119. String param = lua_tostring(L, 2);
  120. inst->fullPath = param;
  121. return 0;
  122. }
  123. static int Polycore_OSFileEntry_set_type(lua_State *L) {
  124. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  125. OSFileEntry *inst = (OSFileEntry*)lua_topointer(L, 1);
  126. int param = lua_tointeger(L, 2);
  127. inst->type = param;
  128. return 0;
  129. }
  130. static int Polycore_OSFileEntry(lua_State *L) {
  131. OSFileEntry *inst = new OSFileEntry();
  132. lua_pushlightuserdata(L, (void*)inst);
  133. return 1;
  134. }
  135. static int Polycore_delete_OSFileEntry(lua_State *L) {
  136. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  137. OSFileEntry *inst = (OSFileEntry*)lua_topointer(L, 1);
  138. delete inst;
  139. return 0;
  140. }
  141. static int Polycore_OSBasics_open(lua_State *L) {
  142. luaL_checktype(L, 2, LUA_TSTRING);
  143. String filename = String(lua_tostring(L, 2));
  144. luaL_checktype(L, 3, LUA_TSTRING);
  145. String opts = String(lua_tostring(L, 3));
  146. void *ptrRetVal = (void*)OSBasics::open(filename, opts);
  147. if(ptrRetVal == NULL) {
  148. lua_pushnil(L);
  149. } else {
  150. lua_pushlightuserdata(L, ptrRetVal);
  151. }
  152. return 1;
  153. }
  154. static int Polycore_OSBasics_close(lua_State *L) {
  155. luaL_checktype(L, 2, LUA_TLIGHTUSERDATA);
  156. OSFILE * file = (OSFILE *)lua_topointer(L, 2);
  157. lua_pushinteger(L, OSBasics::close(file));
  158. return 1;
  159. }
  160. static int Polycore_OSBasics_read(lua_State *L) {
  161. luaL_checktype(L, 2, LUA_TLIGHTUSERDATA);
  162. void * ptr = (void *)lua_topointer(L, 2);
  163. luaL_checktype(L, 3, LUA_TLIGHTUSERDATA);
  164. size_t size = *(size_t*)lua_topointer(L, 3);
  165. luaL_checktype(L, 4, LUA_TLIGHTUSERDATA);
  166. size_t count = *(size_t*)lua_topointer(L, 4);
  167. luaL_checktype(L, 5, LUA_TLIGHTUSERDATA);
  168. OSFILE * stream = (OSFILE *)lua_topointer(L, 5);
  169. lua_pushinteger(L, OSBasics::read(ptr, size, count, stream));
  170. return 1;
  171. }
  172. static int Polycore_OSBasics_write(lua_State *L) {
  173. luaL_checktype(L, 2, LUA_TLIGHTUSERDATA);
  174. const void * ptr = (const void *)lua_topointer(L, 2);
  175. luaL_checktype(L, 3, LUA_TLIGHTUSERDATA);
  176. size_t size = *(size_t*)lua_topointer(L, 3);
  177. luaL_checktype(L, 4, LUA_TLIGHTUSERDATA);
  178. size_t count = *(size_t*)lua_topointer(L, 4);
  179. luaL_checktype(L, 5, LUA_TLIGHTUSERDATA);
  180. OSFILE * stream = (OSFILE *)lua_topointer(L, 5);
  181. lua_pushinteger(L, OSBasics::write(ptr, size, count, stream));
  182. return 1;
  183. }
  184. static int Polycore_OSBasics_seek(lua_State *L) {
  185. luaL_checktype(L, 2, LUA_TLIGHTUSERDATA);
  186. OSFILE * stream = (OSFILE *)lua_topointer(L, 2);
  187. luaL_checktype(L, 3, LUA_TLIGHTUSERDATA);
  188. long int offset = *(long int*)lua_topointer(L, 3);
  189. luaL_checktype(L, 4, LUA_TNUMBER);
  190. int origin = lua_tointeger(L, 4);
  191. lua_pushinteger(L, OSBasics::seek(stream, offset, origin));
  192. return 1;
  193. }
  194. static int Polycore_OSBasics_tell(lua_State *L) {
  195. luaL_checktype(L, 2, LUA_TLIGHTUSERDATA);
  196. OSFILE * stream = (OSFILE *)lua_topointer(L, 2);
  197. lua_pushinteger(L, OSBasics::tell(stream));
  198. return 1;
  199. }
  200. static int Polycore_OSBasics_isFolder(lua_State *L) {
  201. luaL_checktype(L, 2, LUA_TSTRING);
  202. String pathString = String(lua_tostring(L, 2));
  203. lua_pushboolean(L, OSBasics::isFolder(pathString));
  204. return 1;
  205. }
  206. static int Polycore_OSBasics_createFolder(lua_State *L) {
  207. luaL_checktype(L, 2, LUA_TSTRING);
  208. String pathString = String(lua_tostring(L, 2));
  209. OSBasics::createFolder(pathString);
  210. return 0;
  211. }
  212. static int Polycore_OSBasics_removeItem(lua_State *L) {
  213. luaL_checktype(L, 2, LUA_TSTRING);
  214. String pathString = String(lua_tostring(L, 2));
  215. OSBasics::removeItem(pathString);
  216. return 0;
  217. }
  218. static int Polycore_delete_OSBasics(lua_State *L) {
  219. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  220. OSBasics *inst = (OSBasics*)lua_topointer(L, 1);
  221. delete inst;
  222. return 0;
  223. }
  224. static int Polycore_BezierCurve(lua_State *L) {
  225. BezierCurve *inst = new BezierCurve();
  226. lua_pushlightuserdata(L, (void*)inst);
  227. return 1;
  228. }
  229. static int Polycore_BezierCurve_getControlPoint(lua_State *L) {
  230. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  231. BezierCurve *inst = (BezierCurve*)lua_topointer(L, 1);
  232. luaL_checktype(L, 2, LUA_TNUMBER);
  233. unsigned int index = lua_tointeger(L, 2);
  234. void *ptrRetVal = (void*)inst->getControlPoint(index);
  235. if(ptrRetVal == NULL) {
  236. lua_pushnil(L);
  237. } else {
  238. lua_pushlightuserdata(L, ptrRetVal);
  239. }
  240. return 1;
  241. }
  242. static int Polycore_BezierCurve_getNumControlPoints(lua_State *L) {
  243. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  244. BezierCurve *inst = (BezierCurve*)lua_topointer(L, 1);
  245. lua_pushinteger(L, inst->getNumControlPoints());
  246. return 1;
  247. }
  248. static int Polycore_BezierCurve_addControlPoint(lua_State *L) {
  249. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  250. BezierCurve *inst = (BezierCurve*)lua_topointer(L, 1);
  251. luaL_checktype(L, 2, LUA_TNUMBER);
  252. Number p1x = lua_tonumber(L, 2);
  253. luaL_checktype(L, 3, LUA_TNUMBER);
  254. Number p1y = lua_tonumber(L, 3);
  255. luaL_checktype(L, 4, LUA_TNUMBER);
  256. Number p1z = lua_tonumber(L, 4);
  257. luaL_checktype(L, 5, LUA_TNUMBER);
  258. Number p2x = lua_tonumber(L, 5);
  259. luaL_checktype(L, 6, LUA_TNUMBER);
  260. Number p2y = lua_tonumber(L, 6);
  261. luaL_checktype(L, 7, LUA_TNUMBER);
  262. Number p2z = lua_tonumber(L, 7);
  263. luaL_checktype(L, 8, LUA_TNUMBER);
  264. Number p3x = lua_tonumber(L, 8);
  265. luaL_checktype(L, 9, LUA_TNUMBER);
  266. Number p3y = lua_tonumber(L, 9);
  267. luaL_checktype(L, 10, LUA_TNUMBER);
  268. Number p3z = lua_tonumber(L, 10);
  269. inst->addControlPoint(p1x, p1y, p1z, p2x, p2y, p2z, p3x, p3y, p3z);
  270. return 0;
  271. }
  272. static int Polycore_BezierCurve_addControlPoint3dWithHandles(lua_State *L) {
  273. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  274. BezierCurve *inst = (BezierCurve*)lua_topointer(L, 1);
  275. luaL_checktype(L, 2, LUA_TNUMBER);
  276. Number p1x = lua_tonumber(L, 2);
  277. luaL_checktype(L, 3, LUA_TNUMBER);
  278. Number p1y = lua_tonumber(L, 3);
  279. luaL_checktype(L, 4, LUA_TNUMBER);
  280. Number p1z = lua_tonumber(L, 4);
  281. luaL_checktype(L, 5, LUA_TNUMBER);
  282. Number p2x = lua_tonumber(L, 5);
  283. luaL_checktype(L, 6, LUA_TNUMBER);
  284. Number p2y = lua_tonumber(L, 6);
  285. luaL_checktype(L, 7, LUA_TNUMBER);
  286. Number p2z = lua_tonumber(L, 7);
  287. luaL_checktype(L, 8, LUA_TNUMBER);
  288. Number p3x = lua_tonumber(L, 8);
  289. luaL_checktype(L, 9, LUA_TNUMBER);
  290. Number p3y = lua_tonumber(L, 9);
  291. luaL_checktype(L, 10, LUA_TNUMBER);
  292. Number p3z = lua_tonumber(L, 10);
  293. inst->addControlPoint3dWithHandles(p1x, p1y, p1z, p2x, p2y, p2z, p3x, p3y, p3z);
  294. return 0;
  295. }
  296. static int Polycore_BezierCurve_addControlPoint3d(lua_State *L) {
  297. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  298. BezierCurve *inst = (BezierCurve*)lua_topointer(L, 1);
  299. luaL_checktype(L, 2, LUA_TNUMBER);
  300. Number x = lua_tonumber(L, 2);
  301. luaL_checktype(L, 3, LUA_TNUMBER);
  302. Number y = lua_tonumber(L, 3);
  303. luaL_checktype(L, 4, LUA_TNUMBER);
  304. Number z = lua_tonumber(L, 4);
  305. inst->addControlPoint3d(x, y, z);
  306. return 0;
  307. }
  308. static int Polycore_BezierCurve_addControlPoint2dWithHandles(lua_State *L) {
  309. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  310. BezierCurve *inst = (BezierCurve*)lua_topointer(L, 1);
  311. luaL_checktype(L, 2, LUA_TNUMBER);
  312. Number p1x = lua_tonumber(L, 2);
  313. luaL_checktype(L, 3, LUA_TNUMBER);
  314. Number p1y = lua_tonumber(L, 3);
  315. luaL_checktype(L, 4, LUA_TNUMBER);
  316. Number p2x = lua_tonumber(L, 4);
  317. luaL_checktype(L, 5, LUA_TNUMBER);
  318. Number p2y = lua_tonumber(L, 5);
  319. luaL_checktype(L, 6, LUA_TNUMBER);
  320. Number p3x = lua_tonumber(L, 6);
  321. luaL_checktype(L, 7, LUA_TNUMBER);
  322. Number p3y = lua_tonumber(L, 7);
  323. inst->addControlPoint2dWithHandles(p1x, p1y, p2x, p2y, p3x, p3y);
  324. return 0;
  325. }
  326. static int Polycore_BezierCurve_addControlPoint2d(lua_State *L) {
  327. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  328. BezierCurve *inst = (BezierCurve*)lua_topointer(L, 1);
  329. luaL_checktype(L, 2, LUA_TNUMBER);
  330. Number x = lua_tonumber(L, 2);
  331. luaL_checktype(L, 3, LUA_TNUMBER);
  332. Number y = lua_tonumber(L, 3);
  333. inst->addControlPoint2d(x, y);
  334. return 0;
  335. }
  336. static int Polycore_BezierCurve_getHeightAt(lua_State *L) {
  337. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  338. BezierCurve *inst = (BezierCurve*)lua_topointer(L, 1);
  339. luaL_checktype(L, 2, LUA_TNUMBER);
  340. Number a = lua_tonumber(L, 2);
  341. lua_pushnumber(L, inst->getHeightAt(a));
  342. return 1;
  343. }
  344. static int Polycore_BezierCurve_getPointAt(lua_State *L) {
  345. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  346. BezierCurve *inst = (BezierCurve*)lua_topointer(L, 1);
  347. luaL_checktype(L, 2, LUA_TNUMBER);
  348. Number a = lua_tonumber(L, 2);
  349. Vector3 *retInst = new Vector3();
  350. *retInst = inst->getPointAt(a);
  351. lua_pushlightuserdata(L, retInst);
  352. return 1;
  353. }
  354. static int Polycore_BezierCurve_getPointBetween(lua_State *L) {
  355. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  356. BezierCurve *inst = (BezierCurve*)lua_topointer(L, 1);
  357. luaL_checktype(L, 2, LUA_TNUMBER);
  358. Number a = lua_tonumber(L, 2);
  359. luaL_checktype(L, 3, LUA_TLIGHTUSERDATA);
  360. BezierPoint * bp1 = (BezierPoint *)lua_topointer(L, 3);
  361. luaL_checktype(L, 4, LUA_TLIGHTUSERDATA);
  362. BezierPoint * bp2 = (BezierPoint *)lua_topointer(L, 4);
  363. Vector3 *retInst = new Vector3();
  364. *retInst = inst->getPointBetween(a, bp1, bp2);
  365. lua_pushlightuserdata(L, retInst);
  366. return 1;
  367. }
  368. static int Polycore_BezierCurve_rebuildBuffers(lua_State *L) {
  369. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  370. BezierCurve *inst = (BezierCurve*)lua_topointer(L, 1);
  371. inst->rebuildBuffers();
  372. return 0;
  373. }
  374. static int Polycore_delete_BezierCurve(lua_State *L) {
  375. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  376. BezierCurve *inst = (BezierCurve*)lua_topointer(L, 1);
  377. delete inst;
  378. return 0;
  379. }
  380. static int Polycore_Bone_get_parentBoneId(lua_State *L) {
  381. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  382. Bone *inst = (Bone*)lua_topointer(L, 1);
  383. lua_pushinteger(L, inst->parentBoneId);
  384. return 1;
  385. }
  386. static int Polycore_Bone_get_boneMatrix(lua_State *L) {
  387. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  388. Bone *inst = (Bone*)lua_topointer(L, 1);
  389. lua_pushlightuserdata(L, &inst->boneMatrix);
  390. return 1;
  391. }
  392. static int Polycore_Bone_get_restMatrix(lua_State *L) {
  393. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  394. Bone *inst = (Bone*)lua_topointer(L, 1);
  395. lua_pushlightuserdata(L, &inst->restMatrix);
  396. return 1;
  397. }
  398. static int Polycore_Bone_get_baseMatrix(lua_State *L) {
  399. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  400. Bone *inst = (Bone*)lua_topointer(L, 1);
  401. lua_pushlightuserdata(L, &inst->baseMatrix);
  402. return 1;
  403. }
  404. static int Polycore_Bone_set_parentBoneId(lua_State *L) {
  405. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  406. Bone *inst = (Bone*)lua_topointer(L, 1);
  407. int param = lua_tointeger(L, 2);
  408. inst->parentBoneId = param;
  409. return 0;
  410. }
  411. static int Polycore_Bone(lua_State *L) {
  412. luaL_checktype(L, 1, LUA_TSTRING);
  413. String boneName = String(lua_tostring(L, 1));
  414. Bone *inst = new Bone(boneName);
  415. lua_pushlightuserdata(L, (void*)inst);
  416. return 1;
  417. }
  418. static int Polycore_Bone_enableBoneLabel(lua_State *L) {
  419. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  420. Bone *inst = (Bone*)lua_topointer(L, 1);
  421. luaL_checktype(L, 2, LUA_TSTRING);
  422. String labelFont = String(lua_tostring(L, 2));
  423. luaL_checktype(L, 3, LUA_TNUMBER);
  424. Number size = lua_tonumber(L, 3);
  425. luaL_checktype(L, 4, LUA_TNUMBER);
  426. Number scale = lua_tonumber(L, 4);
  427. luaL_checktype(L, 5, LUA_TLIGHTUSERDATA);
  428. Color labelColor = *(Color*)lua_topointer(L, 5);
  429. inst->enableBoneLabel(labelFont, size, scale, labelColor);
  430. return 0;
  431. }
  432. static int Polycore_Bone_getName(lua_State *L) {
  433. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  434. Bone *inst = (Bone*)lua_topointer(L, 1);
  435. lua_pushstring(L, inst->getName().c_str());
  436. return 1;
  437. }
  438. static int Polycore_Bone_Render(lua_State *L) {
  439. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  440. Bone *inst = (Bone*)lua_topointer(L, 1);
  441. inst->Render();
  442. return 0;
  443. }
  444. static int Polycore_Bone_setParentBone(lua_State *L) {
  445. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  446. Bone *inst = (Bone*)lua_topointer(L, 1);
  447. luaL_checktype(L, 2, LUA_TLIGHTUSERDATA);
  448. Bone * bone = (Bone *)lua_topointer(L, 2);
  449. inst->setParentBone(bone);
  450. return 0;
  451. }
  452. static int Polycore_Bone_addChildBone(lua_State *L) {
  453. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  454. Bone *inst = (Bone*)lua_topointer(L, 1);
  455. luaL_checktype(L, 2, LUA_TLIGHTUSERDATA);
  456. Bone * bone = (Bone *)lua_topointer(L, 2);
  457. inst->addChildBone(bone);
  458. return 0;
  459. }
  460. static int Polycore_Bone_getParentBone(lua_State *L) {
  461. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  462. Bone *inst = (Bone*)lua_topointer(L, 1);
  463. void *ptrRetVal = (void*)inst->getParentBone();
  464. if(ptrRetVal == NULL) {
  465. lua_pushnil(L);
  466. } else {
  467. lua_pushlightuserdata(L, ptrRetVal);
  468. }
  469. return 1;
  470. }
  471. static int Polycore_Bone_getNumChildBones(lua_State *L) {
  472. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  473. Bone *inst = (Bone*)lua_topointer(L, 1);
  474. lua_pushinteger(L, inst->getNumChildBones());
  475. return 1;
  476. }
  477. static int Polycore_Bone_getChildBone(lua_State *L) {
  478. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  479. Bone *inst = (Bone*)lua_topointer(L, 1);
  480. luaL_checktype(L, 2, LUA_TNUMBER);
  481. unsigned int index = lua_tointeger(L, 2);
  482. void *ptrRetVal = (void*)inst->getChildBone(index);
  483. if(ptrRetVal == NULL) {
  484. lua_pushnil(L);
  485. } else {
  486. lua_pushlightuserdata(L, ptrRetVal);
  487. }
  488. return 1;
  489. }
  490. static int Polycore_Bone_getBoneMatrix(lua_State *L) {
  491. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  492. Bone *inst = (Bone*)lua_topointer(L, 1);
  493. Matrix4 *retInst = new Matrix4();
  494. *retInst = inst->getBoneMatrix();
  495. lua_pushlightuserdata(L, retInst);
  496. return 1;
  497. }
  498. static int Polycore_Bone_setBoneMatrix(lua_State *L) {
  499. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  500. Bone *inst = (Bone*)lua_topointer(L, 1);
  501. luaL_checktype(L, 2, LUA_TLIGHTUSERDATA);
  502. Matrix4 matrix = *(Matrix4*)lua_topointer(L, 2);
  503. inst->setBoneMatrix(matrix);
  504. return 0;
  505. }
  506. static int Polycore_Bone_getRestMatrix(lua_State *L) {
  507. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  508. Bone *inst = (Bone*)lua_topointer(L, 1);
  509. Matrix4 *retInst = new Matrix4();
  510. *retInst = inst->getRestMatrix();
  511. lua_pushlightuserdata(L, retInst);
  512. return 1;
  513. }
  514. static int Polycore_Bone_getFullRestMatrix(lua_State *L) {
  515. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  516. Bone *inst = (Bone*)lua_topointer(L, 1);
  517. Matrix4 *retInst = new Matrix4();
  518. *retInst = inst->getFullRestMatrix();
  519. lua_pushlightuserdata(L, retInst);
  520. return 1;
  521. }
  522. static int Polycore_Bone_getParentRestMatrix(lua_State *L) {
  523. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  524. Bone *inst = (Bone*)lua_topointer(L, 1);
  525. Matrix4 *retInst = new Matrix4();
  526. *retInst = inst->getParentRestMatrix();
  527. lua_pushlightuserdata(L, retInst);
  528. return 1;
  529. }
  530. static int Polycore_Bone_getFinalMatrix(lua_State *L) {
  531. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  532. Bone *inst = (Bone*)lua_topointer(L, 1);
  533. Matrix4 *retInst = new Matrix4();
  534. *retInst = inst->getFinalMatrix();
  535. lua_pushlightuserdata(L, retInst);
  536. return 1;
  537. }
  538. static int Polycore_Bone_setRestMatrix(lua_State *L) {
  539. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  540. Bone *inst = (Bone*)lua_topointer(L, 1);
  541. luaL_checktype(L, 2, LUA_TLIGHTUSERDATA);
  542. Matrix4 matrix = *(Matrix4*)lua_topointer(L, 2);
  543. inst->setRestMatrix(matrix);
  544. return 0;
  545. }
  546. static int Polycore_Bone_setBaseMatrix(lua_State *L) {
  547. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  548. Bone *inst = (Bone*)lua_topointer(L, 1);
  549. luaL_checktype(L, 2, LUA_TLIGHTUSERDATA);
  550. Matrix4 matrix = *(Matrix4*)lua_topointer(L, 2);
  551. inst->setBaseMatrix(matrix);
  552. return 0;
  553. }
  554. static int Polycore_Bone_getBaseMatrix(lua_State *L) {
  555. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  556. Bone *inst = (Bone*)lua_topointer(L, 1);
  557. Matrix4 *retInst = new Matrix4();
  558. *retInst = inst->getBaseMatrix();
  559. lua_pushlightuserdata(L, retInst);
  560. return 1;
  561. }
  562. static int Polycore_Bone_getFullBaseMatrix(lua_State *L) {
  563. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  564. Bone *inst = (Bone*)lua_topointer(L, 1);
  565. Matrix4 *retInst = new Matrix4();
  566. *retInst = inst->getFullBaseMatrix();
  567. lua_pushlightuserdata(L, retInst);
  568. return 1;
  569. }
  570. static int Polycore_delete_Bone(lua_State *L) {
  571. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  572. Bone *inst = (Bone*)lua_topointer(L, 1);
  573. delete inst;
  574. return 0;
  575. }
  576. static int Polycore_Camera(lua_State *L) {
  577. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  578. Scene * parentScene = (Scene *)lua_topointer(L, 1);
  579. Camera *inst = new Camera(parentScene);
  580. lua_pushlightuserdata(L, (void*)inst);
  581. return 1;
  582. }
  583. static int Polycore_Camera_buildFrustrumPlanes(lua_State *L) {
  584. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  585. Camera *inst = (Camera*)lua_topointer(L, 1);
  586. inst->buildFrustrumPlanes();
  587. return 0;
  588. }
  589. static int Polycore_Camera_isSphereInFrustrum(lua_State *L) {
  590. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  591. Camera *inst = (Camera*)lua_topointer(L, 1);
  592. luaL_checktype(L, 2, LUA_TLIGHTUSERDATA);
  593. Vector3 pos = *(Vector3*)lua_topointer(L, 2);
  594. luaL_checktype(L, 3, LUA_TNUMBER);
  595. Number fRadius = lua_tonumber(L, 3);
  596. lua_pushboolean(L, inst->isSphereInFrustrum(pos, fRadius));
  597. return 1;
  598. }
  599. static int Polycore_Camera_canSee(lua_State *L) {
  600. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  601. Camera *inst = (Camera*)lua_topointer(L, 1);
  602. luaL_checktype(L, 2, LUA_TLIGHTUSERDATA);
  603. SceneEntity * entity = (SceneEntity *)lua_topointer(L, 2);
  604. lua_pushboolean(L, inst->canSee(entity));
  605. return 1;
  606. }
  607. static int Polycore_Camera_setOrthoMode(lua_State *L) {
  608. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  609. Camera *inst = (Camera*)lua_topointer(L, 1);
  610. luaL_checktype(L, 2, LUA_TBOOLEAN);
  611. bool mode = lua_toboolean(L, 2);
  612. inst->setOrthoMode(mode);
  613. return 0;
  614. }
  615. static int Polycore_Camera_getOrthoMode(lua_State *L) {
  616. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  617. Camera *inst = (Camera*)lua_topointer(L, 1);
  618. lua_pushboolean(L, inst->getOrthoMode());
  619. return 1;
  620. }
  621. static int Polycore_Camera_setFOV(lua_State *L) {
  622. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  623. Camera *inst = (Camera*)lua_topointer(L, 1);
  624. luaL_checktype(L, 2, LUA_TNUMBER);
  625. Number fov = lua_tonumber(L, 2);
  626. inst->setFOV(fov);
  627. return 0;
  628. }
  629. static int Polycore_Camera_getFOV(lua_State *L) {
  630. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  631. Camera *inst = (Camera*)lua_topointer(L, 1);
  632. lua_pushnumber(L, inst->getFOV());
  633. return 1;
  634. }
  635. static int Polycore_Camera_setParentScene(lua_State *L) {
  636. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  637. Camera *inst = (Camera*)lua_topointer(L, 1);
  638. luaL_checktype(L, 2, LUA_TLIGHTUSERDATA);
  639. Scene * parentScene = (Scene *)lua_topointer(L, 2);
  640. inst->setParentScene(parentScene);
  641. return 0;
  642. }
  643. static int Polycore_Camera_doCameraTransform(lua_State *L) {
  644. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  645. Camera *inst = (Camera*)lua_topointer(L, 1);
  646. inst->doCameraTransform();
  647. return 0;
  648. }
  649. static int Polycore_Camera_setLightDepthTexture(lua_State *L) {
  650. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  651. Camera *inst = (Camera*)lua_topointer(L, 1);
  652. luaL_checktype(L, 2, LUA_TLIGHTUSERDATA);
  653. Texture * texture = (Texture *)lua_topointer(L, 2);
  654. inst->setLightDepthTexture(texture);
  655. return 0;
  656. }
  657. static int Polycore_Camera_hasFilterShader(lua_State *L) {
  658. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  659. Camera *inst = (Camera*)lua_topointer(L, 1);
  660. lua_pushboolean(L, inst->hasFilterShader());
  661. return 1;
  662. }
  663. static int Polycore_Camera_drawFilter(lua_State *L) {
  664. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  665. Camera *inst = (Camera*)lua_topointer(L, 1);
  666. inst->drawFilter();
  667. return 0;
  668. }
  669. static int Polycore_Camera_setExposureLevel(lua_State *L) {
  670. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  671. Camera *inst = (Camera*)lua_topointer(L, 1);
  672. luaL_checktype(L, 2, LUA_TNUMBER);
  673. Number level = lua_tonumber(L, 2);
  674. inst->setExposureLevel(level);
  675. return 0;
  676. }
  677. static int Polycore_Camera_getExposureLevel(lua_State *L) {
  678. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  679. Camera *inst = (Camera*)lua_topointer(L, 1);
  680. lua_pushnumber(L, inst->getExposureLevel());
  681. return 1;
  682. }
  683. static int Polycore_Camera_createPostFilter(lua_State *L) {
  684. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  685. Camera *inst = (Camera*)lua_topointer(L, 1);
  686. luaL_checktype(L, 2, LUA_TLIGHTUSERDATA);
  687. Material * shaderMaterial = (Material *)lua_topointer(L, 2);
  688. inst->createPostFilter(shaderMaterial);
  689. return 0;
  690. }
  691. static int Polycore_Camera_setPostFilter(lua_State *L) {
  692. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  693. Camera *inst = (Camera*)lua_topointer(L, 1);
  694. luaL_checktype(L, 2, LUA_TSTRING);
  695. String shaderName = String(lua_tostring(L, 2));
  696. inst->setPostFilter(shaderName);
  697. return 0;
  698. }
  699. static int Polycore_Camera_removePostFilter(lua_State *L) {
  700. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  701. Camera *inst = (Camera*)lua_topointer(L, 1);
  702. inst->removePostFilter();
  703. return 0;
  704. }
  705. static int Polycore_delete_Camera(lua_State *L) {
  706. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  707. Camera *inst = (Camera*)lua_topointer(L, 1);
  708. delete inst;
  709. return 0;
  710. }
  711. static int Polycore_Color_get_r(lua_State *L) {
  712. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  713. Color *inst = (Color*)lua_topointer(L, 1);
  714. lua_pushnumber(L, inst->r);
  715. return 1;
  716. }
  717. static int Polycore_Color_get_g(lua_State *L) {
  718. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  719. Color *inst = (Color*)lua_topointer(L, 1);
  720. lua_pushnumber(L, inst->g);
  721. return 1;
  722. }
  723. static int Polycore_Color_get_b(lua_State *L) {
  724. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  725. Color *inst = (Color*)lua_topointer(L, 1);
  726. lua_pushnumber(L, inst->b);
  727. return 1;
  728. }
  729. static int Polycore_Color_get_a(lua_State *L) {
  730. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  731. Color *inst = (Color*)lua_topointer(L, 1);
  732. lua_pushnumber(L, inst->a);
  733. return 1;
  734. }
  735. static int Polycore_Color_set_r(lua_State *L) {
  736. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  737. Color *inst = (Color*)lua_topointer(L, 1);
  738. Number param = lua_tonumber(L, 2);
  739. inst->r = param;
  740. return 0;
  741. }
  742. static int Polycore_Color_set_g(lua_State *L) {
  743. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  744. Color *inst = (Color*)lua_topointer(L, 1);
  745. Number param = lua_tonumber(L, 2);
  746. inst->g = param;
  747. return 0;
  748. }
  749. static int Polycore_Color_set_b(lua_State *L) {
  750. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  751. Color *inst = (Color*)lua_topointer(L, 1);
  752. Number param = lua_tonumber(L, 2);
  753. inst->b = param;
  754. return 0;
  755. }
  756. static int Polycore_Color_set_a(lua_State *L) {
  757. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  758. Color *inst = (Color*)lua_topointer(L, 1);
  759. Number param = lua_tonumber(L, 2);
  760. inst->a = param;
  761. return 0;
  762. }
  763. static int Polycore_Color(lua_State *L) {
  764. Color *inst = new Color();
  765. lua_pushlightuserdata(L, (void*)inst);
  766. return 1;
  767. }
  768. static int Polycore_Color_setColorHex(lua_State *L) {
  769. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  770. Color *inst = (Color*)lua_topointer(L, 1);
  771. luaL_checktype(L, 2, LUA_TNUMBER);
  772. unsigned int hex = lua_tointeger(L, 2);
  773. inst->setColorHex(hex);
  774. return 0;
  775. }
  776. static int Polycore_Color_setColorHexRGB(lua_State *L) {
  777. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  778. Color *inst = (Color*)lua_topointer(L, 1);
  779. luaL_checktype(L, 2, LUA_TNUMBER);
  780. unsigned int hex = lua_tointeger(L, 2);
  781. inst->setColorHexRGB(hex);
  782. return 0;
  783. }
  784. static int Polycore_Color_setColorHSV(lua_State *L) {
  785. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  786. Color *inst = (Color*)lua_topointer(L, 1);
  787. luaL_checktype(L, 2, LUA_TNUMBER);
  788. Number h = lua_tonumber(L, 2);
  789. luaL_checktype(L, 3, LUA_TNUMBER);
  790. Number s = lua_tonumber(L, 3);
  791. luaL_checktype(L, 4, LUA_TNUMBER);
  792. Number v = lua_tonumber(L, 4);
  793. inst->setColorHSV(h, s, v);
  794. return 0;
  795. }
  796. static int Polycore_Color_setColorRGBA(lua_State *L) {
  797. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  798. Color *inst = (Color*)lua_topointer(L, 1);
  799. luaL_checktype(L, 2, LUA_TNUMBER);
  800. int r = lua_tointeger(L, 2);
  801. luaL_checktype(L, 3, LUA_TNUMBER);
  802. int g = lua_tointeger(L, 3);
  803. luaL_checktype(L, 4, LUA_TNUMBER);
  804. int b = lua_tointeger(L, 4);
  805. luaL_checktype(L, 5, LUA_TNUMBER);
  806. int a = lua_tointeger(L, 5);
  807. inst->setColorRGBA(r, g, b, a);
  808. return 0;
  809. }
  810. static int Polycore_Color_setColorRGB(lua_State *L) {
  811. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  812. Color *inst = (Color*)lua_topointer(L, 1);
  813. luaL_checktype(L, 2, LUA_TNUMBER);
  814. int r = lua_tointeger(L, 2);
  815. luaL_checktype(L, 3, LUA_TNUMBER);
  816. int g = lua_tointeger(L, 3);
  817. luaL_checktype(L, 4, LUA_TNUMBER);
  818. int b = lua_tointeger(L, 4);
  819. inst->setColorRGB(r, g, b);
  820. return 0;
  821. }
  822. static int Polycore_Color_setColor(lua_State *L) {
  823. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  824. Color *inst = (Color*)lua_topointer(L, 1);
  825. luaL_checktype(L, 2, LUA_TNUMBER);
  826. Number r = lua_tonumber(L, 2);
  827. luaL_checktype(L, 3, LUA_TNUMBER);
  828. Number g = lua_tonumber(L, 3);
  829. luaL_checktype(L, 4, LUA_TNUMBER);
  830. Number b = lua_tonumber(L, 4);
  831. luaL_checktype(L, 5, LUA_TNUMBER);
  832. Number a = lua_tonumber(L, 5);
  833. inst->setColor(r, g, b, a);
  834. return 0;
  835. }
  836. static int Polycore_Color_Random(lua_State *L) {
  837. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  838. Color *inst = (Color*)lua_topointer(L, 1);
  839. inst->Random();
  840. return 0;
  841. }
  842. static int Polycore_Color_getBrightness(lua_State *L) {
  843. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  844. Color *inst = (Color*)lua_topointer(L, 1);
  845. lua_pushnumber(L, inst->getBrightness());
  846. return 1;
  847. }
  848. static int Polycore_Color_getUint(lua_State *L) {
  849. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  850. Color *inst = (Color*)lua_topointer(L, 1);
  851. lua_pushinteger(L, inst->getUint());
  852. return 1;
  853. }
  854. static int Polycore_delete_Color(lua_State *L) {
  855. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  856. Color *inst = (Color*)lua_topointer(L, 1);
  857. delete inst;
  858. return 0;
  859. }
  860. static int Polycore_Config(lua_State *L) {
  861. Config *inst = new Config();
  862. lua_pushlightuserdata(L, (void*)inst);
  863. return 1;
  864. }
  865. static int Polycore_Config_loadConfig(lua_State *L) {
  866. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  867. Config *inst = (Config*)lua_topointer(L, 1);
  868. luaL_checktype(L, 2, LUA_TSTRING);
  869. String configNamespace = String(lua_tostring(L, 2));
  870. luaL_checktype(L, 3, LUA_TSTRING);
  871. String fileName = String(lua_tostring(L, 3));
  872. inst->loadConfig(configNamespace, fileName);
  873. return 0;
  874. }
  875. static int Polycore_Config_saveConfig(lua_State *L) {
  876. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  877. Config *inst = (Config*)lua_topointer(L, 1);
  878. luaL_checktype(L, 2, LUA_TSTRING);
  879. String configNamespace = String(lua_tostring(L, 2));
  880. luaL_checktype(L, 3, LUA_TSTRING);
  881. String fileName = String(lua_tostring(L, 3));
  882. inst->saveConfig(configNamespace, fileName);
  883. return 0;
  884. }
  885. static int Polycore_Config_getEntry(lua_State *L) {
  886. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  887. Config *inst = (Config*)lua_topointer(L, 1);
  888. luaL_checktype(L, 2, LUA_TSTRING);
  889. String configNamespace = String(lua_tostring(L, 2));
  890. luaL_checktype(L, 3, LUA_TSTRING);
  891. String key = String(lua_tostring(L, 3));
  892. void *ptrRetVal = (void*)inst->getEntry(configNamespace, key);
  893. if(ptrRetVal == NULL) {
  894. lua_pushnil(L);
  895. } else {
  896. lua_pushlightuserdata(L, ptrRetVal);
  897. }
  898. return 1;
  899. }
  900. static int Polycore_Config_setStringValue(lua_State *L) {
  901. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  902. Config *inst = (Config*)lua_topointer(L, 1);
  903. luaL_checktype(L, 2, LUA_TSTRING);
  904. String configNamespace = String(lua_tostring(L, 2));
  905. luaL_checktype(L, 3, LUA_TSTRING);
  906. String key = String(lua_tostring(L, 3));
  907. luaL_checktype(L, 4, LUA_TSTRING);
  908. String value = String(lua_tostring(L, 4));
  909. inst->setStringValue(configNamespace, key, value);
  910. return 0;
  911. }
  912. static int Polycore_Config_setNumericValue(lua_State *L) {
  913. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  914. Config *inst = (Config*)lua_topointer(L, 1);
  915. luaL_checktype(L, 2, LUA_TSTRING);
  916. String configNamespace = String(lua_tostring(L, 2));
  917. luaL_checktype(L, 3, LUA_TSTRING);
  918. String key = String(lua_tostring(L, 3));
  919. luaL_checktype(L, 4, LUA_TNUMBER);
  920. Number value = lua_tonumber(L, 4);
  921. inst->setNumericValue(configNamespace, key, value);
  922. return 0;
  923. }
  924. static int Polycore_Config_getNumericValue(lua_State *L) {
  925. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  926. Config *inst = (Config*)lua_topointer(L, 1);
  927. luaL_checktype(L, 2, LUA_TSTRING);
  928. String configNamespace = String(lua_tostring(L, 2));
  929. luaL_checktype(L, 3, LUA_TSTRING);
  930. String key = String(lua_tostring(L, 3));
  931. lua_pushnumber(L, inst->getNumericValue(configNamespace, key));
  932. return 1;
  933. }
  934. static int Polycore_Config_getStringValue(lua_State *L) {
  935. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  936. Config *inst = (Config*)lua_topointer(L, 1);
  937. luaL_checktype(L, 2, LUA_TSTRING);
  938. String configNamespace = String(lua_tostring(L, 2));
  939. luaL_checktype(L, 3, LUA_TSTRING);
  940. String key = String(lua_tostring(L, 3));
  941. lua_pushstring(L, inst->getStringValue(configNamespace, key).c_str());
  942. return 1;
  943. }
  944. static int Polycore_delete_Config(lua_State *L) {
  945. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  946. Config *inst = (Config*)lua_topointer(L, 1);
  947. delete inst;
  948. return 0;
  949. }
  950. static int Polycore_PolycodeViewBase(lua_State *L) {
  951. PolycodeViewBase *inst = new PolycodeViewBase();
  952. lua_pushlightuserdata(L, (void*)inst);
  953. return 1;
  954. }
  955. static int Polycore_delete_PolycodeViewBase(lua_State *L) {
  956. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  957. PolycodeViewBase *inst = (PolycodeViewBase*)lua_topointer(L, 1);
  958. delete inst;
  959. return 0;
  960. }
  961. static int Polycore_Core_Update(lua_State *L) {
  962. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  963. Core *inst = (Core*)lua_topointer(L, 1);
  964. lua_pushboolean(L, inst->Update());
  965. return 1;
  966. }
  967. static int Polycore_Core_enableMouse(lua_State *L) {
  968. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  969. Core *inst = (Core*)lua_topointer(L, 1);
  970. luaL_checktype(L, 2, LUA_TBOOLEAN);
  971. bool newval = lua_toboolean(L, 2);
  972. inst->enableMouse(newval);
  973. return 0;
  974. }
  975. static int Polycore_Core_setCursor(lua_State *L) {
  976. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  977. Core *inst = (Core*)lua_topointer(L, 1);
  978. luaL_checktype(L, 2, LUA_TNUMBER);
  979. int cursorType = lua_tointeger(L, 2);
  980. inst->setCursor(cursorType);
  981. return 0;
  982. }
  983. static int Polycore_Core_createThread(lua_State *L) {
  984. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  985. Core *inst = (Core*)lua_topointer(L, 1);
  986. luaL_checktype(L, 2, LUA_TLIGHTUSERDATA);
  987. Threaded * target = (Threaded *)lua_topointer(L, 2);
  988. inst->createThread(target);
  989. return 0;
  990. }
  991. static int Polycore_Core_lockMutex(lua_State *L) {
  992. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  993. Core *inst = (Core*)lua_topointer(L, 1);
  994. luaL_checktype(L, 2, LUA_TLIGHTUSERDATA);
  995. CoreMutex * mutex = (CoreMutex *)lua_topointer(L, 2);
  996. inst->lockMutex(mutex);
  997. return 0;
  998. }
  999. static int Polycore_Core_unlockMutex(lua_State *L) {
  1000. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  1001. Core *inst = (Core*)lua_topointer(L, 1);
  1002. luaL_checktype(L, 2, LUA_TLIGHTUSERDATA);
  1003. CoreMutex * mutex = (CoreMutex *)lua_topointer(L, 2);
  1004. inst->unlockMutex(mutex);
  1005. return 0;
  1006. }
  1007. static int Polycore_Core_createMutex(lua_State *L) {
  1008. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  1009. Core *inst = (Core*)lua_topointer(L, 1);
  1010. void *ptrRetVal = (void*)inst->createMutex();
  1011. if(ptrRetVal == NULL) {
  1012. lua_pushnil(L);
  1013. } else {
  1014. lua_pushlightuserdata(L, ptrRetVal);
  1015. }
  1016. return 1;
  1017. }
  1018. static int Polycore_Core_copyStringToClipboard(lua_State *L) {
  1019. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  1020. Core *inst = (Core*)lua_topointer(L, 1);
  1021. luaL_checktype(L, 2, LUA_TSTRING);
  1022. String str = String(lua_tostring(L, 2));
  1023. inst->copyStringToClipboard(str);
  1024. return 0;
  1025. }
  1026. static int Polycore_Core_getClipboardString(lua_State *L) {
  1027. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  1028. Core *inst = (Core*)lua_topointer(L, 1);
  1029. String *retInst = new String();
  1030. *retInst = inst->getClipboardString();
  1031. lua_pushlightuserdata(L, retInst);
  1032. return 1;
  1033. }
  1034. static int Polycore_Core_getServices(lua_State *L) {
  1035. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  1036. Core *inst = (Core*)lua_topointer(L, 1);
  1037. void *ptrRetVal = (void*)inst->getServices();
  1038. if(ptrRetVal == NULL) {
  1039. lua_pushnil(L);
  1040. } else {
  1041. lua_pushlightuserdata(L, ptrRetVal);
  1042. }
  1043. return 1;
  1044. }
  1045. static int Polycore_Core_getFPS(lua_State *L) {
  1046. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  1047. Core *inst = (Core*)lua_topointer(L, 1);
  1048. lua_pushnumber(L, inst->getFPS());
  1049. return 1;
  1050. }
  1051. static int Polycore_Core_Shutdown(lua_State *L) {
  1052. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  1053. Core *inst = (Core*)lua_topointer(L, 1);
  1054. inst->Shutdown();
  1055. return 0;
  1056. }
  1057. static int Polycore_Core_isFullscreen(lua_State *L) {
  1058. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  1059. Core *inst = (Core*)lua_topointer(L, 1);
  1060. lua_pushboolean(L, inst->isFullscreen());
  1061. return 1;
  1062. }
  1063. static int Polycore_Core_getAALevel(lua_State *L) {
  1064. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  1065. Core *inst = (Core*)lua_topointer(L, 1);
  1066. lua_pushinteger(L, inst->getAALevel());
  1067. return 1;
  1068. }
  1069. static int Polycore_Core_getInput(lua_State *L) {
  1070. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  1071. Core *inst = (Core*)lua_topointer(L, 1);
  1072. void *ptrRetVal = (void*)inst->getInput();
  1073. if(ptrRetVal == NULL) {
  1074. lua_pushnil(L);
  1075. } else {
  1076. lua_pushlightuserdata(L, ptrRetVal);
  1077. }
  1078. return 1;
  1079. }
  1080. static int Polycore_Core_getXRes(lua_State *L) {
  1081. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  1082. Core *inst = (Core*)lua_topointer(L, 1);
  1083. lua_pushnumber(L, inst->getXRes());
  1084. return 1;
  1085. }
  1086. static int Polycore_Core_getYRes(lua_State *L) {
  1087. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  1088. Core *inst = (Core*)lua_topointer(L, 1);
  1089. lua_pushnumber(L, inst->getYRes());
  1090. return 1;
  1091. }
  1092. static int Polycore_Core_getNumVideoModes(lua_State *L) {
  1093. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  1094. Core *inst = (Core*)lua_topointer(L, 1);
  1095. lua_pushinteger(L, inst->getNumVideoModes());
  1096. return 1;
  1097. }
  1098. static int Polycore_Core_createFolder(lua_State *L) {
  1099. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  1100. Core *inst = (Core*)lua_topointer(L, 1);
  1101. luaL_checktype(L, 2, LUA_TSTRING);
  1102. String folderPath = String(lua_tostring(L, 2));
  1103. inst->createFolder(folderPath);
  1104. return 0;
  1105. }
  1106. static int Polycore_Core_copyDiskItem(lua_State *L) {
  1107. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  1108. Core *inst = (Core*)lua_topointer(L, 1);
  1109. luaL_checktype(L, 2, LUA_TSTRING);
  1110. String itemPath = String(lua_tostring(L, 2));
  1111. luaL_checktype(L, 3, LUA_TSTRING);
  1112. String destItemPath = String(lua_tostring(L, 3));
  1113. inst->copyDiskItem(itemPath, destItemPath);
  1114. return 0;
  1115. }
  1116. static int Polycore_Core_moveDiskItem(lua_State *L) {
  1117. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  1118. Core *inst = (Core*)lua_topointer(L, 1);
  1119. luaL_checktype(L, 2, LUA_TSTRING);
  1120. String itemPath = String(lua_tostring(L, 2));
  1121. luaL_checktype(L, 3, LUA_TSTRING);
  1122. String destItemPath = String(lua_tostring(L, 3));
  1123. inst->moveDiskItem(itemPath, destItemPath);
  1124. return 0;
  1125. }
  1126. static int Polycore_Core_removeDiskItem(lua_State *L) {
  1127. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  1128. Core *inst = (Core*)lua_topointer(L, 1);
  1129. luaL_checktype(L, 2, LUA_TSTRING);
  1130. String itemPath = String(lua_tostring(L, 2));
  1131. inst->removeDiskItem(itemPath);
  1132. return 0;
  1133. }
  1134. static int Polycore_Core_openFolderPicker(lua_State *L) {
  1135. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  1136. Core *inst = (Core*)lua_topointer(L, 1);
  1137. String *retInst = new String();
  1138. *retInst = inst->openFolderPicker();
  1139. lua_pushlightuserdata(L, retInst);
  1140. return 1;
  1141. }
  1142. static int Polycore_Core_setVideoModeIndex(lua_State *L) {
  1143. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  1144. Core *inst = (Core*)lua_topointer(L, 1);
  1145. luaL_checktype(L, 2, LUA_TNUMBER);
  1146. int index = lua_tointeger(L, 2);
  1147. luaL_checktype(L, 3, LUA_TBOOLEAN);
  1148. bool fullScreen = lua_toboolean(L, 3);
  1149. luaL_checktype(L, 4, LUA_TNUMBER);
  1150. int aaLevel = lua_tointeger(L, 4);
  1151. inst->setVideoModeIndex(index, fullScreen, aaLevel);
  1152. return 0;
  1153. }
  1154. static int Polycore_Core_setVideoMode(lua_State *L) {
  1155. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  1156. Core *inst = (Core*)lua_topointer(L, 1);
  1157. luaL_checktype(L, 2, LUA_TNUMBER);
  1158. int xRes = lua_tointeger(L, 2);
  1159. luaL_checktype(L, 3, LUA_TNUMBER);
  1160. int yRes = lua_tointeger(L, 3);
  1161. luaL_checktype(L, 4, LUA_TBOOLEAN);
  1162. bool fullScreen = lua_toboolean(L, 4);
  1163. luaL_checktype(L, 5, LUA_TNUMBER);
  1164. int aaLevel = lua_tointeger(L, 5);
  1165. inst->setVideoMode(xRes, yRes, fullScreen, aaLevel);
  1166. return 0;
  1167. }
  1168. static int Polycore_Core_resizeTo(lua_State *L) {
  1169. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  1170. Core *inst = (Core*)lua_topointer(L, 1);
  1171. luaL_checktype(L, 2, LUA_TNUMBER);
  1172. int xRes = lua_tointeger(L, 2);
  1173. luaL_checktype(L, 3, LUA_TNUMBER);
  1174. int yRes = lua_tointeger(L, 3);
  1175. inst->resizeTo(xRes, yRes);
  1176. return 0;
  1177. }
  1178. static int Polycore_Core_doSleep(lua_State *L) {
  1179. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  1180. Core *inst = (Core*)lua_topointer(L, 1);
  1181. inst->doSleep();
  1182. return 0;
  1183. }
  1184. static int Polycore_Core_getElapsed(lua_State *L) {
  1185. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  1186. Core *inst = (Core*)lua_topointer(L, 1);
  1187. lua_pushnumber(L, inst->getElapsed());
  1188. return 1;
  1189. }
  1190. static int Polycore_Core_getTicks(lua_State *L) {
  1191. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  1192. Core *inst = (Core*)lua_topointer(L, 1);
  1193. unsigned int *retInst = new unsigned int();
  1194. *retInst = inst->getTicks();
  1195. lua_pushlightuserdata(L, retInst);
  1196. return 1;
  1197. }
  1198. static int Polycore_Core_getTicksFloat(lua_State *L) {
  1199. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  1200. Core *inst = (Core*)lua_topointer(L, 1);
  1201. lua_pushnumber(L, inst->getTicksFloat());
  1202. return 1;
  1203. }
  1204. static int Polycore_Core_setUserPointer(lua_State *L) {
  1205. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  1206. Core *inst = (Core*)lua_topointer(L, 1);
  1207. luaL_checktype(L, 2, LUA_TLIGHTUSERDATA);
  1208. void * ptr = (void *)lua_topointer(L, 2);
  1209. inst->setUserPointer(ptr);
  1210. return 0;
  1211. }
  1212. static int Polycore_Core_getUserPointer(lua_State *L) {
  1213. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  1214. Core *inst = (Core*)lua_topointer(L, 1);
  1215. void *ptrRetVal = (void*)inst->getUserPointer();
  1216. if(ptrRetVal == NULL) {
  1217. lua_pushnil(L);
  1218. } else {
  1219. lua_pushlightuserdata(L, ptrRetVal);
  1220. }
  1221. return 1;
  1222. }
  1223. static int Polycore_delete_Core(lua_State *L) {
  1224. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  1225. Core *inst = (Core*)lua_topointer(L, 1);
  1226. delete inst;
  1227. return 0;
  1228. }
  1229. static int Polycore_CoreInput(lua_State *L) {
  1230. CoreInput *inst = new CoreInput();
  1231. lua_pushlightuserdata(L, (void*)inst);
  1232. return 1;
  1233. }
  1234. static int Polycore_CoreInput_getMousePosition(lua_State *L) {
  1235. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  1236. CoreInput *inst = (CoreInput*)lua_topointer(L, 1);
  1237. Vector2 *retInst = new Vector2();
  1238. *retInst = inst->getMousePosition();
  1239. lua_pushlightuserdata(L, retInst);
  1240. return 1;
  1241. }
  1242. static int Polycore_CoreInput_getKeyState(lua_State *L) {
  1243. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  1244. CoreInput *inst = (CoreInput*)lua_topointer(L, 1);
  1245. luaL_checktype(L, 2, LUA_TLIGHTUSERDATA);
  1246. PolyKEY keyCode = *(PolyKEY*)lua_topointer(L, 2);
  1247. lua_pushboolean(L, inst->getKeyState(keyCode));
  1248. return 1;
  1249. }
  1250. static int Polycore_CoreInput_getMouseDelta(lua_State *L) {
  1251. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  1252. CoreInput *inst = (CoreInput*)lua_topointer(L, 1);
  1253. Vector2 *retInst = new Vector2();
  1254. *retInst = inst->getMouseDelta();
  1255. lua_pushlightuserdata(L, retInst);
  1256. return 1;
  1257. }
  1258. static int Polycore_CoreInput_getMouseButtonState(lua_State *L) {
  1259. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  1260. CoreInput *inst = (CoreInput*)lua_topointer(L, 1);
  1261. luaL_checktype(L, 2, LUA_TNUMBER);
  1262. int mouseButton = lua_tointeger(L, 2);
  1263. lua_pushboolean(L, inst->getMouseButtonState(mouseButton));
  1264. return 1;
  1265. }
  1266. static int Polycore_CoreInput_mouseWheelUp(lua_State *L) {
  1267. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  1268. CoreInput *inst = (CoreInput*)lua_topointer(L, 1);
  1269. luaL_checktype(L, 2, LUA_TNUMBER);
  1270. int ticks = lua_tointeger(L, 2);
  1271. inst->mouseWheelUp(ticks);
  1272. return 0;
  1273. }
  1274. static int Polycore_CoreInput_mouseWheelDown(lua_State *L) {
  1275. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  1276. CoreInput *inst = (CoreInput*)lua_topointer(L, 1);
  1277. luaL_checktype(L, 2, LUA_TNUMBER);
  1278. int ticks = lua_tointeger(L, 2);
  1279. inst->mouseWheelDown(ticks);
  1280. return 0;
  1281. }
  1282. static int Polycore_CoreInput_setMouseButtonState(lua_State *L) {
  1283. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  1284. CoreInput *inst = (CoreInput*)lua_topointer(L, 1);
  1285. luaL_checktype(L, 2, LUA_TNUMBER);
  1286. int mouseButton = lua_tointeger(L, 2);
  1287. luaL_checktype(L, 3, LUA_TBOOLEAN);
  1288. bool state = lua_toboolean(L, 3);
  1289. luaL_checktype(L, 4, LUA_TNUMBER);
  1290. int ticks = lua_tointeger(L, 4);
  1291. inst->setMouseButtonState(mouseButton, state, ticks);
  1292. return 0;
  1293. }
  1294. static int Polycore_CoreInput_setMousePosition(lua_State *L) {
  1295. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  1296. CoreInput *inst = (CoreInput*)lua_topointer(L, 1);
  1297. luaL_checktype(L, 2, LUA_TNUMBER);
  1298. int x = lua_tointeger(L, 2);
  1299. luaL_checktype(L, 3, LUA_TNUMBER);
  1300. int y = lua_tointeger(L, 3);
  1301. luaL_checktype(L, 4, LUA_TNUMBER);
  1302. int ticks = lua_tointeger(L, 4);
  1303. inst->setMousePosition(x, y, ticks);
  1304. return 0;
  1305. }
  1306. static int Polycore_CoreInput_setKeyState(lua_State *L) {
  1307. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  1308. CoreInput *inst = (CoreInput*)lua_topointer(L, 1);
  1309. luaL_checktype(L, 2, LUA_TLIGHTUSERDATA);
  1310. PolyKEY keyCode = *(PolyKEY*)lua_topointer(L, 2);
  1311. luaL_checktype(L, 3, LUA_TLIGHTUSERDATA);
  1312. wchar_t code = *(wchar_t*)lua_topointer(L, 3);
  1313. luaL_checktype(L, 4, LUA_TBOOLEAN);
  1314. bool newState = lua_toboolean(L, 4);
  1315. luaL_checktype(L, 5, LUA_TNUMBER);
  1316. int ticks = lua_tointeger(L, 5);
  1317. inst->setKeyState(keyCode, code, newState, ticks);
  1318. return 0;
  1319. }
  1320. static int Polycore_CoreInput_setDeltaPosition(lua_State *L) {
  1321. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  1322. CoreInput *inst = (CoreInput*)lua_topointer(L, 1);
  1323. luaL_checktype(L, 2, LUA_TNUMBER);
  1324. int x = lua_tointeger(L, 2);
  1325. luaL_checktype(L, 3, LUA_TNUMBER);
  1326. int y = lua_tointeger(L, 3);
  1327. inst->setDeltaPosition(x, y);
  1328. return 0;
  1329. }
  1330. static int Polycore_CoreInput_createEvent(lua_State *L) {
  1331. luaL_checktype(L, 2, LUA_TLIGHTUSERDATA);
  1332. Event * event = (Event *)lua_topointer(L, 2);
  1333. void *ptrRetVal = (void*)CoreInput::createEvent(event);
  1334. if(ptrRetVal == NULL) {
  1335. lua_pushnil(L);
  1336. } else {
  1337. lua_pushlightuserdata(L, ptrRetVal);
  1338. }
  1339. return 1;
  1340. }
  1341. static int Polycore_delete_CoreInput(lua_State *L) {
  1342. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  1343. CoreInput *inst = (CoreInput*)lua_topointer(L, 1);
  1344. delete inst;
  1345. return 0;
  1346. }
  1347. static int Polycore_CoreServices_getInstance(lua_State *L) {
  1348. void *ptrRetVal = (void*)CoreServices::getInstance();
  1349. if(ptrRetVal == NULL) {
  1350. lua_pushnil(L);
  1351. } else {
  1352. lua_pushlightuserdata(L, ptrRetVal);
  1353. }
  1354. return 1;
  1355. }
  1356. static int Polycore_CoreServices_setInstance(lua_State *L) {
  1357. luaL_checktype(L, 2, LUA_TLIGHTUSERDATA);
  1358. CoreServices * _instance = (CoreServices *)lua_topointer(L, 2);
  1359. CoreServices::setInstance(_instance);
  1360. return 0;
  1361. }
  1362. static int Polycore_CoreServices_getRenderMutex(lua_State *L) {
  1363. void *ptrRetVal = (void*)CoreServices::getRenderMutex();
  1364. if(ptrRetVal == NULL) {
  1365. lua_pushnil(L);
  1366. } else {
  1367. lua_pushlightuserdata(L, ptrRetVal);
  1368. }
  1369. return 1;
  1370. }
  1371. static int Polycore_CoreServices_setRenderer(lua_State *L) {
  1372. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  1373. CoreServices *inst = (CoreServices*)lua_topointer(L, 1);
  1374. luaL_checktype(L, 2, LUA_TLIGHTUSERDATA);
  1375. Renderer * r_enderer = (Renderer *)lua_topointer(L, 2);
  1376. inst->setRenderer(r_enderer);
  1377. return 0;
  1378. }
  1379. static int Polycore_CoreServices_getRenderer(lua_State *L) {
  1380. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  1381. CoreServices *inst = (CoreServices*)lua_topointer(L, 1);
  1382. void *ptrRetVal = (void*)inst->getRenderer();
  1383. if(ptrRetVal == NULL) {
  1384. lua_pushnil(L);
  1385. } else {
  1386. lua_pushlightuserdata(L, ptrRetVal);
  1387. }
  1388. return 1;
  1389. }
  1390. static int Polycore_CoreServices_Update(lua_State *L) {
  1391. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  1392. CoreServices *inst = (CoreServices*)lua_topointer(L, 1);
  1393. luaL_checktype(L, 2, LUA_TNUMBER);
  1394. int elapsed = lua_tointeger(L, 2);
  1395. inst->Update(elapsed);
  1396. return 0;
  1397. }
  1398. static int Polycore_CoreServices_setCore(lua_State *L) {
  1399. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  1400. CoreServices *inst = (CoreServices*)lua_topointer(L, 1);
  1401. luaL_checktype(L, 2, LUA_TLIGHTUSERDATA);
  1402. Core * core = (Core *)lua_topointer(L, 2);
  1403. inst->setCore(core);
  1404. return 0;
  1405. }
  1406. static int Polycore_CoreServices_getCore(lua_State *L) {
  1407. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  1408. CoreServices *inst = (CoreServices*)lua_topointer(L, 1);
  1409. void *ptrRetVal = (void*)inst->getCore();
  1410. if(ptrRetVal == NULL) {
  1411. lua_pushnil(L);
  1412. } else {
  1413. lua_pushlightuserdata(L, ptrRetVal);
  1414. }
  1415. return 1;
  1416. }
  1417. static int Polycore_CoreServices_installModule(lua_State *L) {
  1418. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  1419. CoreServices *inst = (CoreServices*)lua_topointer(L, 1);
  1420. luaL_checktype(L, 2, LUA_TLIGHTUSERDATA);
  1421. PolycodeModule * module = (PolycodeModule *)lua_topointer(L, 2);
  1422. inst->installModule(module);
  1423. return 0;
  1424. }
  1425. static int Polycore_CoreServices_getMaterialManager(lua_State *L) {
  1426. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  1427. CoreServices *inst = (CoreServices*)lua_topointer(L, 1);
  1428. void *ptrRetVal = (void*)inst->getMaterialManager();
  1429. if(ptrRetVal == NULL) {
  1430. lua_pushnil(L);
  1431. } else {
  1432. lua_pushlightuserdata(L, ptrRetVal);
  1433. }
  1434. return 1;
  1435. }
  1436. static int Polycore_CoreServices_getScreenManager(lua_State *L) {
  1437. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  1438. CoreServices *inst = (CoreServices*)lua_topointer(L, 1);
  1439. void *ptrRetVal = (void*)inst->getScreenManager();
  1440. if(ptrRetVal == NULL) {
  1441. lua_pushnil(L);
  1442. } else {
  1443. lua_pushlightuserdata(L, ptrRetVal);
  1444. }
  1445. return 1;
  1446. }
  1447. static int Polycore_CoreServices_getSceneManager(lua_State *L) {
  1448. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  1449. CoreServices *inst = (CoreServices*)lua_topointer(L, 1);
  1450. void *ptrRetVal = (void*)inst->getSceneManager();
  1451. if(ptrRetVal == NULL) {
  1452. lua_pushnil(L);
  1453. } else {
  1454. lua_pushlightuserdata(L, ptrRetVal);
  1455. }
  1456. return 1;
  1457. }
  1458. static int Polycore_CoreServices_getTimerManager(lua_State *L) {
  1459. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  1460. CoreServices *inst = (CoreServices*)lua_topointer(L, 1);
  1461. void *ptrRetVal = (void*)inst->getTimerManager();
  1462. if(ptrRetVal == NULL) {
  1463. lua_pushnil(L);
  1464. } else {
  1465. lua_pushlightuserdata(L, ptrRetVal);
  1466. }
  1467. return 1;
  1468. }
  1469. static int Polycore_CoreServices_getTweenManager(lua_State *L) {
  1470. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  1471. CoreServices *inst = (CoreServices*)lua_topointer(L, 1);
  1472. void *ptrRetVal = (void*)inst->getTweenManager();
  1473. if(ptrRetVal == NULL) {
  1474. lua_pushnil(L);
  1475. } else {
  1476. lua_pushlightuserdata(L, ptrRetVal);
  1477. }
  1478. return 1;
  1479. }
  1480. static int Polycore_CoreServices_getResourceManager(lua_State *L) {
  1481. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  1482. CoreServices *inst = (CoreServices*)lua_topointer(L, 1);
  1483. void *ptrRetVal = (void*)inst->getResourceManager();
  1484. if(ptrRetVal == NULL) {
  1485. lua_pushnil(L);
  1486. } else {
  1487. lua_pushlightuserdata(L, ptrRetVal);
  1488. }
  1489. return 1;
  1490. }
  1491. static int Polycore_CoreServices_getSoundManager(lua_State *L) {
  1492. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  1493. CoreServices *inst = (CoreServices*)lua_topointer(L, 1);
  1494. void *ptrRetVal = (void*)inst->getSoundManager();
  1495. if(ptrRetVal == NULL) {
  1496. lua_pushnil(L);
  1497. } else {
  1498. lua_pushlightuserdata(L, ptrRetVal);
  1499. }
  1500. return 1;
  1501. }
  1502. static int Polycore_CoreServices_getFontManager(lua_State *L) {
  1503. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  1504. CoreServices *inst = (CoreServices*)lua_topointer(L, 1);
  1505. void *ptrRetVal = (void*)inst->getFontManager();
  1506. if(ptrRetVal == NULL) {
  1507. lua_pushnil(L);
  1508. } else {
  1509. lua_pushlightuserdata(L, ptrRetVal);
  1510. }
  1511. return 1;
  1512. }
  1513. static int Polycore_CoreServices_getConfig(lua_State *L) {
  1514. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  1515. CoreServices *inst = (CoreServices*)lua_topointer(L, 1);
  1516. void *ptrRetVal = (void*)inst->getConfig();
  1517. if(ptrRetVal == NULL) {
  1518. lua_pushnil(L);
  1519. } else {
  1520. lua_pushlightuserdata(L, ptrRetVal);
  1521. }
  1522. return 1;
  1523. }
  1524. static int Polycore_delete_CoreServices(lua_State *L) {
  1525. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  1526. CoreServices *inst = (CoreServices*)lua_topointer(L, 1);
  1527. delete inst;
  1528. return 0;
  1529. }
  1530. static int Polycore_Cubemap(lua_State *L) {
  1531. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  1532. Texture * t0 = (Texture *)lua_topointer(L, 1);
  1533. luaL_checktype(L, 2, LUA_TLIGHTUSERDATA);
  1534. Texture * t1 = (Texture *)lua_topointer(L, 2);
  1535. luaL_checktype(L, 3, LUA_TLIGHTUSERDATA);
  1536. Texture * t2 = (Texture *)lua_topointer(L, 3);
  1537. luaL_checktype(L, 4, LUA_TLIGHTUSERDATA);
  1538. Texture * t3 = (Texture *)lua_topointer(L, 4);
  1539. luaL_checktype(L, 5, LUA_TLIGHTUSERDATA);
  1540. Texture * t4 = (Texture *)lua_topointer(L, 5);
  1541. luaL_checktype(L, 6, LUA_TLIGHTUSERDATA);
  1542. Texture * t5 = (Texture *)lua_topointer(L, 6);
  1543. Cubemap *inst = new Cubemap(t0, t1, t2, t3, t4, t5);
  1544. lua_pushlightuserdata(L, (void*)inst);
  1545. return 1;
  1546. }
  1547. static int Polycore_delete_Cubemap(lua_State *L) {
  1548. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  1549. Cubemap *inst = (Cubemap*)lua_topointer(L, 1);
  1550. delete inst;
  1551. return 0;
  1552. }
  1553. static int Polycore_Data(lua_State *L) {
  1554. Data *inst = new Data();
  1555. lua_pushlightuserdata(L, (void*)inst);
  1556. return 1;
  1557. }
  1558. static int Polycore_Data_loadFromFile(lua_State *L) {
  1559. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  1560. Data *inst = (Data*)lua_topointer(L, 1);
  1561. luaL_checktype(L, 2, LUA_TSTRING);
  1562. String fileName = String(lua_tostring(L, 2));
  1563. inst->loadFromFile(fileName);
  1564. return 0;
  1565. }
  1566. static int Polycore_Data_getAsString(lua_State *L) {
  1567. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  1568. Data *inst = (Data*)lua_topointer(L, 1);
  1569. luaL_checktype(L, 2, LUA_TNUMBER);
  1570. int encoding = lua_tointeger(L, 2);
  1571. lua_pushstring(L, inst->getAsString(encoding).c_str());
  1572. return 1;
  1573. }
  1574. static int Polycore_Data_setFromString(lua_State *L) {
  1575. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  1576. Data *inst = (Data*)lua_topointer(L, 1);
  1577. luaL_checktype(L, 2, LUA_TSTRING);
  1578. String str = String(lua_tostring(L, 2));
  1579. luaL_checktype(L, 3, LUA_TNUMBER);
  1580. int encoding = lua_tointeger(L, 3);
  1581. inst->setFromString(str, encoding);
  1582. return 0;
  1583. }
  1584. static int Polycore_Data_saveToFile(lua_State *L) {
  1585. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  1586. Data *inst = (Data*)lua_topointer(L, 1);
  1587. luaL_checktype(L, 2, LUA_TSTRING);
  1588. String fileName = String(lua_tostring(L, 2));
  1589. lua_pushboolean(L, inst->saveToFile(fileName));
  1590. return 1;
  1591. }
  1592. static int Polycore_Data_getData(lua_State *L) {
  1593. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  1594. Data *inst = (Data*)lua_topointer(L, 1);
  1595. void *ptrRetVal = (void*)inst->getData();
  1596. if(ptrRetVal == NULL) {
  1597. lua_pushnil(L);
  1598. } else {
  1599. lua_pushlightuserdata(L, ptrRetVal);
  1600. }
  1601. return 1;
  1602. }
  1603. static int Polycore_delete_Data(lua_State *L) {
  1604. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  1605. Data *inst = (Data*)lua_topointer(L, 1);
  1606. delete inst;
  1607. return 0;
  1608. }
  1609. static int Polycore_Entity_get_custEntityType(lua_State *L) {
  1610. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  1611. Entity *inst = (Entity*)lua_topointer(L, 1);
  1612. lua_pushstring(L, inst->custEntityType.c_str());
  1613. return 1;
  1614. }
  1615. static int Polycore_Entity_get_billboardMode(lua_State *L) {
  1616. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  1617. Entity *inst = (Entity*)lua_topointer(L, 1);
  1618. lua_pushboolean(L, inst->billboardMode);
  1619. return 1;
  1620. }
  1621. static int Polycore_Entity_get_billboardRoll(lua_State *L) {
  1622. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  1623. Entity *inst = (Entity*)lua_topointer(L, 1);
  1624. lua_pushboolean(L, inst->billboardRoll);
  1625. return 1;
  1626. }
  1627. static int Polycore_Entity_get_alphaTest(lua_State *L) {
  1628. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  1629. Entity *inst = (Entity*)lua_topointer(L, 1);
  1630. lua_pushboolean(L, inst->alphaTest);
  1631. return 1;
  1632. }
  1633. static int Polycore_Entity_get_backfaceCulled(lua_State *L) {
  1634. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  1635. Entity *inst = (Entity*)lua_topointer(L, 1);
  1636. lua_pushboolean(L, inst->backfaceCulled);
  1637. return 1;
  1638. }
  1639. static int Polycore_Entity_get_renderWireframe(lua_State *L) {
  1640. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  1641. Entity *inst = (Entity*)lua_topointer(L, 1);
  1642. lua_pushboolean(L, inst->renderWireframe);
  1643. return 1;
  1644. }
  1645. static int Polycore_Entity_get_color(lua_State *L) {
  1646. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  1647. Entity *inst = (Entity*)lua_topointer(L, 1);
  1648. lua_pushlightuserdata(L, &inst->color);
  1649. return 1;
  1650. }
  1651. static int Polycore_Entity_get_enabled(lua_State *L) {
  1652. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  1653. Entity *inst = (Entity*)lua_topointer(L, 1);
  1654. lua_pushboolean(L, inst->enabled);
  1655. return 1;
  1656. }
  1657. static int Polycore_Entity_get_visible(lua_State *L) {
  1658. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  1659. Entity *inst = (Entity*)lua_topointer(L, 1);
  1660. lua_pushboolean(L, inst->visible);
  1661. return 1;
  1662. }
  1663. static int Polycore_Entity_get_depthWrite(lua_State *L) {
  1664. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  1665. Entity *inst = (Entity*)lua_topointer(L, 1);
  1666. lua_pushboolean(L, inst->depthWrite);
  1667. return 1;
  1668. }
  1669. static int Polycore_Entity_get_depthTest(lua_State *L) {
  1670. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  1671. Entity *inst = (Entity*)lua_topointer(L, 1);
  1672. lua_pushboolean(L, inst->depthTest);
  1673. return 1;
  1674. }
  1675. static int Polycore_Entity_get_blendingMode(lua_State *L) {
  1676. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  1677. Entity *inst = (Entity*)lua_topointer(L, 1);
  1678. lua_pushinteger(L, inst->blendingMode);
  1679. return 1;
  1680. }
  1681. static int Polycore_Entity_get_colorAffectsChildren(lua_State *L) {
  1682. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  1683. Entity *inst = (Entity*)lua_topointer(L, 1);
  1684. lua_pushboolean(L, inst->colorAffectsChildren);
  1685. return 1;
  1686. }
  1687. static int Polycore_Entity_get_depthOnly(lua_State *L) {
  1688. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  1689. Entity *inst = (Entity*)lua_topointer(L, 1);
  1690. lua_pushboolean(L, inst->depthOnly);
  1691. return 1;
  1692. }
  1693. static int Polycore_Entity_get_bBox(lua_State *L) {
  1694. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  1695. Entity *inst = (Entity*)lua_topointer(L, 1);
  1696. lua_pushlightuserdata(L, &inst->bBox);
  1697. return 1;
  1698. }
  1699. static int Polycore_Entity_get_ignoreParentMatrix(lua_State *L) {
  1700. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  1701. Entity *inst = (Entity*)lua_topointer(L, 1);
  1702. lua_pushboolean(L, inst->ignoreParentMatrix);
  1703. return 1;
  1704. }
  1705. static int Polycore_Entity_get_isMask(lua_State *L) {
  1706. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  1707. Entity *inst = (Entity*)lua_topointer(L, 1);
  1708. lua_pushboolean(L, inst->isMask);
  1709. return 1;
  1710. }
  1711. static int Polycore_Entity_set_custEntityType(lua_State *L) {
  1712. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  1713. Entity *inst = (Entity*)lua_topointer(L, 1);
  1714. String param = lua_tostring(L, 2);
  1715. inst->custEntityType = param;
  1716. return 0;
  1717. }
  1718. static int Polycore_Entity_set_billboardMode(lua_State *L) {
  1719. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  1720. Entity *inst = (Entity*)lua_topointer(L, 1);
  1721. bool param = lua_toboolean(L, 2);
  1722. inst->billboardMode = param;
  1723. return 0;
  1724. }
  1725. static int Polycore_Entity_set_billboardRoll(lua_State *L) {
  1726. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  1727. Entity *inst = (Entity*)lua_topointer(L, 1);
  1728. bool param = lua_toboolean(L, 2);
  1729. inst->billboardRoll = param;
  1730. return 0;
  1731. }
  1732. static int Polycore_Entity_set_alphaTest(lua_State *L) {
  1733. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  1734. Entity *inst = (Entity*)lua_topointer(L, 1);
  1735. bool param = lua_toboolean(L, 2);
  1736. inst->alphaTest = param;
  1737. return 0;
  1738. }
  1739. static int Polycore_Entity_set_backfaceCulled(lua_State *L) {
  1740. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  1741. Entity *inst = (Entity*)lua_topointer(L, 1);
  1742. bool param = lua_toboolean(L, 2);
  1743. inst->backfaceCulled = param;
  1744. return 0;
  1745. }
  1746. static int Polycore_Entity_set_renderWireframe(lua_State *L) {
  1747. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  1748. Entity *inst = (Entity*)lua_topointer(L, 1);
  1749. bool param = lua_toboolean(L, 2);
  1750. inst->renderWireframe = param;
  1751. return 0;
  1752. }
  1753. static int Polycore_Entity_set_enabled(lua_State *L) {
  1754. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  1755. Entity *inst = (Entity*)lua_topointer(L, 1);
  1756. bool param = lua_toboolean(L, 2);
  1757. inst->enabled = param;
  1758. return 0;
  1759. }
  1760. static int Polycore_Entity_set_visible(lua_State *L) {
  1761. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  1762. Entity *inst = (Entity*)lua_topointer(L, 1);
  1763. bool param = lua_toboolean(L, 2);
  1764. inst->visible = param;
  1765. return 0;
  1766. }
  1767. static int Polycore_Entity_set_depthWrite(lua_State *L) {
  1768. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  1769. Entity *inst = (Entity*)lua_topointer(L, 1);
  1770. bool param = lua_toboolean(L, 2);
  1771. inst->depthWrite = param;
  1772. return 0;
  1773. }
  1774. static int Polycore_Entity_set_depthTest(lua_State *L) {
  1775. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  1776. Entity *inst = (Entity*)lua_topointer(L, 1);
  1777. bool param = lua_toboolean(L, 2);
  1778. inst->depthTest = param;
  1779. return 0;
  1780. }
  1781. static int Polycore_Entity_set_blendingMode(lua_State *L) {
  1782. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  1783. Entity *inst = (Entity*)lua_topointer(L, 1);
  1784. int param = lua_tointeger(L, 2);
  1785. inst->blendingMode = param;
  1786. return 0;
  1787. }
  1788. static int Polycore_Entity_set_colorAffectsChildren(lua_State *L) {
  1789. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  1790. Entity *inst = (Entity*)lua_topointer(L, 1);
  1791. bool param = lua_toboolean(L, 2);
  1792. inst->colorAffectsChildren = param;
  1793. return 0;
  1794. }
  1795. static int Polycore_Entity_set_depthOnly(lua_State *L) {
  1796. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  1797. Entity *inst = (Entity*)lua_topointer(L, 1);
  1798. bool param = lua_toboolean(L, 2);
  1799. inst->depthOnly = param;
  1800. return 0;
  1801. }
  1802. static int Polycore_Entity_set_ignoreParentMatrix(lua_State *L) {
  1803. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  1804. Entity *inst = (Entity*)lua_topointer(L, 1);
  1805. bool param = lua_toboolean(L, 2);
  1806. inst->ignoreParentMatrix = param;
  1807. return 0;
  1808. }
  1809. static int Polycore_Entity_set_isMask(lua_State *L) {
  1810. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  1811. Entity *inst = (Entity*)lua_topointer(L, 1);
  1812. bool param = lua_toboolean(L, 2);
  1813. inst->isMask = param;
  1814. return 0;
  1815. }
  1816. static int Polycore_Entity(lua_State *L) {
  1817. Entity *inst = new Entity();
  1818. lua_pushlightuserdata(L, (void*)inst);
  1819. return 1;
  1820. }
  1821. static int Polycore_Entity_Render(lua_State *L) {
  1822. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  1823. Entity *inst = (Entity*)lua_topointer(L, 1);
  1824. inst->Render();
  1825. return 0;
  1826. }
  1827. static int Polycore_Entity_Update(lua_State *L) {
  1828. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  1829. Entity *inst = (Entity*)lua_topointer(L, 1);
  1830. inst->Update();
  1831. return 0;
  1832. }
  1833. static int Polycore_Entity_transformAndRender(lua_State *L) {
  1834. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  1835. Entity *inst = (Entity*)lua_topointer(L, 1);
  1836. inst->transformAndRender();
  1837. return 0;
  1838. }
  1839. static int Polycore_Entity_renderChildren(lua_State *L) {
  1840. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  1841. Entity *inst = (Entity*)lua_topointer(L, 1);
  1842. inst->renderChildren();
  1843. return 0;
  1844. }
  1845. static int Polycore_Entity_dirtyMatrix(lua_State *L) {
  1846. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  1847. Entity *inst = (Entity*)lua_topointer(L, 1);
  1848. luaL_checktype(L, 2, LUA_TBOOLEAN);
  1849. bool val = lua_toboolean(L, 2);
  1850. inst->dirtyMatrix(val);
  1851. return 0;
  1852. }
  1853. static int Polycore_Entity_rebuildTransformMatrix(lua_State *L) {
  1854. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  1855. Entity *inst = (Entity*)lua_topointer(L, 1);
  1856. inst->rebuildTransformMatrix();
  1857. return 0;
  1858. }
  1859. static int Polycore_Entity_updateEntityMatrix(lua_State *L) {
  1860. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  1861. Entity *inst = (Entity*)lua_topointer(L, 1);
  1862. inst->updateEntityMatrix();
  1863. return 0;
  1864. }
  1865. static int Polycore_Entity_getTransformMatrix(lua_State *L) {
  1866. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  1867. Entity *inst = (Entity*)lua_topointer(L, 1);
  1868. Matrix4 *retInst = new Matrix4();
  1869. *retInst = inst->getTransformMatrix();
  1870. lua_pushlightuserdata(L, retInst);
  1871. return 1;
  1872. }
  1873. static int Polycore_Entity_getConcatenatedMatrix(lua_State *L) {
  1874. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  1875. Entity *inst = (Entity*)lua_topointer(L, 1);
  1876. Matrix4 *retInst = new Matrix4();
  1877. *retInst = inst->getConcatenatedMatrix();
  1878. lua_pushlightuserdata(L, retInst);
  1879. return 1;
  1880. }
  1881. static int Polycore_Entity_getConcatenatedRollMatrix(lua_State *L) {
  1882. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  1883. Entity *inst = (Entity*)lua_topointer(L, 1);
  1884. Matrix4 *retInst = new Matrix4();
  1885. *retInst = inst->getConcatenatedRollMatrix();
  1886. lua_pushlightuserdata(L, retInst);
  1887. return 1;
  1888. }
  1889. static int Polycore_Entity_setTransformByMatrix(lua_State *L) {
  1890. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  1891. Entity *inst = (Entity*)lua_topointer(L, 1);
  1892. luaL_checktype(L, 2, LUA_TLIGHTUSERDATA);
  1893. Matrix4 matrix = *(Matrix4*)lua_topointer(L, 2);
  1894. inst->setTransformByMatrix(matrix);
  1895. return 0;
  1896. }
  1897. static int Polycore_Entity_setTransformByMatrixPure(lua_State *L) {
  1898. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  1899. Entity *inst = (Entity*)lua_topointer(L, 1);
  1900. luaL_checktype(L, 2, LUA_TLIGHTUSERDATA);
  1901. Matrix4 matrix = *(Matrix4*)lua_topointer(L, 2);
  1902. inst->setTransformByMatrixPure(matrix);
  1903. return 0;
  1904. }
  1905. static int Polycore_Entity_getLookAtMatrix(lua_State *L) {
  1906. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  1907. Entity *inst = (Entity*)lua_topointer(L, 1);
  1908. luaL_checktype(L, 2, LUA_TLIGHTUSERDATA);
  1909. const Vector3 & loc = *( Vector3 *)lua_topointer(L, 2);
  1910. luaL_checktype(L, 3, LUA_TLIGHTUSERDATA);
  1911. const Vector3 & upVector = *( Vector3 *)lua_topointer(L, 3);
  1912. Matrix4 *retInst = new Matrix4();
  1913. *retInst = inst->getLookAtMatrix(loc, upVector);
  1914. lua_pushlightuserdata(L, retInst);
  1915. return 1;
  1916. }
  1917. static int Polycore_Entity_addEntity(lua_State *L) {
  1918. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  1919. Entity *inst = (Entity*)lua_topointer(L, 1);
  1920. luaL_checktype(L, 2, LUA_TLIGHTUSERDATA);
  1921. Entity * newChild = (Entity *)lua_topointer(L, 2);
  1922. inst->addEntity(newChild);
  1923. return 0;
  1924. }
  1925. static int Polycore_Entity_addChild(lua_State *L) {
  1926. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  1927. Entity *inst = (Entity*)lua_topointer(L, 1);
  1928. luaL_checktype(L, 2, LUA_TLIGHTUSERDATA);
  1929. Entity * newChild = (Entity *)lua_topointer(L, 2);
  1930. inst->addChild(newChild);
  1931. return 0;
  1932. }
  1933. static int Polycore_Entity_removeChild(lua_State *L) {
  1934. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  1935. Entity *inst = (Entity*)lua_topointer(L, 1);
  1936. luaL_checktype(L, 2, LUA_TLIGHTUSERDATA);
  1937. Entity * entityToRemove = (Entity *)lua_topointer(L, 2);
  1938. inst->removeChild(entityToRemove);
  1939. return 0;
  1940. }
  1941. static int Polycore_Entity_setParentEntity(lua_State *L) {
  1942. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  1943. Entity *inst = (Entity*)lua_topointer(L, 1);
  1944. luaL_checktype(L, 2, LUA_TLIGHTUSERDATA);
  1945. Entity * entity = (Entity *)lua_topointer(L, 2);
  1946. inst->setParentEntity(entity);
  1947. return 0;
  1948. }
  1949. static int Polycore_Entity_getParentEntity(lua_State *L) {
  1950. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  1951. Entity *inst = (Entity*)lua_topointer(L, 1);
  1952. void *ptrRetVal = (void*)inst->getParentEntity();
  1953. if(ptrRetVal == NULL) {
  1954. lua_pushnil(L);
  1955. } else {
  1956. lua_pushlightuserdata(L, ptrRetVal);
  1957. }
  1958. return 1;
  1959. }
  1960. static int Polycore_Entity_getPosition(lua_State *L) {
  1961. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  1962. Entity *inst = (Entity*)lua_topointer(L, 1);
  1963. Vector3 *retInst = new Vector3();
  1964. *retInst = inst->getPosition();
  1965. lua_pushlightuserdata(L, retInst);
  1966. return 1;
  1967. }
  1968. static int Polycore_Entity_getCombinedPosition(lua_State *L) {
  1969. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  1970. Entity *inst = (Entity*)lua_topointer(L, 1);
  1971. Vector3 *retInst = new Vector3();
  1972. *retInst = inst->getCombinedPosition();
  1973. lua_pushlightuserdata(L, retInst);
  1974. return 1;
  1975. }
  1976. static int Polycore_Entity_setPosition(lua_State *L) {
  1977. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  1978. Entity *inst = (Entity*)lua_topointer(L, 1);
  1979. luaL_checktype(L, 2, LUA_TNUMBER);
  1980. Number x = lua_tonumber(L, 2);
  1981. luaL_checktype(L, 3, LUA_TNUMBER);
  1982. Number y = lua_tonumber(L, 3);
  1983. luaL_checktype(L, 4, LUA_TNUMBER);
  1984. Number z = lua_tonumber(L, 4);
  1985. inst->setPosition(x, y, z);
  1986. return 0;
  1987. }
  1988. static int Polycore_Entity_setPositionX(lua_State *L) {
  1989. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  1990. Entity *inst = (Entity*)lua_topointer(L, 1);
  1991. luaL_checktype(L, 2, LUA_TNUMBER);
  1992. Number x = lua_tonumber(L, 2);
  1993. inst->setPositionX(x);
  1994. return 0;
  1995. }
  1996. static int Polycore_Entity_setPositionY(lua_State *L) {
  1997. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  1998. Entity *inst = (Entity*)lua_topointer(L, 1);
  1999. luaL_checktype(L, 2, LUA_TNUMBER);
  2000. Number y = lua_tonumber(L, 2);
  2001. inst->setPositionY(y);
  2002. return 0;
  2003. }
  2004. static int Polycore_Entity_Translate(lua_State *L) {
  2005. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  2006. Entity *inst = (Entity*)lua_topointer(L, 1);
  2007. luaL_checktype(L, 2, LUA_TNUMBER);
  2008. Number x = lua_tonumber(L, 2);
  2009. luaL_checktype(L, 3, LUA_TNUMBER);
  2010. Number y = lua_tonumber(L, 3);
  2011. luaL_checktype(L, 4, LUA_TNUMBER);
  2012. Number z = lua_tonumber(L, 4);
  2013. inst->Translate(x, y, z);
  2014. return 0;
  2015. }
  2016. static int Polycore_Entity_setPositionZ(lua_State *L) {
  2017. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  2018. Entity *inst = (Entity*)lua_topointer(L, 1);
  2019. luaL_checktype(L, 2, LUA_TNUMBER);
  2020. Number z = lua_tonumber(L, 2);
  2021. inst->setPositionZ(z);
  2022. return 0;
  2023. }
  2024. static int Polycore_Entity_setScaleX(lua_State *L) {
  2025. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  2026. Entity *inst = (Entity*)lua_topointer(L, 1);
  2027. luaL_checktype(L, 2, LUA_TNUMBER);
  2028. Number x = lua_tonumber(L, 2);
  2029. inst->setScaleX(x);
  2030. return 0;
  2031. }
  2032. static int Polycore_Entity_setScaleY(lua_State *L) {
  2033. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  2034. Entity *inst = (Entity*)lua_topointer(L, 1);
  2035. luaL_checktype(L, 2, LUA_TNUMBER);
  2036. Number y = lua_tonumber(L, 2);
  2037. inst->setScaleY(y);
  2038. return 0;
  2039. }
  2040. static int Polycore_Entity_setScaleZ(lua_State *L) {
  2041. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  2042. Entity *inst = (Entity*)lua_topointer(L, 1);
  2043. luaL_checktype(L, 2, LUA_TNUMBER);
  2044. Number z = lua_tonumber(L, 2);
  2045. inst->setScaleZ(z);
  2046. return 0;
  2047. }
  2048. static int Polycore_Entity_Scale(lua_State *L) {
  2049. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  2050. Entity *inst = (Entity*)lua_topointer(L, 1);
  2051. luaL_checktype(L, 2, LUA_TNUMBER);
  2052. Number x = lua_tonumber(L, 2);
  2053. luaL_checktype(L, 3, LUA_TNUMBER);
  2054. Number y = lua_tonumber(L, 3);
  2055. luaL_checktype(L, 4, LUA_TNUMBER);
  2056. Number z = lua_tonumber(L, 4);
  2057. inst->Scale(x, y, z);
  2058. return 0;
  2059. }
  2060. static int Polycore_Entity_setScale(lua_State *L) {
  2061. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  2062. Entity *inst = (Entity*)lua_topointer(L, 1);
  2063. luaL_checktype(L, 2, LUA_TNUMBER);
  2064. Number x = lua_tonumber(L, 2);
  2065. luaL_checktype(L, 3, LUA_TNUMBER);
  2066. Number y = lua_tonumber(L, 3);
  2067. luaL_checktype(L, 4, LUA_TNUMBER);
  2068. Number z = lua_tonumber(L, 4);
  2069. inst->setScale(x, y, z);
  2070. return 0;
  2071. }
  2072. static int Polycore_Entity_getCompoundScale(lua_State *L) {
  2073. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  2074. Entity *inst = (Entity*)lua_topointer(L, 1);
  2075. Vector3 *retInst = new Vector3();
  2076. *retInst = inst->getCompoundScale();
  2077. lua_pushlightuserdata(L, retInst);
  2078. return 1;
  2079. }
  2080. static int Polycore_Entity_getScale(lua_State *L) {
  2081. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  2082. Entity *inst = (Entity*)lua_topointer(L, 1);
  2083. Vector3 *retInst = new Vector3();
  2084. *retInst = inst->getScale();
  2085. lua_pushlightuserdata(L, retInst);
  2086. return 1;
  2087. }
  2088. static int Polycore_Entity_getCombinedPitch(lua_State *L) {
  2089. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  2090. Entity *inst = (Entity*)lua_topointer(L, 1);
  2091. lua_pushnumber(L, inst->getCombinedPitch());
  2092. return 1;
  2093. }
  2094. static int Polycore_Entity_getCombinedYaw(lua_State *L) {
  2095. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  2096. Entity *inst = (Entity*)lua_topointer(L, 1);
  2097. lua_pushnumber(L, inst->getCombinedYaw());
  2098. return 1;
  2099. }
  2100. static int Polycore_Entity_getCombinedRoll(lua_State *L) {
  2101. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  2102. Entity *inst = (Entity*)lua_topointer(L, 1);
  2103. lua_pushnumber(L, inst->getCombinedRoll());
  2104. return 1;
  2105. }
  2106. static int Polycore_Entity_rebuildRotation(lua_State *L) {
  2107. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  2108. Entity *inst = (Entity*)lua_topointer(L, 1);
  2109. inst->rebuildRotation();
  2110. return 0;
  2111. }
  2112. static int Polycore_Entity_setPitch(lua_State *L) {
  2113. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  2114. Entity *inst = (Entity*)lua_topointer(L, 1);
  2115. luaL_checktype(L, 2, LUA_TNUMBER);
  2116. Number pitch = lua_tonumber(L, 2);
  2117. inst->setPitch(pitch);
  2118. return 0;
  2119. }
  2120. static int Polycore_Entity_setYaw(lua_State *L) {
  2121. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  2122. Entity *inst = (Entity*)lua_topointer(L, 1);
  2123. luaL_checktype(L, 2, LUA_TNUMBER);
  2124. Number yaw = lua_tonumber(L, 2);
  2125. inst->setYaw(yaw);
  2126. return 0;
  2127. }
  2128. static int Polycore_Entity_setRoll(lua_State *L) {
  2129. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  2130. Entity *inst = (Entity*)lua_topointer(L, 1);
  2131. luaL_checktype(L, 2, LUA_TNUMBER);
  2132. Number roll = lua_tonumber(L, 2);
  2133. inst->setRoll(roll);
  2134. return 0;
  2135. }
  2136. static int Polycore_Entity_Roll(lua_State *L) {
  2137. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  2138. Entity *inst = (Entity*)lua_topointer(L, 1);
  2139. luaL_checktype(L, 2, LUA_TNUMBER);
  2140. Number roll = lua_tonumber(L, 2);
  2141. inst->Roll(roll);
  2142. return 0;
  2143. }
  2144. static int Polycore_Entity_Yaw(lua_State *L) {
  2145. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  2146. Entity *inst = (Entity*)lua_topointer(L, 1);
  2147. luaL_checktype(L, 2, LUA_TNUMBER);
  2148. Number yaw = lua_tonumber(L, 2);
  2149. inst->Yaw(yaw);
  2150. return 0;
  2151. }
  2152. static int Polycore_Entity_Pitch(lua_State *L) {
  2153. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  2154. Entity *inst = (Entity*)lua_topointer(L, 1);
  2155. luaL_checktype(L, 2, LUA_TNUMBER);
  2156. Number pitch = lua_tonumber(L, 2);
  2157. inst->Pitch(pitch);
  2158. return 0;
  2159. }
  2160. static int Polycore_Entity_getPitch(lua_State *L) {
  2161. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  2162. Entity *inst = (Entity*)lua_topointer(L, 1);
  2163. lua_pushnumber(L, inst->getPitch());
  2164. return 1;
  2165. }
  2166. static int Polycore_Entity_getYaw(lua_State *L) {
  2167. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  2168. Entity *inst = (Entity*)lua_topointer(L, 1);
  2169. lua_pushnumber(L, inst->getYaw());
  2170. return 1;
  2171. }
  2172. static int Polycore_Entity_getRoll(lua_State *L) {
  2173. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  2174. Entity *inst = (Entity*)lua_topointer(L, 1);
  2175. lua_pushnumber(L, inst->getRoll());
  2176. return 1;
  2177. }
  2178. static int Polycore_Entity_setRotationQuat(lua_State *L) {
  2179. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  2180. Entity *inst = (Entity*)lua_topointer(L, 1);
  2181. luaL_checktype(L, 2, LUA_TNUMBER);
  2182. Number w = lua_tonumber(L, 2);
  2183. luaL_checktype(L, 3, LUA_TNUMBER);
  2184. Number x = lua_tonumber(L, 3);
  2185. luaL_checktype(L, 4, LUA_TNUMBER);
  2186. Number y = lua_tonumber(L, 4);
  2187. luaL_checktype(L, 5, LUA_TNUMBER);
  2188. Number z = lua_tonumber(L, 5);
  2189. inst->setRotationQuat(w, x, y, z);
  2190. return 0;
  2191. }
  2192. static int Polycore_Entity_getRotationQuat(lua_State *L) {
  2193. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  2194. Entity *inst = (Entity*)lua_topointer(L, 1);
  2195. Quaternion *retInst = new Quaternion();
  2196. *retInst = inst->getRotationQuat();
  2197. lua_pushlightuserdata(L, retInst);
  2198. return 1;
  2199. }
  2200. static int Polycore_Entity_lookAt(lua_State *L) {
  2201. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  2202. Entity *inst = (Entity*)lua_topointer(L, 1);
  2203. luaL_checktype(L, 2, LUA_TLIGHTUSERDATA);
  2204. const Vector3 & loc = *( Vector3 *)lua_topointer(L, 2);
  2205. luaL_checktype(L, 3, LUA_TLIGHTUSERDATA);
  2206. const Vector3 & upVector = *( Vector3 *)lua_topointer(L, 3);
  2207. inst->lookAt(loc, upVector);
  2208. return 0;
  2209. }
  2210. static int Polycore_Entity_lookAtEntity(lua_State *L) {
  2211. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  2212. Entity *inst = (Entity*)lua_topointer(L, 1);
  2213. luaL_checktype(L, 2, LUA_TLIGHTUSERDATA);
  2214. Entity * entity = (Entity *)lua_topointer(L, 2);
  2215. luaL_checktype(L, 3, LUA_TLIGHTUSERDATA);
  2216. const Vector3 & upVector = *( Vector3 *)lua_topointer(L, 3);
  2217. inst->lookAtEntity(entity, upVector);
  2218. return 0;
  2219. }
  2220. static int Polycore_Entity_getCombinedColor(lua_State *L) {
  2221. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  2222. Entity *inst = (Entity*)lua_topointer(L, 1);
  2223. Color *retInst = new Color();
  2224. *retInst = inst->getCombinedColor();
  2225. lua_pushlightuserdata(L, retInst);
  2226. return 1;
  2227. }
  2228. static int Polycore_Entity_setColor(lua_State *L) {
  2229. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  2230. Entity *inst = (Entity*)lua_topointer(L, 1);
  2231. luaL_checktype(L, 2, LUA_TNUMBER);
  2232. Number r = lua_tonumber(L, 2);
  2233. luaL_checktype(L, 3, LUA_TNUMBER);
  2234. Number g = lua_tonumber(L, 3);
  2235. luaL_checktype(L, 4, LUA_TNUMBER);
  2236. Number b = lua_tonumber(L, 4);
  2237. luaL_checktype(L, 5, LUA_TNUMBER);
  2238. Number a = lua_tonumber(L, 5);
  2239. inst->setColor(r, g, b, a);
  2240. return 0;
  2241. }
  2242. static int Polycore_Entity_setColorInt(lua_State *L) {
  2243. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  2244. Entity *inst = (Entity*)lua_topointer(L, 1);
  2245. luaL_checktype(L, 2, LUA_TNUMBER);
  2246. int r = lua_tointeger(L, 2);
  2247. luaL_checktype(L, 3, LUA_TNUMBER);
  2248. int g = lua_tointeger(L, 3);
  2249. luaL_checktype(L, 4, LUA_TNUMBER);
  2250. int b = lua_tointeger(L, 4);
  2251. luaL_checktype(L, 5, LUA_TNUMBER);
  2252. int a = lua_tointeger(L, 5);
  2253. inst->setColorInt(r, g, b, a);
  2254. return 0;
  2255. }
  2256. static int Polycore_Entity_recalculateBBox(lua_State *L) {
  2257. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  2258. Entity *inst = (Entity*)lua_topointer(L, 1);
  2259. inst->recalculateBBox();
  2260. return 0;
  2261. }
  2262. static int Polycore_Entity_getBBoxRadius(lua_State *L) {
  2263. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  2264. Entity *inst = (Entity*)lua_topointer(L, 1);
  2265. lua_pushnumber(L, inst->getBBoxRadius());
  2266. return 1;
  2267. }
  2268. static int Polycore_Entity_getCompoundBBoxRadius(lua_State *L) {
  2269. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  2270. Entity *inst = (Entity*)lua_topointer(L, 1);
  2271. lua_pushnumber(L, inst->getCompoundBBoxRadius());
  2272. return 1;
  2273. }
  2274. static int Polycore_Entity_setBBoxRadius(lua_State *L) {
  2275. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  2276. Entity *inst = (Entity*)lua_topointer(L, 1);
  2277. luaL_checktype(L, 2, LUA_TNUMBER);
  2278. Number rad = lua_tonumber(L, 2);
  2279. inst->setBBoxRadius(rad);
  2280. return 0;
  2281. }
  2282. static int Polycore_Entity_setMask(lua_State *L) {
  2283. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  2284. Entity *inst = (Entity*)lua_topointer(L, 1);
  2285. luaL_checktype(L, 2, LUA_TLIGHTUSERDATA);
  2286. Entity * mask = (Entity *)lua_topointer(L, 2);
  2287. inst->setMask(mask);
  2288. return 0;
  2289. }
  2290. static int Polycore_Entity_clearMask(lua_State *L) {
  2291. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  2292. Entity *inst = (Entity*)lua_topointer(L, 1);
  2293. inst->clearMask();
  2294. return 0;
  2295. }
  2296. static int Polycore_Entity_setBlendingMode(lua_State *L) {
  2297. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  2298. Entity *inst = (Entity*)lua_topointer(L, 1);
  2299. luaL_checktype(L, 2, LUA_TNUMBER);
  2300. int newBl_endingMode = lua_tointeger(L, 2);
  2301. inst->setBlendingMode(newBl_endingMode);
  2302. return 0;
  2303. }
  2304. static int Polycore_Entity_getChildCenter(lua_State *L) {
  2305. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  2306. Entity *inst = (Entity*)lua_topointer(L, 1);
  2307. Vector3 *retInst = new Vector3();
  2308. *retInst = inst->getChildCenter();
  2309. lua_pushlightuserdata(L, retInst);
  2310. return 1;
  2311. }
  2312. static int Polycore_Entity_getEntityProp(lua_State *L) {
  2313. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  2314. Entity *inst = (Entity*)lua_topointer(L, 1);
  2315. luaL_checktype(L, 2, LUA_TSTRING);
  2316. String propName = String(lua_tostring(L, 2));
  2317. lua_pushstring(L, inst->getEntityProp(propName).c_str());
  2318. return 1;
  2319. }
  2320. static int Polycore_Entity_doUpdates(lua_State *L) {
  2321. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  2322. Entity *inst = (Entity*)lua_topointer(L, 1);
  2323. inst->doUpdates();
  2324. return 0;
  2325. }
  2326. static int Polycore_Entity_buildPositionMatrix(lua_State *L) {
  2327. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  2328. Entity *inst = (Entity*)lua_topointer(L, 1);
  2329. Matrix4 *retInst = new Matrix4();
  2330. *retInst = inst->buildPositionMatrix();
  2331. lua_pushlightuserdata(L, retInst);
  2332. return 1;
  2333. }
  2334. static int Polycore_Entity_adjustMatrixForChildren(lua_State *L) {
  2335. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  2336. Entity *inst = (Entity*)lua_topointer(L, 1);
  2337. inst->adjustMatrixForChildren();
  2338. return 0;
  2339. }
  2340. static int Polycore_Entity_setRenderer(lua_State *L) {
  2341. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  2342. Entity *inst = (Entity*)lua_topointer(L, 1);
  2343. luaL_checktype(L, 2, LUA_TLIGHTUSERDATA);
  2344. Renderer * r_enderer = (Renderer *)lua_topointer(L, 2);
  2345. inst->setRenderer(r_enderer);
  2346. return 0;
  2347. }
  2348. static int Polycore_delete_Entity(lua_State *L) {
  2349. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  2350. Entity *inst = (Entity*)lua_topointer(L, 1);
  2351. delete inst;
  2352. return 0;
  2353. }
  2354. static int Polycore_Event(lua_State *L) {
  2355. Event *inst = new Event();
  2356. lua_pushlightuserdata(L, (void*)inst);
  2357. return 1;
  2358. }
  2359. static int Polycore_Event_getEventCode(lua_State *L) {
  2360. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  2361. Event *inst = (Event*)lua_topointer(L, 1);
  2362. lua_pushinteger(L, inst->getEventCode());
  2363. return 1;
  2364. }
  2365. static int Polycore_Event_getDispatcher(lua_State *L) {
  2366. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  2367. Event *inst = (Event*)lua_topointer(L, 1);
  2368. void *ptrRetVal = (void*)inst->getDispatcher();
  2369. if(ptrRetVal == NULL) {
  2370. lua_pushnil(L);
  2371. } else {
  2372. lua_pushlightuserdata(L, ptrRetVal);
  2373. }
  2374. return 1;
  2375. }
  2376. static int Polycore_Event_setEventCode(lua_State *L) {
  2377. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  2378. Event *inst = (Event*)lua_topointer(L, 1);
  2379. luaL_checktype(L, 2, LUA_TNUMBER);
  2380. int eventCode = lua_tointeger(L, 2);
  2381. inst->setEventCode(eventCode);
  2382. return 0;
  2383. }
  2384. static int Polycore_Event_setDispatcher(lua_State *L) {
  2385. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  2386. Event *inst = (Event*)lua_topointer(L, 1);
  2387. luaL_checktype(L, 2, LUA_TLIGHTUSERDATA);
  2388. EventDispatcher * dispatcher = (EventDispatcher *)lua_topointer(L, 2);
  2389. inst->setDispatcher(dispatcher);
  2390. return 0;
  2391. }
  2392. static int Polycore_Event_getEventType(lua_State *L) {
  2393. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  2394. Event *inst = (Event*)lua_topointer(L, 1);
  2395. lua_pushstring(L, inst->getEventType().c_str());
  2396. return 1;
  2397. }
  2398. static int Polycore_delete_Event(lua_State *L) {
  2399. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  2400. Event *inst = (Event*)lua_topointer(L, 1);
  2401. delete inst;
  2402. return 0;
  2403. }
  2404. static int Polycore_EventDispatcher(lua_State *L) {
  2405. EventDispatcher *inst = new EventDispatcher();
  2406. lua_pushlightuserdata(L, (void*)inst);
  2407. return 1;
  2408. }
  2409. static int Polycore_EventDispatcher_removeAllHandlers(lua_State *L) {
  2410. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  2411. EventDispatcher *inst = (EventDispatcher*)lua_topointer(L, 1);
  2412. inst->removeAllHandlers();
  2413. return 0;
  2414. }
  2415. static int Polycore_EventDispatcher_removeAllHandlersForListener(lua_State *L) {
  2416. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  2417. EventDispatcher *inst = (EventDispatcher*)lua_topointer(L, 1);
  2418. luaL_checktype(L, 2, LUA_TLIGHTUSERDATA);
  2419. void * listener = (void *)lua_topointer(L, 2);
  2420. inst->removeAllHandlersForListener(listener);
  2421. return 0;
  2422. }
  2423. static int Polycore_EventDispatcher_addEventListener(lua_State *L) {
  2424. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  2425. EventDispatcher *inst = (EventDispatcher*)lua_topointer(L, 1);
  2426. luaL_checktype(L, 2, LUA_TLIGHTUSERDATA);
  2427. EventHandler * handler = (EventHandler *)lua_topointer(L, 2);
  2428. luaL_checktype(L, 3, LUA_TNUMBER);
  2429. int eventCode = lua_tointeger(L, 3);
  2430. inst->addEventListener(handler, eventCode);
  2431. return 0;
  2432. }
  2433. static int Polycore_EventDispatcher_removeEventListener(lua_State *L) {
  2434. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  2435. EventDispatcher *inst = (EventDispatcher*)lua_topointer(L, 1);
  2436. luaL_checktype(L, 2, LUA_TLIGHTUSERDATA);
  2437. EventHandler * handler = (EventHandler *)lua_topointer(L, 2);
  2438. luaL_checktype(L, 3, LUA_TNUMBER);
  2439. int eventCode = lua_tointeger(L, 3);
  2440. inst->removeEventListener(handler, eventCode);
  2441. return 0;
  2442. }
  2443. static int Polycore_EventDispatcher___dispatchEvent(lua_State *L) {
  2444. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  2445. EventDispatcher *inst = (EventDispatcher*)lua_topointer(L, 1);
  2446. luaL_checktype(L, 2, LUA_TLIGHTUSERDATA);
  2447. Event * event = (Event *)lua_topointer(L, 2);
  2448. luaL_checktype(L, 3, LUA_TNUMBER);
  2449. int eventCode = lua_tointeger(L, 3);
  2450. inst->__dispatchEvent(event, eventCode);
  2451. return 0;
  2452. }
  2453. static int Polycore_EventDispatcher_dispatchEvent(lua_State *L) {
  2454. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  2455. EventDispatcher *inst = (EventDispatcher*)lua_topointer(L, 1);
  2456. luaL_checktype(L, 2, LUA_TLIGHTUSERDATA);
  2457. Event * event = (Event *)lua_topointer(L, 2);
  2458. luaL_checktype(L, 3, LUA_TNUMBER);
  2459. int eventCode = lua_tointeger(L, 3);
  2460. inst->dispatchEvent(event, eventCode);
  2461. return 0;
  2462. }
  2463. static int Polycore_EventDispatcher_dispatchEventNoDelete(lua_State *L) {
  2464. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  2465. EventDispatcher *inst = (EventDispatcher*)lua_topointer(L, 1);
  2466. luaL_checktype(L, 2, LUA_TLIGHTUSERDATA);
  2467. Event * event = (Event *)lua_topointer(L, 2);
  2468. luaL_checktype(L, 3, LUA_TNUMBER);
  2469. int eventCode = lua_tointeger(L, 3);
  2470. inst->dispatchEventNoDelete(event, eventCode);
  2471. return 0;
  2472. }
  2473. static int Polycore_delete_EventDispatcher(lua_State *L) {
  2474. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  2475. EventDispatcher *inst = (EventDispatcher*)lua_topointer(L, 1);
  2476. delete inst;
  2477. return 0;
  2478. }
  2479. static int Polycore_EventHandler(lua_State *L) {
  2480. LuaEventHandler *inst = new LuaEventHandler();
  2481. inst->wrapperIndex = luaL_ref(L, LUA_REGISTRYINDEX );
  2482. inst->L = L;
  2483. lua_pushlightuserdata(L, (void*)inst);
  2484. return 1;
  2485. }
  2486. static int Polycore_delete_EventHandler(lua_State *L) {
  2487. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  2488. EventHandler *inst = (EventHandler*)lua_topointer(L, 1);
  2489. delete inst;
  2490. return 0;
  2491. }
  2492. static int Polycore_FixedShader(lua_State *L) {
  2493. FixedShader *inst = new FixedShader();
  2494. lua_pushlightuserdata(L, (void*)inst);
  2495. return 1;
  2496. }
  2497. static int Polycore_FixedShader_createBinding(lua_State *L) {
  2498. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  2499. FixedShader *inst = (FixedShader*)lua_topointer(L, 1);
  2500. void *ptrRetVal = (void*)inst->createBinding();
  2501. if(ptrRetVal == NULL) {
  2502. lua_pushnil(L);
  2503. } else {
  2504. lua_pushlightuserdata(L, ptrRetVal);
  2505. }
  2506. return 1;
  2507. }
  2508. static int Polycore_delete_FixedShader(lua_State *L) {
  2509. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  2510. FixedShader *inst = (FixedShader*)lua_topointer(L, 1);
  2511. delete inst;
  2512. return 0;
  2513. }
  2514. static int Polycore_FixedShaderBinding(lua_State *L) {
  2515. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  2516. FixedShader * shader = (FixedShader *)lua_topointer(L, 1);
  2517. FixedShaderBinding *inst = new FixedShaderBinding(shader);
  2518. lua_pushlightuserdata(L, (void*)inst);
  2519. return 1;
  2520. }
  2521. static int Polycore_FixedShaderBinding_addTexture(lua_State *L) {
  2522. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  2523. FixedShaderBinding *inst = (FixedShaderBinding*)lua_topointer(L, 1);
  2524. luaL_checktype(L, 2, LUA_TSTRING);
  2525. String name = String(lua_tostring(L, 2));
  2526. luaL_checktype(L, 3, LUA_TLIGHTUSERDATA);
  2527. Texture * texture = (Texture *)lua_topointer(L, 3);
  2528. inst->addTexture(name, texture);
  2529. return 0;
  2530. }
  2531. static int Polycore_FixedShaderBinding_addCubemap(lua_State *L) {
  2532. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  2533. FixedShaderBinding *inst = (FixedShaderBinding*)lua_topointer(L, 1);
  2534. luaL_checktype(L, 2, LUA_TSTRING);
  2535. String name = String(lua_tostring(L, 2));
  2536. luaL_checktype(L, 3, LUA_TLIGHTUSERDATA);
  2537. Cubemap * cubemap = (Cubemap *)lua_topointer(L, 3);
  2538. inst->addCubemap(name, cubemap);
  2539. return 0;
  2540. }
  2541. static int Polycore_FixedShaderBinding_addParam(lua_State *L) {
  2542. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  2543. FixedShaderBinding *inst = (FixedShaderBinding*)lua_topointer(L, 1);
  2544. luaL_checktype(L, 2, LUA_TSTRING);
  2545. String type = String(lua_tostring(L, 2));
  2546. luaL_checktype(L, 3, LUA_TSTRING);
  2547. String name = String(lua_tostring(L, 3));
  2548. luaL_checktype(L, 4, LUA_TSTRING);
  2549. String value = String(lua_tostring(L, 4));
  2550. inst->addParam(type, name, value);
  2551. return 0;
  2552. }
  2553. static int Polycore_FixedShaderBinding_getDiffuseTexture(lua_State *L) {
  2554. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  2555. FixedShaderBinding *inst = (FixedShaderBinding*)lua_topointer(L, 1);
  2556. void *ptrRetVal = (void*)inst->getDiffuseTexture();
  2557. if(ptrRetVal == NULL) {
  2558. lua_pushnil(L);
  2559. } else {
  2560. lua_pushlightuserdata(L, ptrRetVal);
  2561. }
  2562. return 1;
  2563. }
  2564. static int Polycore_delete_FixedShaderBinding(lua_State *L) {
  2565. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  2566. FixedShaderBinding *inst = (FixedShaderBinding*)lua_topointer(L, 1);
  2567. delete inst;
  2568. return 0;
  2569. }
  2570. static int Polycore_Font(lua_State *L) {
  2571. luaL_checktype(L, 1, LUA_TSTRING);
  2572. String fileName = String(lua_tostring(L, 1));
  2573. Font *inst = new Font(fileName);
  2574. lua_pushlightuserdata(L, (void*)inst);
  2575. return 1;
  2576. }
  2577. static int Polycore_Font_getFace(lua_State *L) {
  2578. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  2579. Font *inst = (Font*)lua_topointer(L, 1);
  2580. FT_Face *retInst = new FT_Face();
  2581. *retInst = inst->getFace();
  2582. lua_pushlightuserdata(L, retInst);
  2583. return 1;
  2584. }
  2585. static int Polycore_Font_isValid(lua_State *L) {
  2586. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  2587. Font *inst = (Font*)lua_topointer(L, 1);
  2588. lua_pushboolean(L, inst->isValid());
  2589. return 1;
  2590. }
  2591. static int Polycore_delete_Font(lua_State *L) {
  2592. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  2593. Font *inst = (Font*)lua_topointer(L, 1);
  2594. delete inst;
  2595. return 0;
  2596. }
  2597. static int Polycore_FontManager(lua_State *L) {
  2598. FontManager *inst = new FontManager();
  2599. lua_pushlightuserdata(L, (void*)inst);
  2600. return 1;
  2601. }
  2602. static int Polycore_FontManager_registerFont(lua_State *L) {
  2603. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  2604. FontManager *inst = (FontManager*)lua_topointer(L, 1);
  2605. luaL_checktype(L, 2, LUA_TSTRING);
  2606. String fontName = String(lua_tostring(L, 2));
  2607. luaL_checktype(L, 3, LUA_TSTRING);
  2608. String fontPath = String(lua_tostring(L, 3));
  2609. inst->registerFont(fontName, fontPath);
  2610. return 0;
  2611. }
  2612. static int Polycore_FontManager_getFontByName(lua_State *L) {
  2613. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  2614. FontManager *inst = (FontManager*)lua_topointer(L, 1);
  2615. luaL_checktype(L, 2, LUA_TSTRING);
  2616. String fontName = String(lua_tostring(L, 2));
  2617. void *ptrRetVal = (void*)inst->getFontByName(fontName);
  2618. if(ptrRetVal == NULL) {
  2619. lua_pushnil(L);
  2620. } else {
  2621. lua_pushlightuserdata(L, ptrRetVal);
  2622. }
  2623. return 1;
  2624. }
  2625. static int Polycore_delete_FontManager(lua_State *L) {
  2626. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  2627. FontManager *inst = (FontManager*)lua_topointer(L, 1);
  2628. delete inst;
  2629. return 0;
  2630. }
  2631. static int Polycore_Image(lua_State *L) {
  2632. luaL_checktype(L, 1, LUA_TSTRING);
  2633. String fileName = String(lua_tostring(L, 1));
  2634. Image *inst = new Image(fileName);
  2635. lua_pushlightuserdata(L, (void*)inst);
  2636. return 1;
  2637. }
  2638. static int Polycore_Image_loadImage(lua_State *L) {
  2639. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  2640. Image *inst = (Image*)lua_topointer(L, 1);
  2641. luaL_checktype(L, 2, LUA_TSTRING);
  2642. String fileName = String(lua_tostring(L, 2));
  2643. lua_pushboolean(L, inst->loadImage(fileName));
  2644. return 1;
  2645. }
  2646. static int Polycore_Image_loadPNG(lua_State *L) {
  2647. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  2648. Image *inst = (Image*)lua_topointer(L, 1);
  2649. luaL_checktype(L, 2, LUA_TSTRING);
  2650. String fileName = String(lua_tostring(L, 2));
  2651. lua_pushboolean(L, inst->loadPNG(fileName));
  2652. return 1;
  2653. }
  2654. static int Polycore_Image_createEmpty(lua_State *L) {
  2655. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  2656. Image *inst = (Image*)lua_topointer(L, 1);
  2657. luaL_checktype(L, 2, LUA_TNUMBER);
  2658. unsigned int width = lua_tointeger(L, 2);
  2659. luaL_checktype(L, 3, LUA_TNUMBER);
  2660. unsigned int height = lua_tointeger(L, 3);
  2661. inst->createEmpty(width, height);
  2662. return 0;
  2663. }
  2664. static int Polycore_Image_fill(lua_State *L) {
  2665. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  2666. Image *inst = (Image*)lua_topointer(L, 1);
  2667. luaL_checktype(L, 2, LUA_TNUMBER);
  2668. Number r = lua_tonumber(L, 2);
  2669. luaL_checktype(L, 3, LUA_TNUMBER);
  2670. Number g = lua_tonumber(L, 3);
  2671. luaL_checktype(L, 4, LUA_TNUMBER);
  2672. Number b = lua_tonumber(L, 4);
  2673. luaL_checktype(L, 5, LUA_TNUMBER);
  2674. Number a = lua_tonumber(L, 5);
  2675. inst->fill(r, g, b, a);
  2676. return 0;
  2677. }
  2678. static int Polycore_Image_setPixel(lua_State *L) {
  2679. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  2680. Image *inst = (Image*)lua_topointer(L, 1);
  2681. luaL_checktype(L, 2, LUA_TNUMBER);
  2682. int x = lua_tointeger(L, 2);
  2683. luaL_checktype(L, 3, LUA_TNUMBER);
  2684. int y = lua_tointeger(L, 3);
  2685. luaL_checktype(L, 4, LUA_TNUMBER);
  2686. Number r = lua_tonumber(L, 4);
  2687. luaL_checktype(L, 5, LUA_TNUMBER);
  2688. Number g = lua_tonumber(L, 5);
  2689. luaL_checktype(L, 6, LUA_TNUMBER);
  2690. Number b = lua_tonumber(L, 6);
  2691. luaL_checktype(L, 7, LUA_TNUMBER);
  2692. Number a = lua_tonumber(L, 7);
  2693. inst->setPixel(x, y, r, g, b, a);
  2694. return 0;
  2695. }
  2696. static int Polycore_Image_getPixel(lua_State *L) {
  2697. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  2698. Image *inst = (Image*)lua_topointer(L, 1);
  2699. luaL_checktype(L, 2, LUA_TNUMBER);
  2700. int x = lua_tointeger(L, 2);
  2701. luaL_checktype(L, 3, LUA_TNUMBER);
  2702. int y = lua_tointeger(L, 3);
  2703. Color *retInst = new Color();
  2704. *retInst = inst->getPixel(x, y);
  2705. lua_pushlightuserdata(L, retInst);
  2706. return 1;
  2707. }
  2708. static int Polycore_Image_swap(lua_State *L) {
  2709. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  2710. Image *inst = (Image*)lua_topointer(L, 1);
  2711. luaL_checktype(L, 2, LUA_TLIGHTUSERDATA);
  2712. int * v1 = (int *)lua_topointer(L, 2);
  2713. luaL_checktype(L, 3, LUA_TLIGHTUSERDATA);
  2714. int * v2 = (int *)lua_topointer(L, 3);
  2715. inst->swap(v1, v2);
  2716. return 0;
  2717. }
  2718. static int Polycore_Image_line(lua_State *L) {
  2719. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  2720. Image *inst = (Image*)lua_topointer(L, 1);
  2721. luaL_checktype(L, 2, LUA_TNUMBER);
  2722. int x0 = lua_tointeger(L, 2);
  2723. luaL_checktype(L, 3, LUA_TNUMBER);
  2724. int y0 = lua_tointeger(L, 3);
  2725. luaL_checktype(L, 4, LUA_TNUMBER);
  2726. int x1 = lua_tointeger(L, 4);
  2727. luaL_checktype(L, 5, LUA_TNUMBER);
  2728. int y1 = lua_tointeger(L, 5);
  2729. luaL_checktype(L, 6, LUA_TLIGHTUSERDATA);
  2730. Color col = *(Color*)lua_topointer(L, 6);
  2731. inst->line(x0, y0, x1, y1, col);
  2732. return 0;
  2733. }
  2734. static int Polycore_Image_moveTo(lua_State *L) {
  2735. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  2736. Image *inst = (Image*)lua_topointer(L, 1);
  2737. luaL_checktype(L, 2, LUA_TNUMBER);
  2738. int x = lua_tointeger(L, 2);
  2739. luaL_checktype(L, 3, LUA_TNUMBER);
  2740. int y = lua_tointeger(L, 3);
  2741. inst->moveTo(x, y);
  2742. return 0;
  2743. }
  2744. static int Polycore_Image_move(lua_State *L) {
  2745. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  2746. Image *inst = (Image*)lua_topointer(L, 1);
  2747. luaL_checktype(L, 2, LUA_TNUMBER);
  2748. int x = lua_tointeger(L, 2);
  2749. luaL_checktype(L, 3, LUA_TNUMBER);
  2750. int y = lua_tointeger(L, 3);
  2751. inst->move(x, y);
  2752. return 0;
  2753. }
  2754. static int Polycore_Image_lineTo(lua_State *L) {
  2755. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  2756. Image *inst = (Image*)lua_topointer(L, 1);
  2757. luaL_checktype(L, 2, LUA_TNUMBER);
  2758. int x = lua_tointeger(L, 2);
  2759. luaL_checktype(L, 3, LUA_TNUMBER);
  2760. int y = lua_tointeger(L, 3);
  2761. luaL_checktype(L, 4, LUA_TLIGHTUSERDATA);
  2762. Color col = *(Color*)lua_topointer(L, 4);
  2763. inst->lineTo(x, y, col);
  2764. return 0;
  2765. }
  2766. static int Polycore_Image_drawRect(lua_State *L) {
  2767. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  2768. Image *inst = (Image*)lua_topointer(L, 1);
  2769. luaL_checktype(L, 2, LUA_TNUMBER);
  2770. int x = lua_tointeger(L, 2);
  2771. luaL_checktype(L, 3, LUA_TNUMBER);
  2772. int y = lua_tointeger(L, 3);
  2773. luaL_checktype(L, 4, LUA_TNUMBER);
  2774. int w = lua_tointeger(L, 4);
  2775. luaL_checktype(L, 5, LUA_TNUMBER);
  2776. int h = lua_tointeger(L, 5);
  2777. luaL_checktype(L, 6, LUA_TLIGHTUSERDATA);
  2778. Color col = *(Color*)lua_topointer(L, 6);
  2779. inst->drawRect(x, y, w, h, col);
  2780. return 0;
  2781. }
  2782. static int Polycore_Image_perlinNoise(lua_State *L) {
  2783. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  2784. Image *inst = (Image*)lua_topointer(L, 1);
  2785. luaL_checktype(L, 2, LUA_TNUMBER);
  2786. int seed = lua_tointeger(L, 2);
  2787. luaL_checktype(L, 3, LUA_TBOOLEAN);
  2788. bool alpha = lua_toboolean(L, 3);
  2789. inst->perlinNoise(seed, alpha);
  2790. return 0;
  2791. }
  2792. static int Polycore_Image_fastBlur(lua_State *L) {
  2793. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  2794. Image *inst = (Image*)lua_topointer(L, 1);
  2795. luaL_checktype(L, 2, LUA_TNUMBER);
  2796. int blurSize = lua_tointeger(L, 2);
  2797. inst->fastBlur(blurSize);
  2798. return 0;
  2799. }
  2800. static int Polycore_Image_fastBlurVert(lua_State *L) {
  2801. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  2802. Image *inst = (Image*)lua_topointer(L, 1);
  2803. luaL_checktype(L, 2, LUA_TNUMBER);
  2804. int blurSize = lua_tointeger(L, 2);
  2805. inst->fastBlurVert(blurSize);
  2806. return 0;
  2807. }
  2808. static int Polycore_Image_fastBlurHor(lua_State *L) {
  2809. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  2810. Image *inst = (Image*)lua_topointer(L, 1);
  2811. luaL_checktype(L, 2, LUA_TNUMBER);
  2812. int blurSize = lua_tointeger(L, 2);
  2813. inst->fastBlurHor(blurSize);
  2814. return 0;
  2815. }
  2816. static int Polycore_Image_darken(lua_State *L) {
  2817. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  2818. Image *inst = (Image*)lua_topointer(L, 1);
  2819. luaL_checktype(L, 2, LUA_TNUMBER);
  2820. Number amt = lua_tonumber(L, 2);
  2821. luaL_checktype(L, 3, LUA_TBOOLEAN);
  2822. bool color = lua_toboolean(L, 3);
  2823. luaL_checktype(L, 4, LUA_TBOOLEAN);
  2824. bool alpha = lua_toboolean(L, 4);
  2825. inst->darken(amt, color, alpha);
  2826. return 0;
  2827. }
  2828. static int Polycore_Image_lighten(lua_State *L) {
  2829. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  2830. Image *inst = (Image*)lua_topointer(L, 1);
  2831. luaL_checktype(L, 2, LUA_TNUMBER);
  2832. Number amt = lua_tonumber(L, 2);
  2833. luaL_checktype(L, 3, LUA_TBOOLEAN);
  2834. bool color = lua_toboolean(L, 3);
  2835. luaL_checktype(L, 4, LUA_TBOOLEAN);
  2836. bool alpha = lua_toboolean(L, 4);
  2837. inst->lighten(amt, color, alpha);
  2838. return 0;
  2839. }
  2840. static int Polycore_Image_multiply(lua_State *L) {
  2841. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  2842. Image *inst = (Image*)lua_topointer(L, 1);
  2843. luaL_checktype(L, 2, LUA_TNUMBER);
  2844. Number amt = lua_tonumber(L, 2);
  2845. luaL_checktype(L, 3, LUA_TBOOLEAN);
  2846. bool color = lua_toboolean(L, 3);
  2847. luaL_checktype(L, 4, LUA_TBOOLEAN);
  2848. bool alpha = lua_toboolean(L, 4);
  2849. inst->multiply(amt, color, alpha);
  2850. return 0;
  2851. }
  2852. static int Polycore_Image_getBrushX(lua_State *L) {
  2853. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  2854. Image *inst = (Image*)lua_topointer(L, 1);
  2855. lua_pushinteger(L, inst->getBrushX());
  2856. return 1;
  2857. }
  2858. static int Polycore_Image_getBrushY(lua_State *L) {
  2859. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  2860. Image *inst = (Image*)lua_topointer(L, 1);
  2861. lua_pushinteger(L, inst->getBrushY());
  2862. return 1;
  2863. }
  2864. static int Polycore_Image_isLoaded(lua_State *L) {
  2865. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  2866. Image *inst = (Image*)lua_topointer(L, 1);
  2867. lua_pushboolean(L, inst->isLoaded());
  2868. return 1;
  2869. }
  2870. static int Polycore_Image_getType(lua_State *L) {
  2871. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  2872. Image *inst = (Image*)lua_topointer(L, 1);
  2873. lua_pushinteger(L, inst->getType());
  2874. return 1;
  2875. }
  2876. static int Polycore_Image_writeBMP(lua_State *L) {
  2877. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  2878. Image *inst = (Image*)lua_topointer(L, 1);
  2879. luaL_checktype(L, 2, LUA_TSTRING);
  2880. String fileName = String(lua_tostring(L, 2));
  2881. inst->writeBMP(fileName);
  2882. return 0;
  2883. }
  2884. static int Polycore_Image_getWidth(lua_State *L) {
  2885. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  2886. Image *inst = (Image*)lua_topointer(L, 1);
  2887. lua_pushinteger(L, inst->getWidth());
  2888. return 1;
  2889. }
  2890. static int Polycore_Image_getHeight(lua_State *L) {
  2891. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  2892. Image *inst = (Image*)lua_topointer(L, 1);
  2893. lua_pushinteger(L, inst->getHeight());
  2894. return 1;
  2895. }
  2896. static int Polycore_Image_getPixels(lua_State *L) {
  2897. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  2898. Image *inst = (Image*)lua_topointer(L, 1);
  2899. void *ptrRetVal = (void*)inst->getPixels();
  2900. if(ptrRetVal == NULL) {
  2901. lua_pushnil(L);
  2902. } else {
  2903. lua_pushlightuserdata(L, ptrRetVal);
  2904. }
  2905. return 1;
  2906. }
  2907. static int Polycore_delete_Image(lua_State *L) {
  2908. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  2909. Image *inst = (Image*)lua_topointer(L, 1);
  2910. delete inst;
  2911. return 0;
  2912. }
  2913. static int Polycore_InputEvent_get_mouseButton(lua_State *L) {
  2914. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  2915. InputEvent *inst = (InputEvent*)lua_topointer(L, 1);
  2916. lua_pushinteger(L, inst->mouseButton);
  2917. return 1;
  2918. }
  2919. static int Polycore_InputEvent_get_mousePosition(lua_State *L) {
  2920. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  2921. InputEvent *inst = (InputEvent*)lua_topointer(L, 1);
  2922. lua_pushlightuserdata(L, &inst->mousePosition);
  2923. return 1;
  2924. }
  2925. static int Polycore_InputEvent_get_key(lua_State *L) {
  2926. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  2927. InputEvent *inst = (InputEvent*)lua_topointer(L, 1);
  2928. lua_pushlightuserdata(L, &inst->key);
  2929. return 1;
  2930. }
  2931. static int Polycore_InputEvent_get_charCode(lua_State *L) {
  2932. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  2933. InputEvent *inst = (InputEvent*)lua_topointer(L, 1);
  2934. lua_pushlightuserdata(L, &inst->charCode);
  2935. return 1;
  2936. }
  2937. static int Polycore_InputEvent_get_timestamp(lua_State *L) {
  2938. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  2939. InputEvent *inst = (InputEvent*)lua_topointer(L, 1);
  2940. lua_pushinteger(L, inst->timestamp);
  2941. return 1;
  2942. }
  2943. static int Polycore_InputEvent_set_mouseButton(lua_State *L) {
  2944. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  2945. InputEvent *inst = (InputEvent*)lua_topointer(L, 1);
  2946. int param = lua_tointeger(L, 2);
  2947. inst->mouseButton = param;
  2948. return 0;
  2949. }
  2950. static int Polycore_InputEvent_set_timestamp(lua_State *L) {
  2951. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  2952. InputEvent *inst = (InputEvent*)lua_topointer(L, 1);
  2953. int param = lua_tointeger(L, 2);
  2954. inst->timestamp = param;
  2955. return 0;
  2956. }
  2957. static int Polycore_InputEvent(lua_State *L) {
  2958. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  2959. Vector2 mousePosition = *(Vector2*)lua_topointer(L, 1);
  2960. luaL_checktype(L, 2, LUA_TNUMBER);
  2961. int timestamp = lua_tointeger(L, 2);
  2962. InputEvent *inst = new InputEvent(mousePosition, timestamp);
  2963. lua_pushlightuserdata(L, (void*)inst);
  2964. return 1;
  2965. }
  2966. static int Polycore_InputEvent_getMousePosition(lua_State *L) {
  2967. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  2968. InputEvent *inst = (InputEvent*)lua_topointer(L, 1);
  2969. Vector2 *retInst = new Vector2();
  2970. *retInst = inst->getMousePosition();
  2971. lua_pushlightuserdata(L, retInst);
  2972. return 1;
  2973. }
  2974. static int Polycore_InputEvent_getKey(lua_State *L) {
  2975. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  2976. InputEvent *inst = (InputEvent*)lua_topointer(L, 1);
  2977. PolyKEY *retInst = new PolyKEY();
  2978. *retInst = inst->getKey();
  2979. lua_pushlightuserdata(L, retInst);
  2980. return 1;
  2981. }
  2982. static int Polycore_InputEvent_getMouseButton(lua_State *L) {
  2983. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  2984. InputEvent *inst = (InputEvent*)lua_topointer(L, 1);
  2985. lua_pushinteger(L, inst->getMouseButton());
  2986. return 1;
  2987. }
  2988. static int Polycore_InputEvent_keyCode(lua_State *L) {
  2989. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  2990. InputEvent *inst = (InputEvent*)lua_topointer(L, 1);
  2991. lua_pushinteger(L, inst->keyCode());
  2992. return 1;
  2993. }
  2994. static int Polycore_delete_InputEvent(lua_State *L) {
  2995. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  2996. InputEvent *inst = (InputEvent*)lua_topointer(L, 1);
  2997. delete inst;
  2998. return 0;
  2999. }
  3000. static int Polycore_Label(lua_State *L) {
  3001. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  3002. Font * font = (Font *)lua_topointer(L, 1);
  3003. luaL_checktype(L, 2, LUA_TSTRING);
  3004. String text = String(lua_tostring(L, 2));
  3005. luaL_checktype(L, 3, LUA_TNUMBER);
  3006. int size = lua_tointeger(L, 3);
  3007. luaL_checktype(L, 4, LUA_TNUMBER);
  3008. int antiAliasMode = lua_tointeger(L, 4);
  3009. Label *inst = new Label(font, text, size, antiAliasMode);
  3010. lua_pushlightuserdata(L, (void*)inst);
  3011. return 1;
  3012. }
  3013. static int Polycore_Label_setText(lua_State *L) {
  3014. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  3015. Label *inst = (Label*)lua_topointer(L, 1);
  3016. luaL_checktype(L, 2, LUA_TSTRING);
  3017. String text = String(lua_tostring(L, 2));
  3018. inst->setText(text);
  3019. return 0;
  3020. }
  3021. static int Polycore_Label_getText(lua_State *L) {
  3022. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  3023. Label *inst = (Label*)lua_topointer(L, 1);
  3024. lua_pushstring(L, inst->getText().c_str());
  3025. return 1;
  3026. }
  3027. static int Polycore_Label_getTextWidth(lua_State *L) {
  3028. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  3029. Label *inst = (Label*)lua_topointer(L, 1);
  3030. luaL_checktype(L, 2, LUA_TLIGHTUSERDATA);
  3031. Font * font = (Font *)lua_topointer(L, 2);
  3032. luaL_checktype(L, 3, LUA_TSTRING);
  3033. String text = String(lua_tostring(L, 3));
  3034. luaL_checktype(L, 4, LUA_TNUMBER);
  3035. int size = lua_tointeger(L, 4);
  3036. lua_pushinteger(L, inst->getTextWidth(font, text, size));
  3037. return 1;
  3038. }
  3039. static int Polycore_Label_getTextHeight(lua_State *L) {
  3040. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  3041. Label *inst = (Label*)lua_topointer(L, 1);
  3042. luaL_checktype(L, 2, LUA_TLIGHTUSERDATA);
  3043. Font * font = (Font *)lua_topointer(L, 2);
  3044. luaL_checktype(L, 3, LUA_TSTRING);
  3045. String text = String(lua_tostring(L, 3));
  3046. luaL_checktype(L, 4, LUA_TNUMBER);
  3047. int size = lua_tointeger(L, 4);
  3048. lua_pushinteger(L, inst->getTextHeight(font, text, size));
  3049. return 1;
  3050. }
  3051. static int Polycore_Label_getFont(lua_State *L) {
  3052. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  3053. Label *inst = (Label*)lua_topointer(L, 1);
  3054. void *ptrRetVal = (void*)inst->getFont();
  3055. if(ptrRetVal == NULL) {
  3056. lua_pushnil(L);
  3057. } else {
  3058. lua_pushlightuserdata(L, ptrRetVal);
  3059. }
  3060. return 1;
  3061. }
  3062. static int Polycore_delete_Label(lua_State *L) {
  3063. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  3064. Label *inst = (Label*)lua_topointer(L, 1);
  3065. delete inst;
  3066. return 0;
  3067. }
  3068. static int Polycore_Logger(lua_State *L) {
  3069. Logger *inst = new Logger();
  3070. lua_pushlightuserdata(L, (void*)inst);
  3071. return 1;
  3072. }
  3073. static int Polycore_Logger_log(lua_State *L) {
  3074. luaL_checktype(L, 2, LUA_TLIGHTUSERDATA);
  3075. const char * format = (const char *)lua_topointer(L, 2);
  3076. Logger::log(format);
  3077. return 0;
  3078. }
  3079. static int Polycore_Logger_logw(lua_State *L) {
  3080. luaL_checktype(L, 2, LUA_TLIGHTUSERDATA);
  3081. const char * str = (const char *)lua_topointer(L, 2);
  3082. Logger::logw(str);
  3083. return 0;
  3084. }
  3085. static int Polycore_delete_Logger(lua_State *L) {
  3086. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  3087. Logger *inst = (Logger*)lua_topointer(L, 1);
  3088. delete inst;
  3089. return 0;
  3090. }
  3091. static int Polycore_Material(lua_State *L) {
  3092. luaL_checktype(L, 1, LUA_TSTRING);
  3093. String name = String(lua_tostring(L, 1));
  3094. Material *inst = new Material(name);
  3095. lua_pushlightuserdata(L, (void*)inst);
  3096. return 1;
  3097. }
  3098. static int Polycore_Material_addShader(lua_State *L) {
  3099. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  3100. Material *inst = (Material*)lua_topointer(L, 1);
  3101. luaL_checktype(L, 2, LUA_TLIGHTUSERDATA);
  3102. Shader * shader = (Shader *)lua_topointer(L, 2);
  3103. luaL_checktype(L, 3, LUA_TLIGHTUSERDATA);
  3104. ShaderBinding * shaderBinding = (ShaderBinding *)lua_topointer(L, 3);
  3105. inst->addShader(shader, shaderBinding);
  3106. return 0;
  3107. }
  3108. static int Polycore_Material_getNumShaders(lua_State *L) {
  3109. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  3110. Material *inst = (Material*)lua_topointer(L, 1);
  3111. lua_pushinteger(L, inst->getNumShaders());
  3112. return 1;
  3113. }
  3114. static int Polycore_Material_addShaderRenderTarget(lua_State *L) {
  3115. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  3116. Material *inst = (Material*)lua_topointer(L, 1);
  3117. luaL_checktype(L, 2, LUA_TLIGHTUSERDATA);
  3118. ShaderRenderTarget * newTarget = (ShaderRenderTarget *)lua_topointer(L, 2);
  3119. inst->addShaderRenderTarget(newTarget);
  3120. return 0;
  3121. }
  3122. static int Polycore_Material_getNumShaderRenderTargets(lua_State *L) {
  3123. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  3124. Material *inst = (Material*)lua_topointer(L, 1);
  3125. lua_pushinteger(L, inst->getNumShaderRenderTargets());
  3126. return 1;
  3127. }
  3128. static int Polycore_Material_getShaderRenderTarget(lua_State *L) {
  3129. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  3130. Material *inst = (Material*)lua_topointer(L, 1);
  3131. luaL_checktype(L, 2, LUA_TNUMBER);
  3132. unsigned int index = lua_tointeger(L, 2);
  3133. void *ptrRetVal = (void*)inst->getShaderRenderTarget(index);
  3134. if(ptrRetVal == NULL) {
  3135. lua_pushnil(L);
  3136. } else {
  3137. lua_pushlightuserdata(L, ptrRetVal);
  3138. }
  3139. return 1;
  3140. }
  3141. static int Polycore_Material_getName(lua_State *L) {
  3142. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  3143. Material *inst = (Material*)lua_topointer(L, 1);
  3144. lua_pushstring(L, inst->getName().c_str());
  3145. return 1;
  3146. }
  3147. static int Polycore_Material_getShader(lua_State *L) {
  3148. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  3149. Material *inst = (Material*)lua_topointer(L, 1);
  3150. luaL_checktype(L, 2, LUA_TNUMBER);
  3151. unsigned int index = lua_tointeger(L, 2);
  3152. void *ptrRetVal = (void*)inst->getShader(index);
  3153. if(ptrRetVal == NULL) {
  3154. lua_pushnil(L);
  3155. } else {
  3156. lua_pushlightuserdata(L, ptrRetVal);
  3157. }
  3158. return 1;
  3159. }
  3160. static int Polycore_Material_getShaderBinding(lua_State *L) {
  3161. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  3162. Material *inst = (Material*)lua_topointer(L, 1);
  3163. luaL_checktype(L, 2, LUA_TNUMBER);
  3164. unsigned int index = lua_tointeger(L, 2);
  3165. void *ptrRetVal = (void*)inst->getShaderBinding(index);
  3166. if(ptrRetVal == NULL) {
  3167. lua_pushnil(L);
  3168. } else {
  3169. lua_pushlightuserdata(L, ptrRetVal);
  3170. }
  3171. return 1;
  3172. }
  3173. static int Polycore_Material_loadMaterial(lua_State *L) {
  3174. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  3175. Material *inst = (Material*)lua_topointer(L, 1);
  3176. luaL_checktype(L, 2, LUA_TSTRING);
  3177. String fileName = String(lua_tostring(L, 2));
  3178. inst->loadMaterial(fileName);
  3179. return 0;
  3180. }
  3181. static int Polycore_delete_Material(lua_State *L) {
  3182. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  3183. Material *inst = (Material*)lua_topointer(L, 1);
  3184. delete inst;
  3185. return 0;
  3186. }
  3187. static int Polycore_MaterialManager(lua_State *L) {
  3188. MaterialManager *inst = new MaterialManager();
  3189. lua_pushlightuserdata(L, (void*)inst);
  3190. return 1;
  3191. }
  3192. static int Polycore_MaterialManager_Update(lua_State *L) {
  3193. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  3194. MaterialManager *inst = (MaterialManager*)lua_topointer(L, 1);
  3195. luaL_checktype(L, 2, LUA_TNUMBER);
  3196. int elapsed = lua_tointeger(L, 2);
  3197. inst->Update(elapsed);
  3198. return 0;
  3199. }
  3200. static int Polycore_MaterialManager_createFramebufferTexture(lua_State *L) {
  3201. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  3202. MaterialManager *inst = (MaterialManager*)lua_topointer(L, 1);
  3203. luaL_checktype(L, 2, LUA_TNUMBER);
  3204. int width = lua_tointeger(L, 2);
  3205. luaL_checktype(L, 3, LUA_TNUMBER);
  3206. int height = lua_tointeger(L, 3);
  3207. luaL_checktype(L, 4, LUA_TNUMBER);
  3208. int type = lua_tointeger(L, 4);
  3209. void *ptrRetVal = (void*)inst->createFramebufferTexture(width, height, type);
  3210. if(ptrRetVal == NULL) {
  3211. lua_pushnil(L);
  3212. } else {
  3213. lua_pushlightuserdata(L, ptrRetVal);
  3214. }
  3215. return 1;
  3216. }
  3217. static int Polycore_MaterialManager_createTexture(lua_State *L) {
  3218. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  3219. MaterialManager *inst = (MaterialManager*)lua_topointer(L, 1);
  3220. luaL_checktype(L, 2, LUA_TNUMBER);
  3221. int width = lua_tointeger(L, 2);
  3222. luaL_checktype(L, 3, LUA_TNUMBER);
  3223. int height = lua_tointeger(L, 3);
  3224. luaL_checktype(L, 4, LUA_TLIGHTUSERDATA);
  3225. char * imageData = (char *)lua_topointer(L, 4);
  3226. bool clamp;
  3227. if(lua_isboolean(L, 5)) {
  3228. clamp = lua_toboolean(L, 5);
  3229. } else {
  3230. clamp = true;
  3231. }
  3232. int type;
  3233. if(lua_isnumber(L, 6)) {
  3234. type = lua_tointeger(L, 6);
  3235. } else {
  3236. type = Image :: IMAGE_RGBA;
  3237. }
  3238. void *ptrRetVal = (void*)inst->createTexture(width, height, imageData, clamp, type);
  3239. if(ptrRetVal == NULL) {
  3240. lua_pushnil(L);
  3241. } else {
  3242. lua_pushlightuserdata(L, ptrRetVal);
  3243. }
  3244. return 1;
  3245. }
  3246. static int Polycore_MaterialManager_createNewTexture(lua_State *L) {
  3247. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  3248. MaterialManager *inst = (MaterialManager*)lua_topointer(L, 1);
  3249. luaL_checktype(L, 2, LUA_TNUMBER);
  3250. int width = lua_tointeger(L, 2);
  3251. luaL_checktype(L, 3, LUA_TNUMBER);
  3252. int height = lua_tointeger(L, 3);
  3253. bool clamp;
  3254. if(lua_isboolean(L, 4)) {
  3255. clamp = lua_toboolean(L, 4);
  3256. } else {
  3257. clamp = true;
  3258. }
  3259. int type;
  3260. if(lua_isnumber(L, 5)) {
  3261. type = lua_tointeger(L, 5);
  3262. } else {
  3263. type = Image :: IMAGE_RGBA;
  3264. }
  3265. void *ptrRetVal = (void*)inst->createNewTexture(width, height, clamp, type);
  3266. if(ptrRetVal == NULL) {
  3267. lua_pushnil(L);
  3268. } else {
  3269. lua_pushlightuserdata(L, ptrRetVal);
  3270. }
  3271. return 1;
  3272. }
  3273. static int Polycore_MaterialManager_createTextureFromImage(lua_State *L) {
  3274. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  3275. MaterialManager *inst = (MaterialManager*)lua_topointer(L, 1);
  3276. luaL_checktype(L, 2, LUA_TLIGHTUSERDATA);
  3277. Image * image = (Image *)lua_topointer(L, 2);
  3278. bool clamp;
  3279. if(lua_isboolean(L, 3)) {
  3280. clamp = lua_toboolean(L, 3);
  3281. } else {
  3282. clamp = true;
  3283. }
  3284. void *ptrRetVal = (void*)inst->createTextureFromImage(image, clamp);
  3285. if(ptrRetVal == NULL) {
  3286. lua_pushnil(L);
  3287. } else {
  3288. lua_pushlightuserdata(L, ptrRetVal);
  3289. }
  3290. return 1;
  3291. }
  3292. static int Polycore_MaterialManager_createTextureFromFile(lua_State *L) {
  3293. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  3294. MaterialManager *inst = (MaterialManager*)lua_topointer(L, 1);
  3295. luaL_checktype(L, 2, LUA_TSTRING);
  3296. String fileName = String(lua_tostring(L, 2));
  3297. bool clamp;
  3298. if(lua_isboolean(L, 3)) {
  3299. clamp = lua_toboolean(L, 3);
  3300. } else {
  3301. clamp = true;
  3302. }
  3303. void *ptrRetVal = (void*)inst->createTextureFromFile(fileName, clamp);
  3304. if(ptrRetVal == NULL) {
  3305. lua_pushnil(L);
  3306. } else {
  3307. lua_pushlightuserdata(L, ptrRetVal);
  3308. }
  3309. return 1;
  3310. }
  3311. static int Polycore_MaterialManager_deleteTexture(lua_State *L) {
  3312. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  3313. MaterialManager *inst = (MaterialManager*)lua_topointer(L, 1);
  3314. luaL_checktype(L, 2, LUA_TLIGHTUSERDATA);
  3315. Texture * texture = (Texture *)lua_topointer(L, 2);
  3316. inst->deleteTexture(texture);
  3317. return 0;
  3318. }
  3319. static int Polycore_MaterialManager_reloadTextures(lua_State *L) {
  3320. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  3321. MaterialManager *inst = (MaterialManager*)lua_topointer(L, 1);
  3322. inst->reloadTextures();
  3323. return 0;
  3324. }
  3325. static int Polycore_MaterialManager_reloadProgramsAndTextures(lua_State *L) {
  3326. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  3327. MaterialManager *inst = (MaterialManager*)lua_topointer(L, 1);
  3328. inst->reloadProgramsAndTextures();
  3329. return 0;
  3330. }
  3331. static int Polycore_MaterialManager_reloadPrograms(lua_State *L) {
  3332. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  3333. MaterialManager *inst = (MaterialManager*)lua_topointer(L, 1);
  3334. inst->reloadPrograms();
  3335. return 0;
  3336. }
  3337. static int Polycore_MaterialManager_addShaderModule(lua_State *L) {
  3338. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  3339. MaterialManager *inst = (MaterialManager*)lua_topointer(L, 1);
  3340. luaL_checktype(L, 2, LUA_TLIGHTUSERDATA);
  3341. PolycodeShaderModule * module = (PolycodeShaderModule *)lua_topointer(L, 2);
  3342. inst->addShaderModule(module);
  3343. return 0;
  3344. }
  3345. static int Polycore_MaterialManager_getTextureByResourcePath(lua_State *L) {
  3346. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  3347. MaterialManager *inst = (MaterialManager*)lua_topointer(L, 1);
  3348. luaL_checktype(L, 2, LUA_TSTRING);
  3349. String resourcePath = String(lua_tostring(L, 2));
  3350. void *ptrRetVal = (void*)inst->getTextureByResourcePath(resourcePath);
  3351. if(ptrRetVal == NULL) {
  3352. lua_pushnil(L);
  3353. } else {
  3354. lua_pushlightuserdata(L, ptrRetVal);
  3355. }
  3356. return 1;
  3357. }
  3358. static int Polycore_MaterialManager_cubemapFromXMLNode(lua_State *L) {
  3359. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  3360. MaterialManager *inst = (MaterialManager*)lua_topointer(L, 1);
  3361. luaL_checktype(L, 2, LUA_TLIGHTUSERDATA);
  3362. TiXmlNode * node = (TiXmlNode *)lua_topointer(L, 2);
  3363. void *ptrRetVal = (void*)inst->cubemapFromXMLNode(node);
  3364. if(ptrRetVal == NULL) {
  3365. lua_pushnil(L);
  3366. } else {
  3367. lua_pushlightuserdata(L, ptrRetVal);
  3368. }
  3369. return 1;
  3370. }
  3371. static int Polycore_MaterialManager_loadMaterialsFromFile(lua_State *L) {
  3372. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  3373. MaterialManager *inst = (MaterialManager*)lua_topointer(L, 1);
  3374. luaL_checktype(L, 2, LUA_TSTRING);
  3375. String fileName = String(lua_tostring(L, 2));
  3376. inst->loadMaterialsFromFile(fileName);
  3377. return 0;
  3378. }
  3379. static int Polycore_MaterialManager_materialFromXMLNode(lua_State *L) {
  3380. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  3381. MaterialManager *inst = (MaterialManager*)lua_topointer(L, 1);
  3382. luaL_checktype(L, 2, LUA_TLIGHTUSERDATA);
  3383. TiXmlNode * node = (TiXmlNode *)lua_topointer(L, 2);
  3384. void *ptrRetVal = (void*)inst->materialFromXMLNode(node);
  3385. if(ptrRetVal == NULL) {
  3386. lua_pushnil(L);
  3387. } else {
  3388. lua_pushlightuserdata(L, ptrRetVal);
  3389. }
  3390. return 1;
  3391. }
  3392. static int Polycore_MaterialManager_setShaderFromXMLNode(lua_State *L) {
  3393. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  3394. MaterialManager *inst = (MaterialManager*)lua_topointer(L, 1);
  3395. luaL_checktype(L, 2, LUA_TLIGHTUSERDATA);
  3396. TiXmlNode * node = (TiXmlNode *)lua_topointer(L, 2);
  3397. void *ptrRetVal = (void*)inst->setShaderFromXMLNode(node);
  3398. if(ptrRetVal == NULL) {
  3399. lua_pushnil(L);
  3400. } else {
  3401. lua_pushlightuserdata(L, ptrRetVal);
  3402. }
  3403. return 1;
  3404. }
  3405. static int Polycore_MaterialManager_createShaderFromXMLNode(lua_State *L) {
  3406. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  3407. MaterialManager *inst = (MaterialManager*)lua_topointer(L, 1);
  3408. luaL_checktype(L, 2, LUA_TLIGHTUSERDATA);
  3409. TiXmlNode * node = (TiXmlNode *)lua_topointer(L, 2);
  3410. void *ptrRetVal = (void*)inst->createShaderFromXMLNode(node);
  3411. if(ptrRetVal == NULL) {
  3412. lua_pushnil(L);
  3413. } else {
  3414. lua_pushlightuserdata(L, ptrRetVal);
  3415. }
  3416. return 1;
  3417. }
  3418. static int Polycore_delete_MaterialManager(lua_State *L) {
  3419. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  3420. MaterialManager *inst = (MaterialManager*)lua_topointer(L, 1);
  3421. delete inst;
  3422. return 0;
  3423. }
  3424. static int Polycore_Matrix4(lua_State *L) {
  3425. Matrix4 *inst = new Matrix4();
  3426. lua_pushlightuserdata(L, (void*)inst);
  3427. return 1;
  3428. }
  3429. static int Polycore_Matrix4_identity(lua_State *L) {
  3430. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  3431. Matrix4 *inst = (Matrix4*)lua_topointer(L, 1);
  3432. inst->identity();
  3433. return 0;
  3434. }
  3435. static int Polycore_Matrix4_rotateVector(lua_State *L) {
  3436. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  3437. Matrix4 *inst = (Matrix4*)lua_topointer(L, 1);
  3438. luaL_checktype(L, 2, LUA_TLIGHTUSERDATA);
  3439. const Vector3 & v2 = *( Vector3 *)lua_topointer(L, 2);
  3440. Vector3 *retInst = new Vector3();
  3441. *retInst = inst->rotateVector(v2);
  3442. lua_pushlightuserdata(L, retInst);
  3443. return 1;
  3444. }
  3445. static int Polycore_Matrix4_getPosition(lua_State *L) {
  3446. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  3447. Matrix4 *inst = (Matrix4*)lua_topointer(L, 1);
  3448. Vector3 *retInst = new Vector3();
  3449. *retInst = inst->getPosition();
  3450. lua_pushlightuserdata(L, retInst);
  3451. return 1;
  3452. }
  3453. static int Polycore_Matrix4_setPosition(lua_State *L) {
  3454. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  3455. Matrix4 *inst = (Matrix4*)lua_topointer(L, 1);
  3456. luaL_checktype(L, 2, LUA_TNUMBER);
  3457. Number x = lua_tonumber(L, 2);
  3458. luaL_checktype(L, 3, LUA_TNUMBER);
  3459. Number y = lua_tonumber(L, 3);
  3460. luaL_checktype(L, 4, LUA_TNUMBER);
  3461. Number z = lua_tonumber(L, 4);
  3462. inst->setPosition(x, y, z);
  3463. return 0;
  3464. }
  3465. static int Polycore_Matrix4_setScale(lua_State *L) {
  3466. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  3467. Matrix4 *inst = (Matrix4*)lua_topointer(L, 1);
  3468. luaL_checktype(L, 2, LUA_TLIGHTUSERDATA);
  3469. Vector3 scale = *(Vector3*)lua_topointer(L, 2);
  3470. inst->setScale(scale);
  3471. return 0;
  3472. }
  3473. static int Polycore_Matrix4_getEulerAngles(lua_State *L) {
  3474. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  3475. Matrix4 *inst = (Matrix4*)lua_topointer(L, 1);
  3476. luaL_checktype(L, 2, LUA_TLIGHTUSERDATA);
  3477. Number * ax = (Number *)lua_topointer(L, 2);
  3478. luaL_checktype(L, 3, LUA_TLIGHTUSERDATA);
  3479. Number * ay = (Number *)lua_topointer(L, 3);
  3480. luaL_checktype(L, 4, LUA_TLIGHTUSERDATA);
  3481. Number * az = (Number *)lua_topointer(L, 4);
  3482. inst->getEulerAngles(ax, ay, az);
  3483. return 0;
  3484. }
  3485. static int Polycore_Matrix4_inverse(lua_State *L) {
  3486. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  3487. Matrix4 *inst = (Matrix4*)lua_topointer(L, 1);
  3488. Matrix4 *retInst = new Matrix4();
  3489. *retInst = inst->inverse();
  3490. lua_pushlightuserdata(L, retInst);
  3491. return 1;
  3492. }
  3493. static int Polycore_Matrix4_inverseAffine(lua_State *L) {
  3494. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  3495. Matrix4 *inst = (Matrix4*)lua_topointer(L, 1);
  3496. Matrix4 *retInst = new Matrix4();
  3497. *retInst = inst->inverseAffine();
  3498. lua_pushlightuserdata(L, retInst);
  3499. return 1;
  3500. }
  3501. static int Polycore_delete_Matrix4(lua_State *L) {
  3502. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  3503. Matrix4 *inst = (Matrix4*)lua_topointer(L, 1);
  3504. delete inst;
  3505. return 0;
  3506. }
  3507. static int Polycore_Mesh_get_useVertexColors(lua_State *L) {
  3508. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  3509. Mesh *inst = (Mesh*)lua_topointer(L, 1);
  3510. lua_pushboolean(L, inst->useVertexColors);
  3511. return 1;
  3512. }
  3513. static int Polycore_Mesh_set_useVertexColors(lua_State *L) {
  3514. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  3515. Mesh *inst = (Mesh*)lua_topointer(L, 1);
  3516. bool param = lua_toboolean(L, 2);
  3517. inst->useVertexColors = param;
  3518. return 0;
  3519. }
  3520. static int Polycore_Mesh(lua_State *L) {
  3521. luaL_checktype(L, 1, LUA_TNUMBER);
  3522. int meshType = lua_tointeger(L, 1);
  3523. Mesh *inst = new Mesh(meshType);
  3524. lua_pushlightuserdata(L, (void*)inst);
  3525. return 1;
  3526. }
  3527. static int Polycore_Mesh_addPolygon(lua_State *L) {
  3528. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  3529. Mesh *inst = (Mesh*)lua_topointer(L, 1);
  3530. luaL_checktype(L, 2, LUA_TLIGHTUSERDATA);
  3531. Polycode::Polygon * newPolygon = (Polycode::Polygon *)lua_topointer(L, 2);
  3532. inst->addPolygon(newPolygon);
  3533. return 0;
  3534. }
  3535. static int Polycore_Mesh_loadMesh(lua_State *L) {
  3536. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  3537. Mesh *inst = (Mesh*)lua_topointer(L, 1);
  3538. luaL_checktype(L, 2, LUA_TSTRING);
  3539. String fileName = String(lua_tostring(L, 2));
  3540. inst->loadMesh(fileName);
  3541. return 0;
  3542. }
  3543. static int Polycore_Mesh_saveToFile(lua_State *L) {
  3544. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  3545. Mesh *inst = (Mesh*)lua_topointer(L, 1);
  3546. luaL_checktype(L, 2, LUA_TSTRING);
  3547. String fileName = String(lua_tostring(L, 2));
  3548. inst->saveToFile(fileName);
  3549. return 0;
  3550. }
  3551. static int Polycore_Mesh_loadFromFile(lua_State *L) {
  3552. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  3553. Mesh *inst = (Mesh*)lua_topointer(L, 1);
  3554. luaL_checktype(L, 2, LUA_TLIGHTUSERDATA);
  3555. OSFILE * inFile = (OSFILE *)lua_topointer(L, 2);
  3556. inst->loadFromFile(inFile);
  3557. return 0;
  3558. }
  3559. static int Polycore_Mesh_getPolygonCount(lua_State *L) {
  3560. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  3561. Mesh *inst = (Mesh*)lua_topointer(L, 1);
  3562. lua_pushinteger(L, inst->getPolygonCount());
  3563. return 1;
  3564. }
  3565. static int Polycore_Mesh_getVertexCount(lua_State *L) {
  3566. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  3567. Mesh *inst = (Mesh*)lua_topointer(L, 1);
  3568. lua_pushinteger(L, inst->getVertexCount());
  3569. return 1;
  3570. }
  3571. static int Polycore_Mesh_getPolygon(lua_State *L) {
  3572. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  3573. Mesh *inst = (Mesh*)lua_topointer(L, 1);
  3574. luaL_checktype(L, 2, LUA_TNUMBER);
  3575. unsigned int index = lua_tointeger(L, 2);
  3576. void *ptrRetVal = (void*)inst->getPolygon(index);
  3577. if(ptrRetVal == NULL) {
  3578. lua_pushnil(L);
  3579. } else {
  3580. lua_pushlightuserdata(L, ptrRetVal);
  3581. }
  3582. return 1;
  3583. }
  3584. static int Polycore_Mesh_createPlane(lua_State *L) {
  3585. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  3586. Mesh *inst = (Mesh*)lua_topointer(L, 1);
  3587. luaL_checktype(L, 2, LUA_TNUMBER);
  3588. Number w = lua_tonumber(L, 2);
  3589. luaL_checktype(L, 3, LUA_TNUMBER);
  3590. Number h = lua_tonumber(L, 3);
  3591. inst->createPlane(w, h);
  3592. return 0;
  3593. }
  3594. static int Polycore_Mesh_createBox(lua_State *L) {
  3595. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  3596. Mesh *inst = (Mesh*)lua_topointer(L, 1);
  3597. luaL_checktype(L, 2, LUA_TNUMBER);
  3598. Number w = lua_tonumber(L, 2);
  3599. luaL_checktype(L, 3, LUA_TNUMBER);
  3600. Number d = lua_tonumber(L, 3);
  3601. luaL_checktype(L, 4, LUA_TNUMBER);
  3602. Number h = lua_tonumber(L, 4);
  3603. inst->createBox(w, d, h);
  3604. return 0;
  3605. }
  3606. static int Polycore_Mesh_createSphere(lua_State *L) {
  3607. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  3608. Mesh *inst = (Mesh*)lua_topointer(L, 1);
  3609. luaL_checktype(L, 2, LUA_TNUMBER);
  3610. Number radius = lua_tonumber(L, 2);
  3611. luaL_checktype(L, 3, LUA_TNUMBER);
  3612. Number numRings = lua_tonumber(L, 3);
  3613. luaL_checktype(L, 4, LUA_TNUMBER);
  3614. Number numSegments = lua_tonumber(L, 4);
  3615. inst->createSphere(radius, numRings, numSegments);
  3616. return 0;
  3617. }
  3618. static int Polycore_Mesh_createCylinder(lua_State *L) {
  3619. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  3620. Mesh *inst = (Mesh*)lua_topointer(L, 1);
  3621. luaL_checktype(L, 2, LUA_TNUMBER);
  3622. Number height = lua_tonumber(L, 2);
  3623. luaL_checktype(L, 3, LUA_TNUMBER);
  3624. Number radius = lua_tonumber(L, 3);
  3625. luaL_checktype(L, 4, LUA_TNUMBER);
  3626. int numSegments = lua_tointeger(L, 4);
  3627. inst->createCylinder(height, radius, numSegments);
  3628. return 0;
  3629. }
  3630. static int Polycore_Mesh_createCone(lua_State *L) {
  3631. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  3632. Mesh *inst = (Mesh*)lua_topointer(L, 1);
  3633. luaL_checktype(L, 2, LUA_TNUMBER);
  3634. Number height = lua_tonumber(L, 2);
  3635. luaL_checktype(L, 3, LUA_TNUMBER);
  3636. Number radius = lua_tonumber(L, 3);
  3637. luaL_checktype(L, 4, LUA_TNUMBER);
  3638. int numSegments = lua_tointeger(L, 4);
  3639. inst->createCone(height, radius, numSegments);
  3640. return 0;
  3641. }
  3642. static int Polycore_Mesh_recenterMesh(lua_State *L) {
  3643. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  3644. Mesh *inst = (Mesh*)lua_topointer(L, 1);
  3645. Vector3 *retInst = new Vector3();
  3646. *retInst = inst->recenterMesh();
  3647. lua_pushlightuserdata(L, retInst);
  3648. return 1;
  3649. }
  3650. static int Polycore_Mesh_useVertexNormals(lua_State *L) {
  3651. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  3652. Mesh *inst = (Mesh*)lua_topointer(L, 1);
  3653. luaL_checktype(L, 2, LUA_TBOOLEAN);
  3654. bool val = lua_toboolean(L, 2);
  3655. inst->useVertexNormals(val);
  3656. return 0;
  3657. }
  3658. static int Polycore_Mesh_setVertexBuffer(lua_State *L) {
  3659. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  3660. Mesh *inst = (Mesh*)lua_topointer(L, 1);
  3661. luaL_checktype(L, 2, LUA_TLIGHTUSERDATA);
  3662. VertexBuffer * buffer = (VertexBuffer *)lua_topointer(L, 2);
  3663. inst->setVertexBuffer(buffer);
  3664. return 0;
  3665. }
  3666. static int Polycore_Mesh_getVertexBuffer(lua_State *L) {
  3667. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  3668. Mesh *inst = (Mesh*)lua_topointer(L, 1);
  3669. void *ptrRetVal = (void*)inst->getVertexBuffer();
  3670. if(ptrRetVal == NULL) {
  3671. lua_pushnil(L);
  3672. } else {
  3673. lua_pushlightuserdata(L, ptrRetVal);
  3674. }
  3675. return 1;
  3676. }
  3677. static int Polycore_Mesh_getRadius(lua_State *L) {
  3678. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  3679. Mesh *inst = (Mesh*)lua_topointer(L, 1);
  3680. lua_pushnumber(L, inst->getRadius());
  3681. return 1;
  3682. }
  3683. static int Polycore_Mesh_calculateNormals(lua_State *L) {
  3684. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  3685. Mesh *inst = (Mesh*)lua_topointer(L, 1);
  3686. inst->calculateNormals();
  3687. return 0;
  3688. }
  3689. static int Polycore_Mesh_getMeshType(lua_State *L) {
  3690. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  3691. Mesh *inst = (Mesh*)lua_topointer(L, 1);
  3692. lua_pushinteger(L, inst->getMeshType());
  3693. return 1;
  3694. }
  3695. static int Polycore_Mesh_setMeshType(lua_State *L) {
  3696. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  3697. Mesh *inst = (Mesh*)lua_topointer(L, 1);
  3698. luaL_checktype(L, 2, LUA_TNUMBER);
  3699. int newType = lua_tointeger(L, 2);
  3700. inst->setMeshType(newType);
  3701. return 0;
  3702. }
  3703. static int Polycore_Mesh_calculateBBox(lua_State *L) {
  3704. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  3705. Mesh *inst = (Mesh*)lua_topointer(L, 1);
  3706. Vector3 *retInst = new Vector3();
  3707. *retInst = inst->calculateBBox();
  3708. lua_pushlightuserdata(L, retInst);
  3709. return 1;
  3710. }
  3711. static int Polycore_Mesh_hasVertexBuffer(lua_State *L) {
  3712. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  3713. Mesh *inst = (Mesh*)lua_topointer(L, 1);
  3714. lua_pushboolean(L, inst->hasVertexBuffer());
  3715. return 1;
  3716. }
  3717. static int Polycore_delete_Mesh(lua_State *L) {
  3718. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  3719. Mesh *inst = (Mesh*)lua_topointer(L, 1);
  3720. delete inst;
  3721. return 0;
  3722. }
  3723. static int Polycore_VertexBuffer_get_verticesPerFace(lua_State *L) {
  3724. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  3725. VertexBuffer *inst = (VertexBuffer*)lua_topointer(L, 1);
  3726. lua_pushinteger(L, inst->verticesPerFace);
  3727. return 1;
  3728. }
  3729. static int Polycore_VertexBuffer_get_meshType(lua_State *L) {
  3730. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  3731. VertexBuffer *inst = (VertexBuffer*)lua_topointer(L, 1);
  3732. lua_pushinteger(L, inst->meshType);
  3733. return 1;
  3734. }
  3735. static int Polycore_VertexBuffer_set_verticesPerFace(lua_State *L) {
  3736. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  3737. VertexBuffer *inst = (VertexBuffer*)lua_topointer(L, 1);
  3738. int param = lua_tointeger(L, 2);
  3739. inst->verticesPerFace = param;
  3740. return 0;
  3741. }
  3742. static int Polycore_VertexBuffer_set_meshType(lua_State *L) {
  3743. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  3744. VertexBuffer *inst = (VertexBuffer*)lua_topointer(L, 1);
  3745. int param = lua_tointeger(L, 2);
  3746. inst->meshType = param;
  3747. return 0;
  3748. }
  3749. static int Polycore_VertexBuffer(lua_State *L) {
  3750. VertexBuffer *inst = new VertexBuffer();
  3751. lua_pushlightuserdata(L, (void*)inst);
  3752. return 1;
  3753. }
  3754. static int Polycore_VertexBuffer_getVertexCount(lua_State *L) {
  3755. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  3756. VertexBuffer *inst = (VertexBuffer*)lua_topointer(L, 1);
  3757. lua_pushinteger(L, inst->getVertexCount());
  3758. return 1;
  3759. }
  3760. static int Polycore_delete_VertexBuffer(lua_State *L) {
  3761. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  3762. VertexBuffer *inst = (VertexBuffer*)lua_topointer(L, 1);
  3763. delete inst;
  3764. return 0;
  3765. }
  3766. static int Polycore_PolycodeModule(lua_State *L) {
  3767. PolycodeModule *inst = new PolycodeModule();
  3768. lua_pushlightuserdata(L, (void*)inst);
  3769. return 1;
  3770. }
  3771. static int Polycore_PolycodeModule_getType(lua_State *L) {
  3772. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  3773. PolycodeModule *inst = (PolycodeModule*)lua_topointer(L, 1);
  3774. lua_pushinteger(L, inst->getType());
  3775. return 1;
  3776. }
  3777. static int Polycore_delete_PolycodeModule(lua_State *L) {
  3778. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  3779. PolycodeModule *inst = (PolycodeModule*)lua_topointer(L, 1);
  3780. delete inst;
  3781. return 0;
  3782. }
  3783. static int Polycore_ObjectEntry_get_type(lua_State *L) {
  3784. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  3785. ObjectEntry *inst = (ObjectEntry*)lua_topointer(L, 1);
  3786. lua_pushinteger(L, inst->type);
  3787. return 1;
  3788. }
  3789. static int Polycore_ObjectEntry_get_name(lua_State *L) {
  3790. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  3791. ObjectEntry *inst = (ObjectEntry*)lua_topointer(L, 1);
  3792. lua_pushstring(L, inst->name.c_str());
  3793. return 1;
  3794. }
  3795. static int Polycore_ObjectEntry_get_NumberVal(lua_State *L) {
  3796. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  3797. ObjectEntry *inst = (ObjectEntry*)lua_topointer(L, 1);
  3798. lua_pushnumber(L, inst->NumberVal);
  3799. return 1;
  3800. }
  3801. static int Polycore_ObjectEntry_get_intVal(lua_State *L) {
  3802. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  3803. ObjectEntry *inst = (ObjectEntry*)lua_topointer(L, 1);
  3804. lua_pushinteger(L, inst->intVal);
  3805. return 1;
  3806. }
  3807. static int Polycore_ObjectEntry_get_stringVal(lua_State *L) {
  3808. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  3809. ObjectEntry *inst = (ObjectEntry*)lua_topointer(L, 1);
  3810. lua_pushstring(L, inst->stringVal.c_str());
  3811. return 1;
  3812. }
  3813. static int Polycore_ObjectEntry_get_boolVal(lua_State *L) {
  3814. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  3815. ObjectEntry *inst = (ObjectEntry*)lua_topointer(L, 1);
  3816. lua_pushboolean(L, inst->boolVal);
  3817. return 1;
  3818. }
  3819. static int Polycore_ObjectEntry_get_length(lua_State *L) {
  3820. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  3821. ObjectEntry *inst = (ObjectEntry*)lua_topointer(L, 1);
  3822. lua_pushinteger(L, inst->length);
  3823. return 1;
  3824. }
  3825. static int Polycore_ObjectEntry_set_type(lua_State *L) {
  3826. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  3827. ObjectEntry *inst = (ObjectEntry*)lua_topointer(L, 1);
  3828. int param = lua_tointeger(L, 2);
  3829. inst->type = param;
  3830. return 0;
  3831. }
  3832. static int Polycore_ObjectEntry_set_name(lua_State *L) {
  3833. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  3834. ObjectEntry *inst = (ObjectEntry*)lua_topointer(L, 1);
  3835. String param = lua_tostring(L, 2);
  3836. inst->name = param;
  3837. return 0;
  3838. }
  3839. static int Polycore_ObjectEntry_set_NumberVal(lua_State *L) {
  3840. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  3841. ObjectEntry *inst = (ObjectEntry*)lua_topointer(L, 1);
  3842. Number param = lua_tonumber(L, 2);
  3843. inst->NumberVal = param;
  3844. return 0;
  3845. }
  3846. static int Polycore_ObjectEntry_set_intVal(lua_State *L) {
  3847. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  3848. ObjectEntry *inst = (ObjectEntry*)lua_topointer(L, 1);
  3849. int param = lua_tointeger(L, 2);
  3850. inst->intVal = param;
  3851. return 0;
  3852. }
  3853. static int Polycore_ObjectEntry_set_stringVal(lua_State *L) {
  3854. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  3855. ObjectEntry *inst = (ObjectEntry*)lua_topointer(L, 1);
  3856. String param = lua_tostring(L, 2);
  3857. inst->stringVal = param;
  3858. return 0;
  3859. }
  3860. static int Polycore_ObjectEntry_set_boolVal(lua_State *L) {
  3861. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  3862. ObjectEntry *inst = (ObjectEntry*)lua_topointer(L, 1);
  3863. bool param = lua_toboolean(L, 2);
  3864. inst->boolVal = param;
  3865. return 0;
  3866. }
  3867. static int Polycore_ObjectEntry_set_length(lua_State *L) {
  3868. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  3869. ObjectEntry *inst = (ObjectEntry*)lua_topointer(L, 1);
  3870. int param = lua_tointeger(L, 2);
  3871. inst->length = param;
  3872. return 0;
  3873. }
  3874. static int Polycore_ObjectEntry(lua_State *L) {
  3875. ObjectEntry *inst = new ObjectEntry();
  3876. lua_pushlightuserdata(L, (void*)inst);
  3877. return 1;
  3878. }
  3879. static int Polycore_ObjectEntry_addChild(lua_State *L) {
  3880. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  3881. ObjectEntry *inst = (ObjectEntry*)lua_topointer(L, 1);
  3882. luaL_checktype(L, 2, LUA_TSTRING);
  3883. String name = String(lua_tostring(L, 2));
  3884. void *ptrRetVal = (void*)inst->addChild(name);
  3885. if(ptrRetVal == NULL) {
  3886. lua_pushnil(L);
  3887. } else {
  3888. lua_pushlightuserdata(L, ptrRetVal);
  3889. }
  3890. return 1;
  3891. }
  3892. static int Polycore_delete_ObjectEntry(lua_State *L) {
  3893. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  3894. ObjectEntry *inst = (ObjectEntry*)lua_topointer(L, 1);
  3895. delete inst;
  3896. return 0;
  3897. }
  3898. static int Polycore_Particle_get_velVector(lua_State *L) {
  3899. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  3900. Particle *inst = (Particle*)lua_topointer(L, 1);
  3901. lua_pushlightuserdata(L, &inst->velVector);
  3902. return 1;
  3903. }
  3904. static int Polycore_Particle_get_dirVector(lua_State *L) {
  3905. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  3906. Particle *inst = (Particle*)lua_topointer(L, 1);
  3907. lua_pushlightuserdata(L, &inst->dirVector);
  3908. return 1;
  3909. }
  3910. static int Polycore_Particle_get_deviation(lua_State *L) {
  3911. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  3912. Particle *inst = (Particle*)lua_topointer(L, 1);
  3913. lua_pushlightuserdata(L, &inst->deviation);
  3914. return 1;
  3915. }
  3916. static int Polycore_Particle_get_life(lua_State *L) {
  3917. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  3918. Particle *inst = (Particle*)lua_topointer(L, 1);
  3919. lua_pushnumber(L, inst->life);
  3920. return 1;
  3921. }
  3922. static int Polycore_Particle_get_lifespan(lua_State *L) {
  3923. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  3924. Particle *inst = (Particle*)lua_topointer(L, 1);
  3925. lua_pushnumber(L, inst->lifespan);
  3926. return 1;
  3927. }
  3928. static int Polycore_Particle_get_brightnessDeviation(lua_State *L) {
  3929. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  3930. Particle *inst = (Particle*)lua_topointer(L, 1);
  3931. lua_pushnumber(L, inst->brightnessDeviation);
  3932. return 1;
  3933. }
  3934. static int Polycore_Particle_get_perlinPosX(lua_State *L) {
  3935. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  3936. Particle *inst = (Particle*)lua_topointer(L, 1);
  3937. lua_pushnumber(L, inst->perlinPosX);
  3938. return 1;
  3939. }
  3940. static int Polycore_Particle_get_perlinPosY(lua_State *L) {
  3941. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  3942. Particle *inst = (Particle*)lua_topointer(L, 1);
  3943. lua_pushnumber(L, inst->perlinPosY);
  3944. return 1;
  3945. }
  3946. static int Polycore_Particle_get_perlinPosZ(lua_State *L) {
  3947. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  3948. Particle *inst = (Particle*)lua_topointer(L, 1);
  3949. lua_pushnumber(L, inst->perlinPosZ);
  3950. return 1;
  3951. }
  3952. static int Polycore_Particle_set_life(lua_State *L) {
  3953. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  3954. Particle *inst = (Particle*)lua_topointer(L, 1);
  3955. Number param = lua_tonumber(L, 2);
  3956. inst->life = param;
  3957. return 0;
  3958. }
  3959. static int Polycore_Particle_set_lifespan(lua_State *L) {
  3960. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  3961. Particle *inst = (Particle*)lua_topointer(L, 1);
  3962. Number param = lua_tonumber(L, 2);
  3963. inst->lifespan = param;
  3964. return 0;
  3965. }
  3966. static int Polycore_Particle_set_brightnessDeviation(lua_State *L) {
  3967. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  3968. Particle *inst = (Particle*)lua_topointer(L, 1);
  3969. Number param = lua_tonumber(L, 2);
  3970. inst->brightnessDeviation = param;
  3971. return 0;
  3972. }
  3973. static int Polycore_Particle_set_perlinPosX(lua_State *L) {
  3974. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  3975. Particle *inst = (Particle*)lua_topointer(L, 1);
  3976. Number param = lua_tonumber(L, 2);
  3977. inst->perlinPosX = param;
  3978. return 0;
  3979. }
  3980. static int Polycore_Particle_set_perlinPosY(lua_State *L) {
  3981. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  3982. Particle *inst = (Particle*)lua_topointer(L, 1);
  3983. Number param = lua_tonumber(L, 2);
  3984. inst->perlinPosY = param;
  3985. return 0;
  3986. }
  3987. static int Polycore_Particle_set_perlinPosZ(lua_State *L) {
  3988. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  3989. Particle *inst = (Particle*)lua_topointer(L, 1);
  3990. Number param = lua_tonumber(L, 2);
  3991. inst->perlinPosZ = param;
  3992. return 0;
  3993. }
  3994. static int Polycore_Particle(lua_State *L) {
  3995. luaL_checktype(L, 1, LUA_TNUMBER);
  3996. int particleType = lua_tointeger(L, 1);
  3997. luaL_checktype(L, 2, LUA_TBOOLEAN);
  3998. bool isScreenParticle = lua_toboolean(L, 2);
  3999. luaL_checktype(L, 3, LUA_TLIGHTUSERDATA);
  4000. Material * material = (Material *)lua_topointer(L, 3);
  4001. luaL_checktype(L, 4, LUA_TLIGHTUSERDATA);
  4002. Texture * texture = (Texture *)lua_topointer(L, 4);
  4003. luaL_checktype(L, 5, LUA_TLIGHTUSERDATA);
  4004. Mesh * particleMesh = (Mesh *)lua_topointer(L, 5);
  4005. Particle *inst = new Particle(particleType, isScreenParticle, material, texture, particleMesh);
  4006. lua_pushlightuserdata(L, (void*)inst);
  4007. return 1;
  4008. }
  4009. static int Polycore_Particle_Reset(lua_State *L) {
  4010. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  4011. Particle *inst = (Particle*)lua_topointer(L, 1);
  4012. luaL_checktype(L, 2, LUA_TBOOLEAN);
  4013. bool continuious = lua_toboolean(L, 2);
  4014. inst->Reset(continuious);
  4015. return 0;
  4016. }
  4017. static int Polycore_Particle_createSceneParticle(lua_State *L) {
  4018. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  4019. Particle *inst = (Particle*)lua_topointer(L, 1);
  4020. luaL_checktype(L, 2, LUA_TNUMBER);
  4021. int particleType = lua_tointeger(L, 2);
  4022. luaL_checktype(L, 3, LUA_TLIGHTUSERDATA);
  4023. Material * material = (Material *)lua_topointer(L, 3);
  4024. luaL_checktype(L, 4, LUA_TLIGHTUSERDATA);
  4025. Mesh * particleMesh = (Mesh *)lua_topointer(L, 4);
  4026. inst->createSceneParticle(particleType, material, particleMesh);
  4027. return 0;
  4028. }
  4029. static int Polycore_Particle_createScreenParticle(lua_State *L) {
  4030. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  4031. Particle *inst = (Particle*)lua_topointer(L, 1);
  4032. luaL_checktype(L, 2, LUA_TNUMBER);
  4033. int particleType = lua_tointeger(L, 2);
  4034. luaL_checktype(L, 3, LUA_TLIGHTUSERDATA);
  4035. Texture * texture = (Texture *)lua_topointer(L, 3);
  4036. luaL_checktype(L, 4, LUA_TLIGHTUSERDATA);
  4037. Mesh * particleMesh = (Mesh *)lua_topointer(L, 4);
  4038. inst->createScreenParticle(particleType, texture, particleMesh);
  4039. return 0;
  4040. }
  4041. static int Polycore_delete_Particle(lua_State *L) {
  4042. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  4043. Particle *inst = (Particle*)lua_topointer(L, 1);
  4044. delete inst;
  4045. return 0;
  4046. }
  4047. static int Polycore_ScreenParticleEmitter(lua_State *L) {
  4048. luaL_checktype(L, 1, LUA_TSTRING);
  4049. String imageFile = String(lua_tostring(L, 1));
  4050. luaL_checktype(L, 2, LUA_TLIGHTUSERDATA);
  4051. Screen * particleParentScreen = (Screen *)lua_topointer(L, 2);
  4052. luaL_checktype(L, 3, LUA_TNUMBER);
  4053. int particleType = lua_tointeger(L, 3);
  4054. luaL_checktype(L, 4, LUA_TNUMBER);
  4055. int emitterType = lua_tointeger(L, 4);
  4056. luaL_checktype(L, 5, LUA_TNUMBER);
  4057. Number lifespan = lua_tonumber(L, 5);
  4058. luaL_checktype(L, 6, LUA_TNUMBER);
  4059. unsigned int numParticles = lua_tointeger(L, 6);
  4060. luaL_checktype(L, 7, LUA_TLIGHTUSERDATA);
  4061. Vector3 direction = *(Vector3*)lua_topointer(L, 7);
  4062. luaL_checktype(L, 8, LUA_TLIGHTUSERDATA);
  4063. Vector3 gravity = *(Vector3*)lua_topointer(L, 8);
  4064. luaL_checktype(L, 9, LUA_TLIGHTUSERDATA);
  4065. Vector3 deviation = *(Vector3*)lua_topointer(L, 9);
  4066. Mesh * particleMesh;
  4067. if(lua_islightuserdata(L, 10)) {
  4068. particleMesh = (Mesh *)lua_topointer(L, 10);
  4069. } else {
  4070. particleMesh = NULL;
  4071. }
  4072. ScreenMesh * emitter;
  4073. if(lua_islightuserdata(L, 11)) {
  4074. emitter = (ScreenMesh *)lua_topointer(L, 11);
  4075. } else {
  4076. emitter = NULL;
  4077. }
  4078. ScreenParticleEmitter *inst = new ScreenParticleEmitter(imageFile, particleParentScreen, particleType, emitterType, lifespan, numParticles, direction, gravity, deviation, particleMesh, emitter);
  4079. lua_pushlightuserdata(L, (void*)inst);
  4080. return 1;
  4081. }
  4082. static int Polycore_ScreenParticleEmitter_getEmitter(lua_State *L) {
  4083. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  4084. ScreenParticleEmitter *inst = (ScreenParticleEmitter*)lua_topointer(L, 1);
  4085. void *ptrRetVal = (void*)inst->getEmitter();
  4086. if(ptrRetVal == NULL) {
  4087. lua_pushnil(L);
  4088. } else {
  4089. lua_pushlightuserdata(L, ptrRetVal);
  4090. }
  4091. return 1;
  4092. }
  4093. static int Polycore_ScreenParticleEmitter_addParticleBody(lua_State *L) {
  4094. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  4095. ScreenParticleEmitter *inst = (ScreenParticleEmitter*)lua_topointer(L, 1);
  4096. luaL_checktype(L, 2, LUA_TLIGHTUSERDATA);
  4097. Entity * particleBody = (Entity *)lua_topointer(L, 2);
  4098. inst->addParticleBody(particleBody);
  4099. return 0;
  4100. }
  4101. static int Polycore_ScreenParticleEmitter_getBaseMatrix(lua_State *L) {
  4102. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  4103. ScreenParticleEmitter *inst = (ScreenParticleEmitter*)lua_topointer(L, 1);
  4104. Matrix4 *retInst = new Matrix4();
  4105. *retInst = inst->getBaseMatrix();
  4106. lua_pushlightuserdata(L, retInst);
  4107. return 1;
  4108. }
  4109. static int Polycore_ScreenParticleEmitter_Update(lua_State *L) {
  4110. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  4111. ScreenParticleEmitter *inst = (ScreenParticleEmitter*)lua_topointer(L, 1);
  4112. inst->Update();
  4113. return 0;
  4114. }
  4115. static int Polycore_delete_ScreenParticleEmitter(lua_State *L) {
  4116. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  4117. ScreenParticleEmitter *inst = (ScreenParticleEmitter*)lua_topointer(L, 1);
  4118. delete inst;
  4119. return 0;
  4120. }
  4121. static int Polycore_SceneParticleEmitter(lua_State *L) {
  4122. luaL_checktype(L, 1, LUA_TSTRING);
  4123. String imageFile = String(lua_tostring(L, 1));
  4124. luaL_checktype(L, 2, LUA_TLIGHTUSERDATA);
  4125. Scene * particleParentScene = (Scene *)lua_topointer(L, 2);
  4126. luaL_checktype(L, 3, LUA_TNUMBER);
  4127. int particleType = lua_tointeger(L, 3);
  4128. luaL_checktype(L, 4, LUA_TNUMBER);
  4129. int emitterType = lua_tointeger(L, 4);
  4130. luaL_checktype(L, 5, LUA_TNUMBER);
  4131. Number lifespan = lua_tonumber(L, 5);
  4132. luaL_checktype(L, 6, LUA_TNUMBER);
  4133. unsigned int numParticles = lua_tointeger(L, 6);
  4134. luaL_checktype(L, 7, LUA_TLIGHTUSERDATA);
  4135. Vector3 direction = *(Vector3*)lua_topointer(L, 7);
  4136. luaL_checktype(L, 8, LUA_TLIGHTUSERDATA);
  4137. Vector3 gravity = *(Vector3*)lua_topointer(L, 8);
  4138. luaL_checktype(L, 9, LUA_TLIGHTUSERDATA);
  4139. Vector3 deviation = *(Vector3*)lua_topointer(L, 9);
  4140. Mesh * particleMesh;
  4141. if(lua_islightuserdata(L, 10)) {
  4142. particleMesh = (Mesh *)lua_topointer(L, 10);
  4143. } else {
  4144. particleMesh = NULL;
  4145. }
  4146. SceneMesh * emitter;
  4147. if(lua_islightuserdata(L, 11)) {
  4148. emitter = (SceneMesh *)lua_topointer(L, 11);
  4149. } else {
  4150. emitter = NULL;
  4151. }
  4152. SceneParticleEmitter *inst = new SceneParticleEmitter(imageFile, particleParentScene, particleType, emitterType, lifespan, numParticles, direction, gravity, deviation, particleMesh, emitter);
  4153. lua_pushlightuserdata(L, (void*)inst);
  4154. return 1;
  4155. }
  4156. static int Polycore_SceneParticleEmitter_getEmitter(lua_State *L) {
  4157. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  4158. SceneParticleEmitter *inst = (SceneParticleEmitter*)lua_topointer(L, 1);
  4159. void *ptrRetVal = (void*)inst->getEmitter();
  4160. if(ptrRetVal == NULL) {
  4161. lua_pushnil(L);
  4162. } else {
  4163. lua_pushlightuserdata(L, ptrRetVal);
  4164. }
  4165. return 1;
  4166. }
  4167. static int Polycore_SceneParticleEmitter_addParticleBody(lua_State *L) {
  4168. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  4169. SceneParticleEmitter *inst = (SceneParticleEmitter*)lua_topointer(L, 1);
  4170. luaL_checktype(L, 2, LUA_TLIGHTUSERDATA);
  4171. Entity * particleBody = (Entity *)lua_topointer(L, 2);
  4172. inst->addParticleBody(particleBody);
  4173. return 0;
  4174. }
  4175. static int Polycore_SceneParticleEmitter_getBaseMatrix(lua_State *L) {
  4176. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  4177. SceneParticleEmitter *inst = (SceneParticleEmitter*)lua_topointer(L, 1);
  4178. Matrix4 *retInst = new Matrix4();
  4179. *retInst = inst->getBaseMatrix();
  4180. lua_pushlightuserdata(L, retInst);
  4181. return 1;
  4182. }
  4183. static int Polycore_SceneParticleEmitter_Update(lua_State *L) {
  4184. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  4185. SceneParticleEmitter *inst = (SceneParticleEmitter*)lua_topointer(L, 1);
  4186. inst->Update();
  4187. return 0;
  4188. }
  4189. static int Polycore_delete_SceneParticleEmitter(lua_State *L) {
  4190. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  4191. SceneParticleEmitter *inst = (SceneParticleEmitter*)lua_topointer(L, 1);
  4192. delete inst;
  4193. return 0;
  4194. }
  4195. static int Polycore_ParticleEmitter_get_particleSpeedMod(lua_State *L) {
  4196. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  4197. ParticleEmitter *inst = (ParticleEmitter*)lua_topointer(L, 1);
  4198. lua_pushnumber(L, inst->particleSpeedMod);
  4199. return 1;
  4200. }
  4201. static int Polycore_ParticleEmitter_get_brightnessDeviation(lua_State *L) {
  4202. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  4203. ParticleEmitter *inst = (ParticleEmitter*)lua_topointer(L, 1);
  4204. lua_pushnumber(L, inst->brightnessDeviation);
  4205. return 1;
  4206. }
  4207. static int Polycore_ParticleEmitter_get_deviation(lua_State *L) {
  4208. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  4209. ParticleEmitter *inst = (ParticleEmitter*)lua_topointer(L, 1);
  4210. lua_pushlightuserdata(L, &inst->deviation);
  4211. return 1;
  4212. }
  4213. static int Polycore_ParticleEmitter_get_dirVector(lua_State *L) {
  4214. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  4215. ParticleEmitter *inst = (ParticleEmitter*)lua_topointer(L, 1);
  4216. lua_pushlightuserdata(L, &inst->dirVector);
  4217. return 1;
  4218. }
  4219. static int Polycore_ParticleEmitter_get_gravVector(lua_State *L) {
  4220. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  4221. ParticleEmitter *inst = (ParticleEmitter*)lua_topointer(L, 1);
  4222. lua_pushlightuserdata(L, &inst->gravVector);
  4223. return 1;
  4224. }
  4225. static int Polycore_ParticleEmitter_get_lifespan(lua_State *L) {
  4226. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  4227. ParticleEmitter *inst = (ParticleEmitter*)lua_topointer(L, 1);
  4228. lua_pushnumber(L, inst->lifespan);
  4229. return 1;
  4230. }
  4231. static int Polycore_ParticleEmitter_get_rotationFollowsPath(lua_State *L) {
  4232. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  4233. ParticleEmitter *inst = (ParticleEmitter*)lua_topointer(L, 1);
  4234. lua_pushboolean(L, inst->rotationFollowsPath);
  4235. return 1;
  4236. }
  4237. static int Polycore_ParticleEmitter_get_scaleCurve(lua_State *L) {
  4238. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  4239. ParticleEmitter *inst = (ParticleEmitter*)lua_topointer(L, 1);
  4240. lua_pushlightuserdata(L, &inst->scaleCurve);
  4241. return 1;
  4242. }
  4243. static int Polycore_ParticleEmitter_get_colorCurveR(lua_State *L) {
  4244. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  4245. ParticleEmitter *inst = (ParticleEmitter*)lua_topointer(L, 1);
  4246. lua_pushlightuserdata(L, &inst->colorCurveR);
  4247. return 1;
  4248. }
  4249. static int Polycore_ParticleEmitter_get_colorCurveG(lua_State *L) {
  4250. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  4251. ParticleEmitter *inst = (ParticleEmitter*)lua_topointer(L, 1);
  4252. lua_pushlightuserdata(L, &inst->colorCurveG);
  4253. return 1;
  4254. }
  4255. static int Polycore_ParticleEmitter_get_colorCurveB(lua_State *L) {
  4256. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  4257. ParticleEmitter *inst = (ParticleEmitter*)lua_topointer(L, 1);
  4258. lua_pushlightuserdata(L, &inst->colorCurveB);
  4259. return 1;
  4260. }
  4261. static int Polycore_ParticleEmitter_get_colorCurveA(lua_State *L) {
  4262. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  4263. ParticleEmitter *inst = (ParticleEmitter*)lua_topointer(L, 1);
  4264. lua_pushlightuserdata(L, &inst->colorCurveA);
  4265. return 1;
  4266. }
  4267. static int Polycore_ParticleEmitter_get_useColorCurves(lua_State *L) {
  4268. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  4269. ParticleEmitter *inst = (ParticleEmitter*)lua_topointer(L, 1);
  4270. lua_pushboolean(L, inst->useColorCurves);
  4271. return 1;
  4272. }
  4273. static int Polycore_ParticleEmitter_get_useScaleCurves(lua_State *L) {
  4274. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  4275. ParticleEmitter *inst = (ParticleEmitter*)lua_topointer(L, 1);
  4276. lua_pushboolean(L, inst->useScaleCurves);
  4277. return 1;
  4278. }
  4279. static int Polycore_ParticleEmitter_set_particleSpeedMod(lua_State *L) {
  4280. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  4281. ParticleEmitter *inst = (ParticleEmitter*)lua_topointer(L, 1);
  4282. Number param = lua_tonumber(L, 2);
  4283. inst->particleSpeedMod = param;
  4284. return 0;
  4285. }
  4286. static int Polycore_ParticleEmitter_set_brightnessDeviation(lua_State *L) {
  4287. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  4288. ParticleEmitter *inst = (ParticleEmitter*)lua_topointer(L, 1);
  4289. Number param = lua_tonumber(L, 2);
  4290. inst->brightnessDeviation = param;
  4291. return 0;
  4292. }
  4293. static int Polycore_ParticleEmitter_set_lifespan(lua_State *L) {
  4294. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  4295. ParticleEmitter *inst = (ParticleEmitter*)lua_topointer(L, 1);
  4296. Number param = lua_tonumber(L, 2);
  4297. inst->lifespan = param;
  4298. return 0;
  4299. }
  4300. static int Polycore_ParticleEmitter_set_rotationFollowsPath(lua_State *L) {
  4301. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  4302. ParticleEmitter *inst = (ParticleEmitter*)lua_topointer(L, 1);
  4303. bool param = lua_toboolean(L, 2);
  4304. inst->rotationFollowsPath = param;
  4305. return 0;
  4306. }
  4307. static int Polycore_ParticleEmitter_set_useColorCurves(lua_State *L) {
  4308. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  4309. ParticleEmitter *inst = (ParticleEmitter*)lua_topointer(L, 1);
  4310. bool param = lua_toboolean(L, 2);
  4311. inst->useColorCurves = param;
  4312. return 0;
  4313. }
  4314. static int Polycore_ParticleEmitter_set_useScaleCurves(lua_State *L) {
  4315. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  4316. ParticleEmitter *inst = (ParticleEmitter*)lua_topointer(L, 1);
  4317. bool param = lua_toboolean(L, 2);
  4318. inst->useScaleCurves = param;
  4319. return 0;
  4320. }
  4321. static int Polycore_ParticleEmitter(lua_State *L) {
  4322. luaL_checktype(L, 1, LUA_TSTRING);
  4323. String imageFile = String(lua_tostring(L, 1));
  4324. luaL_checktype(L, 2, LUA_TLIGHTUSERDATA);
  4325. Mesh * particleMesh = (Mesh *)lua_topointer(L, 2);
  4326. luaL_checktype(L, 3, LUA_TNUMBER);
  4327. int particleType = lua_tointeger(L, 3);
  4328. luaL_checktype(L, 4, LUA_TNUMBER);
  4329. int emitterType = lua_tointeger(L, 4);
  4330. luaL_checktype(L, 5, LUA_TNUMBER);
  4331. Number lifespan = lua_tonumber(L, 5);
  4332. luaL_checktype(L, 6, LUA_TNUMBER);
  4333. unsigned int numParticles = lua_tointeger(L, 6);
  4334. luaL_checktype(L, 7, LUA_TLIGHTUSERDATA);
  4335. Vector3 direction = *(Vector3*)lua_topointer(L, 7);
  4336. luaL_checktype(L, 8, LUA_TLIGHTUSERDATA);
  4337. Vector3 gravity = *(Vector3*)lua_topointer(L, 8);
  4338. luaL_checktype(L, 9, LUA_TLIGHTUSERDATA);
  4339. Vector3 deviation = *(Vector3*)lua_topointer(L, 9);
  4340. ParticleEmitter *inst = new ParticleEmitter(imageFile, particleMesh, particleType, emitterType, lifespan, numParticles, direction, gravity, deviation);
  4341. lua_pushlightuserdata(L, (void*)inst);
  4342. return 1;
  4343. }
  4344. static int Polycore_ParticleEmitter_createParticles(lua_State *L) {
  4345. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  4346. ParticleEmitter *inst = (ParticleEmitter*)lua_topointer(L, 1);
  4347. inst->createParticles();
  4348. return 0;
  4349. }
  4350. static int Polycore_ParticleEmitter_setRotationSpeed(lua_State *L) {
  4351. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  4352. ParticleEmitter *inst = (ParticleEmitter*)lua_topointer(L, 1);
  4353. luaL_checktype(L, 2, LUA_TNUMBER);
  4354. Number speed = lua_tonumber(L, 2);
  4355. inst->setRotationSpeed(speed);
  4356. return 0;
  4357. }
  4358. static int Polycore_ParticleEmitter_setParticleBlendingMode(lua_State *L) {
  4359. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  4360. ParticleEmitter *inst = (ParticleEmitter*)lua_topointer(L, 1);
  4361. luaL_checktype(L, 2, LUA_TNUMBER);
  4362. int mode = lua_tointeger(L, 2);
  4363. inst->setParticleBlendingMode(mode);
  4364. return 0;
  4365. }
  4366. static int Polycore_ParticleEmitter_setDepthWrite(lua_State *L) {
  4367. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  4368. ParticleEmitter *inst = (ParticleEmitter*)lua_topointer(L, 1);
  4369. luaL_checktype(L, 2, LUA_TBOOLEAN);
  4370. bool val = lua_toboolean(L, 2);
  4371. inst->setDepthWrite(val);
  4372. return 0;
  4373. }
  4374. static int Polycore_ParticleEmitter_setDepthTest(lua_State *L) {
  4375. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  4376. ParticleEmitter *inst = (ParticleEmitter*)lua_topointer(L, 1);
  4377. luaL_checktype(L, 2, LUA_TBOOLEAN);
  4378. bool val = lua_toboolean(L, 2);
  4379. inst->setDepthTest(val);
  4380. return 0;
  4381. }
  4382. static int Polycore_ParticleEmitter_setAlphaTest(lua_State *L) {
  4383. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  4384. ParticleEmitter *inst = (ParticleEmitter*)lua_topointer(L, 1);
  4385. luaL_checktype(L, 2, LUA_TBOOLEAN);
  4386. bool val = lua_toboolean(L, 2);
  4387. inst->setAlphaTest(val);
  4388. return 0;
  4389. }
  4390. static int Polycore_ParticleEmitter_enablePerlin(lua_State *L) {
  4391. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  4392. ParticleEmitter *inst = (ParticleEmitter*)lua_topointer(L, 1);
  4393. luaL_checktype(L, 2, LUA_TBOOLEAN);
  4394. bool val = lua_toboolean(L, 2);
  4395. inst->enablePerlin(val);
  4396. return 0;
  4397. }
  4398. static int Polycore_ParticleEmitter_setBillboardMode(lua_State *L) {
  4399. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  4400. ParticleEmitter *inst = (ParticleEmitter*)lua_topointer(L, 1);
  4401. luaL_checktype(L, 2, LUA_TBOOLEAN);
  4402. bool mode = lua_toboolean(L, 2);
  4403. inst->setBillboardMode(mode);
  4404. return 0;
  4405. }
  4406. static int Polycore_ParticleEmitter_enableEmitter(lua_State *L) {
  4407. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  4408. ParticleEmitter *inst = (ParticleEmitter*)lua_topointer(L, 1);
  4409. luaL_checktype(L, 2, LUA_TBOOLEAN);
  4410. bool val = lua_toboolean(L, 2);
  4411. inst->enableEmitter(val);
  4412. return 0;
  4413. }
  4414. static int Polycore_ParticleEmitter_emitterEnabled(lua_State *L) {
  4415. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  4416. ParticleEmitter *inst = (ParticleEmitter*)lua_topointer(L, 1);
  4417. lua_pushboolean(L, inst->emitterEnabled());
  4418. return 1;
  4419. }
  4420. static int Polycore_ParticleEmitter_setEmitterRadius(lua_State *L) {
  4421. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  4422. ParticleEmitter *inst = (ParticleEmitter*)lua_topointer(L, 1);
  4423. luaL_checktype(L, 2, LUA_TLIGHTUSERDATA);
  4424. Vector3 rad = *(Vector3*)lua_topointer(L, 2);
  4425. inst->setEmitterRadius(rad);
  4426. return 0;
  4427. }
  4428. static int Polycore_ParticleEmitter_setAllAtOnce(lua_State *L) {
  4429. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  4430. ParticleEmitter *inst = (ParticleEmitter*)lua_topointer(L, 1);
  4431. luaL_checktype(L, 2, LUA_TBOOLEAN);
  4432. bool val = lua_toboolean(L, 2);
  4433. inst->setAllAtOnce(val);
  4434. return 0;
  4435. }
  4436. static int Polycore_ParticleEmitter_Trigger(lua_State *L) {
  4437. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  4438. ParticleEmitter *inst = (ParticleEmitter*)lua_topointer(L, 1);
  4439. inst->Trigger();
  4440. return 0;
  4441. }
  4442. static int Polycore_ParticleEmitter_resetParticle(lua_State *L) {
  4443. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  4444. ParticleEmitter *inst = (ParticleEmitter*)lua_topointer(L, 1);
  4445. luaL_checktype(L, 2, LUA_TLIGHTUSERDATA);
  4446. Particle * particle = (Particle *)lua_topointer(L, 2);
  4447. inst->resetParticle(particle);
  4448. return 0;
  4449. }
  4450. static int Polycore_ParticleEmitter_setPerlinModSize(lua_State *L) {
  4451. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  4452. ParticleEmitter *inst = (ParticleEmitter*)lua_topointer(L, 1);
  4453. luaL_checktype(L, 2, LUA_TNUMBER);
  4454. Number size = lua_tonumber(L, 2);
  4455. inst->setPerlinModSize(size);
  4456. return 0;
  4457. }
  4458. static int Polycore_ParticleEmitter_setParticleCount(lua_State *L) {
  4459. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  4460. ParticleEmitter *inst = (ParticleEmitter*)lua_topointer(L, 1);
  4461. luaL_checktype(L, 2, LUA_TNUMBER);
  4462. int count = lua_tointeger(L, 2);
  4463. inst->setParticleCount(count);
  4464. return 0;
  4465. }
  4466. static int Polycore_ParticleEmitter_addParticleBody(lua_State *L) {
  4467. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  4468. ParticleEmitter *inst = (ParticleEmitter*)lua_topointer(L, 1);
  4469. luaL_checktype(L, 2, LUA_TLIGHTUSERDATA);
  4470. Entity * particleBody = (Entity *)lua_topointer(L, 2);
  4471. inst->addParticleBody(particleBody);
  4472. return 0;
  4473. }
  4474. static int Polycore_ParticleEmitter_getBaseMatrix(lua_State *L) {
  4475. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  4476. ParticleEmitter *inst = (ParticleEmitter*)lua_topointer(L, 1);
  4477. Matrix4 *retInst = new Matrix4();
  4478. *retInst = inst->getBaseMatrix();
  4479. lua_pushlightuserdata(L, retInst);
  4480. return 1;
  4481. }
  4482. static int Polycore_ParticleEmitter_updateEmitter(lua_State *L) {
  4483. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  4484. ParticleEmitter *inst = (ParticleEmitter*)lua_topointer(L, 1);
  4485. inst->updateEmitter();
  4486. return 0;
  4487. }
  4488. static int Polycore_delete_ParticleEmitter(lua_State *L) {
  4489. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  4490. ParticleEmitter *inst = (ParticleEmitter*)lua_topointer(L, 1);
  4491. delete inst;
  4492. return 0;
  4493. }
  4494. static int Polycore_Perlin(lua_State *L) {
  4495. luaL_checktype(L, 1, LUA_TNUMBER);
  4496. int octaves = lua_tointeger(L, 1);
  4497. luaL_checktype(L, 2, LUA_TNUMBER);
  4498. Number freq = lua_tonumber(L, 2);
  4499. luaL_checktype(L, 3, LUA_TNUMBER);
  4500. Number amp = lua_tonumber(L, 3);
  4501. luaL_checktype(L, 4, LUA_TNUMBER);
  4502. int seed = lua_tointeger(L, 4);
  4503. Perlin *inst = new Perlin(octaves, freq, amp, seed);
  4504. lua_pushlightuserdata(L, (void*)inst);
  4505. return 1;
  4506. }
  4507. static int Polycore_Perlin_Get(lua_State *L) {
  4508. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  4509. Perlin *inst = (Perlin*)lua_topointer(L, 1);
  4510. luaL_checktype(L, 2, LUA_TNUMBER);
  4511. Number x = lua_tonumber(L, 2);
  4512. luaL_checktype(L, 3, LUA_TNUMBER);
  4513. Number y = lua_tonumber(L, 3);
  4514. lua_pushnumber(L, inst->Get(x, y));
  4515. return 1;
  4516. }
  4517. static int Polycore_delete_Perlin(lua_State *L) {
  4518. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  4519. Perlin *inst = (Perlin*)lua_topointer(L, 1);
  4520. delete inst;
  4521. return 0;
  4522. }
  4523. static int Polycore_Polygon_get_useVertexNormals(lua_State *L) {
  4524. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  4525. Polycode::Polygon *inst = (Polycode::Polygon*)lua_topointer(L, 1);
  4526. lua_pushboolean(L, inst->useVertexNormals);
  4527. return 1;
  4528. }
  4529. static int Polycore_Polygon_set_useVertexNormals(lua_State *L) {
  4530. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  4531. Polycode::Polygon *inst = (Polycode::Polygon*)lua_topointer(L, 1);
  4532. bool param = lua_toboolean(L, 2);
  4533. inst->useVertexNormals = param;
  4534. return 0;
  4535. }
  4536. static int Polycore_Polygon(lua_State *L) {
  4537. Polycode::Polygon *inst = new Polycode::Polygon();
  4538. lua_pushlightuserdata(L, (void*)inst);
  4539. return 1;
  4540. }
  4541. static int Polycore_Polygon_getVertexCount(lua_State *L) {
  4542. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  4543. Polycode::Polygon *inst = (Polycode::Polygon*)lua_topointer(L, 1);
  4544. lua_pushinteger(L, inst->getVertexCount());
  4545. return 1;
  4546. }
  4547. static int Polycore_Polygon_getVertex(lua_State *L) {
  4548. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  4549. Polycode::Polygon *inst = (Polycode::Polygon*)lua_topointer(L, 1);
  4550. luaL_checktype(L, 2, LUA_TNUMBER);
  4551. unsigned int index = lua_tointeger(L, 2);
  4552. void *ptrRetVal = (void*)inst->getVertex(index);
  4553. if(ptrRetVal == NULL) {
  4554. lua_pushnil(L);
  4555. } else {
  4556. lua_pushlightuserdata(L, ptrRetVal);
  4557. }
  4558. return 1;
  4559. }
  4560. static int Polycore_Polygon_addVertex(lua_State *L) {
  4561. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  4562. Polycode::Polygon *inst = (Polycode::Polygon*)lua_topointer(L, 1);
  4563. luaL_checktype(L, 2, LUA_TNUMBER);
  4564. Number x = lua_tonumber(L, 2);
  4565. luaL_checktype(L, 3, LUA_TNUMBER);
  4566. Number y = lua_tonumber(L, 3);
  4567. luaL_checktype(L, 4, LUA_TNUMBER);
  4568. Number z = lua_tonumber(L, 4);
  4569. void *ptrRetVal = (void*)inst->addVertex(x, y, z);
  4570. if(ptrRetVal == NULL) {
  4571. lua_pushnil(L);
  4572. } else {
  4573. lua_pushlightuserdata(L, ptrRetVal);
  4574. }
  4575. return 1;
  4576. }
  4577. static int Polycore_Polygon_removeVertex(lua_State *L) {
  4578. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  4579. Polycode::Polygon *inst = (Polycode::Polygon*)lua_topointer(L, 1);
  4580. luaL_checktype(L, 2, LUA_TNUMBER);
  4581. int index = lua_tointeger(L, 2);
  4582. inst->removeVertex(index);
  4583. return 0;
  4584. }
  4585. static int Polycore_Polygon_calculateNormal(lua_State *L) {
  4586. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  4587. Polycode::Polygon *inst = (Polycode::Polygon*)lua_topointer(L, 1);
  4588. inst->calculateNormal();
  4589. return 0;
  4590. }
  4591. static int Polycore_Polygon_getFaceNormal(lua_State *L) {
  4592. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  4593. Polycode::Polygon *inst = (Polycode::Polygon*)lua_topointer(L, 1);
  4594. Vector3 *retInst = new Vector3();
  4595. *retInst = inst->getFaceNormal();
  4596. lua_pushlightuserdata(L, retInst);
  4597. return 1;
  4598. }
  4599. static int Polycore_Polygon_getBounds2D(lua_State *L) {
  4600. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  4601. Polycode::Polygon *inst = (Polycode::Polygon*)lua_topointer(L, 1);
  4602. Polycode::Rectangle *retInst = new Polycode::Rectangle();
  4603. *retInst = inst->getBounds2D();
  4604. lua_pushlightuserdata(L, retInst);
  4605. return 1;
  4606. }
  4607. static int Polycore_Polygon_setNormal(lua_State *L) {
  4608. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  4609. Polycode::Polygon *inst = (Polycode::Polygon*)lua_topointer(L, 1);
  4610. luaL_checktype(L, 2, LUA_TLIGHTUSERDATA);
  4611. Vector3 normal = *(Vector3*)lua_topointer(L, 2);
  4612. inst->setNormal(normal);
  4613. return 0;
  4614. }
  4615. static int Polycore_Polygon_flipUVY(lua_State *L) {
  4616. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  4617. Polycode::Polygon *inst = (Polycode::Polygon*)lua_topointer(L, 1);
  4618. inst->flipUVY();
  4619. return 0;
  4620. }
  4621. static int Polycore_delete_Polygon(lua_State *L) {
  4622. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  4623. Polycode::Polygon *inst = (Polycode::Polygon*)lua_topointer(L, 1);
  4624. delete inst;
  4625. return 0;
  4626. }
  4627. static int Polycore_Quaternion_get_x(lua_State *L) {
  4628. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  4629. Quaternion *inst = (Quaternion*)lua_topointer(L, 1);
  4630. lua_pushnumber(L, inst->x);
  4631. return 1;
  4632. }
  4633. static int Polycore_Quaternion_get_y(lua_State *L) {
  4634. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  4635. Quaternion *inst = (Quaternion*)lua_topointer(L, 1);
  4636. lua_pushnumber(L, inst->y);
  4637. return 1;
  4638. }
  4639. static int Polycore_Quaternion_get_z(lua_State *L) {
  4640. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  4641. Quaternion *inst = (Quaternion*)lua_topointer(L, 1);
  4642. lua_pushnumber(L, inst->z);
  4643. return 1;
  4644. }
  4645. static int Polycore_Quaternion_get_w(lua_State *L) {
  4646. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  4647. Quaternion *inst = (Quaternion*)lua_topointer(L, 1);
  4648. lua_pushnumber(L, inst->w);
  4649. return 1;
  4650. }
  4651. static int Polycore_Quaternion_set_x(lua_State *L) {
  4652. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  4653. Quaternion *inst = (Quaternion*)lua_topointer(L, 1);
  4654. Number param = lua_tonumber(L, 2);
  4655. inst->x = param;
  4656. return 0;
  4657. }
  4658. static int Polycore_Quaternion_set_y(lua_State *L) {
  4659. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  4660. Quaternion *inst = (Quaternion*)lua_topointer(L, 1);
  4661. Number param = lua_tonumber(L, 2);
  4662. inst->y = param;
  4663. return 0;
  4664. }
  4665. static int Polycore_Quaternion_set_z(lua_State *L) {
  4666. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  4667. Quaternion *inst = (Quaternion*)lua_topointer(L, 1);
  4668. Number param = lua_tonumber(L, 2);
  4669. inst->z = param;
  4670. return 0;
  4671. }
  4672. static int Polycore_Quaternion_set_w(lua_State *L) {
  4673. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  4674. Quaternion *inst = (Quaternion*)lua_topointer(L, 1);
  4675. Number param = lua_tonumber(L, 2);
  4676. inst->w = param;
  4677. return 0;
  4678. }
  4679. static int Polycore_Quaternion(lua_State *L) {
  4680. luaL_checktype(L, 1, LUA_TNUMBER);
  4681. Number w = lua_tonumber(L, 1);
  4682. luaL_checktype(L, 2, LUA_TNUMBER);
  4683. Number x = lua_tonumber(L, 2);
  4684. luaL_checktype(L, 3, LUA_TNUMBER);
  4685. Number y = lua_tonumber(L, 3);
  4686. luaL_checktype(L, 4, LUA_TNUMBER);
  4687. Number z = lua_tonumber(L, 4);
  4688. Quaternion *inst = new Quaternion(w, x, y, z);
  4689. lua_pushlightuserdata(L, (void*)inst);
  4690. return 1;
  4691. }
  4692. static int Polycore_Quaternion_setFromMatrix(lua_State *L) {
  4693. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  4694. Quaternion *inst = (Quaternion*)lua_topointer(L, 1);
  4695. luaL_checktype(L, 2, LUA_TLIGHTUSERDATA);
  4696. const Matrix4 & _mat = *( Matrix4 *)lua_topointer(L, 2);
  4697. inst->setFromMatrix(_mat);
  4698. return 0;
  4699. }
  4700. static int Polycore_Quaternion_Slerp(lua_State *L) {
  4701. luaL_checktype(L, 2, LUA_TNUMBER);
  4702. Number fT = lua_tonumber(L, 2);
  4703. luaL_checktype(L, 3, LUA_TLIGHTUSERDATA);
  4704. const Quaternion & rkP = *( Quaternion *)lua_topointer(L, 3);
  4705. luaL_checktype(L, 4, LUA_TLIGHTUSERDATA);
  4706. const Quaternion & rkQ = *( Quaternion *)lua_topointer(L, 4);
  4707. bool shortestPath;
  4708. if(lua_isboolean(L, 5)) {
  4709. shortestPath = lua_toboolean(L, 5);
  4710. } else {
  4711. shortestPath = false;
  4712. }
  4713. Quaternion *retInst = new Quaternion();
  4714. *retInst = Quaternion::Slerp(fT, rkP, rkQ, shortestPath);
  4715. lua_pushlightuserdata(L, retInst);
  4716. return 1;
  4717. }
  4718. static int Polycore_Quaternion_Dot(lua_State *L) {
  4719. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  4720. Quaternion *inst = (Quaternion*)lua_topointer(L, 1);
  4721. luaL_checktype(L, 2, LUA_TLIGHTUSERDATA);
  4722. const Quaternion & rkQ = *( Quaternion *)lua_topointer(L, 2);
  4723. lua_pushnumber(L, inst->Dot(rkQ));
  4724. return 1;
  4725. }
  4726. static int Polycore_Quaternion_Log(lua_State *L) {
  4727. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  4728. Quaternion *inst = (Quaternion*)lua_topointer(L, 1);
  4729. Quaternion *retInst = new Quaternion();
  4730. *retInst = inst->Log();
  4731. lua_pushlightuserdata(L, retInst);
  4732. return 1;
  4733. }
  4734. static int Polycore_Quaternion_Exp(lua_State *L) {
  4735. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  4736. Quaternion *inst = (Quaternion*)lua_topointer(L, 1);
  4737. Quaternion *retInst = new Quaternion();
  4738. *retInst = inst->Exp();
  4739. lua_pushlightuserdata(L, retInst);
  4740. return 1;
  4741. }
  4742. static int Polycore_Quaternion_Norm(lua_State *L) {
  4743. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  4744. Quaternion *inst = (Quaternion*)lua_topointer(L, 1);
  4745. lua_pushnumber(L, inst->Norm());
  4746. return 1;
  4747. }
  4748. static int Polycore_Quaternion_normalize(lua_State *L) {
  4749. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  4750. Quaternion *inst = (Quaternion*)lua_topointer(L, 1);
  4751. lua_pushnumber(L, inst->normalize());
  4752. return 1;
  4753. }
  4754. static int Polycore_Quaternion_lookAt(lua_State *L) {
  4755. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  4756. Quaternion *inst = (Quaternion*)lua_topointer(L, 1);
  4757. luaL_checktype(L, 2, LUA_TLIGHTUSERDATA);
  4758. const Vector3 & D = *( Vector3 *)lua_topointer(L, 2);
  4759. luaL_checktype(L, 3, LUA_TLIGHTUSERDATA);
  4760. const Vector3 & upVector = *( Vector3 *)lua_topointer(L, 3);
  4761. inst->lookAt(D, upVector);
  4762. return 0;
  4763. }
  4764. static int Polycore_Quaternion_createFromMatrix(lua_State *L) {
  4765. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  4766. Quaternion *inst = (Quaternion*)lua_topointer(L, 1);
  4767. luaL_checktype(L, 2, LUA_TLIGHTUSERDATA);
  4768. Matrix4 matrix = *(Matrix4*)lua_topointer(L, 2);
  4769. inst->createFromMatrix(matrix);
  4770. return 0;
  4771. }
  4772. static int Polycore_Quaternion_Squad(lua_State *L) {
  4773. luaL_checktype(L, 2, LUA_TNUMBER);
  4774. Number fT = lua_tonumber(L, 2);
  4775. luaL_checktype(L, 3, LUA_TLIGHTUSERDATA);
  4776. const Quaternion & rkP = *( Quaternion *)lua_topointer(L, 3);
  4777. luaL_checktype(L, 4, LUA_TLIGHTUSERDATA);
  4778. const Quaternion & rkA = *( Quaternion *)lua_topointer(L, 4);
  4779. luaL_checktype(L, 5, LUA_TLIGHTUSERDATA);
  4780. const Quaternion & rkB = *( Quaternion *)lua_topointer(L, 5);
  4781. luaL_checktype(L, 6, LUA_TLIGHTUSERDATA);
  4782. const Quaternion & rkQ = *( Quaternion *)lua_topointer(L, 6);
  4783. luaL_checktype(L, 7, LUA_TBOOLEAN);
  4784. bool shortestPath = lua_toboolean(L, 7);
  4785. Quaternion *retInst = new Quaternion();
  4786. *retInst = Quaternion::Squad(fT, rkP, rkA, rkB, rkQ, shortestPath);
  4787. lua_pushlightuserdata(L, retInst);
  4788. return 1;
  4789. }
  4790. static int Polycore_Quaternion_Inverse(lua_State *L) {
  4791. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  4792. Quaternion *inst = (Quaternion*)lua_topointer(L, 1);
  4793. Quaternion *retInst = new Quaternion();
  4794. *retInst = inst->Inverse();
  4795. lua_pushlightuserdata(L, retInst);
  4796. return 1;
  4797. }
  4798. static int Polycore_Quaternion_set(lua_State *L) {
  4799. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  4800. Quaternion *inst = (Quaternion*)lua_topointer(L, 1);
  4801. luaL_checktype(L, 2, LUA_TNUMBER);
  4802. Number w = lua_tonumber(L, 2);
  4803. luaL_checktype(L, 3, LUA_TNUMBER);
  4804. Number x = lua_tonumber(L, 3);
  4805. luaL_checktype(L, 4, LUA_TNUMBER);
  4806. Number y = lua_tonumber(L, 4);
  4807. luaL_checktype(L, 5, LUA_TNUMBER);
  4808. Number z = lua_tonumber(L, 5);
  4809. inst->set(w, x, y, z);
  4810. return 0;
  4811. }
  4812. static int Polycore_Quaternion_inverse(lua_State *L) {
  4813. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  4814. Quaternion *inst = (Quaternion*)lua_topointer(L, 1);
  4815. Quaternion *retInst = new Quaternion();
  4816. *retInst = inst->inverse();
  4817. lua_pushlightuserdata(L, retInst);
  4818. return 1;
  4819. }
  4820. static int Polycore_Quaternion_InvSqrt(lua_State *L) {
  4821. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  4822. Quaternion *inst = (Quaternion*)lua_topointer(L, 1);
  4823. luaL_checktype(L, 2, LUA_TNUMBER);
  4824. Number x = lua_tonumber(L, 2);
  4825. lua_pushnumber(L, inst->InvSqrt(x));
  4826. return 1;
  4827. }
  4828. static int Polycore_Quaternion_fromAxes(lua_State *L) {
  4829. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  4830. Quaternion *inst = (Quaternion*)lua_topointer(L, 1);
  4831. luaL_checktype(L, 2, LUA_TNUMBER);
  4832. Number az = lua_tonumber(L, 2);
  4833. luaL_checktype(L, 3, LUA_TNUMBER);
  4834. Number ay = lua_tonumber(L, 3);
  4835. luaL_checktype(L, 4, LUA_TNUMBER);
  4836. Number ax = lua_tonumber(L, 4);
  4837. inst->fromAxes(az, ay, ax);
  4838. return 0;
  4839. }
  4840. static int Polycore_Quaternion_FromAngleAxis(lua_State *L) {
  4841. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  4842. Quaternion *inst = (Quaternion*)lua_topointer(L, 1);
  4843. luaL_checktype(L, 2, LUA_TLIGHTUSERDATA);
  4844. const Number & rfAngle = *( Number *)lua_topointer(L, 2);
  4845. luaL_checktype(L, 3, LUA_TLIGHTUSERDATA);
  4846. const Vector3 & rkAxis = *( Vector3 *)lua_topointer(L, 3);
  4847. inst->FromAngleAxis(rfAngle, rkAxis);
  4848. return 0;
  4849. }
  4850. static int Polycore_Quaternion_ToAngleAxis(lua_State *L) {
  4851. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  4852. Quaternion *inst = (Quaternion*)lua_topointer(L, 1);
  4853. luaL_checktype(L, 2, LUA_TLIGHTUSERDATA);
  4854. Number & rfAngle = *(Number *)lua_topointer(L, 2);
  4855. luaL_checktype(L, 3, LUA_TLIGHTUSERDATA);
  4856. Vector3 & rkAxis = *(Vector3 *)lua_topointer(L, 3);
  4857. inst->ToAngleAxis(rfAngle, rkAxis);
  4858. return 0;
  4859. }
  4860. static int Polycore_Quaternion_createFromAxisAngle(lua_State *L) {
  4861. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  4862. Quaternion *inst = (Quaternion*)lua_topointer(L, 1);
  4863. luaL_checktype(L, 2, LUA_TNUMBER);
  4864. Number x = lua_tonumber(L, 2);
  4865. luaL_checktype(L, 3, LUA_TNUMBER);
  4866. Number y = lua_tonumber(L, 3);
  4867. luaL_checktype(L, 4, LUA_TNUMBER);
  4868. Number z = lua_tonumber(L, 4);
  4869. luaL_checktype(L, 5, LUA_TNUMBER);
  4870. Number degrees = lua_tonumber(L, 5);
  4871. inst->createFromAxisAngle(x, y, z, degrees);
  4872. return 0;
  4873. }
  4874. static int Polycore_Quaternion_createMatrix(lua_State *L) {
  4875. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  4876. Quaternion *inst = (Quaternion*)lua_topointer(L, 1);
  4877. Matrix4 *retInst = new Matrix4();
  4878. *retInst = inst->createMatrix();
  4879. lua_pushlightuserdata(L, retInst);
  4880. return 1;
  4881. }
  4882. static int Polycore_delete_Quaternion(lua_State *L) {
  4883. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  4884. Quaternion *inst = (Quaternion*)lua_topointer(L, 1);
  4885. delete inst;
  4886. return 0;
  4887. }
  4888. static int Polycore_QuaternionCurve(lua_State *L) {
  4889. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  4890. BezierCurve * wCurve = (BezierCurve *)lua_topointer(L, 1);
  4891. luaL_checktype(L, 2, LUA_TLIGHTUSERDATA);
  4892. BezierCurve * xCurve = (BezierCurve *)lua_topointer(L, 2);
  4893. luaL_checktype(L, 3, LUA_TLIGHTUSERDATA);
  4894. BezierCurve * yCurve = (BezierCurve *)lua_topointer(L, 3);
  4895. luaL_checktype(L, 4, LUA_TLIGHTUSERDATA);
  4896. BezierCurve * zCurve = (BezierCurve *)lua_topointer(L, 4);
  4897. QuaternionCurve *inst = new QuaternionCurve(wCurve, xCurve, yCurve, zCurve);
  4898. lua_pushlightuserdata(L, (void*)inst);
  4899. return 1;
  4900. }
  4901. static int Polycore_QuaternionCurve_interpolate(lua_State *L) {
  4902. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  4903. QuaternionCurve *inst = (QuaternionCurve*)lua_topointer(L, 1);
  4904. luaL_checktype(L, 2, LUA_TNUMBER);
  4905. Number t = lua_tonumber(L, 2);
  4906. luaL_checktype(L, 3, LUA_TBOOLEAN);
  4907. bool useShortestPath = lua_toboolean(L, 3);
  4908. Quaternion *retInst = new Quaternion();
  4909. *retInst = inst->interpolate(t, useShortestPath);
  4910. lua_pushlightuserdata(L, retInst);
  4911. return 1;
  4912. }
  4913. static int Polycore_QuaternionCurve_generatePointsFromCurves(lua_State *L) {
  4914. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  4915. QuaternionCurve *inst = (QuaternionCurve*)lua_topointer(L, 1);
  4916. luaL_checktype(L, 2, LUA_TLIGHTUSERDATA);
  4917. BezierCurve * wCurve = (BezierCurve *)lua_topointer(L, 2);
  4918. luaL_checktype(L, 3, LUA_TLIGHTUSERDATA);
  4919. BezierCurve * xCurve = (BezierCurve *)lua_topointer(L, 3);
  4920. luaL_checktype(L, 4, LUA_TLIGHTUSERDATA);
  4921. BezierCurve * yCurve = (BezierCurve *)lua_topointer(L, 4);
  4922. luaL_checktype(L, 5, LUA_TLIGHTUSERDATA);
  4923. BezierCurve * zCurve = (BezierCurve *)lua_topointer(L, 5);
  4924. inst->generatePointsFromCurves(wCurve, xCurve, yCurve, zCurve);
  4925. return 0;
  4926. }
  4927. static int Polycore_QuaternionCurve_recalcTangents(lua_State *L) {
  4928. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  4929. QuaternionCurve *inst = (QuaternionCurve*)lua_topointer(L, 1);
  4930. inst->recalcTangents();
  4931. return 0;
  4932. }
  4933. static int Polycore_delete_QuaternionCurve(lua_State *L) {
  4934. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  4935. QuaternionCurve *inst = (QuaternionCurve*)lua_topointer(L, 1);
  4936. delete inst;
  4937. return 0;
  4938. }
  4939. static int Polycore_Rectangle_get_x(lua_State *L) {
  4940. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  4941. Polycode::Rectangle *inst = (Polycode::Rectangle*)lua_topointer(L, 1);
  4942. lua_pushnumber(L, inst->x);
  4943. return 1;
  4944. }
  4945. static int Polycore_Rectangle_get_y(lua_State *L) {
  4946. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  4947. Polycode::Rectangle *inst = (Polycode::Rectangle*)lua_topointer(L, 1);
  4948. lua_pushnumber(L, inst->y);
  4949. return 1;
  4950. }
  4951. static int Polycore_Rectangle_get_w(lua_State *L) {
  4952. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  4953. Polycode::Rectangle *inst = (Polycode::Rectangle*)lua_topointer(L, 1);
  4954. lua_pushnumber(L, inst->w);
  4955. return 1;
  4956. }
  4957. static int Polycore_Rectangle_get_h(lua_State *L) {
  4958. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  4959. Polycode::Rectangle *inst = (Polycode::Rectangle*)lua_topointer(L, 1);
  4960. lua_pushnumber(L, inst->h);
  4961. return 1;
  4962. }
  4963. static int Polycore_Rectangle_set_x(lua_State *L) {
  4964. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  4965. Polycode::Rectangle *inst = (Polycode::Rectangle*)lua_topointer(L, 1);
  4966. Number param = lua_tonumber(L, 2);
  4967. inst->x = param;
  4968. return 0;
  4969. }
  4970. static int Polycore_Rectangle_set_y(lua_State *L) {
  4971. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  4972. Polycode::Rectangle *inst = (Polycode::Rectangle*)lua_topointer(L, 1);
  4973. Number param = lua_tonumber(L, 2);
  4974. inst->y = param;
  4975. return 0;
  4976. }
  4977. static int Polycore_Rectangle_set_w(lua_State *L) {
  4978. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  4979. Polycode::Rectangle *inst = (Polycode::Rectangle*)lua_topointer(L, 1);
  4980. Number param = lua_tonumber(L, 2);
  4981. inst->w = param;
  4982. return 0;
  4983. }
  4984. static int Polycore_Rectangle_set_h(lua_State *L) {
  4985. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  4986. Polycode::Rectangle *inst = (Polycode::Rectangle*)lua_topointer(L, 1);
  4987. Number param = lua_tonumber(L, 2);
  4988. inst->h = param;
  4989. return 0;
  4990. }
  4991. static int Polycore_Rectangle(lua_State *L) {
  4992. Polycode::Rectangle *inst = new Polycode::Rectangle();
  4993. lua_pushlightuserdata(L, (void*)inst);
  4994. return 1;
  4995. }
  4996. static int Polycore_Rectangle_setRect(lua_State *L) {
  4997. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  4998. Polycode::Rectangle *inst = (Polycode::Rectangle*)lua_topointer(L, 1);
  4999. luaL_checktype(L, 2, LUA_TNUMBER);
  5000. Number x = lua_tonumber(L, 2);
  5001. luaL_checktype(L, 3, LUA_TNUMBER);
  5002. Number y = lua_tonumber(L, 3);
  5003. luaL_checktype(L, 4, LUA_TNUMBER);
  5004. Number w = lua_tonumber(L, 4);
  5005. luaL_checktype(L, 5, LUA_TNUMBER);
  5006. Number h = lua_tonumber(L, 5);
  5007. inst->setRect(x, y, w, h);
  5008. return 0;
  5009. }
  5010. static int Polycore_delete_Rectangle(lua_State *L) {
  5011. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  5012. Polycode::Rectangle *inst = (Polycode::Rectangle*)lua_topointer(L, 1);
  5013. delete inst;
  5014. return 0;
  5015. }
  5016. static int Polycore_Renderer_get_ambientColor(lua_State *L) {
  5017. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  5018. Renderer *inst = (Renderer*)lua_topointer(L, 1);
  5019. lua_pushlightuserdata(L, &inst->ambientColor);
  5020. return 1;
  5021. }
  5022. static int Polycore_Renderer_get_clearColor(lua_State *L) {
  5023. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  5024. Renderer *inst = (Renderer*)lua_topointer(L, 1);
  5025. lua_pushlightuserdata(L, &inst->clearColor);
  5026. return 1;
  5027. }
  5028. static int Polycore_Renderer_get_exposureLevel(lua_State *L) {
  5029. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  5030. Renderer *inst = (Renderer*)lua_topointer(L, 1);
  5031. lua_pushnumber(L, inst->exposureLevel);
  5032. return 1;
  5033. }
  5034. static int Polycore_Renderer_get_cameraPosition(lua_State *L) {
  5035. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  5036. Renderer *inst = (Renderer*)lua_topointer(L, 1);
  5037. lua_pushlightuserdata(L, &inst->cameraPosition);
  5038. return 1;
  5039. }
  5040. static int Polycore_Renderer_set_exposureLevel(lua_State *L) {
  5041. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  5042. Renderer *inst = (Renderer*)lua_topointer(L, 1);
  5043. Number param = lua_tonumber(L, 2);
  5044. inst->exposureLevel = param;
  5045. return 0;
  5046. }
  5047. static int Polycore_Renderer_Resize(lua_State *L) {
  5048. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  5049. Renderer *inst = (Renderer*)lua_topointer(L, 1);
  5050. luaL_checktype(L, 2, LUA_TNUMBER);
  5051. int xRes = lua_tointeger(L, 2);
  5052. luaL_checktype(L, 3, LUA_TNUMBER);
  5053. int yRes = lua_tointeger(L, 3);
  5054. inst->Resize(xRes, yRes);
  5055. return 0;
  5056. }
  5057. static int Polycore_Renderer_BeginRender(lua_State *L) {
  5058. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  5059. Renderer *inst = (Renderer*)lua_topointer(L, 1);
  5060. inst->BeginRender();
  5061. return 0;
  5062. }
  5063. static int Polycore_Renderer_EndRender(lua_State *L) {
  5064. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  5065. Renderer *inst = (Renderer*)lua_topointer(L, 1);
  5066. inst->EndRender();
  5067. return 0;
  5068. }
  5069. static int Polycore_Renderer_createCubemap(lua_State *L) {
  5070. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  5071. Renderer *inst = (Renderer*)lua_topointer(L, 1);
  5072. luaL_checktype(L, 2, LUA_TLIGHTUSERDATA);
  5073. Texture * t0 = (Texture *)lua_topointer(L, 2);
  5074. luaL_checktype(L, 3, LUA_TLIGHTUSERDATA);
  5075. Texture * t1 = (Texture *)lua_topointer(L, 3);
  5076. luaL_checktype(L, 4, LUA_TLIGHTUSERDATA);
  5077. Texture * t2 = (Texture *)lua_topointer(L, 4);
  5078. luaL_checktype(L, 5, LUA_TLIGHTUSERDATA);
  5079. Texture * t3 = (Texture *)lua_topointer(L, 5);
  5080. luaL_checktype(L, 6, LUA_TLIGHTUSERDATA);
  5081. Texture * t4 = (Texture *)lua_topointer(L, 6);
  5082. luaL_checktype(L, 7, LUA_TLIGHTUSERDATA);
  5083. Texture * t5 = (Texture *)lua_topointer(L, 7);
  5084. void *ptrRetVal = (void*)inst->createCubemap(t0, t1, t2, t3, t4, t5);
  5085. if(ptrRetVal == NULL) {
  5086. lua_pushnil(L);
  5087. } else {
  5088. lua_pushlightuserdata(L, ptrRetVal);
  5089. }
  5090. return 1;
  5091. }
  5092. static int Polycore_Renderer_createTexture(lua_State *L) {
  5093. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  5094. Renderer *inst = (Renderer*)lua_topointer(L, 1);
  5095. luaL_checktype(L, 2, LUA_TNUMBER);
  5096. unsigned int width = lua_tointeger(L, 2);
  5097. luaL_checktype(L, 3, LUA_TNUMBER);
  5098. unsigned int height = lua_tointeger(L, 3);
  5099. luaL_checktype(L, 4, LUA_TLIGHTUSERDATA);
  5100. char * textureData = (char *)lua_topointer(L, 4);
  5101. luaL_checktype(L, 5, LUA_TBOOLEAN);
  5102. bool clamp = lua_toboolean(L, 5);
  5103. int type;
  5104. if(lua_isnumber(L, 6)) {
  5105. type = lua_tointeger(L, 6);
  5106. } else {
  5107. type = Image :: IMAGE_RGBA;
  5108. }
  5109. void *ptrRetVal = (void*)inst->createTexture(width, height, textureData, clamp, type);
  5110. if(ptrRetVal == NULL) {
  5111. lua_pushnil(L);
  5112. } else {
  5113. lua_pushlightuserdata(L, ptrRetVal);
  5114. }
  5115. return 1;
  5116. }
  5117. static int Polycore_Renderer_createRenderTextures(lua_State *L) {
  5118. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  5119. Renderer *inst = (Renderer*)lua_topointer(L, 1);
  5120. luaL_checktype(L, 2, LUA_TLIGHTUSERDATA);
  5121. Texture * * colorBuffer = (Texture * *)lua_topointer(L, 2);
  5122. luaL_checktype(L, 3, LUA_TLIGHTUSERDATA);
  5123. Texture * * depthBuffer = (Texture * *)lua_topointer(L, 3);
  5124. luaL_checktype(L, 4, LUA_TNUMBER);
  5125. int width = lua_tointeger(L, 4);
  5126. luaL_checktype(L, 5, LUA_TNUMBER);
  5127. int height = lua_tointeger(L, 5);
  5128. inst->createRenderTextures(colorBuffer, depthBuffer, width, height);
  5129. return 0;
  5130. }
  5131. static int Polycore_Renderer_createFramebufferTexture(lua_State *L) {
  5132. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  5133. Renderer *inst = (Renderer*)lua_topointer(L, 1);
  5134. luaL_checktype(L, 2, LUA_TNUMBER);
  5135. unsigned int width = lua_tointeger(L, 2);
  5136. luaL_checktype(L, 3, LUA_TNUMBER);
  5137. unsigned int height = lua_tointeger(L, 3);
  5138. void *ptrRetVal = (void*)inst->createFramebufferTexture(width, height);
  5139. if(ptrRetVal == NULL) {
  5140. lua_pushnil(L);
  5141. } else {
  5142. lua_pushlightuserdata(L, ptrRetVal);
  5143. }
  5144. return 1;
  5145. }
  5146. static int Polycore_Renderer_bindFrameBufferTexture(lua_State *L) {
  5147. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  5148. Renderer *inst = (Renderer*)lua_topointer(L, 1);
  5149. luaL_checktype(L, 2, LUA_TLIGHTUSERDATA);
  5150. Texture * texture = (Texture *)lua_topointer(L, 2);
  5151. inst->bindFrameBufferTexture(texture);
  5152. return 0;
  5153. }
  5154. static int Polycore_Renderer_unbindFramebuffers(lua_State *L) {
  5155. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  5156. Renderer *inst = (Renderer*)lua_topointer(L, 1);
  5157. inst->unbindFramebuffers();
  5158. return 0;
  5159. }
  5160. static int Polycore_Renderer_renderToTexture(lua_State *L) {
  5161. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  5162. Renderer *inst = (Renderer*)lua_topointer(L, 1);
  5163. luaL_checktype(L, 2, LUA_TLIGHTUSERDATA);
  5164. Texture * targetTexture = (Texture *)lua_topointer(L, 2);
  5165. inst->renderToTexture(targetTexture);
  5166. return 0;
  5167. }
  5168. static int Polycore_Renderer_renderZBufferToTexture(lua_State *L) {
  5169. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  5170. Renderer *inst = (Renderer*)lua_topointer(L, 1);
  5171. luaL_checktype(L, 2, LUA_TLIGHTUSERDATA);
  5172. Texture * targetTexture = (Texture *)lua_topointer(L, 2);
  5173. inst->renderZBufferToTexture(targetTexture);
  5174. return 0;
  5175. }
  5176. static int Polycore_Renderer_setViewportSize(lua_State *L) {
  5177. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  5178. Renderer *inst = (Renderer*)lua_topointer(L, 1);
  5179. luaL_checktype(L, 2, LUA_TNUMBER);
  5180. int w = lua_tointeger(L, 2);
  5181. luaL_checktype(L, 3, LUA_TNUMBER);
  5182. int h = lua_tointeger(L, 3);
  5183. Number fov;
  5184. if(lua_isnumber(L, 4)) {
  5185. fov = lua_tonumber(L, 4);
  5186. } else {
  5187. fov = 45.0f;
  5188. }
  5189. inst->setViewportSize(w, h, fov);
  5190. return 0;
  5191. }
  5192. static int Polycore_Renderer_loadIdentity(lua_State *L) {
  5193. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  5194. Renderer *inst = (Renderer*)lua_topointer(L, 1);
  5195. inst->loadIdentity();
  5196. return 0;
  5197. }
  5198. static int Polycore_Renderer_setOrthoMode(lua_State *L) {
  5199. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  5200. Renderer *inst = (Renderer*)lua_topointer(L, 1);
  5201. Number xSize;
  5202. if(lua_isnumber(L, 2)) {
  5203. xSize = lua_tonumber(L, 2);
  5204. } else {
  5205. xSize = 0.0f;
  5206. }
  5207. Number ySize;
  5208. if(lua_isnumber(L, 3)) {
  5209. ySize = lua_tonumber(L, 3);
  5210. } else {
  5211. ySize = 0.0f;
  5212. }
  5213. inst->setOrthoMode(xSize, ySize);
  5214. return 0;
  5215. }
  5216. static int Polycore_Renderer__setOrthoMode(lua_State *L) {
  5217. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  5218. Renderer *inst = (Renderer*)lua_topointer(L, 1);
  5219. inst->_setOrthoMode();
  5220. return 0;
  5221. }
  5222. static int Polycore_Renderer_setPerspectiveMode(lua_State *L) {
  5223. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  5224. Renderer *inst = (Renderer*)lua_topointer(L, 1);
  5225. inst->setPerspectiveMode();
  5226. return 0;
  5227. }
  5228. static int Polycore_Renderer_setTexture(lua_State *L) {
  5229. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  5230. Renderer *inst = (Renderer*)lua_topointer(L, 1);
  5231. luaL_checktype(L, 2, LUA_TLIGHTUSERDATA);
  5232. Texture * texture = (Texture *)lua_topointer(L, 2);
  5233. inst->setTexture(texture);
  5234. return 0;
  5235. }
  5236. static int Polycore_Renderer_enableBackfaceCulling(lua_State *L) {
  5237. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  5238. Renderer *inst = (Renderer*)lua_topointer(L, 1);
  5239. luaL_checktype(L, 2, LUA_TBOOLEAN);
  5240. bool val = lua_toboolean(L, 2);
  5241. inst->enableBackfaceCulling(val);
  5242. return 0;
  5243. }
  5244. static int Polycore_Renderer_setClearColor(lua_State *L) {
  5245. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  5246. Renderer *inst = (Renderer*)lua_topointer(L, 1);
  5247. luaL_checktype(L, 2, LUA_TNUMBER);
  5248. Number r = lua_tonumber(L, 2);
  5249. luaL_checktype(L, 3, LUA_TNUMBER);
  5250. Number g = lua_tonumber(L, 3);
  5251. luaL_checktype(L, 4, LUA_TNUMBER);
  5252. Number b = lua_tonumber(L, 4);
  5253. inst->setClearColor(r, g, b);
  5254. return 0;
  5255. }
  5256. static int Polycore_Renderer_setAmbientColor(lua_State *L) {
  5257. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  5258. Renderer *inst = (Renderer*)lua_topointer(L, 1);
  5259. luaL_checktype(L, 2, LUA_TNUMBER);
  5260. Number r = lua_tonumber(L, 2);
  5261. luaL_checktype(L, 3, LUA_TNUMBER);
  5262. Number g = lua_tonumber(L, 3);
  5263. luaL_checktype(L, 4, LUA_TNUMBER);
  5264. Number b = lua_tonumber(L, 4);
  5265. inst->setAmbientColor(r, g, b);
  5266. return 0;
  5267. }
  5268. static int Polycore_Renderer_clearScreen(lua_State *L) {
  5269. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  5270. Renderer *inst = (Renderer*)lua_topointer(L, 1);
  5271. inst->clearScreen();
  5272. return 0;
  5273. }
  5274. static int Polycore_Renderer_translate2D(lua_State *L) {
  5275. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  5276. Renderer *inst = (Renderer*)lua_topointer(L, 1);
  5277. luaL_checktype(L, 2, LUA_TNUMBER);
  5278. Number x = lua_tonumber(L, 2);
  5279. luaL_checktype(L, 3, LUA_TNUMBER);
  5280. Number y = lua_tonumber(L, 3);
  5281. inst->translate2D(x, y);
  5282. return 0;
  5283. }
  5284. static int Polycore_Renderer_rotate2D(lua_State *L) {
  5285. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  5286. Renderer *inst = (Renderer*)lua_topointer(L, 1);
  5287. luaL_checktype(L, 2, LUA_TNUMBER);
  5288. Number angle = lua_tonumber(L, 2);
  5289. inst->rotate2D(angle);
  5290. return 0;
  5291. }
  5292. static int Polycore_Renderer_scale2D(lua_State *L) {
  5293. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  5294. Renderer *inst = (Renderer*)lua_topointer(L, 1);
  5295. luaL_checktype(L, 2, LUA_TLIGHTUSERDATA);
  5296. Vector2 * scale = (Vector2 *)lua_topointer(L, 2);
  5297. inst->scale2D(scale);
  5298. return 0;
  5299. }
  5300. static int Polycore_Renderer_setFOV(lua_State *L) {
  5301. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  5302. Renderer *inst = (Renderer*)lua_topointer(L, 1);
  5303. luaL_checktype(L, 2, LUA_TNUMBER);
  5304. Number fov = lua_tonumber(L, 2);
  5305. inst->setFOV(fov);
  5306. return 0;
  5307. }
  5308. static int Polycore_Renderer_setVertexColor(lua_State *L) {
  5309. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  5310. Renderer *inst = (Renderer*)lua_topointer(L, 1);
  5311. luaL_checktype(L, 2, LUA_TNUMBER);
  5312. Number r = lua_tonumber(L, 2);
  5313. luaL_checktype(L, 3, LUA_TNUMBER);
  5314. Number g = lua_tonumber(L, 3);
  5315. luaL_checktype(L, 4, LUA_TNUMBER);
  5316. Number b = lua_tonumber(L, 4);
  5317. luaL_checktype(L, 5, LUA_TNUMBER);
  5318. Number a = lua_tonumber(L, 5);
  5319. inst->setVertexColor(r, g, b, a);
  5320. return 0;
  5321. }
  5322. static int Polycore_Renderer_pushDataArrayForMesh(lua_State *L) {
  5323. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  5324. Renderer *inst = (Renderer*)lua_topointer(L, 1);
  5325. luaL_checktype(L, 2, LUA_TLIGHTUSERDATA);
  5326. Mesh * mesh = (Mesh *)lua_topointer(L, 2);
  5327. luaL_checktype(L, 3, LUA_TNUMBER);
  5328. int arrayType = lua_tointeger(L, 3);
  5329. inst->pushDataArrayForMesh(mesh, arrayType);
  5330. return 0;
  5331. }
  5332. static int Polycore_Renderer_pushRenderDataArray(lua_State *L) {
  5333. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  5334. Renderer *inst = (Renderer*)lua_topointer(L, 1);
  5335. luaL_checktype(L, 2, LUA_TLIGHTUSERDATA);
  5336. RenderDataArray * array = (RenderDataArray *)lua_topointer(L, 2);
  5337. inst->pushRenderDataArray(array);
  5338. return 0;
  5339. }
  5340. static int Polycore_Renderer_createRenderDataArrayForMesh(lua_State *L) {
  5341. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  5342. Renderer *inst = (Renderer*)lua_topointer(L, 1);
  5343. luaL_checktype(L, 2, LUA_TLIGHTUSERDATA);
  5344. Mesh * mesh = (Mesh *)lua_topointer(L, 2);
  5345. luaL_checktype(L, 3, LUA_TNUMBER);
  5346. int arrayType = lua_tointeger(L, 3);
  5347. void *ptrRetVal = (void*)inst->createRenderDataArrayForMesh(mesh, arrayType);
  5348. if(ptrRetVal == NULL) {
  5349. lua_pushnil(L);
  5350. } else {
  5351. lua_pushlightuserdata(L, ptrRetVal);
  5352. }
  5353. return 1;
  5354. }
  5355. static int Polycore_Renderer_createRenderDataArray(lua_State *L) {
  5356. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  5357. Renderer *inst = (Renderer*)lua_topointer(L, 1);
  5358. luaL_checktype(L, 2, LUA_TNUMBER);
  5359. int arrayType = lua_tointeger(L, 2);
  5360. void *ptrRetVal = (void*)inst->createRenderDataArray(arrayType);
  5361. if(ptrRetVal == NULL) {
  5362. lua_pushnil(L);
  5363. } else {
  5364. lua_pushlightuserdata(L, ptrRetVal);
  5365. }
  5366. return 1;
  5367. }
  5368. static int Polycore_Renderer_setRenderArrayData(lua_State *L) {
  5369. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  5370. Renderer *inst = (Renderer*)lua_topointer(L, 1);
  5371. luaL_checktype(L, 2, LUA_TLIGHTUSERDATA);
  5372. RenderDataArray * array = (RenderDataArray *)lua_topointer(L, 2);
  5373. luaL_checktype(L, 3, LUA_TLIGHTUSERDATA);
  5374. Number * arrayData = (Number *)lua_topointer(L, 3);
  5375. inst->setRenderArrayData(array, arrayData);
  5376. return 0;
  5377. }
  5378. static int Polycore_Renderer_drawArrays(lua_State *L) {
  5379. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  5380. Renderer *inst = (Renderer*)lua_topointer(L, 1);
  5381. luaL_checktype(L, 2, LUA_TNUMBER);
  5382. int drawType = lua_tointeger(L, 2);
  5383. inst->drawArrays(drawType);
  5384. return 0;
  5385. }
  5386. static int Polycore_Renderer_translate3D(lua_State *L) {
  5387. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  5388. Renderer *inst = (Renderer*)lua_topointer(L, 1);
  5389. luaL_checktype(L, 2, LUA_TLIGHTUSERDATA);
  5390. Vector3 * position = (Vector3 *)lua_topointer(L, 2);
  5391. inst->translate3D(position);
  5392. return 0;
  5393. }
  5394. static int Polycore_Renderer_scale3D(lua_State *L) {
  5395. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  5396. Renderer *inst = (Renderer*)lua_topointer(L, 1);
  5397. luaL_checktype(L, 2, LUA_TLIGHTUSERDATA);
  5398. Vector3 * scale = (Vector3 *)lua_topointer(L, 2);
  5399. inst->scale3D(scale);
  5400. return 0;
  5401. }
  5402. static int Polycore_Renderer_pushMatrix(lua_State *L) {
  5403. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  5404. Renderer *inst = (Renderer*)lua_topointer(L, 1);
  5405. inst->pushMatrix();
  5406. return 0;
  5407. }
  5408. static int Polycore_Renderer_popMatrix(lua_State *L) {
  5409. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  5410. Renderer *inst = (Renderer*)lua_topointer(L, 1);
  5411. inst->popMatrix();
  5412. return 0;
  5413. }
  5414. static int Polycore_Renderer_setLineSmooth(lua_State *L) {
  5415. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  5416. Renderer *inst = (Renderer*)lua_topointer(L, 1);
  5417. luaL_checktype(L, 2, LUA_TBOOLEAN);
  5418. bool val = lua_toboolean(L, 2);
  5419. inst->setLineSmooth(val);
  5420. return 0;
  5421. }
  5422. static int Polycore_Renderer_setLineSize(lua_State *L) {
  5423. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  5424. Renderer *inst = (Renderer*)lua_topointer(L, 1);
  5425. luaL_checktype(L, 2, LUA_TNUMBER);
  5426. Number lineSize = lua_tonumber(L, 2);
  5427. inst->setLineSize(lineSize);
  5428. return 0;
  5429. }
  5430. static int Polycore_Renderer_enableLighting(lua_State *L) {
  5431. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  5432. Renderer *inst = (Renderer*)lua_topointer(L, 1);
  5433. luaL_checktype(L, 2, LUA_TBOOLEAN);
  5434. bool enable = lua_toboolean(L, 2);
  5435. inst->enableLighting(enable);
  5436. return 0;
  5437. }
  5438. static int Polycore_Renderer_enableFog(lua_State *L) {
  5439. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  5440. Renderer *inst = (Renderer*)lua_topointer(L, 1);
  5441. luaL_checktype(L, 2, LUA_TBOOLEAN);
  5442. bool enable = lua_toboolean(L, 2);
  5443. inst->enableFog(enable);
  5444. return 0;
  5445. }
  5446. static int Polycore_Renderer_setFogProperties(lua_State *L) {
  5447. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  5448. Renderer *inst = (Renderer*)lua_topointer(L, 1);
  5449. luaL_checktype(L, 2, LUA_TNUMBER);
  5450. int fogMode = lua_tointeger(L, 2);
  5451. luaL_checktype(L, 3, LUA_TLIGHTUSERDATA);
  5452. Color color = *(Color*)lua_topointer(L, 3);
  5453. luaL_checktype(L, 4, LUA_TNUMBER);
  5454. Number density = lua_tonumber(L, 4);
  5455. luaL_checktype(L, 5, LUA_TNUMBER);
  5456. Number startDepth = lua_tonumber(L, 5);
  5457. luaL_checktype(L, 6, LUA_TNUMBER);
  5458. Number _endDepth = lua_tonumber(L, 6);
  5459. inst->setFogProperties(fogMode, color, density, startDepth, _endDepth);
  5460. return 0;
  5461. }
  5462. static int Polycore_Renderer_multModelviewMatrix(lua_State *L) {
  5463. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  5464. Renderer *inst = (Renderer*)lua_topointer(L, 1);
  5465. luaL_checktype(L, 2, LUA_TLIGHTUSERDATA);
  5466. Matrix4 m = *(Matrix4*)lua_topointer(L, 2);
  5467. inst->multModelviewMatrix(m);
  5468. return 0;
  5469. }
  5470. static int Polycore_Renderer_setModelviewMatrix(lua_State *L) {
  5471. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  5472. Renderer *inst = (Renderer*)lua_topointer(L, 1);
  5473. luaL_checktype(L, 2, LUA_TLIGHTUSERDATA);
  5474. Matrix4 m = *(Matrix4*)lua_topointer(L, 2);
  5475. inst->setModelviewMatrix(m);
  5476. return 0;
  5477. }
  5478. static int Polycore_Renderer_setBlendingMode(lua_State *L) {
  5479. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  5480. Renderer *inst = (Renderer*)lua_topointer(L, 1);
  5481. luaL_checktype(L, 2, LUA_TNUMBER);
  5482. int bl_endingMode = lua_tointeger(L, 2);
  5483. inst->setBlendingMode(bl_endingMode);
  5484. return 0;
  5485. }
  5486. static int Polycore_Renderer_applyMaterial(lua_State *L) {
  5487. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  5488. Renderer *inst = (Renderer*)lua_topointer(L, 1);
  5489. luaL_checktype(L, 2, LUA_TLIGHTUSERDATA);
  5490. Material * material = (Material *)lua_topointer(L, 2);
  5491. luaL_checktype(L, 3, LUA_TLIGHTUSERDATA);
  5492. ShaderBinding * localOptions = (ShaderBinding *)lua_topointer(L, 3);
  5493. luaL_checktype(L, 4, LUA_TNUMBER);
  5494. unsigned int shaderIndex = lua_tointeger(L, 4);
  5495. inst->applyMaterial(material, localOptions, shaderIndex);
  5496. return 0;
  5497. }
  5498. static int Polycore_Renderer_clearShader(lua_State *L) {
  5499. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  5500. Renderer *inst = (Renderer*)lua_topointer(L, 1);
  5501. inst->clearShader();
  5502. return 0;
  5503. }
  5504. static int Polycore_Renderer_setDepthFunction(lua_State *L) {
  5505. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  5506. Renderer *inst = (Renderer*)lua_topointer(L, 1);
  5507. luaL_checktype(L, 2, LUA_TNUMBER);
  5508. int depthFunction = lua_tointeger(L, 2);
  5509. inst->setDepthFunction(depthFunction);
  5510. return 0;
  5511. }
  5512. static int Polycore_Renderer_createVertexBufferForMesh(lua_State *L) {
  5513. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  5514. Renderer *inst = (Renderer*)lua_topointer(L, 1);
  5515. luaL_checktype(L, 2, LUA_TLIGHTUSERDATA);
  5516. Mesh * mesh = (Mesh *)lua_topointer(L, 2);
  5517. inst->createVertexBufferForMesh(mesh);
  5518. return 0;
  5519. }
  5520. static int Polycore_Renderer_drawVertexBuffer(lua_State *L) {
  5521. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  5522. Renderer *inst = (Renderer*)lua_topointer(L, 1);
  5523. luaL_checktype(L, 2, LUA_TLIGHTUSERDATA);
  5524. VertexBuffer * buffer = (VertexBuffer *)lua_topointer(L, 2);
  5525. inst->drawVertexBuffer(buffer);
  5526. return 0;
  5527. }
  5528. static int Polycore_Renderer_setRenderMode(lua_State *L) {
  5529. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  5530. Renderer *inst = (Renderer*)lua_topointer(L, 1);
  5531. luaL_checktype(L, 2, LUA_TNUMBER);
  5532. int newR_enderMode = lua_tointeger(L, 2);
  5533. inst->setRenderMode(newR_enderMode);
  5534. return 0;
  5535. }
  5536. static int Polycore_Renderer_getRenderMode(lua_State *L) {
  5537. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  5538. Renderer *inst = (Renderer*)lua_topointer(L, 1);
  5539. lua_pushinteger(L, inst->getRenderMode());
  5540. return 1;
  5541. }
  5542. static int Polycore_Renderer_enableDepthTest(lua_State *L) {
  5543. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  5544. Renderer *inst = (Renderer*)lua_topointer(L, 1);
  5545. luaL_checktype(L, 2, LUA_TBOOLEAN);
  5546. bool val = lua_toboolean(L, 2);
  5547. inst->enableDepthTest(val);
  5548. return 0;
  5549. }
  5550. static int Polycore_Renderer_enableDepthWrite(lua_State *L) {
  5551. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  5552. Renderer *inst = (Renderer*)lua_topointer(L, 1);
  5553. luaL_checktype(L, 2, LUA_TBOOLEAN);
  5554. bool val = lua_toboolean(L, 2);
  5555. inst->enableDepthWrite(val);
  5556. return 0;
  5557. }
  5558. static int Polycore_Renderer_billboardMatrix(lua_State *L) {
  5559. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  5560. Renderer *inst = (Renderer*)lua_topointer(L, 1);
  5561. inst->billboardMatrix();
  5562. return 0;
  5563. }
  5564. static int Polycore_Renderer_billboardMatrixWithScale(lua_State *L) {
  5565. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  5566. Renderer *inst = (Renderer*)lua_topointer(L, 1);
  5567. luaL_checktype(L, 2, LUA_TLIGHTUSERDATA);
  5568. Vector3 scale = *(Vector3*)lua_topointer(L, 2);
  5569. inst->billboardMatrixWithScale(scale);
  5570. return 0;
  5571. }
  5572. static int Polycore_Renderer_setTextureFilteringMode(lua_State *L) {
  5573. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  5574. Renderer *inst = (Renderer*)lua_topointer(L, 1);
  5575. luaL_checktype(L, 2, LUA_TNUMBER);
  5576. int mode = lua_tointeger(L, 2);
  5577. inst->setTextureFilteringMode(mode);
  5578. return 0;
  5579. }
  5580. static int Polycore_Renderer_enableAlphaTest(lua_State *L) {
  5581. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  5582. Renderer *inst = (Renderer*)lua_topointer(L, 1);
  5583. luaL_checktype(L, 2, LUA_TBOOLEAN);
  5584. bool val = lua_toboolean(L, 2);
  5585. inst->enableAlphaTest(val);
  5586. return 0;
  5587. }
  5588. static int Polycore_Renderer_clearBuffer(lua_State *L) {
  5589. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  5590. Renderer *inst = (Renderer*)lua_topointer(L, 1);
  5591. luaL_checktype(L, 2, LUA_TBOOLEAN);
  5592. bool colorBuffer = lua_toboolean(L, 2);
  5593. luaL_checktype(L, 3, LUA_TBOOLEAN);
  5594. bool depthBuffer = lua_toboolean(L, 3);
  5595. inst->clearBuffer(colorBuffer, depthBuffer);
  5596. return 0;
  5597. }
  5598. static int Polycore_Renderer_drawToColorBuffer(lua_State *L) {
  5599. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  5600. Renderer *inst = (Renderer*)lua_topointer(L, 1);
  5601. luaL_checktype(L, 2, LUA_TBOOLEAN);
  5602. bool val = lua_toboolean(L, 2);
  5603. inst->drawToColorBuffer(val);
  5604. return 0;
  5605. }
  5606. static int Polycore_Renderer_getCameraMatrix(lua_State *L) {
  5607. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  5608. Renderer *inst = (Renderer*)lua_topointer(L, 1);
  5609. Matrix4 *retInst = new Matrix4();
  5610. *retInst = inst->getCameraMatrix();
  5611. lua_pushlightuserdata(L, retInst);
  5612. return 1;
  5613. }
  5614. static int Polycore_Renderer_setCameraMatrix(lua_State *L) {
  5615. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  5616. Renderer *inst = (Renderer*)lua_topointer(L, 1);
  5617. luaL_checktype(L, 2, LUA_TLIGHTUSERDATA);
  5618. Matrix4 matrix = *(Matrix4*)lua_topointer(L, 2);
  5619. inst->setCameraMatrix(matrix);
  5620. return 0;
  5621. }
  5622. static int Polycore_Renderer_setCameraPosition(lua_State *L) {
  5623. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  5624. Renderer *inst = (Renderer*)lua_topointer(L, 1);
  5625. luaL_checktype(L, 2, LUA_TLIGHTUSERDATA);
  5626. Vector3 pos = *(Vector3*)lua_topointer(L, 2);
  5627. inst->setCameraPosition(pos);
  5628. return 0;
  5629. }
  5630. static int Polycore_Renderer_drawScreenQuad(lua_State *L) {
  5631. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  5632. Renderer *inst = (Renderer*)lua_topointer(L, 1);
  5633. luaL_checktype(L, 2, LUA_TNUMBER);
  5634. Number qx = lua_tonumber(L, 2);
  5635. luaL_checktype(L, 3, LUA_TNUMBER);
  5636. Number qy = lua_tonumber(L, 3);
  5637. inst->drawScreenQuad(qx, qy);
  5638. return 0;
  5639. }
  5640. static int Polycore_Renderer_getXRes(lua_State *L) {
  5641. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  5642. Renderer *inst = (Renderer*)lua_topointer(L, 1);
  5643. lua_pushinteger(L, inst->getXRes());
  5644. return 1;
  5645. }
  5646. static int Polycore_Renderer_getYRes(lua_State *L) {
  5647. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  5648. Renderer *inst = (Renderer*)lua_topointer(L, 1);
  5649. lua_pushinteger(L, inst->getYRes());
  5650. return 1;
  5651. }
  5652. static int Polycore_Renderer_cullFrontFaces(lua_State *L) {
  5653. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  5654. Renderer *inst = (Renderer*)lua_topointer(L, 1);
  5655. luaL_checktype(L, 2, LUA_TBOOLEAN);
  5656. bool val = lua_toboolean(L, 2);
  5657. inst->cullFrontFaces(val);
  5658. return 0;
  5659. }
  5660. static int Polycore_Renderer_clearLights(lua_State *L) {
  5661. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  5662. Renderer *inst = (Renderer*)lua_topointer(L, 1);
  5663. inst->clearLights();
  5664. return 0;
  5665. }
  5666. static int Polycore_Renderer_addLight(lua_State *L) {
  5667. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  5668. Renderer *inst = (Renderer*)lua_topointer(L, 1);
  5669. luaL_checktype(L, 2, LUA_TLIGHTUSERDATA);
  5670. Vector3 position = *(Vector3*)lua_topointer(L, 2);
  5671. luaL_checktype(L, 3, LUA_TLIGHTUSERDATA);
  5672. Vector3 direction = *(Vector3*)lua_topointer(L, 3);
  5673. luaL_checktype(L, 4, LUA_TNUMBER);
  5674. int type = lua_tointeger(L, 4);
  5675. luaL_checktype(L, 5, LUA_TLIGHTUSERDATA);
  5676. Color color = *(Color*)lua_topointer(L, 5);
  5677. luaL_checktype(L, 6, LUA_TNUMBER);
  5678. Number constantAttenuation = lua_tonumber(L, 6);
  5679. luaL_checktype(L, 7, LUA_TNUMBER);
  5680. Number linearAttenuation = lua_tonumber(L, 7);
  5681. luaL_checktype(L, 8, LUA_TNUMBER);
  5682. Number quadraticAttenuation = lua_tonumber(L, 8);
  5683. luaL_checktype(L, 9, LUA_TNUMBER);
  5684. Number intensity = lua_tonumber(L, 9);
  5685. luaL_checktype(L, 10, LUA_TNUMBER);
  5686. Number spotlightCutoff = lua_tonumber(L, 10);
  5687. luaL_checktype(L, 11, LUA_TNUMBER);
  5688. Number spotlightExponent = lua_tonumber(L, 11);
  5689. luaL_checktype(L, 12, LUA_TBOOLEAN);
  5690. bool shadowsEnabled = lua_toboolean(L, 12);
  5691. luaL_checktype(L, 13, LUA_TLIGHTUSERDATA);
  5692. Matrix4 * textureMatrix = (Matrix4 *)lua_topointer(L, 13);
  5693. inst->addLight(position, direction, type, color, constantAttenuation, linearAttenuation, quadraticAttenuation, intensity, spotlightCutoff, spotlightExponent, shadowsEnabled, textureMatrix);
  5694. return 0;
  5695. }
  5696. static int Polycore_Renderer_setExposureLevel(lua_State *L) {
  5697. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  5698. Renderer *inst = (Renderer*)lua_topointer(L, 1);
  5699. luaL_checktype(L, 2, LUA_TNUMBER);
  5700. Number level = lua_tonumber(L, 2);
  5701. inst->setExposureLevel(level);
  5702. return 0;
  5703. }
  5704. static int Polycore_Renderer_rayTriangleIntersect(lua_State *L) {
  5705. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  5706. Renderer *inst = (Renderer*)lua_topointer(L, 1);
  5707. luaL_checktype(L, 2, LUA_TLIGHTUSERDATA);
  5708. Vector3 ray_origin = *(Vector3*)lua_topointer(L, 2);
  5709. luaL_checktype(L, 3, LUA_TLIGHTUSERDATA);
  5710. Vector3 ray_direction = *(Vector3*)lua_topointer(L, 3);
  5711. luaL_checktype(L, 4, LUA_TLIGHTUSERDATA);
  5712. Vector3 vert0 = *(Vector3*)lua_topointer(L, 4);
  5713. luaL_checktype(L, 5, LUA_TLIGHTUSERDATA);
  5714. Vector3 vert1 = *(Vector3*)lua_topointer(L, 5);
  5715. luaL_checktype(L, 6, LUA_TLIGHTUSERDATA);
  5716. Vector3 vert2 = *(Vector3*)lua_topointer(L, 6);
  5717. luaL_checktype(L, 7, LUA_TLIGHTUSERDATA);
  5718. Vector3 * hitPoint = (Vector3 *)lua_topointer(L, 7);
  5719. lua_pushboolean(L, inst->rayTriangleIntersect(ray_origin, ray_direction, vert0, vert1, vert2, hitPoint));
  5720. return 1;
  5721. }
  5722. static int Polycore_Renderer_enableShaders(lua_State *L) {
  5723. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  5724. Renderer *inst = (Renderer*)lua_topointer(L, 1);
  5725. luaL_checktype(L, 2, LUA_TBOOLEAN);
  5726. bool flag = lua_toboolean(L, 2);
  5727. inst->enableShaders(flag);
  5728. return 0;
  5729. }
  5730. static int Polycore_Renderer_initOSSpecific(lua_State *L) {
  5731. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  5732. Renderer *inst = (Renderer*)lua_topointer(L, 1);
  5733. inst->initOSSpecific();
  5734. return 0;
  5735. }
  5736. static int Polycore_Renderer_addShaderModule(lua_State *L) {
  5737. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  5738. Renderer *inst = (Renderer*)lua_topointer(L, 1);
  5739. luaL_checktype(L, 2, LUA_TLIGHTUSERDATA);
  5740. PolycodeShaderModule * module = (PolycodeShaderModule *)lua_topointer(L, 2);
  5741. inst->addShaderModule(module);
  5742. return 0;
  5743. }
  5744. static int Polycore_Renderer_test2DCoordinate(lua_State *L) {
  5745. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  5746. Renderer *inst = (Renderer*)lua_topointer(L, 1);
  5747. luaL_checktype(L, 2, LUA_TNUMBER);
  5748. Number x = lua_tonumber(L, 2);
  5749. luaL_checktype(L, 3, LUA_TNUMBER);
  5750. Number y = lua_tonumber(L, 3);
  5751. luaL_checktype(L, 4, LUA_TLIGHTUSERDATA);
  5752. Polycode::Polygon * poly = (Polycode::Polygon *)lua_topointer(L, 4);
  5753. luaL_checktype(L, 5, LUA_TLIGHTUSERDATA);
  5754. const Matrix4 & matrix = *( Matrix4 *)lua_topointer(L, 5);
  5755. luaL_checktype(L, 6, LUA_TBOOLEAN);
  5756. bool billboardMode = lua_toboolean(L, 6);
  5757. lua_pushboolean(L, inst->test2DCoordinate(x, y, poly, matrix, billboardMode));
  5758. return 1;
  5759. }
  5760. static int Polycore_Renderer_getProjectionMatrix(lua_State *L) {
  5761. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  5762. Renderer *inst = (Renderer*)lua_topointer(L, 1);
  5763. Matrix4 *retInst = new Matrix4();
  5764. *retInst = inst->getProjectionMatrix();
  5765. lua_pushlightuserdata(L, retInst);
  5766. return 1;
  5767. }
  5768. static int Polycore_Renderer_getModelviewMatrix(lua_State *L) {
  5769. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  5770. Renderer *inst = (Renderer*)lua_topointer(L, 1);
  5771. Matrix4 *retInst = new Matrix4();
  5772. *retInst = inst->getModelviewMatrix();
  5773. lua_pushlightuserdata(L, retInst);
  5774. return 1;
  5775. }
  5776. static int Polycore_Renderer_addShadowMap(lua_State *L) {
  5777. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  5778. Renderer *inst = (Renderer*)lua_topointer(L, 1);
  5779. luaL_checktype(L, 2, LUA_TLIGHTUSERDATA);
  5780. Texture * texture = (Texture *)lua_topointer(L, 2);
  5781. inst->addShadowMap(texture);
  5782. return 0;
  5783. }
  5784. static int Polycore_Renderer_Unproject(lua_State *L) {
  5785. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  5786. Renderer *inst = (Renderer*)lua_topointer(L, 1);
  5787. luaL_checktype(L, 2, LUA_TNUMBER);
  5788. Number x = lua_tonumber(L, 2);
  5789. luaL_checktype(L, 3, LUA_TNUMBER);
  5790. Number y = lua_tonumber(L, 3);
  5791. Vector3 *retInst = new Vector3();
  5792. *retInst = inst->Unproject(x, y);
  5793. lua_pushlightuserdata(L, retInst);
  5794. return 1;
  5795. }
  5796. static int Polycore_Renderer_sortLights(lua_State *L) {
  5797. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  5798. Renderer *inst = (Renderer*)lua_topointer(L, 1);
  5799. inst->sortLights();
  5800. return 0;
  5801. }
  5802. static int Polycore_Renderer_getNumAreaLights(lua_State *L) {
  5803. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  5804. Renderer *inst = (Renderer*)lua_topointer(L, 1);
  5805. lua_pushinteger(L, inst->getNumAreaLights());
  5806. return 1;
  5807. }
  5808. static int Polycore_Renderer_getNumSpotLights(lua_State *L) {
  5809. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  5810. Renderer *inst = (Renderer*)lua_topointer(L, 1);
  5811. lua_pushinteger(L, inst->getNumSpotLights());
  5812. return 1;
  5813. }
  5814. static int Polycore_Renderer_getNumLights(lua_State *L) {
  5815. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  5816. Renderer *inst = (Renderer*)lua_topointer(L, 1);
  5817. lua_pushinteger(L, inst->getNumLights());
  5818. return 1;
  5819. }
  5820. static int Polycore_delete_Renderer(lua_State *L) {
  5821. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  5822. Renderer *inst = (Renderer*)lua_topointer(L, 1);
  5823. delete inst;
  5824. return 0;
  5825. }
  5826. static int Polycore_Resource(lua_State *L) {
  5827. luaL_checktype(L, 1, LUA_TNUMBER);
  5828. int type = lua_tointeger(L, 1);
  5829. Resource *inst = new Resource(type);
  5830. lua_pushlightuserdata(L, (void*)inst);
  5831. return 1;
  5832. }
  5833. static int Polycore_Resource_getResourceName(lua_State *L) {
  5834. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  5835. Resource *inst = (Resource*)lua_topointer(L, 1);
  5836. lua_pushstring(L, inst->getResourceName().c_str());
  5837. return 1;
  5838. }
  5839. static int Polycore_Resource_getResourceType(lua_State *L) {
  5840. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  5841. Resource *inst = (Resource*)lua_topointer(L, 1);
  5842. lua_pushinteger(L, inst->getResourceType());
  5843. return 1;
  5844. }
  5845. static int Polycore_Resource_setResourceName(lua_State *L) {
  5846. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  5847. Resource *inst = (Resource*)lua_topointer(L, 1);
  5848. luaL_checktype(L, 2, LUA_TSTRING);
  5849. String newName = String(lua_tostring(L, 2));
  5850. inst->setResourceName(newName);
  5851. return 0;
  5852. }
  5853. static int Polycore_Resource_setResourcePath(lua_State *L) {
  5854. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  5855. Resource *inst = (Resource*)lua_topointer(L, 1);
  5856. luaL_checktype(L, 2, LUA_TSTRING);
  5857. String path = String(lua_tostring(L, 2));
  5858. inst->setResourcePath(path);
  5859. return 0;
  5860. }
  5861. static int Polycore_Resource_getResourcePath(lua_State *L) {
  5862. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  5863. Resource *inst = (Resource*)lua_topointer(L, 1);
  5864. lua_pushstring(L, inst->getResourcePath().c_str());
  5865. return 1;
  5866. }
  5867. static int Polycore_delete_Resource(lua_State *L) {
  5868. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  5869. Resource *inst = (Resource*)lua_topointer(L, 1);
  5870. delete inst;
  5871. return 0;
  5872. }
  5873. static int Polycore_ResourceManager(lua_State *L) {
  5874. ResourceManager *inst = new ResourceManager();
  5875. lua_pushlightuserdata(L, (void*)inst);
  5876. return 1;
  5877. }
  5878. static int Polycore_ResourceManager_addResource(lua_State *L) {
  5879. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  5880. ResourceManager *inst = (ResourceManager*)lua_topointer(L, 1);
  5881. luaL_checktype(L, 2, LUA_TLIGHTUSERDATA);
  5882. Resource * resource = (Resource *)lua_topointer(L, 2);
  5883. inst->addResource(resource);
  5884. return 0;
  5885. }
  5886. static int Polycore_ResourceManager_addDirResource(lua_State *L) {
  5887. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  5888. ResourceManager *inst = (ResourceManager*)lua_topointer(L, 1);
  5889. luaL_checktype(L, 2, LUA_TSTRING);
  5890. String dirPath = String(lua_tostring(L, 2));
  5891. bool recursive;
  5892. if(lua_isboolean(L, 3)) {
  5893. recursive = lua_toboolean(L, 3);
  5894. } else {
  5895. recursive = true;
  5896. }
  5897. inst->addDirResource(dirPath, recursive);
  5898. return 0;
  5899. }
  5900. static int Polycore_ResourceManager_addArchive(lua_State *L) {
  5901. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  5902. ResourceManager *inst = (ResourceManager*)lua_topointer(L, 1);
  5903. luaL_checktype(L, 2, LUA_TSTRING);
  5904. String zipPath = String(lua_tostring(L, 2));
  5905. inst->addArchive(zipPath);
  5906. return 0;
  5907. }
  5908. static int Polycore_ResourceManager_readFile(lua_State *L) {
  5909. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  5910. ResourceManager *inst = (ResourceManager*)lua_topointer(L, 1);
  5911. luaL_checktype(L, 2, LUA_TSTRING);
  5912. String fileName = String(lua_tostring(L, 2));
  5913. lua_pushboolean(L, inst->readFile(fileName));
  5914. return 1;
  5915. }
  5916. static int Polycore_ResourceManager_parseTextures(lua_State *L) {
  5917. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  5918. ResourceManager *inst = (ResourceManager*)lua_topointer(L, 1);
  5919. luaL_checktype(L, 2, LUA_TSTRING);
  5920. String dirPath = String(lua_tostring(L, 2));
  5921. luaL_checktype(L, 3, LUA_TBOOLEAN);
  5922. bool recursive = lua_toboolean(L, 3);
  5923. inst->parseTextures(dirPath, recursive);
  5924. return 0;
  5925. }
  5926. static int Polycore_ResourceManager_parseMaterials(lua_State *L) {
  5927. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  5928. ResourceManager *inst = (ResourceManager*)lua_topointer(L, 1);
  5929. luaL_checktype(L, 2, LUA_TSTRING);
  5930. String dirPath = String(lua_tostring(L, 2));
  5931. luaL_checktype(L, 3, LUA_TBOOLEAN);
  5932. bool recursive = lua_toboolean(L, 3);
  5933. inst->parseMaterials(dirPath, recursive);
  5934. return 0;
  5935. }
  5936. static int Polycore_ResourceManager_parseShaders(lua_State *L) {
  5937. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  5938. ResourceManager *inst = (ResourceManager*)lua_topointer(L, 1);
  5939. luaL_checktype(L, 2, LUA_TSTRING);
  5940. String dirPath = String(lua_tostring(L, 2));
  5941. luaL_checktype(L, 3, LUA_TBOOLEAN);
  5942. bool recursive = lua_toboolean(L, 3);
  5943. inst->parseShaders(dirPath, recursive);
  5944. return 0;
  5945. }
  5946. static int Polycore_ResourceManager_parsePrograms(lua_State *L) {
  5947. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  5948. ResourceManager *inst = (ResourceManager*)lua_topointer(L, 1);
  5949. luaL_checktype(L, 2, LUA_TSTRING);
  5950. String dirPath = String(lua_tostring(L, 2));
  5951. luaL_checktype(L, 3, LUA_TBOOLEAN);
  5952. bool recursive = lua_toboolean(L, 3);
  5953. inst->parsePrograms(dirPath, recursive);
  5954. return 0;
  5955. }
  5956. static int Polycore_ResourceManager_parseCubemaps(lua_State *L) {
  5957. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  5958. ResourceManager *inst = (ResourceManager*)lua_topointer(L, 1);
  5959. luaL_checktype(L, 2, LUA_TSTRING);
  5960. String dirPath = String(lua_tostring(L, 2));
  5961. luaL_checktype(L, 3, LUA_TBOOLEAN);
  5962. bool recursive = lua_toboolean(L, 3);
  5963. inst->parseCubemaps(dirPath, recursive);
  5964. return 0;
  5965. }
  5966. static int Polycore_ResourceManager_parseOthers(lua_State *L) {
  5967. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  5968. ResourceManager *inst = (ResourceManager*)lua_topointer(L, 1);
  5969. luaL_checktype(L, 2, LUA_TSTRING);
  5970. String dirPath = String(lua_tostring(L, 2));
  5971. luaL_checktype(L, 3, LUA_TBOOLEAN);
  5972. bool recursive = lua_toboolean(L, 3);
  5973. inst->parseOthers(dirPath, recursive);
  5974. return 0;
  5975. }
  5976. static int Polycore_ResourceManager_getResource(lua_State *L) {
  5977. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  5978. ResourceManager *inst = (ResourceManager*)lua_topointer(L, 1);
  5979. luaL_checktype(L, 2, LUA_TNUMBER);
  5980. int resourceType = lua_tointeger(L, 2);
  5981. luaL_checktype(L, 3, LUA_TSTRING);
  5982. String resourceName = String(lua_tostring(L, 3));
  5983. void *ptrRetVal = (void*)inst->getResource(resourceType, resourceName);
  5984. if(ptrRetVal == NULL) {
  5985. lua_pushnil(L);
  5986. } else {
  5987. lua_pushlightuserdata(L, ptrRetVal);
  5988. }
  5989. return 1;
  5990. }
  5991. static int Polycore_ResourceManager_addShaderModule(lua_State *L) {
  5992. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  5993. ResourceManager *inst = (ResourceManager*)lua_topointer(L, 1);
  5994. luaL_checktype(L, 2, LUA_TLIGHTUSERDATA);
  5995. PolycodeShaderModule * module = (PolycodeShaderModule *)lua_topointer(L, 2);
  5996. inst->addShaderModule(module);
  5997. return 0;
  5998. }
  5999. static int Polycore_delete_ResourceManager(lua_State *L) {
  6000. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  6001. ResourceManager *inst = (ResourceManager*)lua_topointer(L, 1);
  6002. delete inst;
  6003. return 0;
  6004. }
  6005. static int Polycore_Scene_get_clearColor(lua_State *L) {
  6006. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  6007. Scene *inst = (Scene*)lua_topointer(L, 1);
  6008. lua_pushlightuserdata(L, &inst->clearColor);
  6009. return 1;
  6010. }
  6011. static int Polycore_Scene_get_useClearColor(lua_State *L) {
  6012. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  6013. Scene *inst = (Scene*)lua_topointer(L, 1);
  6014. lua_pushboolean(L, inst->useClearColor);
  6015. return 1;
  6016. }
  6017. static int Polycore_Scene_get_ambientColor(lua_State *L) {
  6018. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  6019. Scene *inst = (Scene*)lua_topointer(L, 1);
  6020. lua_pushlightuserdata(L, &inst->ambientColor);
  6021. return 1;
  6022. }
  6023. static int Polycore_Scene_get_fogColor(lua_State *L) {
  6024. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  6025. Scene *inst = (Scene*)lua_topointer(L, 1);
  6026. lua_pushlightuserdata(L, &inst->fogColor);
  6027. return 1;
  6028. }
  6029. static int Polycore_Scene_get_enabled(lua_State *L) {
  6030. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  6031. Scene *inst = (Scene*)lua_topointer(L, 1);
  6032. lua_pushboolean(L, inst->enabled);
  6033. return 1;
  6034. }
  6035. static int Polycore_Scene_set_useClearColor(lua_State *L) {
  6036. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  6037. Scene *inst = (Scene*)lua_topointer(L, 1);
  6038. bool param = lua_toboolean(L, 2);
  6039. inst->useClearColor = param;
  6040. return 0;
  6041. }
  6042. static int Polycore_Scene_set_enabled(lua_State *L) {
  6043. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  6044. Scene *inst = (Scene*)lua_topointer(L, 1);
  6045. bool param = lua_toboolean(L, 2);
  6046. inst->enabled = param;
  6047. return 0;
  6048. }
  6049. static int Polycore_Scene(lua_State *L) {
  6050. Scene *inst = new Scene();
  6051. lua_pushlightuserdata(L, (void*)inst);
  6052. return 1;
  6053. }
  6054. static int Polycore_Scene_addEntity(lua_State *L) {
  6055. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  6056. Scene *inst = (Scene*)lua_topointer(L, 1);
  6057. luaL_checktype(L, 2, LUA_TLIGHTUSERDATA);
  6058. SceneEntity * entity = (SceneEntity *)lua_topointer(L, 2);
  6059. inst->addEntity(entity);
  6060. return 0;
  6061. }
  6062. static int Polycore_Scene_removeEntity(lua_State *L) {
  6063. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  6064. Scene *inst = (Scene*)lua_topointer(L, 1);
  6065. luaL_checktype(L, 2, LUA_TLIGHTUSERDATA);
  6066. SceneEntity * entity = (SceneEntity *)lua_topointer(L, 2);
  6067. inst->removeEntity(entity);
  6068. return 0;
  6069. }
  6070. static int Polycore_Scene_getDefaultCamera(lua_State *L) {
  6071. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  6072. Scene *inst = (Scene*)lua_topointer(L, 1);
  6073. void *ptrRetVal = (void*)inst->getDefaultCamera();
  6074. if(ptrRetVal == NULL) {
  6075. lua_pushnil(L);
  6076. } else {
  6077. lua_pushlightuserdata(L, ptrRetVal);
  6078. }
  6079. return 1;
  6080. }
  6081. static int Polycore_Scene_enableLighting(lua_State *L) {
  6082. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  6083. Scene *inst = (Scene*)lua_topointer(L, 1);
  6084. luaL_checktype(L, 2, LUA_TBOOLEAN);
  6085. bool enable = lua_toboolean(L, 2);
  6086. inst->enableLighting(enable);
  6087. return 0;
  6088. }
  6089. static int Polycore_Scene_enableFog(lua_State *L) {
  6090. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  6091. Scene *inst = (Scene*)lua_topointer(L, 1);
  6092. luaL_checktype(L, 2, LUA_TBOOLEAN);
  6093. bool enable = lua_toboolean(L, 2);
  6094. inst->enableFog(enable);
  6095. return 0;
  6096. }
  6097. static int Polycore_Scene_setFogProperties(lua_State *L) {
  6098. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  6099. Scene *inst = (Scene*)lua_topointer(L, 1);
  6100. luaL_checktype(L, 2, LUA_TNUMBER);
  6101. int fogMode = lua_tointeger(L, 2);
  6102. luaL_checktype(L, 3, LUA_TLIGHTUSERDATA);
  6103. Color color = *(Color*)lua_topointer(L, 3);
  6104. luaL_checktype(L, 4, LUA_TNUMBER);
  6105. Number density = lua_tonumber(L, 4);
  6106. luaL_checktype(L, 5, LUA_TNUMBER);
  6107. Number startDepth = lua_tonumber(L, 5);
  6108. luaL_checktype(L, 6, LUA_TNUMBER);
  6109. Number _endDepth = lua_tonumber(L, 6);
  6110. inst->setFogProperties(fogMode, color, density, startDepth, _endDepth);
  6111. return 0;
  6112. }
  6113. static int Polycore_Scene_Update(lua_State *L) {
  6114. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  6115. Scene *inst = (Scene*)lua_topointer(L, 1);
  6116. inst->Update();
  6117. return 0;
  6118. }
  6119. static int Polycore_Scene_setVirtual(lua_State *L) {
  6120. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  6121. Scene *inst = (Scene*)lua_topointer(L, 1);
  6122. luaL_checktype(L, 2, LUA_TBOOLEAN);
  6123. bool val = lua_toboolean(L, 2);
  6124. inst->setVirtual(val);
  6125. return 0;
  6126. }
  6127. static int Polycore_Scene_isVirtual(lua_State *L) {
  6128. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  6129. Scene *inst = (Scene*)lua_topointer(L, 1);
  6130. lua_pushboolean(L, inst->isVirtual());
  6131. return 1;
  6132. }
  6133. static int Polycore_Scene_isEnabled(lua_State *L) {
  6134. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  6135. Scene *inst = (Scene*)lua_topointer(L, 1);
  6136. lua_pushboolean(L, inst->isEnabled());
  6137. return 1;
  6138. }
  6139. static int Polycore_Scene_setEnabled(lua_State *L) {
  6140. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  6141. Scene *inst = (Scene*)lua_topointer(L, 1);
  6142. luaL_checktype(L, 2, LUA_TBOOLEAN);
  6143. bool enabled = lua_toboolean(L, 2);
  6144. inst->setEnabled(enabled);
  6145. return 0;
  6146. }
  6147. static int Polycore_Scene_getNumEntities(lua_State *L) {
  6148. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  6149. Scene *inst = (Scene*)lua_topointer(L, 1);
  6150. lua_pushinteger(L, inst->getNumEntities());
  6151. return 1;
  6152. }
  6153. static int Polycore_Scene_getEntity(lua_State *L) {
  6154. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  6155. Scene *inst = (Scene*)lua_topointer(L, 1);
  6156. luaL_checktype(L, 2, LUA_TNUMBER);
  6157. int index = lua_tointeger(L, 2);
  6158. void *ptrRetVal = (void*)inst->getEntity(index);
  6159. if(ptrRetVal == NULL) {
  6160. lua_pushnil(L);
  6161. } else {
  6162. lua_pushlightuserdata(L, ptrRetVal);
  6163. }
  6164. return 1;
  6165. }
  6166. static int Polycore_Scene_getEntityAtScreenPosition(lua_State *L) {
  6167. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  6168. Scene *inst = (Scene*)lua_topointer(L, 1);
  6169. luaL_checktype(L, 2, LUA_TNUMBER);
  6170. Number x = lua_tonumber(L, 2);
  6171. luaL_checktype(L, 3, LUA_TNUMBER);
  6172. Number y = lua_tonumber(L, 3);
  6173. void *ptrRetVal = (void*)inst->getEntityAtScreenPosition(x, y);
  6174. if(ptrRetVal == NULL) {
  6175. lua_pushnil(L);
  6176. } else {
  6177. lua_pushlightuserdata(L, ptrRetVal);
  6178. }
  6179. return 1;
  6180. }
  6181. static int Polycore_Scene_Render(lua_State *L) {
  6182. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  6183. Scene *inst = (Scene*)lua_topointer(L, 1);
  6184. Camera * targetCamera;
  6185. if(lua_islightuserdata(L, 2)) {
  6186. targetCamera = (Camera *)lua_topointer(L, 2);
  6187. } else {
  6188. targetCamera = NULL;
  6189. }
  6190. inst->Render(targetCamera);
  6191. return 0;
  6192. }
  6193. static int Polycore_Scene_RenderDepthOnly(lua_State *L) {
  6194. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  6195. Scene *inst = (Scene*)lua_topointer(L, 1);
  6196. luaL_checktype(L, 2, LUA_TLIGHTUSERDATA);
  6197. Camera * targetCamera = (Camera *)lua_topointer(L, 2);
  6198. inst->RenderDepthOnly(targetCamera);
  6199. return 0;
  6200. }
  6201. static int Polycore_Scene_readString(lua_State *L) {
  6202. luaL_checktype(L, 2, LUA_TLIGHTUSERDATA);
  6203. OSFILE * inFile = (OSFILE *)lua_topointer(L, 2);
  6204. lua_pushstring(L, Scene::readString(inFile).c_str());
  6205. return 1;
  6206. }
  6207. static int Polycore_Scene_loadScene(lua_State *L) {
  6208. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  6209. Scene *inst = (Scene*)lua_topointer(L, 1);
  6210. luaL_checktype(L, 2, LUA_TSTRING);
  6211. String fileName = String(lua_tostring(L, 2));
  6212. inst->loadScene(fileName);
  6213. return 0;
  6214. }
  6215. static int Polycore_Scene_generateLightmaps(lua_State *L) {
  6216. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  6217. Scene *inst = (Scene*)lua_topointer(L, 1);
  6218. luaL_checktype(L, 2, LUA_TNUMBER);
  6219. Number lightMapRes = lua_tonumber(L, 2);
  6220. luaL_checktype(L, 3, LUA_TNUMBER);
  6221. Number lightMapQuality = lua_tonumber(L, 3);
  6222. luaL_checktype(L, 4, LUA_TNUMBER);
  6223. int numRadPasses = lua_tointeger(L, 4);
  6224. inst->generateLightmaps(lightMapRes, lightMapQuality, numRadPasses);
  6225. return 0;
  6226. }
  6227. static int Polycore_Scene_addLight(lua_State *L) {
  6228. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  6229. Scene *inst = (Scene*)lua_topointer(L, 1);
  6230. luaL_checktype(L, 2, LUA_TLIGHTUSERDATA);
  6231. SceneLight * light = (SceneLight *)lua_topointer(L, 2);
  6232. inst->addLight(light);
  6233. return 0;
  6234. }
  6235. static int Polycore_Scene_getNearestLight(lua_State *L) {
  6236. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  6237. Scene *inst = (Scene*)lua_topointer(L, 1);
  6238. luaL_checktype(L, 2, LUA_TLIGHTUSERDATA);
  6239. Vector3 pos = *(Vector3*)lua_topointer(L, 2);
  6240. void *ptrRetVal = (void*)inst->getNearestLight(pos);
  6241. if(ptrRetVal == NULL) {
  6242. lua_pushnil(L);
  6243. } else {
  6244. lua_pushlightuserdata(L, ptrRetVal);
  6245. }
  6246. return 1;
  6247. }
  6248. static int Polycore_Scene_writeEntityMatrix(lua_State *L) {
  6249. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  6250. Scene *inst = (Scene*)lua_topointer(L, 1);
  6251. luaL_checktype(L, 2, LUA_TLIGHTUSERDATA);
  6252. SceneEntity * entity = (SceneEntity *)lua_topointer(L, 2);
  6253. luaL_checktype(L, 3, LUA_TLIGHTUSERDATA);
  6254. OSFILE * outFile = (OSFILE *)lua_topointer(L, 3);
  6255. inst->writeEntityMatrix(entity, outFile);
  6256. return 0;
  6257. }
  6258. static int Polycore_Scene_writeString(lua_State *L) {
  6259. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  6260. Scene *inst = (Scene*)lua_topointer(L, 1);
  6261. luaL_checktype(L, 2, LUA_TSTRING);
  6262. String str = String(lua_tostring(L, 2));
  6263. luaL_checktype(L, 3, LUA_TLIGHTUSERDATA);
  6264. OSFILE * outFile = (OSFILE *)lua_topointer(L, 3);
  6265. inst->writeString(str, outFile);
  6266. return 0;
  6267. }
  6268. static int Polycore_Scene_saveScene(lua_State *L) {
  6269. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  6270. Scene *inst = (Scene*)lua_topointer(L, 1);
  6271. luaL_checktype(L, 2, LUA_TSTRING);
  6272. String fileName = String(lua_tostring(L, 2));
  6273. inst->saveScene(fileName);
  6274. return 0;
  6275. }
  6276. static int Polycore_Scene_getNumStaticGeometry(lua_State *L) {
  6277. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  6278. Scene *inst = (Scene*)lua_topointer(L, 1);
  6279. lua_pushinteger(L, inst->getNumStaticGeometry());
  6280. return 1;
  6281. }
  6282. static int Polycore_Scene_getStaticGeometry(lua_State *L) {
  6283. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  6284. Scene *inst = (Scene*)lua_topointer(L, 1);
  6285. luaL_checktype(L, 2, LUA_TNUMBER);
  6286. int index = lua_tointeger(L, 2);
  6287. void *ptrRetVal = (void*)inst->getStaticGeometry(index);
  6288. if(ptrRetVal == NULL) {
  6289. lua_pushnil(L);
  6290. } else {
  6291. lua_pushlightuserdata(L, ptrRetVal);
  6292. }
  6293. return 1;
  6294. }
  6295. static int Polycore_Scene_loadCollisionChild(lua_State *L) {
  6296. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  6297. Scene *inst = (Scene*)lua_topointer(L, 1);
  6298. luaL_checktype(L, 2, LUA_TLIGHTUSERDATA);
  6299. SceneEntity * entity = (SceneEntity *)lua_topointer(L, 2);
  6300. bool autoCollide;
  6301. if(lua_isboolean(L, 3)) {
  6302. autoCollide = lua_toboolean(L, 3);
  6303. } else {
  6304. autoCollide = false;
  6305. }
  6306. int type;
  6307. if(lua_isnumber(L, 4)) {
  6308. type = lua_tointeger(L, 4);
  6309. } else {
  6310. type = 0;
  6311. }
  6312. inst->loadCollisionChild(entity, autoCollide, type);
  6313. return 0;
  6314. }
  6315. static int Polycore_Scene_getNumLights(lua_State *L) {
  6316. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  6317. Scene *inst = (Scene*)lua_topointer(L, 1);
  6318. lua_pushinteger(L, inst->getNumLights());
  6319. return 1;
  6320. }
  6321. static int Polycore_Scene_getLight(lua_State *L) {
  6322. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  6323. Scene *inst = (Scene*)lua_topointer(L, 1);
  6324. luaL_checktype(L, 2, LUA_TNUMBER);
  6325. int index = lua_tointeger(L, 2);
  6326. void *ptrRetVal = (void*)inst->getLight(index);
  6327. if(ptrRetVal == NULL) {
  6328. lua_pushnil(L);
  6329. } else {
  6330. lua_pushlightuserdata(L, ptrRetVal);
  6331. }
  6332. return 1;
  6333. }
  6334. static int Polycore_Scene_getCustomEntityByType(lua_State *L) {
  6335. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  6336. Scene *inst = (Scene*)lua_topointer(L, 1);
  6337. luaL_checktype(L, 2, LUA_TSTRING);
  6338. String type = String(lua_tostring(L, 2));
  6339. void *ptrRetVal = (void*)inst->getCustomEntityByType(type);
  6340. if(ptrRetVal == NULL) {
  6341. lua_pushnil(L);
  6342. } else {
  6343. lua_pushlightuserdata(L, ptrRetVal);
  6344. }
  6345. return 1;
  6346. }
  6347. static int Polycore_delete_Scene(lua_State *L) {
  6348. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  6349. Scene *inst = (Scene*)lua_topointer(L, 1);
  6350. delete inst;
  6351. return 0;
  6352. }
  6353. static int Polycore_SceneEntity(lua_State *L) {
  6354. SceneEntity *inst = new SceneEntity();
  6355. lua_pushlightuserdata(L, (void*)inst);
  6356. return 1;
  6357. }
  6358. static int Polycore_SceneEntity_testMouseCollision(lua_State *L) {
  6359. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  6360. SceneEntity *inst = (SceneEntity*)lua_topointer(L, 1);
  6361. luaL_checktype(L, 2, LUA_TNUMBER);
  6362. Number x = lua_tonumber(L, 2);
  6363. luaL_checktype(L, 3, LUA_TNUMBER);
  6364. Number y = lua_tonumber(L, 3);
  6365. lua_pushboolean(L, inst->testMouseCollision(x, y));
  6366. return 1;
  6367. }
  6368. static int Polycore_delete_SceneEntity(lua_State *L) {
  6369. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  6370. SceneEntity *inst = (SceneEntity*)lua_topointer(L, 1);
  6371. delete inst;
  6372. return 0;
  6373. }
  6374. static int Polycore_SceneLabel(lua_State *L) {
  6375. luaL_checktype(L, 1, LUA_TSTRING);
  6376. String fontName = String(lua_tostring(L, 1));
  6377. luaL_checktype(L, 2, LUA_TSTRING);
  6378. String text = String(lua_tostring(L, 2));
  6379. luaL_checktype(L, 3, LUA_TNUMBER);
  6380. int size = lua_tointeger(L, 3);
  6381. luaL_checktype(L, 4, LUA_TNUMBER);
  6382. Number scale = lua_tonumber(L, 4);
  6383. luaL_checktype(L, 5, LUA_TNUMBER);
  6384. int amode = lua_tointeger(L, 5);
  6385. SceneLabel *inst = new SceneLabel(fontName, text, size, scale, amode);
  6386. lua_pushlightuserdata(L, (void*)inst);
  6387. return 1;
  6388. }
  6389. static int Polycore_SceneLabel_testMouseCollision(lua_State *L) {
  6390. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  6391. SceneLabel *inst = (SceneLabel*)lua_topointer(L, 1);
  6392. luaL_checktype(L, 2, LUA_TNUMBER);
  6393. Number x = lua_tonumber(L, 2);
  6394. luaL_checktype(L, 3, LUA_TNUMBER);
  6395. Number y = lua_tonumber(L, 3);
  6396. lua_pushboolean(L, inst->testMouseCollision(x, y));
  6397. return 1;
  6398. }
  6399. static int Polycore_SceneLabel_setText(lua_State *L) {
  6400. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  6401. SceneLabel *inst = (SceneLabel*)lua_topointer(L, 1);
  6402. luaL_checktype(L, 2, LUA_TSTRING);
  6403. String newText = String(lua_tostring(L, 2));
  6404. inst->setText(newText);
  6405. return 0;
  6406. }
  6407. static int Polycore_SceneLabel_getLabel(lua_State *L) {
  6408. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  6409. SceneLabel *inst = (SceneLabel*)lua_topointer(L, 1);
  6410. void *ptrRetVal = (void*)inst->getLabel();
  6411. if(ptrRetVal == NULL) {
  6412. lua_pushnil(L);
  6413. } else {
  6414. lua_pushlightuserdata(L, ptrRetVal);
  6415. }
  6416. return 1;
  6417. }
  6418. static int Polycore_SceneLabel_Render(lua_State *L) {
  6419. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  6420. SceneLabel *inst = (SceneLabel*)lua_topointer(L, 1);
  6421. inst->Render();
  6422. return 0;
  6423. }
  6424. static int Polycore_delete_SceneLabel(lua_State *L) {
  6425. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  6426. SceneLabel *inst = (SceneLabel*)lua_topointer(L, 1);
  6427. delete inst;
  6428. return 0;
  6429. }
  6430. static int Polycore_SceneLight_get_lightColor(lua_State *L) {
  6431. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  6432. SceneLight *inst = (SceneLight*)lua_topointer(L, 1);
  6433. lua_pushlightuserdata(L, &inst->lightColor);
  6434. return 1;
  6435. }
  6436. static int Polycore_SceneLight(lua_State *L) {
  6437. luaL_checktype(L, 1, LUA_TNUMBER);
  6438. int type = lua_tointeger(L, 1);
  6439. luaL_checktype(L, 2, LUA_TLIGHTUSERDATA);
  6440. Scene * parentScene = (Scene *)lua_topointer(L, 2);
  6441. luaL_checktype(L, 3, LUA_TNUMBER);
  6442. Number intensity = lua_tonumber(L, 3);
  6443. Number constantAttenuation;
  6444. if(lua_isnumber(L, 4)) {
  6445. constantAttenuation = lua_tonumber(L, 4);
  6446. } else {
  6447. constantAttenuation = 1;
  6448. }
  6449. Number linearAttenuation;
  6450. if(lua_isnumber(L, 5)) {
  6451. linearAttenuation = lua_tonumber(L, 5);
  6452. } else {
  6453. linearAttenuation = 1;
  6454. }
  6455. Number quadraticAttenuation;
  6456. if(lua_isnumber(L, 6)) {
  6457. quadraticAttenuation = lua_tonumber(L, 6);
  6458. } else {
  6459. quadraticAttenuation = 1;
  6460. }
  6461. SceneLight *inst = new SceneLight(type, parentScene, intensity, constantAttenuation, linearAttenuation, quadraticAttenuation);
  6462. lua_pushlightuserdata(L, (void*)inst);
  6463. return 1;
  6464. }
  6465. static int Polycore_SceneLight_getIntensity(lua_State *L) {
  6466. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  6467. SceneLight *inst = (SceneLight*)lua_topointer(L, 1);
  6468. lua_pushnumber(L, inst->getIntensity());
  6469. return 1;
  6470. }
  6471. static int Polycore_SceneLight_getConstantAttenuation(lua_State *L) {
  6472. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  6473. SceneLight *inst = (SceneLight*)lua_topointer(L, 1);
  6474. lua_pushnumber(L, inst->getConstantAttenuation());
  6475. return 1;
  6476. }
  6477. static int Polycore_SceneLight_getLinearAttenuation(lua_State *L) {
  6478. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  6479. SceneLight *inst = (SceneLight*)lua_topointer(L, 1);
  6480. lua_pushnumber(L, inst->getLinearAttenuation());
  6481. return 1;
  6482. }
  6483. static int Polycore_SceneLight_getQuadraticAttenuation(lua_State *L) {
  6484. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  6485. SceneLight *inst = (SceneLight*)lua_topointer(L, 1);
  6486. lua_pushnumber(L, inst->getQuadraticAttenuation());
  6487. return 1;
  6488. }
  6489. static int Polycore_SceneLight_getType(lua_State *L) {
  6490. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  6491. SceneLight *inst = (SceneLight*)lua_topointer(L, 1);
  6492. lua_pushinteger(L, inst->getType());
  6493. return 1;
  6494. }
  6495. static int Polycore_SceneLight_renderDepthMap(lua_State *L) {
  6496. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  6497. SceneLight *inst = (SceneLight*)lua_topointer(L, 1);
  6498. luaL_checktype(L, 2, LUA_TLIGHTUSERDATA);
  6499. Scene * scene = (Scene *)lua_topointer(L, 2);
  6500. inst->renderDepthMap(scene);
  6501. return 0;
  6502. }
  6503. static int Polycore_SceneLight_Render(lua_State *L) {
  6504. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  6505. SceneLight *inst = (SceneLight*)lua_topointer(L, 1);
  6506. inst->Render();
  6507. return 0;
  6508. }
  6509. static int Polycore_SceneLight_getLightViewMatrix(lua_State *L) {
  6510. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  6511. SceneLight *inst = (SceneLight*)lua_topointer(L, 1);
  6512. Matrix4 *retInst = new Matrix4();
  6513. *retInst = inst->getLightViewMatrix();
  6514. lua_pushlightuserdata(L, retInst);
  6515. return 1;
  6516. }
  6517. static int Polycore_SceneLight_getZBufferTexture(lua_State *L) {
  6518. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  6519. SceneLight *inst = (SceneLight*)lua_topointer(L, 1);
  6520. void *ptrRetVal = (void*)inst->getZBufferTexture();
  6521. if(ptrRetVal == NULL) {
  6522. lua_pushnil(L);
  6523. } else {
  6524. lua_pushlightuserdata(L, ptrRetVal);
  6525. }
  6526. return 1;
  6527. }
  6528. static int Polycore_SceneLight_setLightColor(lua_State *L) {
  6529. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  6530. SceneLight *inst = (SceneLight*)lua_topointer(L, 1);
  6531. luaL_checktype(L, 2, LUA_TNUMBER);
  6532. Number r = lua_tonumber(L, 2);
  6533. luaL_checktype(L, 3, LUA_TNUMBER);
  6534. Number g = lua_tonumber(L, 3);
  6535. luaL_checktype(L, 4, LUA_TNUMBER);
  6536. Number b = lua_tonumber(L, 4);
  6537. inst->setLightColor(r, g, b);
  6538. return 0;
  6539. }
  6540. static int Polycore_SceneLight_setSpotlightProperties(lua_State *L) {
  6541. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  6542. SceneLight *inst = (SceneLight*)lua_topointer(L, 1);
  6543. luaL_checktype(L, 2, LUA_TNUMBER);
  6544. Number spotlightCutoff = lua_tonumber(L, 2);
  6545. luaL_checktype(L, 3, LUA_TNUMBER);
  6546. Number spotlightExponent = lua_tonumber(L, 3);
  6547. inst->setSpotlightProperties(spotlightCutoff, spotlightExponent);
  6548. return 0;
  6549. }
  6550. static int Polycore_SceneLight_getSpotlightCutoff(lua_State *L) {
  6551. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  6552. SceneLight *inst = (SceneLight*)lua_topointer(L, 1);
  6553. lua_pushnumber(L, inst->getSpotlightCutoff());
  6554. return 1;
  6555. }
  6556. static int Polycore_SceneLight_getSpotlightExponent(lua_State *L) {
  6557. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  6558. SceneLight *inst = (SceneLight*)lua_topointer(L, 1);
  6559. lua_pushnumber(L, inst->getSpotlightExponent());
  6560. return 1;
  6561. }
  6562. static int Polycore_SceneLight_enableShadows(lua_State *L) {
  6563. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  6564. SceneLight *inst = (SceneLight*)lua_topointer(L, 1);
  6565. luaL_checktype(L, 2, LUA_TBOOLEAN);
  6566. bool val = lua_toboolean(L, 2);
  6567. Number resolution;
  6568. if(lua_isnumber(L, 3)) {
  6569. resolution = lua_tonumber(L, 3);
  6570. } else {
  6571. resolution = 256;
  6572. }
  6573. inst->enableShadows(val, resolution);
  6574. return 0;
  6575. }
  6576. static int Polycore_SceneLight_setShadowMapFOV(lua_State *L) {
  6577. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  6578. SceneLight *inst = (SceneLight*)lua_topointer(L, 1);
  6579. luaL_checktype(L, 2, LUA_TNUMBER);
  6580. Number fov = lua_tonumber(L, 2);
  6581. inst->setShadowMapFOV(fov);
  6582. return 0;
  6583. }
  6584. static int Polycore_SceneLight_areShadowsEnabled(lua_State *L) {
  6585. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  6586. SceneLight *inst = (SceneLight*)lua_topointer(L, 1);
  6587. lua_pushboolean(L, inst->areShadowsEnabled());
  6588. return 1;
  6589. }
  6590. static int Polycore_SceneLight_getLightType(lua_State *L) {
  6591. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  6592. SceneLight *inst = (SceneLight*)lua_topointer(L, 1);
  6593. lua_pushinteger(L, inst->getLightType());
  6594. return 1;
  6595. }
  6596. static int Polycore_delete_SceneLight(lua_State *L) {
  6597. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  6598. SceneLight *inst = (SceneLight*)lua_topointer(L, 1);
  6599. delete inst;
  6600. return 0;
  6601. }
  6602. static int Polycore_SceneLine(lua_State *L) {
  6603. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  6604. SceneEntity * ent1 = (SceneEntity *)lua_topointer(L, 1);
  6605. luaL_checktype(L, 2, LUA_TLIGHTUSERDATA);
  6606. SceneEntity * ent2 = (SceneEntity *)lua_topointer(L, 2);
  6607. SceneLine *inst = new SceneLine(ent1, ent2);
  6608. lua_pushlightuserdata(L, (void*)inst);
  6609. return 1;
  6610. }
  6611. static int Polycore_SceneLine_Render(lua_State *L) {
  6612. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  6613. SceneLine *inst = (SceneLine*)lua_topointer(L, 1);
  6614. inst->Render();
  6615. return 0;
  6616. }
  6617. static int Polycore_delete_SceneLine(lua_State *L) {
  6618. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  6619. SceneLine *inst = (SceneLine*)lua_topointer(L, 1);
  6620. delete inst;
  6621. return 0;
  6622. }
  6623. static int Polycore_SceneManager(lua_State *L) {
  6624. SceneManager *inst = new SceneManager();
  6625. lua_pushlightuserdata(L, (void*)inst);
  6626. return 1;
  6627. }
  6628. static int Polycore_SceneManager_addScene(lua_State *L) {
  6629. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  6630. SceneManager *inst = (SceneManager*)lua_topointer(L, 1);
  6631. luaL_checktype(L, 2, LUA_TLIGHTUSERDATA);
  6632. Scene * newScene = (Scene *)lua_topointer(L, 2);
  6633. inst->addScene(newScene);
  6634. return 0;
  6635. }
  6636. static int Polycore_SceneManager_Update(lua_State *L) {
  6637. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  6638. SceneManager *inst = (SceneManager*)lua_topointer(L, 1);
  6639. inst->Update();
  6640. return 0;
  6641. }
  6642. static int Polycore_SceneManager_UpdateVirtual(lua_State *L) {
  6643. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  6644. SceneManager *inst = (SceneManager*)lua_topointer(L, 1);
  6645. inst->UpdateVirtual();
  6646. return 0;
  6647. }
  6648. static int Polycore_SceneManager_removeScene(lua_State *L) {
  6649. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  6650. SceneManager *inst = (SceneManager*)lua_topointer(L, 1);
  6651. luaL_checktype(L, 2, LUA_TLIGHTUSERDATA);
  6652. Scene * scene = (Scene *)lua_topointer(L, 2);
  6653. inst->removeScene(scene);
  6654. return 0;
  6655. }
  6656. static int Polycore_SceneManager_registerRenderTexture(lua_State *L) {
  6657. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  6658. SceneManager *inst = (SceneManager*)lua_topointer(L, 1);
  6659. luaL_checktype(L, 2, LUA_TLIGHTUSERDATA);
  6660. SceneRenderTexture * r_enderTexture = (SceneRenderTexture *)lua_topointer(L, 2);
  6661. inst->registerRenderTexture(r_enderTexture);
  6662. return 0;
  6663. }
  6664. static int Polycore_delete_SceneManager(lua_State *L) {
  6665. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  6666. SceneManager *inst = (SceneManager*)lua_topointer(L, 1);
  6667. delete inst;
  6668. return 0;
  6669. }
  6670. static int Polycore_SceneMesh_get_lightmapIndex(lua_State *L) {
  6671. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  6672. SceneMesh *inst = (SceneMesh*)lua_topointer(L, 1);
  6673. lua_pushlightuserdata(L, &inst->lightmapIndex);
  6674. return 1;
  6675. }
  6676. static int Polycore_SceneMesh_get_showVertexNormals(lua_State *L) {
  6677. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  6678. SceneMesh *inst = (SceneMesh*)lua_topointer(L, 1);
  6679. lua_pushboolean(L, inst->showVertexNormals);
  6680. return 1;
  6681. }
  6682. static int Polycore_SceneMesh_set_showVertexNormals(lua_State *L) {
  6683. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  6684. SceneMesh *inst = (SceneMesh*)lua_topointer(L, 1);
  6685. bool param = lua_toboolean(L, 2);
  6686. inst->showVertexNormals = param;
  6687. return 0;
  6688. }
  6689. static int Polycore_SceneMesh(lua_State *L) {
  6690. luaL_checktype(L, 1, LUA_TSTRING);
  6691. String fileName = String(lua_tostring(L, 1));
  6692. SceneMesh *inst = new SceneMesh(fileName);
  6693. lua_pushlightuserdata(L, (void*)inst);
  6694. return 1;
  6695. }
  6696. static int Polycore_SceneMesh_Render(lua_State *L) {
  6697. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  6698. SceneMesh *inst = (SceneMesh*)lua_topointer(L, 1);
  6699. inst->Render();
  6700. return 0;
  6701. }
  6702. static int Polycore_SceneMesh_getLocalShaderOptions(lua_State *L) {
  6703. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  6704. SceneMesh *inst = (SceneMesh*)lua_topointer(L, 1);
  6705. void *ptrRetVal = (void*)inst->getLocalShaderOptions();
  6706. if(ptrRetVal == NULL) {
  6707. lua_pushnil(L);
  6708. } else {
  6709. lua_pushlightuserdata(L, ptrRetVal);
  6710. }
  6711. return 1;
  6712. }
  6713. static int Polycore_SceneMesh_getMesh(lua_State *L) {
  6714. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  6715. SceneMesh *inst = (SceneMesh*)lua_topointer(L, 1);
  6716. void *ptrRetVal = (void*)inst->getMesh();
  6717. if(ptrRetVal == NULL) {
  6718. lua_pushnil(L);
  6719. } else {
  6720. lua_pushlightuserdata(L, ptrRetVal);
  6721. }
  6722. return 1;
  6723. }
  6724. static int Polycore_SceneMesh_getTexture(lua_State *L) {
  6725. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  6726. SceneMesh *inst = (SceneMesh*)lua_topointer(L, 1);
  6727. void *ptrRetVal = (void*)inst->getTexture();
  6728. if(ptrRetVal == NULL) {
  6729. lua_pushnil(L);
  6730. } else {
  6731. lua_pushlightuserdata(L, ptrRetVal);
  6732. }
  6733. return 1;
  6734. }
  6735. static int Polycore_SceneMesh_getMaterial(lua_State *L) {
  6736. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  6737. SceneMesh *inst = (SceneMesh*)lua_topointer(L, 1);
  6738. void *ptrRetVal = (void*)inst->getMaterial();
  6739. if(ptrRetVal == NULL) {
  6740. lua_pushnil(L);
  6741. } else {
  6742. lua_pushlightuserdata(L, ptrRetVal);
  6743. }
  6744. return 1;
  6745. }
  6746. static int Polycore_SceneMesh_loadTexture(lua_State *L) {
  6747. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  6748. SceneMesh *inst = (SceneMesh*)lua_topointer(L, 1);
  6749. luaL_checktype(L, 2, LUA_TSTRING);
  6750. String fileName = String(lua_tostring(L, 2));
  6751. bool clamp;
  6752. if(lua_isboolean(L, 3)) {
  6753. clamp = lua_toboolean(L, 3);
  6754. } else {
  6755. clamp = true;
  6756. }
  6757. inst->loadTexture(fileName, clamp);
  6758. return 0;
  6759. }
  6760. static int Polycore_SceneMesh_loadSkeleton(lua_State *L) {
  6761. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  6762. SceneMesh *inst = (SceneMesh*)lua_topointer(L, 1);
  6763. luaL_checktype(L, 2, LUA_TSTRING);
  6764. String fileName = String(lua_tostring(L, 2));
  6765. inst->loadSkeleton(fileName);
  6766. return 0;
  6767. }
  6768. static int Polycore_SceneMesh_setTexture(lua_State *L) {
  6769. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  6770. SceneMesh *inst = (SceneMesh*)lua_topointer(L, 1);
  6771. luaL_checktype(L, 2, LUA_TLIGHTUSERDATA);
  6772. Texture * texture = (Texture *)lua_topointer(L, 2);
  6773. inst->setTexture(texture);
  6774. return 0;
  6775. }
  6776. static int Polycore_SceneMesh_setMaterial(lua_State *L) {
  6777. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  6778. SceneMesh *inst = (SceneMesh*)lua_topointer(L, 1);
  6779. luaL_checktype(L, 2, LUA_TLIGHTUSERDATA);
  6780. Material * material = (Material *)lua_topointer(L, 2);
  6781. inst->setMaterial(material);
  6782. return 0;
  6783. }
  6784. static int Polycore_SceneMesh_setMaterialByName(lua_State *L) {
  6785. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  6786. SceneMesh *inst = (SceneMesh*)lua_topointer(L, 1);
  6787. luaL_checktype(L, 2, LUA_TSTRING);
  6788. String materialName = String(lua_tostring(L, 2));
  6789. inst->setMaterialByName(materialName);
  6790. return 0;
  6791. }
  6792. static int Polycore_SceneMesh_setMesh(lua_State *L) {
  6793. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  6794. SceneMesh *inst = (SceneMesh*)lua_topointer(L, 1);
  6795. luaL_checktype(L, 2, LUA_TLIGHTUSERDATA);
  6796. Mesh * mesh = (Mesh *)lua_topointer(L, 2);
  6797. inst->setMesh(mesh);
  6798. return 0;
  6799. }
  6800. static int Polycore_SceneMesh_setSkeleton(lua_State *L) {
  6801. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  6802. SceneMesh *inst = (SceneMesh*)lua_topointer(L, 1);
  6803. luaL_checktype(L, 2, LUA_TLIGHTUSERDATA);
  6804. Skeleton * skeleton = (Skeleton *)lua_topointer(L, 2);
  6805. inst->setSkeleton(skeleton);
  6806. return 0;
  6807. }
  6808. static int Polycore_SceneMesh_getSkeleton(lua_State *L) {
  6809. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  6810. SceneMesh *inst = (SceneMesh*)lua_topointer(L, 1);
  6811. void *ptrRetVal = (void*)inst->getSkeleton();
  6812. if(ptrRetVal == NULL) {
  6813. lua_pushnil(L);
  6814. } else {
  6815. lua_pushlightuserdata(L, ptrRetVal);
  6816. }
  6817. return 1;
  6818. }
  6819. static int Polycore_SceneMesh_renderMeshLocally(lua_State *L) {
  6820. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  6821. SceneMesh *inst = (SceneMesh*)lua_topointer(L, 1);
  6822. inst->renderMeshLocally();
  6823. return 0;
  6824. }
  6825. static int Polycore_SceneMesh_cacheToVertexBuffer(lua_State *L) {
  6826. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  6827. SceneMesh *inst = (SceneMesh*)lua_topointer(L, 1);
  6828. luaL_checktype(L, 2, LUA_TBOOLEAN);
  6829. bool cache = lua_toboolean(L, 2);
  6830. inst->cacheToVertexBuffer(cache);
  6831. return 0;
  6832. }
  6833. static int Polycore_delete_SceneMesh(lua_State *L) {
  6834. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  6835. SceneMesh *inst = (SceneMesh*)lua_topointer(L, 1);
  6836. delete inst;
  6837. return 0;
  6838. }
  6839. static int Polycore_ScenePrimitive(lua_State *L) {
  6840. luaL_checktype(L, 1, LUA_TNUMBER);
  6841. int type = lua_tointeger(L, 1);
  6842. Number v1;
  6843. if(lua_isnumber(L, 2)) {
  6844. v1 = lua_tonumber(L, 2);
  6845. } else {
  6846. v1 = 1.0f;
  6847. }
  6848. Number v2;
  6849. if(lua_isnumber(L, 3)) {
  6850. v2 = lua_tonumber(L, 3);
  6851. } else {
  6852. v2 = 1.0f;
  6853. }
  6854. Number v3;
  6855. if(lua_isnumber(L, 4)) {
  6856. v3 = lua_tonumber(L, 4);
  6857. } else {
  6858. v3 = 1.0f;
  6859. }
  6860. ScenePrimitive *inst = new ScenePrimitive(type, v1, v2, v3);
  6861. lua_pushlightuserdata(L, (void*)inst);
  6862. return 1;
  6863. }
  6864. static int Polycore_delete_ScenePrimitive(lua_State *L) {
  6865. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  6866. ScenePrimitive *inst = (ScenePrimitive*)lua_topointer(L, 1);
  6867. delete inst;
  6868. return 0;
  6869. }
  6870. static int Polycore_SceneRenderTexture(lua_State *L) {
  6871. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  6872. Scene * targetScene = (Scene *)lua_topointer(L, 1);
  6873. luaL_checktype(L, 2, LUA_TLIGHTUSERDATA);
  6874. Camera * targetCamera = (Camera *)lua_topointer(L, 2);
  6875. luaL_checktype(L, 3, LUA_TNUMBER);
  6876. int r_enderWidth = lua_tointeger(L, 3);
  6877. luaL_checktype(L, 4, LUA_TNUMBER);
  6878. int r_enderHeight = lua_tointeger(L, 4);
  6879. SceneRenderTexture *inst = new SceneRenderTexture(targetScene, targetCamera, r_enderWidth, r_enderHeight);
  6880. lua_pushlightuserdata(L, (void*)inst);
  6881. return 1;
  6882. }
  6883. static int Polycore_SceneRenderTexture_drawScreen(lua_State *L) {
  6884. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  6885. SceneRenderTexture *inst = (SceneRenderTexture*)lua_topointer(L, 1);
  6886. inst->drawScreen();
  6887. return 0;
  6888. }
  6889. static int Polycore_SceneRenderTexture_getTargetTexture(lua_State *L) {
  6890. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  6891. SceneRenderTexture *inst = (SceneRenderTexture*)lua_topointer(L, 1);
  6892. void *ptrRetVal = (void*)inst->getTargetTexture();
  6893. if(ptrRetVal == NULL) {
  6894. lua_pushnil(L);
  6895. } else {
  6896. lua_pushlightuserdata(L, ptrRetVal);
  6897. }
  6898. return 1;
  6899. }
  6900. static int Polycore_SceneRenderTexture_getTargetScene(lua_State *L) {
  6901. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  6902. SceneRenderTexture *inst = (SceneRenderTexture*)lua_topointer(L, 1);
  6903. void *ptrRetVal = (void*)inst->getTargetScene();
  6904. if(ptrRetVal == NULL) {
  6905. lua_pushnil(L);
  6906. } else {
  6907. lua_pushlightuserdata(L, ptrRetVal);
  6908. }
  6909. return 1;
  6910. }
  6911. static int Polycore_SceneRenderTexture_getTargetCamera(lua_State *L) {
  6912. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  6913. SceneRenderTexture *inst = (SceneRenderTexture*)lua_topointer(L, 1);
  6914. void *ptrRetVal = (void*)inst->getTargetCamera();
  6915. if(ptrRetVal == NULL) {
  6916. lua_pushnil(L);
  6917. } else {
  6918. lua_pushlightuserdata(L, ptrRetVal);
  6919. }
  6920. return 1;
  6921. }
  6922. static int Polycore_delete_SceneRenderTexture(lua_State *L) {
  6923. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  6924. SceneRenderTexture *inst = (SceneRenderTexture*)lua_topointer(L, 1);
  6925. delete inst;
  6926. return 0;
  6927. }
  6928. static int Polycore_SceneSound(lua_State *L) {
  6929. luaL_checktype(L, 1, LUA_TSTRING);
  6930. String fileName = String(lua_tostring(L, 1));
  6931. luaL_checktype(L, 2, LUA_TNUMBER);
  6932. Number referenceDistance = lua_tonumber(L, 2);
  6933. luaL_checktype(L, 3, LUA_TNUMBER);
  6934. Number maxDistance = lua_tonumber(L, 3);
  6935. SceneSound *inst = new SceneSound(fileName, referenceDistance, maxDistance);
  6936. lua_pushlightuserdata(L, (void*)inst);
  6937. return 1;
  6938. }
  6939. static int Polycore_SceneSound_Update(lua_State *L) {
  6940. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  6941. SceneSound *inst = (SceneSound*)lua_topointer(L, 1);
  6942. inst->Update();
  6943. return 0;
  6944. }
  6945. static int Polycore_SceneSound_getSound(lua_State *L) {
  6946. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  6947. SceneSound *inst = (SceneSound*)lua_topointer(L, 1);
  6948. void *ptrRetVal = (void*)inst->getSound();
  6949. if(ptrRetVal == NULL) {
  6950. lua_pushnil(L);
  6951. } else {
  6952. lua_pushlightuserdata(L, ptrRetVal);
  6953. }
  6954. return 1;
  6955. }
  6956. static int Polycore_delete_SceneSound(lua_State *L) {
  6957. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  6958. SceneSound *inst = (SceneSound*)lua_topointer(L, 1);
  6959. delete inst;
  6960. return 0;
  6961. }
  6962. static int Polycore_SceneSoundListener(lua_State *L) {
  6963. SceneSoundListener *inst = new SceneSoundListener();
  6964. lua_pushlightuserdata(L, (void*)inst);
  6965. return 1;
  6966. }
  6967. static int Polycore_SceneSoundListener_Update(lua_State *L) {
  6968. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  6969. SceneSoundListener *inst = (SceneSoundListener*)lua_topointer(L, 1);
  6970. inst->Update();
  6971. return 0;
  6972. }
  6973. static int Polycore_delete_SceneSoundListener(lua_State *L) {
  6974. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  6975. SceneSoundListener *inst = (SceneSoundListener*)lua_topointer(L, 1);
  6976. delete inst;
  6977. return 0;
  6978. }
  6979. static int Polycore_Screen_get_enabled(lua_State *L) {
  6980. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  6981. Screen *inst = (Screen*)lua_topointer(L, 1);
  6982. lua_pushboolean(L, inst->enabled);
  6983. return 1;
  6984. }
  6985. static int Polycore_Screen_set_enabled(lua_State *L) {
  6986. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  6987. Screen *inst = (Screen*)lua_topointer(L, 1);
  6988. bool param = lua_toboolean(L, 2);
  6989. inst->enabled = param;
  6990. return 0;
  6991. }
  6992. static int Polycore_Screen(lua_State *L) {
  6993. Screen *inst = new Screen();
  6994. lua_pushlightuserdata(L, (void*)inst);
  6995. return 1;
  6996. }
  6997. static int Polycore_Screen_addChild(lua_State *L) {
  6998. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  6999. Screen *inst = (Screen*)lua_topointer(L, 1);
  7000. luaL_checktype(L, 2, LUA_TLIGHTUSERDATA);
  7001. ScreenEntity * newEntity = (ScreenEntity *)lua_topointer(L, 2);
  7002. void *ptrRetVal = (void*)inst->addChild(newEntity);
  7003. if(ptrRetVal == NULL) {
  7004. lua_pushnil(L);
  7005. } else {
  7006. lua_pushlightuserdata(L, ptrRetVal);
  7007. }
  7008. return 1;
  7009. }
  7010. static int Polycore_Screen_removeChild(lua_State *L) {
  7011. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  7012. Screen *inst = (Screen*)lua_topointer(L, 1);
  7013. luaL_checktype(L, 2, LUA_TLIGHTUSERDATA);
  7014. ScreenEntity * entityToRemove = (ScreenEntity *)lua_topointer(L, 2);
  7015. void *ptrRetVal = (void*)inst->removeChild(entityToRemove);
  7016. if(ptrRetVal == NULL) {
  7017. lua_pushnil(L);
  7018. } else {
  7019. lua_pushlightuserdata(L, ptrRetVal);
  7020. }
  7021. return 1;
  7022. }
  7023. static int Polycore_Screen_setScreenOffset(lua_State *L) {
  7024. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  7025. Screen *inst = (Screen*)lua_topointer(L, 1);
  7026. luaL_checktype(L, 2, LUA_TNUMBER);
  7027. Number x = lua_tonumber(L, 2);
  7028. luaL_checktype(L, 3, LUA_TNUMBER);
  7029. Number y = lua_tonumber(L, 3);
  7030. inst->setScreenOffset(x, y);
  7031. return 0;
  7032. }
  7033. static int Polycore_Screen_getScreenOffset(lua_State *L) {
  7034. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  7035. Screen *inst = (Screen*)lua_topointer(L, 1);
  7036. Vector2 *retInst = new Vector2();
  7037. *retInst = inst->getScreenOffset();
  7038. lua_pushlightuserdata(L, retInst);
  7039. return 1;
  7040. }
  7041. static int Polycore_Screen_Shutdown(lua_State *L) {
  7042. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  7043. Screen *inst = (Screen*)lua_topointer(L, 1);
  7044. inst->Shutdown();
  7045. return 0;
  7046. }
  7047. static int Polycore_Screen_Update(lua_State *L) {
  7048. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  7049. Screen *inst = (Screen*)lua_topointer(L, 1);
  7050. inst->Update();
  7051. return 0;
  7052. }
  7053. static int Polycore_Screen_getEntityAt(lua_State *L) {
  7054. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  7055. Screen *inst = (Screen*)lua_topointer(L, 1);
  7056. luaL_checktype(L, 2, LUA_TNUMBER);
  7057. Number x = lua_tonumber(L, 2);
  7058. luaL_checktype(L, 3, LUA_TNUMBER);
  7059. Number y = lua_tonumber(L, 3);
  7060. void *ptrRetVal = (void*)inst->getEntityAt(x, y);
  7061. if(ptrRetVal == NULL) {
  7062. lua_pushnil(L);
  7063. } else {
  7064. lua_pushlightuserdata(L, ptrRetVal);
  7065. }
  7066. return 1;
  7067. }
  7068. static int Polycore_Screen_Render(lua_State *L) {
  7069. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  7070. Screen *inst = (Screen*)lua_topointer(L, 1);
  7071. inst->Render();
  7072. return 0;
  7073. }
  7074. static int Polycore_Screen_setRenderer(lua_State *L) {
  7075. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  7076. Screen *inst = (Screen*)lua_topointer(L, 1);
  7077. luaL_checktype(L, 2, LUA_TLIGHTUSERDATA);
  7078. Renderer * r_enderer = (Renderer *)lua_topointer(L, 2);
  7079. inst->setRenderer(r_enderer);
  7080. return 0;
  7081. }
  7082. static int Polycore_Screen_setNormalizedCoordinates(lua_State *L) {
  7083. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  7084. Screen *inst = (Screen*)lua_topointer(L, 1);
  7085. luaL_checktype(L, 2, LUA_TBOOLEAN);
  7086. bool newVal = lua_toboolean(L, 2);
  7087. Number yCoordinateSize;
  7088. if(lua_isnumber(L, 3)) {
  7089. yCoordinateSize = lua_tonumber(L, 3);
  7090. } else {
  7091. yCoordinateSize = 1.0f;
  7092. }
  7093. inst->setNormalizedCoordinates(newVal, yCoordinateSize);
  7094. return 0;
  7095. }
  7096. static int Polycore_Screen_setScreenShader(lua_State *L) {
  7097. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  7098. Screen *inst = (Screen*)lua_topointer(L, 1);
  7099. luaL_checktype(L, 2, LUA_TSTRING);
  7100. String shaderName = String(lua_tostring(L, 2));
  7101. inst->setScreenShader(shaderName);
  7102. return 0;
  7103. }
  7104. static int Polycore_Screen_clearScreenShader(lua_State *L) {
  7105. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  7106. Screen *inst = (Screen*)lua_topointer(L, 1);
  7107. inst->clearScreenShader();
  7108. return 0;
  7109. }
  7110. static int Polycore_Screen_getHighestZIndex(lua_State *L) {
  7111. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  7112. Screen *inst = (Screen*)lua_topointer(L, 1);
  7113. lua_pushinteger(L, inst->getHighestZIndex());
  7114. return 1;
  7115. }
  7116. static int Polycore_Screen_sortChildren(lua_State *L) {
  7117. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  7118. Screen *inst = (Screen*)lua_topointer(L, 1);
  7119. inst->sortChildren();
  7120. return 0;
  7121. }
  7122. static int Polycore_Screen_cmpZindex(lua_State *L) {
  7123. luaL_checktype(L, 2, LUA_TLIGHTUSERDATA);
  7124. const ScreenEntity * left = (const ScreenEntity *)lua_topointer(L, 2);
  7125. luaL_checktype(L, 3, LUA_TLIGHTUSERDATA);
  7126. const ScreenEntity * right = (const ScreenEntity *)lua_topointer(L, 3);
  7127. lua_pushboolean(L, Screen::cmpZindex(left, right));
  7128. return 1;
  7129. }
  7130. static int Polycore_Screen_handleInputEvent(lua_State *L) {
  7131. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  7132. Screen *inst = (Screen*)lua_topointer(L, 1);
  7133. luaL_checktype(L, 2, LUA_TLIGHTUSERDATA);
  7134. InputEvent * inputEvent = (InputEvent *)lua_topointer(L, 2);
  7135. inst->handleInputEvent(inputEvent);
  7136. return 0;
  7137. }
  7138. static int Polycore_Screen_hasFilterShader(lua_State *L) {
  7139. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  7140. Screen *inst = (Screen*)lua_topointer(L, 1);
  7141. lua_pushboolean(L, inst->hasFilterShader());
  7142. return 1;
  7143. }
  7144. static int Polycore_Screen_drawFilter(lua_State *L) {
  7145. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  7146. Screen *inst = (Screen*)lua_topointer(L, 1);
  7147. inst->drawFilter();
  7148. return 0;
  7149. }
  7150. static int Polycore_Screen_usesNormalizedCoordinates(lua_State *L) {
  7151. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  7152. Screen *inst = (Screen*)lua_topointer(L, 1);
  7153. lua_pushboolean(L, inst->usesNormalizedCoordinates());
  7154. return 1;
  7155. }
  7156. static int Polycore_Screen_getYCoordinateSize(lua_State *L) {
  7157. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  7158. Screen *inst = (Screen*)lua_topointer(L, 1);
  7159. lua_pushnumber(L, inst->getYCoordinateSize());
  7160. return 1;
  7161. }
  7162. static int Polycore_Screen_getRootEntity(lua_State *L) {
  7163. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  7164. Screen *inst = (Screen*)lua_topointer(L, 1);
  7165. void *ptrRetVal = (void*)inst->getRootEntity();
  7166. if(ptrRetVal == NULL) {
  7167. lua_pushnil(L);
  7168. } else {
  7169. lua_pushlightuserdata(L, ptrRetVal);
  7170. }
  7171. return 1;
  7172. }
  7173. static int Polycore_delete_Screen(lua_State *L) {
  7174. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  7175. Screen *inst = (Screen*)lua_topointer(L, 1);
  7176. delete inst;
  7177. return 0;
  7178. }
  7179. static int Polycore_ScreenCurve(lua_State *L) {
  7180. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  7181. BezierCurve * curve = (BezierCurve *)lua_topointer(L, 1);
  7182. luaL_checktype(L, 2, LUA_TNUMBER);
  7183. int numVertices = lua_tointeger(L, 2);
  7184. ScreenCurve *inst = new ScreenCurve(curve, numVertices);
  7185. lua_pushlightuserdata(L, (void*)inst);
  7186. return 1;
  7187. }
  7188. static int Polycore_delete_ScreenCurve(lua_State *L) {
  7189. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  7190. ScreenCurve *inst = (ScreenCurve*)lua_topointer(L, 1);
  7191. delete inst;
  7192. return 0;
  7193. }
  7194. static int Polycore_ScreenEntity_get_hasFocus(lua_State *L) {
  7195. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  7196. ScreenEntity *inst = (ScreenEntity*)lua_topointer(L, 1);
  7197. lua_pushboolean(L, inst->hasFocus);
  7198. return 1;
  7199. }
  7200. static int Polycore_ScreenEntity_get_blockMouseInput(lua_State *L) {
  7201. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  7202. ScreenEntity *inst = (ScreenEntity*)lua_topointer(L, 1);
  7203. lua_pushboolean(L, inst->blockMouseInput);
  7204. return 1;
  7205. }
  7206. static int Polycore_ScreenEntity_get_zindex(lua_State *L) {
  7207. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  7208. ScreenEntity *inst = (ScreenEntity*)lua_topointer(L, 1);
  7209. lua_pushinteger(L, inst->zindex);
  7210. return 1;
  7211. }
  7212. static int Polycore_ScreenEntity_get_snapToPixels(lua_State *L) {
  7213. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  7214. ScreenEntity *inst = (ScreenEntity*)lua_topointer(L, 1);
  7215. lua_pushboolean(L, inst->snapToPixels);
  7216. return 1;
  7217. }
  7218. static int Polycore_ScreenEntity_set_hasFocus(lua_State *L) {
  7219. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  7220. ScreenEntity *inst = (ScreenEntity*)lua_topointer(L, 1);
  7221. bool param = lua_toboolean(L, 2);
  7222. inst->hasFocus = param;
  7223. return 0;
  7224. }
  7225. static int Polycore_ScreenEntity_set_blockMouseInput(lua_State *L) {
  7226. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  7227. ScreenEntity *inst = (ScreenEntity*)lua_topointer(L, 1);
  7228. bool param = lua_toboolean(L, 2);
  7229. inst->blockMouseInput = param;
  7230. return 0;
  7231. }
  7232. static int Polycore_ScreenEntity_set_zindex(lua_State *L) {
  7233. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  7234. ScreenEntity *inst = (ScreenEntity*)lua_topointer(L, 1);
  7235. int param = lua_tointeger(L, 2);
  7236. inst->zindex = param;
  7237. return 0;
  7238. }
  7239. static int Polycore_ScreenEntity_set_snapToPixels(lua_State *L) {
  7240. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  7241. ScreenEntity *inst = (ScreenEntity*)lua_topointer(L, 1);
  7242. bool param = lua_toboolean(L, 2);
  7243. inst->snapToPixels = param;
  7244. return 0;
  7245. }
  7246. static int Polycore_ScreenEntity(lua_State *L) {
  7247. ScreenEntity *inst = new ScreenEntity();
  7248. lua_pushlightuserdata(L, (void*)inst);
  7249. return 1;
  7250. }
  7251. static int Polycore_ScreenEntity_setPosition(lua_State *L) {
  7252. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  7253. ScreenEntity *inst = (ScreenEntity*)lua_topointer(L, 1);
  7254. luaL_checktype(L, 2, LUA_TNUMBER);
  7255. Number x = lua_tonumber(L, 2);
  7256. luaL_checktype(L, 3, LUA_TNUMBER);
  7257. Number y = lua_tonumber(L, 3);
  7258. inst->setPosition(x, y);
  7259. return 0;
  7260. }
  7261. static int Polycore_ScreenEntity_setScale(lua_State *L) {
  7262. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  7263. ScreenEntity *inst = (ScreenEntity*)lua_topointer(L, 1);
  7264. luaL_checktype(L, 2, LUA_TNUMBER);
  7265. Number x = lua_tonumber(L, 2);
  7266. luaL_checktype(L, 3, LUA_TNUMBER);
  7267. Number y = lua_tonumber(L, 3);
  7268. inst->setScale(x, y);
  7269. return 0;
  7270. }
  7271. static int Polycore_ScreenEntity_setRotation(lua_State *L) {
  7272. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  7273. ScreenEntity *inst = (ScreenEntity*)lua_topointer(L, 1);
  7274. luaL_checktype(L, 2, LUA_TNUMBER);
  7275. Number roatation = lua_tonumber(L, 2);
  7276. inst->setRotation(roatation);
  7277. return 0;
  7278. }
  7279. static int Polycore_ScreenEntity_getRotation(lua_State *L) {
  7280. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  7281. ScreenEntity *inst = (ScreenEntity*)lua_topointer(L, 1);
  7282. lua_pushnumber(L, inst->getRotation());
  7283. return 1;
  7284. }
  7285. static int Polycore_ScreenEntity__onMouseDown(lua_State *L) {
  7286. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  7287. ScreenEntity *inst = (ScreenEntity*)lua_topointer(L, 1);
  7288. luaL_checktype(L, 2, LUA_TNUMBER);
  7289. Number x = lua_tonumber(L, 2);
  7290. luaL_checktype(L, 3, LUA_TNUMBER);
  7291. Number y = lua_tonumber(L, 3);
  7292. luaL_checktype(L, 4, LUA_TNUMBER);
  7293. int mouseButton = lua_tointeger(L, 4);
  7294. luaL_checktype(L, 5, LUA_TNUMBER);
  7295. int timestamp = lua_tointeger(L, 5);
  7296. lua_pushboolean(L, inst->_onMouseDown(x, y, mouseButton, timestamp));
  7297. return 1;
  7298. }
  7299. static int Polycore_ScreenEntity__onMouseUp(lua_State *L) {
  7300. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  7301. ScreenEntity *inst = (ScreenEntity*)lua_topointer(L, 1);
  7302. luaL_checktype(L, 2, LUA_TNUMBER);
  7303. Number x = lua_tonumber(L, 2);
  7304. luaL_checktype(L, 3, LUA_TNUMBER);
  7305. Number y = lua_tonumber(L, 3);
  7306. luaL_checktype(L, 4, LUA_TNUMBER);
  7307. int mouseButton = lua_tointeger(L, 4);
  7308. luaL_checktype(L, 5, LUA_TNUMBER);
  7309. int timestamp = lua_tointeger(L, 5);
  7310. lua_pushboolean(L, inst->_onMouseUp(x, y, mouseButton, timestamp));
  7311. return 1;
  7312. }
  7313. static int Polycore_ScreenEntity__onMouseMove(lua_State *L) {
  7314. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  7315. ScreenEntity *inst = (ScreenEntity*)lua_topointer(L, 1);
  7316. luaL_checktype(L, 2, LUA_TNUMBER);
  7317. Number x = lua_tonumber(L, 2);
  7318. luaL_checktype(L, 3, LUA_TNUMBER);
  7319. Number y = lua_tonumber(L, 3);
  7320. luaL_checktype(L, 4, LUA_TNUMBER);
  7321. int timestamp = lua_tointeger(L, 4);
  7322. inst->_onMouseMove(x, y, timestamp);
  7323. return 0;
  7324. }
  7325. static int Polycore_ScreenEntity__onMouseWheelUp(lua_State *L) {
  7326. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  7327. ScreenEntity *inst = (ScreenEntity*)lua_topointer(L, 1);
  7328. luaL_checktype(L, 2, LUA_TNUMBER);
  7329. Number x = lua_tonumber(L, 2);
  7330. luaL_checktype(L, 3, LUA_TNUMBER);
  7331. Number y = lua_tonumber(L, 3);
  7332. luaL_checktype(L, 4, LUA_TNUMBER);
  7333. int timestamp = lua_tointeger(L, 4);
  7334. inst->_onMouseWheelUp(x, y, timestamp);
  7335. return 0;
  7336. }
  7337. static int Polycore_ScreenEntity__onMouseWheelDown(lua_State *L) {
  7338. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  7339. ScreenEntity *inst = (ScreenEntity*)lua_topointer(L, 1);
  7340. luaL_checktype(L, 2, LUA_TNUMBER);
  7341. Number x = lua_tonumber(L, 2);
  7342. luaL_checktype(L, 3, LUA_TNUMBER);
  7343. Number y = lua_tonumber(L, 3);
  7344. luaL_checktype(L, 4, LUA_TNUMBER);
  7345. int timestamp = lua_tointeger(L, 4);
  7346. inst->_onMouseWheelDown(x, y, timestamp);
  7347. return 0;
  7348. }
  7349. static int Polycore_ScreenEntity_onMouseDown(lua_State *L) {
  7350. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  7351. ScreenEntity *inst = (ScreenEntity*)lua_topointer(L, 1);
  7352. luaL_checktype(L, 2, LUA_TNUMBER);
  7353. Number x = lua_tonumber(L, 2);
  7354. luaL_checktype(L, 3, LUA_TNUMBER);
  7355. Number y = lua_tonumber(L, 3);
  7356. inst->onMouseDown(x, y);
  7357. return 0;
  7358. }
  7359. static int Polycore_ScreenEntity_onMouseUp(lua_State *L) {
  7360. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  7361. ScreenEntity *inst = (ScreenEntity*)lua_topointer(L, 1);
  7362. luaL_checktype(L, 2, LUA_TNUMBER);
  7363. Number x = lua_tonumber(L, 2);
  7364. luaL_checktype(L, 3, LUA_TNUMBER);
  7365. Number y = lua_tonumber(L, 3);
  7366. inst->onMouseUp(x, y);
  7367. return 0;
  7368. }
  7369. static int Polycore_ScreenEntity_onMouseMove(lua_State *L) {
  7370. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  7371. ScreenEntity *inst = (ScreenEntity*)lua_topointer(L, 1);
  7372. luaL_checktype(L, 2, LUA_TNUMBER);
  7373. Number x = lua_tonumber(L, 2);
  7374. luaL_checktype(L, 3, LUA_TNUMBER);
  7375. Number y = lua_tonumber(L, 3);
  7376. inst->onMouseMove(x, y);
  7377. return 0;
  7378. }
  7379. static int Polycore_ScreenEntity_onMouseWheelUp(lua_State *L) {
  7380. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  7381. ScreenEntity *inst = (ScreenEntity*)lua_topointer(L, 1);
  7382. luaL_checktype(L, 2, LUA_TNUMBER);
  7383. Number x = lua_tonumber(L, 2);
  7384. luaL_checktype(L, 3, LUA_TNUMBER);
  7385. Number y = lua_tonumber(L, 3);
  7386. inst->onMouseWheelUp(x, y);
  7387. return 0;
  7388. }
  7389. static int Polycore_ScreenEntity_onMouseWheelDown(lua_State *L) {
  7390. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  7391. ScreenEntity *inst = (ScreenEntity*)lua_topointer(L, 1);
  7392. luaL_checktype(L, 2, LUA_TNUMBER);
  7393. Number x = lua_tonumber(L, 2);
  7394. luaL_checktype(L, 3, LUA_TNUMBER);
  7395. Number y = lua_tonumber(L, 3);
  7396. inst->onMouseWheelDown(x, y);
  7397. return 0;
  7398. }
  7399. static int Polycore_ScreenEntity__onKeyDown(lua_State *L) {
  7400. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  7401. ScreenEntity *inst = (ScreenEntity*)lua_topointer(L, 1);
  7402. luaL_checktype(L, 2, LUA_TLIGHTUSERDATA);
  7403. PolyKEY key = *(PolyKEY*)lua_topointer(L, 2);
  7404. luaL_checktype(L, 3, LUA_TLIGHTUSERDATA);
  7405. wchar_t charCode = *(wchar_t*)lua_topointer(L, 3);
  7406. inst->_onKeyDown(key, charCode);
  7407. return 0;
  7408. }
  7409. static int Polycore_ScreenEntity__onKeyUp(lua_State *L) {
  7410. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  7411. ScreenEntity *inst = (ScreenEntity*)lua_topointer(L, 1);
  7412. luaL_checktype(L, 2, LUA_TLIGHTUSERDATA);
  7413. PolyKEY key = *(PolyKEY*)lua_topointer(L, 2);
  7414. luaL_checktype(L, 3, LUA_TLIGHTUSERDATA);
  7415. wchar_t charCode = *(wchar_t*)lua_topointer(L, 3);
  7416. inst->_onKeyUp(key, charCode);
  7417. return 0;
  7418. }
  7419. static int Polycore_ScreenEntity_onKeyDown(lua_State *L) {
  7420. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  7421. ScreenEntity *inst = (ScreenEntity*)lua_topointer(L, 1);
  7422. luaL_checktype(L, 2, LUA_TLIGHTUSERDATA);
  7423. PolyKEY key = *(PolyKEY*)lua_topointer(L, 2);
  7424. luaL_checktype(L, 3, LUA_TLIGHTUSERDATA);
  7425. wchar_t charCode = *(wchar_t*)lua_topointer(L, 3);
  7426. inst->onKeyDown(key, charCode);
  7427. return 0;
  7428. }
  7429. static int Polycore_ScreenEntity_onKeyUp(lua_State *L) {
  7430. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  7431. ScreenEntity *inst = (ScreenEntity*)lua_topointer(L, 1);
  7432. luaL_checktype(L, 2, LUA_TLIGHTUSERDATA);
  7433. PolyKEY key = *(PolyKEY*)lua_topointer(L, 2);
  7434. luaL_checktype(L, 3, LUA_TLIGHTUSERDATA);
  7435. wchar_t charCode = *(wchar_t*)lua_topointer(L, 3);
  7436. inst->onKeyUp(key, charCode);
  7437. return 0;
  7438. }
  7439. static int Polycore_ScreenEntity_hitTest(lua_State *L) {
  7440. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  7441. ScreenEntity *inst = (ScreenEntity*)lua_topointer(L, 1);
  7442. luaL_checktype(L, 2, LUA_TNUMBER);
  7443. Number x = lua_tonumber(L, 2);
  7444. luaL_checktype(L, 3, LUA_TNUMBER);
  7445. Number y = lua_tonumber(L, 3);
  7446. lua_pushboolean(L, inst->hitTest(x, y));
  7447. return 1;
  7448. }
  7449. static int Polycore_ScreenEntity_buildPositionMatrix(lua_State *L) {
  7450. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  7451. ScreenEntity *inst = (ScreenEntity*)lua_topointer(L, 1);
  7452. Matrix4 *retInst = new Matrix4();
  7453. *retInst = inst->buildPositionMatrix();
  7454. lua_pushlightuserdata(L, retInst);
  7455. return 1;
  7456. }
  7457. static int Polycore_ScreenEntity_adjustMatrixForChildren(lua_State *L) {
  7458. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  7459. ScreenEntity *inst = (ScreenEntity*)lua_topointer(L, 1);
  7460. inst->adjustMatrixForChildren();
  7461. return 0;
  7462. }
  7463. static int Polycore_ScreenEntity_getWidth(lua_State *L) {
  7464. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  7465. ScreenEntity *inst = (ScreenEntity*)lua_topointer(L, 1);
  7466. lua_pushnumber(L, inst->getWidth());
  7467. return 1;
  7468. }
  7469. static int Polycore_ScreenEntity_getHeight(lua_State *L) {
  7470. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  7471. ScreenEntity *inst = (ScreenEntity*)lua_topointer(L, 1);
  7472. lua_pushnumber(L, inst->getHeight());
  7473. return 1;
  7474. }
  7475. static int Polycore_ScreenEntity_setWidth(lua_State *L) {
  7476. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  7477. ScreenEntity *inst = (ScreenEntity*)lua_topointer(L, 1);
  7478. luaL_checktype(L, 2, LUA_TNUMBER);
  7479. Number w = lua_tonumber(L, 2);
  7480. inst->setWidth(w);
  7481. return 0;
  7482. }
  7483. static int Polycore_ScreenEntity_setHeight(lua_State *L) {
  7484. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  7485. ScreenEntity *inst = (ScreenEntity*)lua_topointer(L, 1);
  7486. luaL_checktype(L, 2, LUA_TNUMBER);
  7487. Number h = lua_tonumber(L, 2);
  7488. inst->setHeight(h);
  7489. return 0;
  7490. }
  7491. static int Polycore_ScreenEntity_onGainFocus(lua_State *L) {
  7492. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  7493. ScreenEntity *inst = (ScreenEntity*)lua_topointer(L, 1);
  7494. inst->onGainFocus();
  7495. return 0;
  7496. }
  7497. static int Polycore_ScreenEntity_onLoseFocus(lua_State *L) {
  7498. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  7499. ScreenEntity *inst = (ScreenEntity*)lua_topointer(L, 1);
  7500. inst->onLoseFocus();
  7501. return 0;
  7502. }
  7503. static int Polycore_ScreenEntity_startDrag(lua_State *L) {
  7504. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  7505. ScreenEntity *inst = (ScreenEntity*)lua_topointer(L, 1);
  7506. luaL_checktype(L, 2, LUA_TNUMBER);
  7507. Number xOffset = lua_tonumber(L, 2);
  7508. luaL_checktype(L, 3, LUA_TNUMBER);
  7509. Number yOffset = lua_tonumber(L, 3);
  7510. inst->startDrag(xOffset, yOffset);
  7511. return 0;
  7512. }
  7513. static int Polycore_ScreenEntity_stopDrag(lua_State *L) {
  7514. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  7515. ScreenEntity *inst = (ScreenEntity*)lua_topointer(L, 1);
  7516. inst->stopDrag();
  7517. return 0;
  7518. }
  7519. static int Polycore_ScreenEntity_setBlendingMode(lua_State *L) {
  7520. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  7521. ScreenEntity *inst = (ScreenEntity*)lua_topointer(L, 1);
  7522. luaL_checktype(L, 2, LUA_TNUMBER);
  7523. int newBl_endingMode = lua_tointeger(L, 2);
  7524. inst->setBlendingMode(newBl_endingMode);
  7525. return 0;
  7526. }
  7527. static int Polycore_ScreenEntity_setPositionMode(lua_State *L) {
  7528. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  7529. ScreenEntity *inst = (ScreenEntity*)lua_topointer(L, 1);
  7530. luaL_checktype(L, 2, LUA_TNUMBER);
  7531. int newPositionMode = lua_tointeger(L, 2);
  7532. inst->setPositionMode(newPositionMode);
  7533. return 0;
  7534. }
  7535. static int Polycore_ScreenEntity_setDragLimits(lua_State *L) {
  7536. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  7537. ScreenEntity *inst = (ScreenEntity*)lua_topointer(L, 1);
  7538. luaL_checktype(L, 2, LUA_TLIGHTUSERDATA);
  7539. Polycode::Rectangle rect = *(Polycode::Rectangle*)lua_topointer(L, 2);
  7540. inst->setDragLimits(rect);
  7541. return 0;
  7542. }
  7543. static int Polycore_ScreenEntity_clearDragLimits(lua_State *L) {
  7544. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  7545. ScreenEntity *inst = (ScreenEntity*)lua_topointer(L, 1);
  7546. inst->clearDragLimits();
  7547. return 0;
  7548. }
  7549. static int Polycore_ScreenEntity_focusChild(lua_State *L) {
  7550. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  7551. ScreenEntity *inst = (ScreenEntity*)lua_topointer(L, 1);
  7552. luaL_checktype(L, 2, LUA_TLIGHTUSERDATA);
  7553. ScreenEntity * child = (ScreenEntity *)lua_topointer(L, 2);
  7554. inst->focusChild(child);
  7555. return 0;
  7556. }
  7557. static int Polycore_ScreenEntity_focusNextChild(lua_State *L) {
  7558. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  7559. ScreenEntity *inst = (ScreenEntity*)lua_topointer(L, 1);
  7560. inst->focusNextChild();
  7561. return 0;
  7562. }
  7563. static int Polycore_ScreenEntity_getPosition2D(lua_State *L) {
  7564. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  7565. ScreenEntity *inst = (ScreenEntity*)lua_topointer(L, 1);
  7566. Vector2 *retInst = new Vector2();
  7567. *retInst = inst->getPosition2D();
  7568. lua_pushlightuserdata(L, retInst);
  7569. return 1;
  7570. }
  7571. static int Polycore_ScreenEntity_isFocusable(lua_State *L) {
  7572. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  7573. ScreenEntity *inst = (ScreenEntity*)lua_topointer(L, 1);
  7574. lua_pushboolean(L, inst->isFocusable());
  7575. return 1;
  7576. }
  7577. static int Polycore_delete_ScreenEntity(lua_State *L) {
  7578. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  7579. ScreenEntity *inst = (ScreenEntity*)lua_topointer(L, 1);
  7580. delete inst;
  7581. return 0;
  7582. }
  7583. static int Polycore_ScreenEvent(lua_State *L) {
  7584. ScreenEvent *inst = new ScreenEvent();
  7585. lua_pushlightuserdata(L, (void*)inst);
  7586. return 1;
  7587. }
  7588. static int Polycore_delete_ScreenEvent(lua_State *L) {
  7589. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  7590. ScreenEvent *inst = (ScreenEvent*)lua_topointer(L, 1);
  7591. delete inst;
  7592. return 0;
  7593. }
  7594. static int Polycore_ScreenImage(lua_State *L) {
  7595. luaL_checktype(L, 1, LUA_TSTRING);
  7596. String fileName = String(lua_tostring(L, 1));
  7597. ScreenImage *inst = new ScreenImage(fileName);
  7598. lua_pushlightuserdata(L, (void*)inst);
  7599. return 1;
  7600. }
  7601. static int Polycore_ScreenImage_setImageCoordinates(lua_State *L) {
  7602. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  7603. ScreenImage *inst = (ScreenImage*)lua_topointer(L, 1);
  7604. luaL_checktype(L, 2, LUA_TNUMBER);
  7605. Number x = lua_tonumber(L, 2);
  7606. luaL_checktype(L, 3, LUA_TNUMBER);
  7607. Number y = lua_tonumber(L, 3);
  7608. luaL_checktype(L, 4, LUA_TNUMBER);
  7609. Number width = lua_tonumber(L, 4);
  7610. luaL_checktype(L, 5, LUA_TNUMBER);
  7611. Number height = lua_tonumber(L, 5);
  7612. inst->setImageCoordinates(x, y, width, height);
  7613. return 0;
  7614. }
  7615. static int Polycore_ScreenImage_getImageWidth(lua_State *L) {
  7616. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  7617. ScreenImage *inst = (ScreenImage*)lua_topointer(L, 1);
  7618. lua_pushnumber(L, inst->getImageWidth());
  7619. return 1;
  7620. }
  7621. static int Polycore_ScreenImage_getImageHeight(lua_State *L) {
  7622. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  7623. ScreenImage *inst = (ScreenImage*)lua_topointer(L, 1);
  7624. lua_pushnumber(L, inst->getImageHeight());
  7625. return 1;
  7626. }
  7627. static int Polycore_delete_ScreenImage(lua_State *L) {
  7628. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  7629. ScreenImage *inst = (ScreenImage*)lua_topointer(L, 1);
  7630. delete inst;
  7631. return 0;
  7632. }
  7633. static int Polycore_ScreenLabel(lua_State *L) {
  7634. luaL_checktype(L, 1, LUA_TSTRING);
  7635. String text = String(lua_tostring(L, 1));
  7636. luaL_checktype(L, 2, LUA_TNUMBER);
  7637. int size = lua_tointeger(L, 2);
  7638. String fontName;
  7639. if(lua_isstring(L, 3)) {
  7640. fontName = lua_tostring(L, 3);
  7641. } else {
  7642. fontName = "sans";
  7643. }
  7644. int amode;
  7645. if(lua_isnumber(L, 4)) {
  7646. amode = lua_tointeger(L, 4);
  7647. } else {
  7648. amode = 0;
  7649. }
  7650. ScreenLabel *inst = new ScreenLabel(text, size, fontName, amode);
  7651. lua_pushlightuserdata(L, (void*)inst);
  7652. return 1;
  7653. }
  7654. static int Polycore_ScreenLabel_addDropShadow(lua_State *L) {
  7655. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  7656. ScreenLabel *inst = (ScreenLabel*)lua_topointer(L, 1);
  7657. luaL_checktype(L, 2, LUA_TLIGHTUSERDATA);
  7658. Color color = *(Color*)lua_topointer(L, 2);
  7659. luaL_checktype(L, 3, LUA_TNUMBER);
  7660. Number size = lua_tonumber(L, 3);
  7661. luaL_checktype(L, 4, LUA_TNUMBER);
  7662. Number offsetX = lua_tonumber(L, 4);
  7663. luaL_checktype(L, 5, LUA_TNUMBER);
  7664. Number offsetY = lua_tonumber(L, 5);
  7665. inst->addDropShadow(color, size, offsetX, offsetY);
  7666. return 0;
  7667. }
  7668. static int Polycore_ScreenLabel_setText(lua_State *L) {
  7669. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  7670. ScreenLabel *inst = (ScreenLabel*)lua_topointer(L, 1);
  7671. luaL_checktype(L, 2, LUA_TSTRING);
  7672. String newText = String(lua_tostring(L, 2));
  7673. inst->setText(newText);
  7674. return 0;
  7675. }
  7676. static int Polycore_ScreenLabel_getText(lua_State *L) {
  7677. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  7678. ScreenLabel *inst = (ScreenLabel*)lua_topointer(L, 1);
  7679. lua_pushstring(L, inst->getText().c_str());
  7680. return 1;
  7681. }
  7682. static int Polycore_ScreenLabel_getLabel(lua_State *L) {
  7683. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  7684. ScreenLabel *inst = (ScreenLabel*)lua_topointer(L, 1);
  7685. void *ptrRetVal = (void*)inst->getLabel();
  7686. if(ptrRetVal == NULL) {
  7687. lua_pushnil(L);
  7688. } else {
  7689. lua_pushlightuserdata(L, ptrRetVal);
  7690. }
  7691. return 1;
  7692. }
  7693. static int Polycore_delete_ScreenLabel(lua_State *L) {
  7694. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  7695. ScreenLabel *inst = (ScreenLabel*)lua_topointer(L, 1);
  7696. delete inst;
  7697. return 0;
  7698. }
  7699. static int Polycore_ScreenLine(lua_State *L) {
  7700. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  7701. Vector2 * start = (Vector2 *)lua_topointer(L, 1);
  7702. luaL_checktype(L, 2, LUA_TLIGHTUSERDATA);
  7703. Vector2 * _end = (Vector2 *)lua_topointer(L, 2);
  7704. ScreenLine *inst = new ScreenLine(start, _end);
  7705. lua_pushlightuserdata(L, (void*)inst);
  7706. return 1;
  7707. }
  7708. static int Polycore_ScreenLine_Update(lua_State *L) {
  7709. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  7710. ScreenLine *inst = (ScreenLine*)lua_topointer(L, 1);
  7711. inst->Update();
  7712. return 0;
  7713. }
  7714. static int Polycore_ScreenLine_Render(lua_State *L) {
  7715. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  7716. ScreenLine *inst = (ScreenLine*)lua_topointer(L, 1);
  7717. inst->Render();
  7718. return 0;
  7719. }
  7720. static int Polycore_ScreenLine_setLineWidth(lua_State *L) {
  7721. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  7722. ScreenLine *inst = (ScreenLine*)lua_topointer(L, 1);
  7723. luaL_checktype(L, 2, LUA_TNUMBER);
  7724. Number width = lua_tonumber(L, 2);
  7725. inst->setLineWidth(width);
  7726. return 0;
  7727. }
  7728. static int Polycore_delete_ScreenLine(lua_State *L) {
  7729. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  7730. ScreenLine *inst = (ScreenLine*)lua_topointer(L, 1);
  7731. delete inst;
  7732. return 0;
  7733. }
  7734. static int Polycore_ScreenManager(lua_State *L) {
  7735. ScreenManager *inst = new ScreenManager();
  7736. lua_pushlightuserdata(L, (void*)inst);
  7737. return 1;
  7738. }
  7739. static int Polycore_ScreenManager_removeScreen(lua_State *L) {
  7740. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  7741. ScreenManager *inst = (ScreenManager*)lua_topointer(L, 1);
  7742. luaL_checktype(L, 2, LUA_TLIGHTUSERDATA);
  7743. Screen * screen = (Screen *)lua_topointer(L, 2);
  7744. inst->removeScreen(screen);
  7745. return 0;
  7746. }
  7747. static int Polycore_ScreenManager_addScreen(lua_State *L) {
  7748. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  7749. ScreenManager *inst = (ScreenManager*)lua_topointer(L, 1);
  7750. luaL_checktype(L, 2, LUA_TLIGHTUSERDATA);
  7751. Screen * screen = (Screen *)lua_topointer(L, 2);
  7752. inst->addScreen(screen);
  7753. return 0;
  7754. }
  7755. static int Polycore_ScreenManager_Update(lua_State *L) {
  7756. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  7757. ScreenManager *inst = (ScreenManager*)lua_topointer(L, 1);
  7758. inst->Update();
  7759. return 0;
  7760. }
  7761. static int Polycore_delete_ScreenManager(lua_State *L) {
  7762. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  7763. ScreenManager *inst = (ScreenManager*)lua_topointer(L, 1);
  7764. delete inst;
  7765. return 0;
  7766. }
  7767. static int Polycore_ScreenMesh(lua_State *L) {
  7768. luaL_checktype(L, 1, LUA_TSTRING);
  7769. String fileName = String(lua_tostring(L, 1));
  7770. ScreenMesh *inst = new ScreenMesh(fileName);
  7771. lua_pushlightuserdata(L, (void*)inst);
  7772. return 1;
  7773. }
  7774. static int Polycore_ScreenMesh_Render(lua_State *L) {
  7775. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  7776. ScreenMesh *inst = (ScreenMesh*)lua_topointer(L, 1);
  7777. inst->Render();
  7778. return 0;
  7779. }
  7780. static int Polycore_ScreenMesh_getMesh(lua_State *L) {
  7781. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  7782. ScreenMesh *inst = (ScreenMesh*)lua_topointer(L, 1);
  7783. void *ptrRetVal = (void*)inst->getMesh();
  7784. if(ptrRetVal == NULL) {
  7785. lua_pushnil(L);
  7786. } else {
  7787. lua_pushlightuserdata(L, ptrRetVal);
  7788. }
  7789. return 1;
  7790. }
  7791. static int Polycore_ScreenMesh_getTexture(lua_State *L) {
  7792. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  7793. ScreenMesh *inst = (ScreenMesh*)lua_topointer(L, 1);
  7794. void *ptrRetVal = (void*)inst->getTexture();
  7795. if(ptrRetVal == NULL) {
  7796. lua_pushnil(L);
  7797. } else {
  7798. lua_pushlightuserdata(L, ptrRetVal);
  7799. }
  7800. return 1;
  7801. }
  7802. static int Polycore_ScreenMesh_loadTexture(lua_State *L) {
  7803. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  7804. ScreenMesh *inst = (ScreenMesh*)lua_topointer(L, 1);
  7805. luaL_checktype(L, 2, LUA_TSTRING);
  7806. String fileName = String(lua_tostring(L, 2));
  7807. inst->loadTexture(fileName);
  7808. return 0;
  7809. }
  7810. static int Polycore_ScreenMesh_setTexture(lua_State *L) {
  7811. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  7812. ScreenMesh *inst = (ScreenMesh*)lua_topointer(L, 1);
  7813. luaL_checktype(L, 2, LUA_TLIGHTUSERDATA);
  7814. Texture * texture = (Texture *)lua_topointer(L, 2);
  7815. inst->setTexture(texture);
  7816. return 0;
  7817. }
  7818. static int Polycore_delete_ScreenMesh(lua_State *L) {
  7819. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  7820. ScreenMesh *inst = (ScreenMesh*)lua_topointer(L, 1);
  7821. delete inst;
  7822. return 0;
  7823. }
  7824. static int Polycore_ScreenShape_get_strokeEnabled(lua_State *L) {
  7825. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  7826. ScreenShape *inst = (ScreenShape*)lua_topointer(L, 1);
  7827. lua_pushboolean(L, inst->strokeEnabled);
  7828. return 1;
  7829. }
  7830. static int Polycore_ScreenShape_get_strokeColor(lua_State *L) {
  7831. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  7832. ScreenShape *inst = (ScreenShape*)lua_topointer(L, 1);
  7833. lua_pushlightuserdata(L, &inst->strokeColor);
  7834. return 1;
  7835. }
  7836. static int Polycore_ScreenShape_get_lineSmooth(lua_State *L) {
  7837. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  7838. ScreenShape *inst = (ScreenShape*)lua_topointer(L, 1);
  7839. lua_pushboolean(L, inst->lineSmooth);
  7840. return 1;
  7841. }
  7842. static int Polycore_ScreenShape_set_strokeEnabled(lua_State *L) {
  7843. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  7844. ScreenShape *inst = (ScreenShape*)lua_topointer(L, 1);
  7845. bool param = lua_toboolean(L, 2);
  7846. inst->strokeEnabled = param;
  7847. return 0;
  7848. }
  7849. static int Polycore_ScreenShape_set_lineSmooth(lua_State *L) {
  7850. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  7851. ScreenShape *inst = (ScreenShape*)lua_topointer(L, 1);
  7852. bool param = lua_toboolean(L, 2);
  7853. inst->lineSmooth = param;
  7854. return 0;
  7855. }
  7856. static int Polycore_ScreenShape(lua_State *L) {
  7857. luaL_checktype(L, 1, LUA_TNUMBER);
  7858. int shapeType = lua_tointeger(L, 1);
  7859. Number option1;
  7860. if(lua_isnumber(L, 2)) {
  7861. option1 = lua_tonumber(L, 2);
  7862. } else {
  7863. option1 = 0;
  7864. }
  7865. Number option2;
  7866. if(lua_isnumber(L, 3)) {
  7867. option2 = lua_tonumber(L, 3);
  7868. } else {
  7869. option2 = 0;
  7870. }
  7871. Number option3;
  7872. if(lua_isnumber(L, 4)) {
  7873. option3 = lua_tonumber(L, 4);
  7874. } else {
  7875. option3 = 0;
  7876. }
  7877. Number option4;
  7878. if(lua_isnumber(L, 5)) {
  7879. option4 = lua_tonumber(L, 5);
  7880. } else {
  7881. option4 = 0;
  7882. }
  7883. ScreenShape *inst = new ScreenShape(shapeType, option1, option2, option3, option4);
  7884. lua_pushlightuserdata(L, (void*)inst);
  7885. return 1;
  7886. }
  7887. static int Polycore_ScreenShape_Render(lua_State *L) {
  7888. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  7889. ScreenShape *inst = (ScreenShape*)lua_topointer(L, 1);
  7890. inst->Render();
  7891. return 0;
  7892. }
  7893. static int Polycore_ScreenShape_setStrokeColor(lua_State *L) {
  7894. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  7895. ScreenShape *inst = (ScreenShape*)lua_topointer(L, 1);
  7896. luaL_checktype(L, 2, LUA_TNUMBER);
  7897. Number r = lua_tonumber(L, 2);
  7898. luaL_checktype(L, 3, LUA_TNUMBER);
  7899. Number g = lua_tonumber(L, 3);
  7900. luaL_checktype(L, 4, LUA_TNUMBER);
  7901. Number b = lua_tonumber(L, 4);
  7902. luaL_checktype(L, 5, LUA_TNUMBER);
  7903. Number a = lua_tonumber(L, 5);
  7904. inst->setStrokeColor(r, g, b, a);
  7905. return 0;
  7906. }
  7907. static int Polycore_ScreenShape_setStrokeWidth(lua_State *L) {
  7908. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  7909. ScreenShape *inst = (ScreenShape*)lua_topointer(L, 1);
  7910. luaL_checktype(L, 2, LUA_TNUMBER);
  7911. Number width = lua_tonumber(L, 2);
  7912. inst->setStrokeWidth(width);
  7913. return 0;
  7914. }
  7915. static int Polycore_ScreenShape_setGradient(lua_State *L) {
  7916. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  7917. ScreenShape *inst = (ScreenShape*)lua_topointer(L, 1);
  7918. luaL_checktype(L, 2, LUA_TNUMBER);
  7919. Number r1 = lua_tonumber(L, 2);
  7920. luaL_checktype(L, 3, LUA_TNUMBER);
  7921. Number g1 = lua_tonumber(L, 3);
  7922. luaL_checktype(L, 4, LUA_TNUMBER);
  7923. Number b1 = lua_tonumber(L, 4);
  7924. luaL_checktype(L, 5, LUA_TNUMBER);
  7925. Number a1 = lua_tonumber(L, 5);
  7926. luaL_checktype(L, 6, LUA_TNUMBER);
  7927. Number r2 = lua_tonumber(L, 6);
  7928. luaL_checktype(L, 7, LUA_TNUMBER);
  7929. Number g2 = lua_tonumber(L, 7);
  7930. luaL_checktype(L, 8, LUA_TNUMBER);
  7931. Number b2 = lua_tonumber(L, 8);
  7932. luaL_checktype(L, 9, LUA_TNUMBER);
  7933. Number a2 = lua_tonumber(L, 9);
  7934. inst->setGradient(r1, g1, b1, a1, r2, g2, b2, a2);
  7935. return 0;
  7936. }
  7937. static int Polycore_ScreenShape_clearGradient(lua_State *L) {
  7938. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  7939. ScreenShape *inst = (ScreenShape*)lua_topointer(L, 1);
  7940. inst->clearGradient();
  7941. return 0;
  7942. }
  7943. static int Polycore_ScreenShape_setShapeSize(lua_State *L) {
  7944. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  7945. ScreenShape *inst = (ScreenShape*)lua_topointer(L, 1);
  7946. luaL_checktype(L, 2, LUA_TNUMBER);
  7947. Number newWidth = lua_tonumber(L, 2);
  7948. luaL_checktype(L, 3, LUA_TNUMBER);
  7949. Number newHeight = lua_tonumber(L, 3);
  7950. inst->setShapeSize(newWidth, newHeight);
  7951. return 0;
  7952. }
  7953. static int Polycore_ScreenShape_addShapePoint(lua_State *L) {
  7954. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  7955. ScreenShape *inst = (ScreenShape*)lua_topointer(L, 1);
  7956. luaL_checktype(L, 2, LUA_TNUMBER);
  7957. Number x = lua_tonumber(L, 2);
  7958. luaL_checktype(L, 3, LUA_TNUMBER);
  7959. Number y = lua_tonumber(L, 3);
  7960. inst->addShapePoint(x, y);
  7961. return 0;
  7962. }
  7963. static int Polycore_delete_ScreenShape(lua_State *L) {
  7964. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  7965. ScreenShape *inst = (ScreenShape*)lua_topointer(L, 1);
  7966. delete inst;
  7967. return 0;
  7968. }
  7969. static int Polycore_ScreenSoundListener(lua_State *L) {
  7970. ScreenSoundListener *inst = new ScreenSoundListener();
  7971. lua_pushlightuserdata(L, (void*)inst);
  7972. return 1;
  7973. }
  7974. static int Polycore_ScreenSoundListener_Update(lua_State *L) {
  7975. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  7976. ScreenSoundListener *inst = (ScreenSoundListener*)lua_topointer(L, 1);
  7977. inst->Update();
  7978. return 0;
  7979. }
  7980. static int Polycore_delete_ScreenSoundListener(lua_State *L) {
  7981. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  7982. ScreenSoundListener *inst = (ScreenSoundListener*)lua_topointer(L, 1);
  7983. delete inst;
  7984. return 0;
  7985. }
  7986. static int Polycore_ScreenSound(lua_State *L) {
  7987. luaL_checktype(L, 1, LUA_TSTRING);
  7988. String fileName = String(lua_tostring(L, 1));
  7989. luaL_checktype(L, 2, LUA_TNUMBER);
  7990. Number referenceDistance = lua_tonumber(L, 2);
  7991. luaL_checktype(L, 3, LUA_TNUMBER);
  7992. Number maxDistance = lua_tonumber(L, 3);
  7993. ScreenSound *inst = new ScreenSound(fileName, referenceDistance, maxDistance);
  7994. lua_pushlightuserdata(L, (void*)inst);
  7995. return 1;
  7996. }
  7997. static int Polycore_ScreenSound_Update(lua_State *L) {
  7998. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  7999. ScreenSound *inst = (ScreenSound*)lua_topointer(L, 1);
  8000. inst->Update();
  8001. return 0;
  8002. }
  8003. static int Polycore_ScreenSound_getSound(lua_State *L) {
  8004. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  8005. ScreenSound *inst = (ScreenSound*)lua_topointer(L, 1);
  8006. void *ptrRetVal = (void*)inst->getSound();
  8007. if(ptrRetVal == NULL) {
  8008. lua_pushnil(L);
  8009. } else {
  8010. lua_pushlightuserdata(L, ptrRetVal);
  8011. }
  8012. return 1;
  8013. }
  8014. static int Polycore_delete_ScreenSound(lua_State *L) {
  8015. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  8016. ScreenSound *inst = (ScreenSound*)lua_topointer(L, 1);
  8017. delete inst;
  8018. return 0;
  8019. }
  8020. static int Polycore_ScreenSprite(lua_State *L) {
  8021. luaL_checktype(L, 1, LUA_TSTRING);
  8022. String fileName = String(lua_tostring(L, 1));
  8023. luaL_checktype(L, 2, LUA_TNUMBER);
  8024. Number spriteWidth = lua_tonumber(L, 2);
  8025. luaL_checktype(L, 3, LUA_TNUMBER);
  8026. Number spriteHeight = lua_tonumber(L, 3);
  8027. ScreenSprite *inst = new ScreenSprite(fileName, spriteWidth, spriteHeight);
  8028. lua_pushlightuserdata(L, (void*)inst);
  8029. return 1;
  8030. }
  8031. static int Polycore_ScreenSprite_addAnimation(lua_State *L) {
  8032. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  8033. ScreenSprite *inst = (ScreenSprite*)lua_topointer(L, 1);
  8034. luaL_checktype(L, 2, LUA_TSTRING);
  8035. String name = String(lua_tostring(L, 2));
  8036. luaL_checktype(L, 3, LUA_TSTRING);
  8037. String frames = String(lua_tostring(L, 3));
  8038. luaL_checktype(L, 4, LUA_TNUMBER);
  8039. Number speed = lua_tonumber(L, 4);
  8040. inst->addAnimation(name, frames, speed);
  8041. return 0;
  8042. }
  8043. static int Polycore_ScreenSprite_playAnimation(lua_State *L) {
  8044. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  8045. ScreenSprite *inst = (ScreenSprite*)lua_topointer(L, 1);
  8046. luaL_checktype(L, 2, LUA_TSTRING);
  8047. String name = String(lua_tostring(L, 2));
  8048. luaL_checktype(L, 3, LUA_TNUMBER);
  8049. int startFrame = lua_tointeger(L, 3);
  8050. luaL_checktype(L, 4, LUA_TBOOLEAN);
  8051. bool once = lua_toboolean(L, 4);
  8052. inst->playAnimation(name, startFrame, once);
  8053. return 0;
  8054. }
  8055. static int Polycore_ScreenSprite_Update(lua_State *L) {
  8056. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  8057. ScreenSprite *inst = (ScreenSprite*)lua_topointer(L, 1);
  8058. inst->Update();
  8059. return 0;
  8060. }
  8061. static int Polycore_delete_ScreenSprite(lua_State *L) {
  8062. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  8063. ScreenSprite *inst = (ScreenSprite*)lua_topointer(L, 1);
  8064. delete inst;
  8065. return 0;
  8066. }
  8067. static int Polycore_Shader_get_numSpotLights(lua_State *L) {
  8068. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  8069. Shader *inst = (Shader*)lua_topointer(L, 1);
  8070. lua_pushinteger(L, inst->numSpotLights);
  8071. return 1;
  8072. }
  8073. static int Polycore_Shader_get_numAreaLights(lua_State *L) {
  8074. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  8075. Shader *inst = (Shader*)lua_topointer(L, 1);
  8076. lua_pushinteger(L, inst->numAreaLights);
  8077. return 1;
  8078. }
  8079. static int Polycore_Shader_set_numSpotLights(lua_State *L) {
  8080. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  8081. Shader *inst = (Shader*)lua_topointer(L, 1);
  8082. int param = lua_tointeger(L, 2);
  8083. inst->numSpotLights = param;
  8084. return 0;
  8085. }
  8086. static int Polycore_Shader_set_numAreaLights(lua_State *L) {
  8087. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  8088. Shader *inst = (Shader*)lua_topointer(L, 1);
  8089. int param = lua_tointeger(L, 2);
  8090. inst->numAreaLights = param;
  8091. return 0;
  8092. }
  8093. static int Polycore_Shader_getType(lua_State *L) {
  8094. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  8095. Shader *inst = (Shader*)lua_topointer(L, 1);
  8096. lua_pushinteger(L, inst->getType());
  8097. return 1;
  8098. }
  8099. static int Polycore_Shader_setName(lua_State *L) {
  8100. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  8101. Shader *inst = (Shader*)lua_topointer(L, 1);
  8102. luaL_checktype(L, 2, LUA_TSTRING);
  8103. String name = String(lua_tostring(L, 2));
  8104. inst->setName(name);
  8105. return 0;
  8106. }
  8107. static int Polycore_Shader_getName(lua_State *L) {
  8108. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  8109. Shader *inst = (Shader*)lua_topointer(L, 1);
  8110. lua_pushstring(L, inst->getName().c_str());
  8111. return 1;
  8112. }
  8113. static int Polycore_Shader_createBinding(lua_State *L) {
  8114. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  8115. Shader *inst = (Shader*)lua_topointer(L, 1);
  8116. void *ptrRetVal = (void*)inst->createBinding();
  8117. if(ptrRetVal == NULL) {
  8118. lua_pushnil(L);
  8119. } else {
  8120. lua_pushlightuserdata(L, ptrRetVal);
  8121. }
  8122. return 1;
  8123. }
  8124. static int Polycore_delete_Shader(lua_State *L) {
  8125. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  8126. Shader *inst = (Shader*)lua_topointer(L, 1);
  8127. delete inst;
  8128. return 0;
  8129. }
  8130. static int Polycore_ShaderBinding(lua_State *L) {
  8131. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  8132. Shader * shader = (Shader *)lua_topointer(L, 1);
  8133. ShaderBinding *inst = new ShaderBinding(shader);
  8134. lua_pushlightuserdata(L, (void*)inst);
  8135. return 1;
  8136. }
  8137. static int Polycore_ShaderBinding_clearTexture(lua_State *L) {
  8138. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  8139. ShaderBinding *inst = (ShaderBinding*)lua_topointer(L, 1);
  8140. luaL_checktype(L, 2, LUA_TSTRING);
  8141. String name = String(lua_tostring(L, 2));
  8142. inst->clearTexture(name);
  8143. return 0;
  8144. }
  8145. static int Polycore_ShaderBinding_addTexture(lua_State *L) {
  8146. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  8147. ShaderBinding *inst = (ShaderBinding*)lua_topointer(L, 1);
  8148. luaL_checktype(L, 2, LUA_TSTRING);
  8149. String name = String(lua_tostring(L, 2));
  8150. luaL_checktype(L, 3, LUA_TLIGHTUSERDATA);
  8151. Texture * texture = (Texture *)lua_topointer(L, 3);
  8152. inst->addTexture(name, texture);
  8153. return 0;
  8154. }
  8155. static int Polycore_ShaderBinding_addParam(lua_State *L) {
  8156. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  8157. ShaderBinding *inst = (ShaderBinding*)lua_topointer(L, 1);
  8158. luaL_checktype(L, 2, LUA_TSTRING);
  8159. String type = String(lua_tostring(L, 2));
  8160. luaL_checktype(L, 3, LUA_TSTRING);
  8161. String name = String(lua_tostring(L, 3));
  8162. luaL_checktype(L, 4, LUA_TSTRING);
  8163. String value = String(lua_tostring(L, 4));
  8164. inst->addParam(type, name, value);
  8165. return 0;
  8166. }
  8167. static int Polycore_ShaderBinding_addCubemap(lua_State *L) {
  8168. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  8169. ShaderBinding *inst = (ShaderBinding*)lua_topointer(L, 1);
  8170. luaL_checktype(L, 2, LUA_TSTRING);
  8171. String name = String(lua_tostring(L, 2));
  8172. luaL_checktype(L, 3, LUA_TLIGHTUSERDATA);
  8173. Cubemap * cubemap = (Cubemap *)lua_topointer(L, 3);
  8174. inst->addCubemap(name, cubemap);
  8175. return 0;
  8176. }
  8177. static int Polycore_ShaderBinding_getNumLocalParams(lua_State *L) {
  8178. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  8179. ShaderBinding *inst = (ShaderBinding*)lua_topointer(L, 1);
  8180. lua_pushinteger(L, inst->getNumLocalParams());
  8181. return 1;
  8182. }
  8183. static int Polycore_ShaderBinding_getLocalParam(lua_State *L) {
  8184. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  8185. ShaderBinding *inst = (ShaderBinding*)lua_topointer(L, 1);
  8186. luaL_checktype(L, 2, LUA_TNUMBER);
  8187. unsigned int index = lua_tointeger(L, 2);
  8188. void *ptrRetVal = (void*)inst->getLocalParam(index);
  8189. if(ptrRetVal == NULL) {
  8190. lua_pushnil(L);
  8191. } else {
  8192. lua_pushlightuserdata(L, ptrRetVal);
  8193. }
  8194. return 1;
  8195. }
  8196. static int Polycore_ShaderBinding_getLocalParamByName(lua_State *L) {
  8197. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  8198. ShaderBinding *inst = (ShaderBinding*)lua_topointer(L, 1);
  8199. luaL_checktype(L, 2, LUA_TSTRING);
  8200. String name = String(lua_tostring(L, 2));
  8201. void *ptrRetVal = (void*)inst->getLocalParamByName(name);
  8202. if(ptrRetVal == NULL) {
  8203. lua_pushnil(L);
  8204. } else {
  8205. lua_pushlightuserdata(L, ptrRetVal);
  8206. }
  8207. return 1;
  8208. }
  8209. static int Polycore_ShaderBinding_addRenderTargetBinding(lua_State *L) {
  8210. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  8211. ShaderBinding *inst = (ShaderBinding*)lua_topointer(L, 1);
  8212. luaL_checktype(L, 2, LUA_TLIGHTUSERDATA);
  8213. RenderTargetBinding * binding = (RenderTargetBinding *)lua_topointer(L, 2);
  8214. inst->addRenderTargetBinding(binding);
  8215. return 0;
  8216. }
  8217. static int Polycore_ShaderBinding_getNumRenderTargetBindings(lua_State *L) {
  8218. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  8219. ShaderBinding *inst = (ShaderBinding*)lua_topointer(L, 1);
  8220. lua_pushinteger(L, inst->getNumRenderTargetBindings());
  8221. return 1;
  8222. }
  8223. static int Polycore_ShaderBinding_getRenderTargetBinding(lua_State *L) {
  8224. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  8225. ShaderBinding *inst = (ShaderBinding*)lua_topointer(L, 1);
  8226. luaL_checktype(L, 2, LUA_TNUMBER);
  8227. unsigned int index = lua_tointeger(L, 2);
  8228. void *ptrRetVal = (void*)inst->getRenderTargetBinding(index);
  8229. if(ptrRetVal == NULL) {
  8230. lua_pushnil(L);
  8231. } else {
  8232. lua_pushlightuserdata(L, ptrRetVal);
  8233. }
  8234. return 1;
  8235. }
  8236. static int Polycore_ShaderBinding_getNumInTargetBindings(lua_State *L) {
  8237. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  8238. ShaderBinding *inst = (ShaderBinding*)lua_topointer(L, 1);
  8239. lua_pushinteger(L, inst->getNumInTargetBindings());
  8240. return 1;
  8241. }
  8242. static int Polycore_ShaderBinding_getInTargetBinding(lua_State *L) {
  8243. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  8244. ShaderBinding *inst = (ShaderBinding*)lua_topointer(L, 1);
  8245. luaL_checktype(L, 2, LUA_TNUMBER);
  8246. unsigned int index = lua_tointeger(L, 2);
  8247. void *ptrRetVal = (void*)inst->getInTargetBinding(index);
  8248. if(ptrRetVal == NULL) {
  8249. lua_pushnil(L);
  8250. } else {
  8251. lua_pushlightuserdata(L, ptrRetVal);
  8252. }
  8253. return 1;
  8254. }
  8255. static int Polycore_ShaderBinding_getNumOutTargetBindings(lua_State *L) {
  8256. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  8257. ShaderBinding *inst = (ShaderBinding*)lua_topointer(L, 1);
  8258. lua_pushinteger(L, inst->getNumOutTargetBindings());
  8259. return 1;
  8260. }
  8261. static int Polycore_ShaderBinding_getOutTargetBinding(lua_State *L) {
  8262. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  8263. ShaderBinding *inst = (ShaderBinding*)lua_topointer(L, 1);
  8264. luaL_checktype(L, 2, LUA_TNUMBER);
  8265. unsigned int index = lua_tointeger(L, 2);
  8266. void *ptrRetVal = (void*)inst->getOutTargetBinding(index);
  8267. if(ptrRetVal == NULL) {
  8268. lua_pushnil(L);
  8269. } else {
  8270. lua_pushlightuserdata(L, ptrRetVal);
  8271. }
  8272. return 1;
  8273. }
  8274. static int Polycore_delete_ShaderBinding(lua_State *L) {
  8275. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  8276. ShaderBinding *inst = (ShaderBinding*)lua_topointer(L, 1);
  8277. delete inst;
  8278. return 0;
  8279. }
  8280. static int Polycore_SkeletonAnimation(lua_State *L) {
  8281. luaL_checktype(L, 1, LUA_TSTRING);
  8282. String name = String(lua_tostring(L, 1));
  8283. luaL_checktype(L, 2, LUA_TNUMBER);
  8284. Number duration = lua_tonumber(L, 2);
  8285. SkeletonAnimation *inst = new SkeletonAnimation(name, duration);
  8286. lua_pushlightuserdata(L, (void*)inst);
  8287. return 1;
  8288. }
  8289. static int Polycore_SkeletonAnimation_addBoneTrack(lua_State *L) {
  8290. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  8291. SkeletonAnimation *inst = (SkeletonAnimation*)lua_topointer(L, 1);
  8292. luaL_checktype(L, 2, LUA_TLIGHTUSERDATA);
  8293. BoneTrack * boneTrack = (BoneTrack *)lua_topointer(L, 2);
  8294. inst->addBoneTrack(boneTrack);
  8295. return 0;
  8296. }
  8297. static int Polycore_SkeletonAnimation_getName(lua_State *L) {
  8298. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  8299. SkeletonAnimation *inst = (SkeletonAnimation*)lua_topointer(L, 1);
  8300. lua_pushstring(L, inst->getName().c_str());
  8301. return 1;
  8302. }
  8303. static int Polycore_SkeletonAnimation_Play(lua_State *L) {
  8304. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  8305. SkeletonAnimation *inst = (SkeletonAnimation*)lua_topointer(L, 1);
  8306. inst->Play();
  8307. return 0;
  8308. }
  8309. static int Polycore_SkeletonAnimation_Stop(lua_State *L) {
  8310. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  8311. SkeletonAnimation *inst = (SkeletonAnimation*)lua_topointer(L, 1);
  8312. inst->Stop();
  8313. return 0;
  8314. }
  8315. static int Polycore_SkeletonAnimation_Update(lua_State *L) {
  8316. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  8317. SkeletonAnimation *inst = (SkeletonAnimation*)lua_topointer(L, 1);
  8318. inst->Update();
  8319. return 0;
  8320. }
  8321. static int Polycore_SkeletonAnimation_setSpeed(lua_State *L) {
  8322. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  8323. SkeletonAnimation *inst = (SkeletonAnimation*)lua_topointer(L, 1);
  8324. luaL_checktype(L, 2, LUA_TNUMBER);
  8325. Number speed = lua_tonumber(L, 2);
  8326. inst->setSpeed(speed);
  8327. return 0;
  8328. }
  8329. static int Polycore_delete_SkeletonAnimation(lua_State *L) {
  8330. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  8331. SkeletonAnimation *inst = (SkeletonAnimation*)lua_topointer(L, 1);
  8332. delete inst;
  8333. return 0;
  8334. }
  8335. static int Polycore_BoneTrack_get_LocXVec(lua_State *L) {
  8336. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  8337. BoneTrack *inst = (BoneTrack*)lua_topointer(L, 1);
  8338. lua_pushlightuserdata(L, &inst->LocXVec);
  8339. return 1;
  8340. }
  8341. static int Polycore_BoneTrack_get_LocYVec(lua_State *L) {
  8342. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  8343. BoneTrack *inst = (BoneTrack*)lua_topointer(L, 1);
  8344. lua_pushlightuserdata(L, &inst->LocYVec);
  8345. return 1;
  8346. }
  8347. static int Polycore_BoneTrack_get_LocZVec(lua_State *L) {
  8348. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  8349. BoneTrack *inst = (BoneTrack*)lua_topointer(L, 1);
  8350. lua_pushlightuserdata(L, &inst->LocZVec);
  8351. return 1;
  8352. }
  8353. static int Polycore_BoneTrack_get_ScaleXVec(lua_State *L) {
  8354. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  8355. BoneTrack *inst = (BoneTrack*)lua_topointer(L, 1);
  8356. lua_pushlightuserdata(L, &inst->ScaleXVec);
  8357. return 1;
  8358. }
  8359. static int Polycore_BoneTrack_get_ScaleYVec(lua_State *L) {
  8360. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  8361. BoneTrack *inst = (BoneTrack*)lua_topointer(L, 1);
  8362. lua_pushlightuserdata(L, &inst->ScaleYVec);
  8363. return 1;
  8364. }
  8365. static int Polycore_BoneTrack_get_ScaleZVec(lua_State *L) {
  8366. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  8367. BoneTrack *inst = (BoneTrack*)lua_topointer(L, 1);
  8368. lua_pushlightuserdata(L, &inst->ScaleZVec);
  8369. return 1;
  8370. }
  8371. static int Polycore_BoneTrack_get_boneQuat(lua_State *L) {
  8372. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  8373. BoneTrack *inst = (BoneTrack*)lua_topointer(L, 1);
  8374. lua_pushlightuserdata(L, &inst->boneQuat);
  8375. return 1;
  8376. }
  8377. static int Polycore_BoneTrack_get_QuatWVec(lua_State *L) {
  8378. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  8379. BoneTrack *inst = (BoneTrack*)lua_topointer(L, 1);
  8380. lua_pushlightuserdata(L, &inst->QuatWVec);
  8381. return 1;
  8382. }
  8383. static int Polycore_BoneTrack_get_QuatXVec(lua_State *L) {
  8384. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  8385. BoneTrack *inst = (BoneTrack*)lua_topointer(L, 1);
  8386. lua_pushlightuserdata(L, &inst->QuatXVec);
  8387. return 1;
  8388. }
  8389. static int Polycore_BoneTrack_get_QuatYVec(lua_State *L) {
  8390. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  8391. BoneTrack *inst = (BoneTrack*)lua_topointer(L, 1);
  8392. lua_pushlightuserdata(L, &inst->QuatYVec);
  8393. return 1;
  8394. }
  8395. static int Polycore_BoneTrack_get_QuatZVec(lua_State *L) {
  8396. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  8397. BoneTrack *inst = (BoneTrack*)lua_topointer(L, 1);
  8398. lua_pushlightuserdata(L, &inst->QuatZVec);
  8399. return 1;
  8400. }
  8401. static int Polycore_BoneTrack(lua_State *L) {
  8402. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  8403. Bone * bone = (Bone *)lua_topointer(L, 1);
  8404. luaL_checktype(L, 2, LUA_TNUMBER);
  8405. Number length = lua_tonumber(L, 2);
  8406. BoneTrack *inst = new BoneTrack(bone, length);
  8407. lua_pushlightuserdata(L, (void*)inst);
  8408. return 1;
  8409. }
  8410. static int Polycore_BoneTrack_Play(lua_State *L) {
  8411. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  8412. BoneTrack *inst = (BoneTrack*)lua_topointer(L, 1);
  8413. inst->Play();
  8414. return 0;
  8415. }
  8416. static int Polycore_BoneTrack_Stop(lua_State *L) {
  8417. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  8418. BoneTrack *inst = (BoneTrack*)lua_topointer(L, 1);
  8419. inst->Stop();
  8420. return 0;
  8421. }
  8422. static int Polycore_BoneTrack_Update(lua_State *L) {
  8423. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  8424. BoneTrack *inst = (BoneTrack*)lua_topointer(L, 1);
  8425. inst->Update();
  8426. return 0;
  8427. }
  8428. static int Polycore_BoneTrack_setSpeed(lua_State *L) {
  8429. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  8430. BoneTrack *inst = (BoneTrack*)lua_topointer(L, 1);
  8431. luaL_checktype(L, 2, LUA_TNUMBER);
  8432. Number speed = lua_tonumber(L, 2);
  8433. inst->setSpeed(speed);
  8434. return 0;
  8435. }
  8436. static int Polycore_delete_BoneTrack(lua_State *L) {
  8437. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  8438. BoneTrack *inst = (BoneTrack*)lua_topointer(L, 1);
  8439. delete inst;
  8440. return 0;
  8441. }
  8442. static int Polycore_Skeleton(lua_State *L) {
  8443. luaL_checktype(L, 1, LUA_TSTRING);
  8444. String fileName = String(lua_tostring(L, 1));
  8445. Skeleton *inst = new Skeleton(fileName);
  8446. lua_pushlightuserdata(L, (void*)inst);
  8447. return 1;
  8448. }
  8449. static int Polycore_Skeleton_loadSkeleton(lua_State *L) {
  8450. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  8451. Skeleton *inst = (Skeleton*)lua_topointer(L, 1);
  8452. luaL_checktype(L, 2, LUA_TSTRING);
  8453. String fileName = String(lua_tostring(L, 2));
  8454. inst->loadSkeleton(fileName);
  8455. return 0;
  8456. }
  8457. static int Polycore_Skeleton_playAnimation(lua_State *L) {
  8458. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  8459. Skeleton *inst = (Skeleton*)lua_topointer(L, 1);
  8460. luaL_checktype(L, 2, LUA_TSTRING);
  8461. String animName = String(lua_tostring(L, 2));
  8462. inst->playAnimation(animName);
  8463. return 0;
  8464. }
  8465. static int Polycore_Skeleton_playAnimationByIndex(lua_State *L) {
  8466. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  8467. Skeleton *inst = (Skeleton*)lua_topointer(L, 1);
  8468. luaL_checktype(L, 2, LUA_TNUMBER);
  8469. int index = lua_tointeger(L, 2);
  8470. inst->playAnimationByIndex(index);
  8471. return 0;
  8472. }
  8473. static int Polycore_Skeleton_addAnimation(lua_State *L) {
  8474. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  8475. Skeleton *inst = (Skeleton*)lua_topointer(L, 1);
  8476. luaL_checktype(L, 2, LUA_TSTRING);
  8477. String name = String(lua_tostring(L, 2));
  8478. luaL_checktype(L, 3, LUA_TSTRING);
  8479. String fileName = String(lua_tostring(L, 3));
  8480. inst->addAnimation(name, fileName);
  8481. return 0;
  8482. }
  8483. static int Polycore_Skeleton_getAnimation(lua_State *L) {
  8484. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  8485. Skeleton *inst = (Skeleton*)lua_topointer(L, 1);
  8486. luaL_checktype(L, 2, LUA_TSTRING);
  8487. String name = String(lua_tostring(L, 2));
  8488. void *ptrRetVal = (void*)inst->getAnimation(name);
  8489. if(ptrRetVal == NULL) {
  8490. lua_pushnil(L);
  8491. } else {
  8492. lua_pushlightuserdata(L, ptrRetVal);
  8493. }
  8494. return 1;
  8495. }
  8496. static int Polycore_Skeleton_Update(lua_State *L) {
  8497. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  8498. Skeleton *inst = (Skeleton*)lua_topointer(L, 1);
  8499. inst->Update();
  8500. return 0;
  8501. }
  8502. static int Polycore_Skeleton_getBoneByName(lua_State *L) {
  8503. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  8504. Skeleton *inst = (Skeleton*)lua_topointer(L, 1);
  8505. luaL_checktype(L, 2, LUA_TSTRING);
  8506. String name = String(lua_tostring(L, 2));
  8507. void *ptrRetVal = (void*)inst->getBoneByName(name);
  8508. if(ptrRetVal == NULL) {
  8509. lua_pushnil(L);
  8510. } else {
  8511. lua_pushlightuserdata(L, ptrRetVal);
  8512. }
  8513. return 1;
  8514. }
  8515. static int Polycore_Skeleton_bonesVisible(lua_State *L) {
  8516. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  8517. Skeleton *inst = (Skeleton*)lua_topointer(L, 1);
  8518. luaL_checktype(L, 2, LUA_TBOOLEAN);
  8519. bool val = lua_toboolean(L, 2);
  8520. inst->bonesVisible(val);
  8521. return 0;
  8522. }
  8523. static int Polycore_Skeleton_enableBoneLabels(lua_State *L) {
  8524. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  8525. Skeleton *inst = (Skeleton*)lua_topointer(L, 1);
  8526. luaL_checktype(L, 2, LUA_TSTRING);
  8527. String labelFont = String(lua_tostring(L, 2));
  8528. luaL_checktype(L, 3, LUA_TNUMBER);
  8529. Number size = lua_tonumber(L, 3);
  8530. luaL_checktype(L, 4, LUA_TNUMBER);
  8531. Number scale = lua_tonumber(L, 4);
  8532. luaL_checktype(L, 5, LUA_TLIGHTUSERDATA);
  8533. Color labelColor = *(Color*)lua_topointer(L, 5);
  8534. inst->enableBoneLabels(labelFont, size, scale, labelColor);
  8535. return 0;
  8536. }
  8537. static int Polycore_Skeleton_getNumBones(lua_State *L) {
  8538. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  8539. Skeleton *inst = (Skeleton*)lua_topointer(L, 1);
  8540. lua_pushinteger(L, inst->getNumBones());
  8541. return 1;
  8542. }
  8543. static int Polycore_Skeleton_getBone(lua_State *L) {
  8544. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  8545. Skeleton *inst = (Skeleton*)lua_topointer(L, 1);
  8546. luaL_checktype(L, 2, LUA_TNUMBER);
  8547. int index = lua_tointeger(L, 2);
  8548. void *ptrRetVal = (void*)inst->getBone(index);
  8549. if(ptrRetVal == NULL) {
  8550. lua_pushnil(L);
  8551. } else {
  8552. lua_pushlightuserdata(L, ptrRetVal);
  8553. }
  8554. return 1;
  8555. }
  8556. static int Polycore_Skeleton_getCurrentAnimation(lua_State *L) {
  8557. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  8558. Skeleton *inst = (Skeleton*)lua_topointer(L, 1);
  8559. void *ptrRetVal = (void*)inst->getCurrentAnimation();
  8560. if(ptrRetVal == NULL) {
  8561. lua_pushnil(L);
  8562. } else {
  8563. lua_pushlightuserdata(L, ptrRetVal);
  8564. }
  8565. return 1;
  8566. }
  8567. static int Polycore_delete_Skeleton(lua_State *L) {
  8568. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  8569. Skeleton *inst = (Skeleton*)lua_topointer(L, 1);
  8570. delete inst;
  8571. return 0;
  8572. }
  8573. static int Polycore_Sound(lua_State *L) {
  8574. luaL_checktype(L, 1, LUA_TSTRING);
  8575. String fileName = String(lua_tostring(L, 1));
  8576. Sound *inst = new Sound(fileName);
  8577. lua_pushlightuserdata(L, (void*)inst);
  8578. return 1;
  8579. }
  8580. static int Polycore_Sound_Play(lua_State *L) {
  8581. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  8582. Sound *inst = (Sound*)lua_topointer(L, 1);
  8583. bool loop;
  8584. if(lua_isboolean(L, 2)) {
  8585. loop = lua_toboolean(L, 2);
  8586. } else {
  8587. loop = false;
  8588. }
  8589. inst->Play(loop);
  8590. return 0;
  8591. }
  8592. static int Polycore_Sound_Stop(lua_State *L) {
  8593. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  8594. Sound *inst = (Sound*)lua_topointer(L, 1);
  8595. inst->Stop();
  8596. return 0;
  8597. }
  8598. static int Polycore_Sound_setVolume(lua_State *L) {
  8599. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  8600. Sound *inst = (Sound*)lua_topointer(L, 1);
  8601. luaL_checktype(L, 2, LUA_TNUMBER);
  8602. Number newVolume = lua_tonumber(L, 2);
  8603. inst->setVolume(newVolume);
  8604. return 0;
  8605. }
  8606. static int Polycore_Sound_setPitch(lua_State *L) {
  8607. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  8608. Sound *inst = (Sound*)lua_topointer(L, 1);
  8609. luaL_checktype(L, 2, LUA_TNUMBER);
  8610. Number newPitch = lua_tonumber(L, 2);
  8611. inst->setPitch(newPitch);
  8612. return 0;
  8613. }
  8614. static int Polycore_Sound_setIsPositional(lua_State *L) {
  8615. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  8616. Sound *inst = (Sound*)lua_topointer(L, 1);
  8617. luaL_checktype(L, 2, LUA_TBOOLEAN);
  8618. bool isPositional = lua_toboolean(L, 2);
  8619. inst->setIsPositional(isPositional);
  8620. return 0;
  8621. }
  8622. static int Polycore_Sound_setSoundPosition(lua_State *L) {
  8623. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  8624. Sound *inst = (Sound*)lua_topointer(L, 1);
  8625. luaL_checktype(L, 2, LUA_TLIGHTUSERDATA);
  8626. Vector3 position = *(Vector3*)lua_topointer(L, 2);
  8627. inst->setSoundPosition(position);
  8628. return 0;
  8629. }
  8630. static int Polycore_Sound_setSoundVelocity(lua_State *L) {
  8631. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  8632. Sound *inst = (Sound*)lua_topointer(L, 1);
  8633. luaL_checktype(L, 2, LUA_TLIGHTUSERDATA);
  8634. Vector3 velocity = *(Vector3*)lua_topointer(L, 2);
  8635. inst->setSoundVelocity(velocity);
  8636. return 0;
  8637. }
  8638. static int Polycore_Sound_setSoundDirection(lua_State *L) {
  8639. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  8640. Sound *inst = (Sound*)lua_topointer(L, 1);
  8641. luaL_checktype(L, 2, LUA_TLIGHTUSERDATA);
  8642. Vector3 direction = *(Vector3*)lua_topointer(L, 2);
  8643. inst->setSoundDirection(direction);
  8644. return 0;
  8645. }
  8646. static int Polycore_Sound_setPositionalProperties(lua_State *L) {
  8647. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  8648. Sound *inst = (Sound*)lua_topointer(L, 1);
  8649. luaL_checktype(L, 2, LUA_TNUMBER);
  8650. Number referenceDistance = lua_tonumber(L, 2);
  8651. luaL_checktype(L, 3, LUA_TNUMBER);
  8652. Number maxDistance = lua_tonumber(L, 3);
  8653. inst->setPositionalProperties(referenceDistance, maxDistance);
  8654. return 0;
  8655. }
  8656. static int Polycore_Sound_loadWAV(lua_State *L) {
  8657. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  8658. Sound *inst = (Sound*)lua_topointer(L, 1);
  8659. luaL_checktype(L, 2, LUA_TSTRING);
  8660. String fileName = String(lua_tostring(L, 2));
  8661. ALuint *retInst = new ALuint();
  8662. *retInst = inst->loadWAV(fileName);
  8663. lua_pushlightuserdata(L, retInst);
  8664. return 1;
  8665. }
  8666. static int Polycore_Sound_loadOGG(lua_State *L) {
  8667. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  8668. Sound *inst = (Sound*)lua_topointer(L, 1);
  8669. luaL_checktype(L, 2, LUA_TSTRING);
  8670. String fileName = String(lua_tostring(L, 2));
  8671. ALuint *retInst = new ALuint();
  8672. *retInst = inst->loadOGG(fileName);
  8673. lua_pushlightuserdata(L, retInst);
  8674. return 1;
  8675. }
  8676. static int Polycore_Sound_GenSource(lua_State *L) {
  8677. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  8678. Sound *inst = (Sound*)lua_topointer(L, 1);
  8679. luaL_checktype(L, 2, LUA_TLIGHTUSERDATA);
  8680. ALuint buffer = *(ALuint*)lua_topointer(L, 2);
  8681. ALuint *retInst = new ALuint();
  8682. *retInst = inst->GenSource(buffer);
  8683. lua_pushlightuserdata(L, retInst);
  8684. return 1;
  8685. }
  8686. static int Polycore_Sound_checkALError(lua_State *L) {
  8687. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  8688. Sound *inst = (Sound*)lua_topointer(L, 1);
  8689. luaL_checktype(L, 2, LUA_TSTRING);
  8690. String operation = String(lua_tostring(L, 2));
  8691. inst->checkALError(operation);
  8692. return 0;
  8693. }
  8694. static int Polycore_Sound_soundError(lua_State *L) {
  8695. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  8696. Sound *inst = (Sound*)lua_topointer(L, 1);
  8697. luaL_checktype(L, 2, LUA_TSTRING);
  8698. String err = String(lua_tostring(L, 2));
  8699. inst->soundError(err);
  8700. return 0;
  8701. }
  8702. static int Polycore_Sound_soundCheck(lua_State *L) {
  8703. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  8704. Sound *inst = (Sound*)lua_topointer(L, 1);
  8705. luaL_checktype(L, 2, LUA_TBOOLEAN);
  8706. bool result = lua_toboolean(L, 2);
  8707. luaL_checktype(L, 3, LUA_TSTRING);
  8708. String err = String(lua_tostring(L, 3));
  8709. inst->soundCheck(result, err);
  8710. return 0;
  8711. }
  8712. static int Polycore_delete_Sound(lua_State *L) {
  8713. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  8714. Sound *inst = (Sound*)lua_topointer(L, 1);
  8715. delete inst;
  8716. return 0;
  8717. }
  8718. static int Polycore_SoundManager(lua_State *L) {
  8719. SoundManager *inst = new SoundManager();
  8720. lua_pushlightuserdata(L, (void*)inst);
  8721. return 1;
  8722. }
  8723. static int Polycore_SoundManager_setListenerPosition(lua_State *L) {
  8724. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  8725. SoundManager *inst = (SoundManager*)lua_topointer(L, 1);
  8726. luaL_checktype(L, 2, LUA_TLIGHTUSERDATA);
  8727. Vector3 position = *(Vector3*)lua_topointer(L, 2);
  8728. inst->setListenerPosition(position);
  8729. return 0;
  8730. }
  8731. static int Polycore_SoundManager_setListenerOrientation(lua_State *L) {
  8732. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  8733. SoundManager *inst = (SoundManager*)lua_topointer(L, 1);
  8734. luaL_checktype(L, 2, LUA_TLIGHTUSERDATA);
  8735. Vector3 orientation = *(Vector3*)lua_topointer(L, 2);
  8736. inst->setListenerOrientation(orientation);
  8737. return 0;
  8738. }
  8739. static int Polycore_SoundManager_initAL(lua_State *L) {
  8740. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  8741. SoundManager *inst = (SoundManager*)lua_topointer(L, 1);
  8742. inst->initAL();
  8743. return 0;
  8744. }
  8745. static int Polycore_SoundManager_setGlobalVolume(lua_State *L) {
  8746. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  8747. SoundManager *inst = (SoundManager*)lua_topointer(L, 1);
  8748. luaL_checktype(L, 2, LUA_TNUMBER);
  8749. Number globalVolume = lua_tonumber(L, 2);
  8750. inst->setGlobalVolume(globalVolume);
  8751. return 0;
  8752. }
  8753. static int Polycore_delete_SoundManager(lua_State *L) {
  8754. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  8755. SoundManager *inst = (SoundManager*)lua_topointer(L, 1);
  8756. delete inst;
  8757. return 0;
  8758. }
  8759. static int Polycore_String_get_contents(lua_State *L) {
  8760. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  8761. String *inst = (String*)lua_topointer(L, 1);
  8762. lua_pushlightuserdata(L, &inst->contents);
  8763. return 1;
  8764. }
  8765. static int Polycore_String_get_s_contents(lua_State *L) {
  8766. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  8767. String *inst = (String*)lua_topointer(L, 1);
  8768. lua_pushlightuserdata(L, &inst->s_contents);
  8769. return 1;
  8770. }
  8771. static int Polycore_String(lua_State *L) {
  8772. String *inst = new String();
  8773. lua_pushlightuserdata(L, (void*)inst);
  8774. return 1;
  8775. }
  8776. static int Polycore_String_size(lua_State *L) {
  8777. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  8778. String *inst = (String*)lua_topointer(L, 1);
  8779. lua_pushinteger(L, inst->size());
  8780. return 1;
  8781. }
  8782. static int Polycore_String_length(lua_State *L) {
  8783. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  8784. String *inst = (String*)lua_topointer(L, 1);
  8785. lua_pushinteger(L, inst->length());
  8786. return 1;
  8787. }
  8788. static int Polycore_String_getSTLString(lua_State *L) {
  8789. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  8790. String *inst = (String*)lua_topointer(L, 1);
  8791. string *retInst = new string();
  8792. *retInst = inst->getSTLString();
  8793. lua_pushlightuserdata(L, retInst);
  8794. return 1;
  8795. }
  8796. static int Polycore_String_getSTLWString(lua_State *L) {
  8797. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  8798. String *inst = (String*)lua_topointer(L, 1);
  8799. wstring *retInst = new wstring();
  8800. *retInst = inst->getSTLWString();
  8801. lua_pushlightuserdata(L, retInst);
  8802. return 1;
  8803. }
  8804. static int Polycore_String_substr(lua_State *L) {
  8805. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  8806. String *inst = (String*)lua_topointer(L, 1);
  8807. luaL_checktype(L, 2, LUA_TLIGHTUSERDATA);
  8808. size_t pos = *(size_t*)lua_topointer(L, 2);
  8809. luaL_checktype(L, 3, LUA_TLIGHTUSERDATA);
  8810. size_t n = *(size_t*)lua_topointer(L, 3);
  8811. lua_pushstring(L, inst->substr(pos, n).c_str());
  8812. return 1;
  8813. }
  8814. static int Polycore_String_rfind(lua_State *L) {
  8815. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  8816. String *inst = (String*)lua_topointer(L, 1);
  8817. luaL_checktype(L, 2, LUA_TLIGHTUSERDATA);
  8818. const String & str = *( String *)lua_topointer(L, 2);
  8819. luaL_checktype(L, 3, LUA_TLIGHTUSERDATA);
  8820. size_t pos = *(size_t*)lua_topointer(L, 3);
  8821. lua_pushinteger(L, inst->rfind(str, pos));
  8822. return 1;
  8823. }
  8824. static int Polycore_String_find(lua_State *L) {
  8825. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  8826. String *inst = (String*)lua_topointer(L, 1);
  8827. luaL_checktype(L, 2, LUA_TLIGHTUSERDATA);
  8828. const String & str = *( String *)lua_topointer(L, 2);
  8829. luaL_checktype(L, 3, LUA_TLIGHTUSERDATA);
  8830. size_t pos = *(size_t*)lua_topointer(L, 3);
  8831. lua_pushinteger(L, inst->find(str, pos));
  8832. return 1;
  8833. }
  8834. static int Polycore_String_find_last_of(lua_State *L) {
  8835. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  8836. String *inst = (String*)lua_topointer(L, 1);
  8837. luaL_checktype(L, 2, LUA_TLIGHTUSERDATA);
  8838. const String & str = *( String *)lua_topointer(L, 2);
  8839. luaL_checktype(L, 3, LUA_TLIGHTUSERDATA);
  8840. size_t pos = *(size_t*)lua_topointer(L, 3);
  8841. lua_pushinteger(L, inst->find_last_of(str, pos));
  8842. return 1;
  8843. }
  8844. static int Polycore_String_toLowerCase(lua_State *L) {
  8845. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  8846. String *inst = (String*)lua_topointer(L, 1);
  8847. lua_pushstring(L, inst->toLowerCase().c_str());
  8848. return 1;
  8849. }
  8850. static int Polycore_String_toUpperCase(lua_State *L) {
  8851. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  8852. String *inst = (String*)lua_topointer(L, 1);
  8853. lua_pushstring(L, inst->toUpperCase().c_str());
  8854. return 1;
  8855. }
  8856. static int Polycore_String_replace(lua_State *L) {
  8857. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  8858. String *inst = (String*)lua_topointer(L, 1);
  8859. luaL_checktype(L, 2, LUA_TLIGHTUSERDATA);
  8860. const String & what = *( String *)lua_topointer(L, 2);
  8861. luaL_checktype(L, 3, LUA_TLIGHTUSERDATA);
  8862. const String & withWhat = *( String *)lua_topointer(L, 3);
  8863. lua_pushstring(L, inst->replace(what, withWhat).c_str());
  8864. return 1;
  8865. }
  8866. static int Polycore_String_NumberToString(lua_State *L) {
  8867. luaL_checktype(L, 2, LUA_TNUMBER);
  8868. Number value = lua_tonumber(L, 2);
  8869. lua_pushstring(L, String::NumberToString(value).c_str());
  8870. return 1;
  8871. }
  8872. static int Polycore_String_c_str(lua_State *L) {
  8873. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  8874. String *inst = (String*)lua_topointer(L, 1);
  8875. void *ptrRetVal = (void*)inst->c_str();
  8876. if(ptrRetVal == NULL) {
  8877. lua_pushnil(L);
  8878. } else {
  8879. lua_pushlightuserdata(L, ptrRetVal);
  8880. }
  8881. return 1;
  8882. }
  8883. static int Polycore_String_wc_str(lua_State *L) {
  8884. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  8885. String *inst = (String*)lua_topointer(L, 1);
  8886. void *ptrRetVal = (void*)inst->wc_str();
  8887. if(ptrRetVal == NULL) {
  8888. lua_pushnil(L);
  8889. } else {
  8890. lua_pushlightuserdata(L, ptrRetVal);
  8891. }
  8892. return 1;
  8893. }
  8894. static int Polycore_String_data(lua_State *L) {
  8895. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  8896. String *inst = (String*)lua_topointer(L, 1);
  8897. void *ptrRetVal = (void*)inst->data();
  8898. if(ptrRetVal == NULL) {
  8899. lua_pushnil(L);
  8900. } else {
  8901. lua_pushlightuserdata(L, ptrRetVal);
  8902. }
  8903. return 1;
  8904. }
  8905. static int Polycore_String_getDataWithEncoding(lua_State *L) {
  8906. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  8907. String *inst = (String*)lua_topointer(L, 1);
  8908. luaL_checktype(L, 2, LUA_TNUMBER);
  8909. int encoding = lua_tointeger(L, 2);
  8910. void *ptrRetVal = (void*)inst->getDataWithEncoding(encoding);
  8911. if(ptrRetVal == NULL) {
  8912. lua_pushnil(L);
  8913. } else {
  8914. lua_pushlightuserdata(L, ptrRetVal);
  8915. }
  8916. return 1;
  8917. }
  8918. static int Polycore_String_getDataSizeWithEncoding(lua_State *L) {
  8919. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  8920. String *inst = (String*)lua_topointer(L, 1);
  8921. luaL_checktype(L, 2, LUA_TNUMBER);
  8922. int encoding = lua_tointeger(L, 2);
  8923. lua_pushinteger(L, inst->getDataSizeWithEncoding(encoding));
  8924. return 1;
  8925. }
  8926. static int Polycore_String_setDataWithEncoding(lua_State *L) {
  8927. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  8928. String *inst = (String*)lua_topointer(L, 1);
  8929. luaL_checktype(L, 2, LUA_TLIGHTUSERDATA);
  8930. char * data = (char *)lua_topointer(L, 2);
  8931. luaL_checktype(L, 3, LUA_TNUMBER);
  8932. int encoding = lua_tointeger(L, 3);
  8933. inst->setDataWithEncoding(data, encoding);
  8934. return 0;
  8935. }
  8936. static int Polycore_delete_String(lua_State *L) {
  8937. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  8938. String *inst = (String*)lua_topointer(L, 1);
  8939. delete inst;
  8940. return 0;
  8941. }
  8942. static int Polycore_Texture_get_scrollSpeedX(lua_State *L) {
  8943. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  8944. Texture *inst = (Texture*)lua_topointer(L, 1);
  8945. lua_pushnumber(L, inst->scrollSpeedX);
  8946. return 1;
  8947. }
  8948. static int Polycore_Texture_get_scrollSpeedY(lua_State *L) {
  8949. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  8950. Texture *inst = (Texture*)lua_topointer(L, 1);
  8951. lua_pushnumber(L, inst->scrollSpeedY);
  8952. return 1;
  8953. }
  8954. static int Polycore_Texture_get_clamp(lua_State *L) {
  8955. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  8956. Texture *inst = (Texture*)lua_topointer(L, 1);
  8957. lua_pushboolean(L, inst->clamp);
  8958. return 1;
  8959. }
  8960. static int Polycore_Texture_set_scrollSpeedX(lua_State *L) {
  8961. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  8962. Texture *inst = (Texture*)lua_topointer(L, 1);
  8963. Number param = lua_tonumber(L, 2);
  8964. inst->scrollSpeedX = param;
  8965. return 0;
  8966. }
  8967. static int Polycore_Texture_set_scrollSpeedY(lua_State *L) {
  8968. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  8969. Texture *inst = (Texture*)lua_topointer(L, 1);
  8970. Number param = lua_tonumber(L, 2);
  8971. inst->scrollSpeedY = param;
  8972. return 0;
  8973. }
  8974. static int Polycore_Texture_set_clamp(lua_State *L) {
  8975. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  8976. Texture *inst = (Texture*)lua_topointer(L, 1);
  8977. bool param = lua_toboolean(L, 2);
  8978. inst->clamp = param;
  8979. return 0;
  8980. }
  8981. static int Polycore_Texture_setTextureData(lua_State *L) {
  8982. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  8983. Texture *inst = (Texture*)lua_topointer(L, 1);
  8984. luaL_checktype(L, 2, LUA_TLIGHTUSERDATA);
  8985. char * data = (char *)lua_topointer(L, 2);
  8986. inst->setTextureData(data);
  8987. return 0;
  8988. }
  8989. static int Polycore_Texture_recreateFromImageData(lua_State *L) {
  8990. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  8991. Texture *inst = (Texture*)lua_topointer(L, 1);
  8992. inst->recreateFromImageData();
  8993. return 0;
  8994. }
  8995. static int Polycore_Texture_getScrollOffsetX(lua_State *L) {
  8996. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  8997. Texture *inst = (Texture*)lua_topointer(L, 1);
  8998. lua_pushnumber(L, inst->getScrollOffsetX());
  8999. return 1;
  9000. }
  9001. static int Polycore_Texture_getScrollOffsetY(lua_State *L) {
  9002. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  9003. Texture *inst = (Texture*)lua_topointer(L, 1);
  9004. lua_pushnumber(L, inst->getScrollOffsetY());
  9005. return 1;
  9006. }
  9007. static int Polycore_Texture_setImageData(lua_State *L) {
  9008. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  9009. Texture *inst = (Texture*)lua_topointer(L, 1);
  9010. luaL_checktype(L, 2, LUA_TLIGHTUSERDATA);
  9011. Image * data = (Image *)lua_topointer(L, 2);
  9012. inst->setImageData(data);
  9013. return 0;
  9014. }
  9015. static int Polycore_Texture_updateScroll(lua_State *L) {
  9016. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  9017. Texture *inst = (Texture*)lua_topointer(L, 1);
  9018. luaL_checktype(L, 2, LUA_TNUMBER);
  9019. int elapsed = lua_tointeger(L, 2);
  9020. inst->updateScroll(elapsed);
  9021. return 0;
  9022. }
  9023. static int Polycore_Texture_setResourcePath(lua_State *L) {
  9024. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  9025. Texture *inst = (Texture*)lua_topointer(L, 1);
  9026. luaL_checktype(L, 2, LUA_TSTRING);
  9027. String newPath = String(lua_tostring(L, 2));
  9028. inst->setResourcePath(newPath);
  9029. return 0;
  9030. }
  9031. static int Polycore_Texture_getResourcePath(lua_State *L) {
  9032. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  9033. Texture *inst = (Texture*)lua_topointer(L, 1);
  9034. lua_pushstring(L, inst->getResourcePath().c_str());
  9035. return 1;
  9036. }
  9037. static int Polycore_Texture_getTextureData(lua_State *L) {
  9038. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  9039. Texture *inst = (Texture*)lua_topointer(L, 1);
  9040. void *ptrRetVal = (void*)inst->getTextureData();
  9041. if(ptrRetVal == NULL) {
  9042. lua_pushnil(L);
  9043. } else {
  9044. lua_pushlightuserdata(L, ptrRetVal);
  9045. }
  9046. return 1;
  9047. }
  9048. static int Polycore_Texture_getWidth(lua_State *L) {
  9049. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  9050. Texture *inst = (Texture*)lua_topointer(L, 1);
  9051. lua_pushinteger(L, inst->getWidth());
  9052. return 1;
  9053. }
  9054. static int Polycore_Texture_getHeight(lua_State *L) {
  9055. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  9056. Texture *inst = (Texture*)lua_topointer(L, 1);
  9057. lua_pushinteger(L, inst->getHeight());
  9058. return 1;
  9059. }
  9060. static int Polycore_delete_Texture(lua_State *L) {
  9061. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  9062. Texture *inst = (Texture*)lua_topointer(L, 1);
  9063. delete inst;
  9064. return 0;
  9065. }
  9066. static int Polycore_Timer(lua_State *L) {
  9067. luaL_checktype(L, 1, LUA_TBOOLEAN);
  9068. bool triggerMode = lua_toboolean(L, 1);
  9069. luaL_checktype(L, 2, LUA_TNUMBER);
  9070. int msecs = lua_tointeger(L, 2);
  9071. Timer *inst = new Timer(triggerMode, msecs);
  9072. lua_pushlightuserdata(L, (void*)inst);
  9073. return 1;
  9074. }
  9075. static int Polycore_Timer_Pause(lua_State *L) {
  9076. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  9077. Timer *inst = (Timer*)lua_topointer(L, 1);
  9078. luaL_checktype(L, 2, LUA_TBOOLEAN);
  9079. bool paused = lua_toboolean(L, 2);
  9080. inst->Pause(paused);
  9081. return 0;
  9082. }
  9083. static int Polycore_Timer_isPaused(lua_State *L) {
  9084. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  9085. Timer *inst = (Timer*)lua_topointer(L, 1);
  9086. lua_pushboolean(L, inst->isPaused());
  9087. return 1;
  9088. }
  9089. static int Polycore_Timer_getTicks(lua_State *L) {
  9090. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  9091. Timer *inst = (Timer*)lua_topointer(L, 1);
  9092. lua_pushinteger(L, inst->getTicks());
  9093. return 1;
  9094. }
  9095. static int Polycore_Timer_Update(lua_State *L) {
  9096. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  9097. Timer *inst = (Timer*)lua_topointer(L, 1);
  9098. luaL_checktype(L, 2, LUA_TNUMBER);
  9099. unsigned int ticks = lua_tointeger(L, 2);
  9100. inst->Update(ticks);
  9101. return 0;
  9102. }
  9103. static int Polycore_Timer_Reset(lua_State *L) {
  9104. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  9105. Timer *inst = (Timer*)lua_topointer(L, 1);
  9106. inst->Reset();
  9107. return 0;
  9108. }
  9109. static int Polycore_Timer_hasElapsed(lua_State *L) {
  9110. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  9111. Timer *inst = (Timer*)lua_topointer(L, 1);
  9112. lua_pushboolean(L, inst->hasElapsed());
  9113. return 1;
  9114. }
  9115. static int Polycore_Timer_getElapsedf(lua_State *L) {
  9116. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  9117. Timer *inst = (Timer*)lua_topointer(L, 1);
  9118. lua_pushnumber(L, inst->getElapsedf());
  9119. return 1;
  9120. }
  9121. static int Polycore_delete_Timer(lua_State *L) {
  9122. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  9123. Timer *inst = (Timer*)lua_topointer(L, 1);
  9124. delete inst;
  9125. return 0;
  9126. }
  9127. static int Polycore_TimerManager(lua_State *L) {
  9128. TimerManager *inst = new TimerManager();
  9129. lua_pushlightuserdata(L, (void*)inst);
  9130. return 1;
  9131. }
  9132. static int Polycore_TimerManager_removeTimer(lua_State *L) {
  9133. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  9134. TimerManager *inst = (TimerManager*)lua_topointer(L, 1);
  9135. luaL_checktype(L, 2, LUA_TLIGHTUSERDATA);
  9136. Timer * timer = (Timer *)lua_topointer(L, 2);
  9137. inst->removeTimer(timer);
  9138. return 0;
  9139. }
  9140. static int Polycore_TimerManager_addTimer(lua_State *L) {
  9141. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  9142. TimerManager *inst = (TimerManager*)lua_topointer(L, 1);
  9143. luaL_checktype(L, 2, LUA_TLIGHTUSERDATA);
  9144. Timer * timer = (Timer *)lua_topointer(L, 2);
  9145. inst->addTimer(timer);
  9146. return 0;
  9147. }
  9148. static int Polycore_TimerManager_Update(lua_State *L) {
  9149. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  9150. TimerManager *inst = (TimerManager*)lua_topointer(L, 1);
  9151. inst->Update();
  9152. return 0;
  9153. }
  9154. static int Polycore_delete_TimerManager(lua_State *L) {
  9155. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  9156. TimerManager *inst = (TimerManager*)lua_topointer(L, 1);
  9157. delete inst;
  9158. return 0;
  9159. }
  9160. static int Polycore_Tween_get_repeat(lua_State *L) {
  9161. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  9162. Tween *inst = (Tween*)lua_topointer(L, 1);
  9163. lua_pushboolean(L, inst->repeat);
  9164. return 1;
  9165. }
  9166. static int Polycore_Tween_set_repeat(lua_State *L) {
  9167. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  9168. Tween *inst = (Tween*)lua_topointer(L, 1);
  9169. bool param = lua_toboolean(L, 2);
  9170. inst->repeat = param;
  9171. return 0;
  9172. }
  9173. static int Polycore_Tween(lua_State *L) {
  9174. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  9175. Number * target = (Number *)lua_topointer(L, 1);
  9176. luaL_checktype(L, 2, LUA_TNUMBER);
  9177. int easeType = lua_tointeger(L, 2);
  9178. luaL_checktype(L, 3, LUA_TNUMBER);
  9179. Number startVal = lua_tonumber(L, 3);
  9180. luaL_checktype(L, 4, LUA_TNUMBER);
  9181. Number _endVal = lua_tonumber(L, 4);
  9182. luaL_checktype(L, 5, LUA_TNUMBER);
  9183. Number time = lua_tonumber(L, 5);
  9184. bool _repeat;
  9185. if(lua_isboolean(L, 6)) {
  9186. _repeat = lua_toboolean(L, 6);
  9187. } else {
  9188. _repeat = false;
  9189. }
  9190. Tween *inst = new Tween(target, easeType, startVal, _endVal, time, _repeat);
  9191. lua_pushlightuserdata(L, (void*)inst);
  9192. return 1;
  9193. }
  9194. static int Polycore_Tween_interpolateTween(lua_State *L) {
  9195. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  9196. Tween *inst = (Tween*)lua_topointer(L, 1);
  9197. lua_pushnumber(L, inst->interpolateTween());
  9198. return 1;
  9199. }
  9200. static int Polycore_Tween_updateCustomTween(lua_State *L) {
  9201. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  9202. Tween *inst = (Tween*)lua_topointer(L, 1);
  9203. inst->updateCustomTween();
  9204. return 0;
  9205. }
  9206. static int Polycore_Tween_doOnComplete(lua_State *L) {
  9207. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  9208. Tween *inst = (Tween*)lua_topointer(L, 1);
  9209. inst->doOnComplete();
  9210. return 0;
  9211. }
  9212. static int Polycore_Tween_Pause(lua_State *L) {
  9213. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  9214. Tween *inst = (Tween*)lua_topointer(L, 1);
  9215. luaL_checktype(L, 2, LUA_TBOOLEAN);
  9216. bool pauseVal = lua_toboolean(L, 2);
  9217. inst->Pause(pauseVal);
  9218. return 0;
  9219. }
  9220. static int Polycore_Tween_Reset(lua_State *L) {
  9221. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  9222. Tween *inst = (Tween*)lua_topointer(L, 1);
  9223. inst->Reset();
  9224. return 0;
  9225. }
  9226. static int Polycore_Tween_isComplete(lua_State *L) {
  9227. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  9228. Tween *inst = (Tween*)lua_topointer(L, 1);
  9229. lua_pushboolean(L, inst->isComplete());
  9230. return 1;
  9231. }
  9232. static int Polycore_Tween_setSpeed(lua_State *L) {
  9233. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  9234. Tween *inst = (Tween*)lua_topointer(L, 1);
  9235. luaL_checktype(L, 2, LUA_TNUMBER);
  9236. Number speed = lua_tonumber(L, 2);
  9237. inst->setSpeed(speed);
  9238. return 0;
  9239. }
  9240. static int Polycore_delete_Tween(lua_State *L) {
  9241. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  9242. Tween *inst = (Tween*)lua_topointer(L, 1);
  9243. delete inst;
  9244. return 0;
  9245. }
  9246. static int Polycore_BezierPathTween(lua_State *L) {
  9247. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  9248. Vector3 * target = (Vector3 *)lua_topointer(L, 1);
  9249. luaL_checktype(L, 2, LUA_TLIGHTUSERDATA);
  9250. BezierCurve * curve = (BezierCurve *)lua_topointer(L, 2);
  9251. luaL_checktype(L, 3, LUA_TNUMBER);
  9252. int easeType = lua_tointeger(L, 3);
  9253. luaL_checktype(L, 4, LUA_TNUMBER);
  9254. Number time = lua_tonumber(L, 4);
  9255. bool _repeat;
  9256. if(lua_isboolean(L, 5)) {
  9257. _repeat = lua_toboolean(L, 5);
  9258. } else {
  9259. _repeat = false;
  9260. }
  9261. BezierPathTween *inst = new BezierPathTween(target, curve, easeType, time, _repeat);
  9262. lua_pushlightuserdata(L, (void*)inst);
  9263. return 1;
  9264. }
  9265. static int Polycore_BezierPathTween_updateCustomTween(lua_State *L) {
  9266. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  9267. BezierPathTween *inst = (BezierPathTween*)lua_topointer(L, 1);
  9268. inst->updateCustomTween();
  9269. return 0;
  9270. }
  9271. static int Polycore_delete_BezierPathTween(lua_State *L) {
  9272. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  9273. BezierPathTween *inst = (BezierPathTween*)lua_topointer(L, 1);
  9274. delete inst;
  9275. return 0;
  9276. }
  9277. static int Polycore_QuaternionTween(lua_State *L) {
  9278. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  9279. Quaternion * target = (Quaternion *)lua_topointer(L, 1);
  9280. luaL_checktype(L, 2, LUA_TLIGHTUSERDATA);
  9281. BezierCurve * wCurve = (BezierCurve *)lua_topointer(L, 2);
  9282. luaL_checktype(L, 3, LUA_TLIGHTUSERDATA);
  9283. BezierCurve * xCurve = (BezierCurve *)lua_topointer(L, 3);
  9284. luaL_checktype(L, 4, LUA_TLIGHTUSERDATA);
  9285. BezierCurve * yCurve = (BezierCurve *)lua_topointer(L, 4);
  9286. luaL_checktype(L, 5, LUA_TLIGHTUSERDATA);
  9287. BezierCurve * zCurve = (BezierCurve *)lua_topointer(L, 5);
  9288. luaL_checktype(L, 6, LUA_TNUMBER);
  9289. int easeType = lua_tointeger(L, 6);
  9290. luaL_checktype(L, 7, LUA_TNUMBER);
  9291. Number time = lua_tonumber(L, 7);
  9292. bool _repeat;
  9293. if(lua_isboolean(L, 8)) {
  9294. _repeat = lua_toboolean(L, 8);
  9295. } else {
  9296. _repeat = false;
  9297. }
  9298. QuaternionTween *inst = new QuaternionTween(target, wCurve, xCurve, yCurve, zCurve, easeType, time, _repeat);
  9299. lua_pushlightuserdata(L, (void*)inst);
  9300. return 1;
  9301. }
  9302. static int Polycore_QuaternionTween_updateCustomTween(lua_State *L) {
  9303. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  9304. QuaternionTween *inst = (QuaternionTween*)lua_topointer(L, 1);
  9305. inst->updateCustomTween();
  9306. return 0;
  9307. }
  9308. static int Polycore_delete_QuaternionTween(lua_State *L) {
  9309. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  9310. QuaternionTween *inst = (QuaternionTween*)lua_topointer(L, 1);
  9311. delete inst;
  9312. return 0;
  9313. }
  9314. static int Polycore_TweenManager(lua_State *L) {
  9315. TweenManager *inst = new TweenManager();
  9316. lua_pushlightuserdata(L, (void*)inst);
  9317. return 1;
  9318. }
  9319. static int Polycore_TweenManager_addTween(lua_State *L) {
  9320. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  9321. TweenManager *inst = (TweenManager*)lua_topointer(L, 1);
  9322. luaL_checktype(L, 2, LUA_TLIGHTUSERDATA);
  9323. Tween * tween = (Tween *)lua_topointer(L, 2);
  9324. inst->addTween(tween);
  9325. return 0;
  9326. }
  9327. static int Polycore_TweenManager_Update(lua_State *L) {
  9328. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  9329. TweenManager *inst = (TweenManager*)lua_topointer(L, 1);
  9330. inst->Update();
  9331. return 0;
  9332. }
  9333. static int Polycore_delete_TweenManager(lua_State *L) {
  9334. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  9335. TweenManager *inst = (TweenManager*)lua_topointer(L, 1);
  9336. delete inst;
  9337. return 0;
  9338. }
  9339. static int Polycore_Vector2(lua_State *L) {
  9340. Vector2 *inst = new Vector2();
  9341. lua_pushlightuserdata(L, (void*)inst);
  9342. return 1;
  9343. }
  9344. static int Polycore_delete_Vector2(lua_State *L) {
  9345. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  9346. Vector2 *inst = (Vector2*)lua_topointer(L, 1);
  9347. delete inst;
  9348. return 0;
  9349. }
  9350. static int Polycore_Vector3_get_x(lua_State *L) {
  9351. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  9352. Vector3 *inst = (Vector3*)lua_topointer(L, 1);
  9353. lua_pushnumber(L, inst->x);
  9354. return 1;
  9355. }
  9356. static int Polycore_Vector3_get_y(lua_State *L) {
  9357. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  9358. Vector3 *inst = (Vector3*)lua_topointer(L, 1);
  9359. lua_pushnumber(L, inst->y);
  9360. return 1;
  9361. }
  9362. static int Polycore_Vector3_get_z(lua_State *L) {
  9363. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  9364. Vector3 *inst = (Vector3*)lua_topointer(L, 1);
  9365. lua_pushnumber(L, inst->z);
  9366. return 1;
  9367. }
  9368. static int Polycore_Vector3_set_x(lua_State *L) {
  9369. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  9370. Vector3 *inst = (Vector3*)lua_topointer(L, 1);
  9371. Number param = lua_tonumber(L, 2);
  9372. inst->x = param;
  9373. return 0;
  9374. }
  9375. static int Polycore_Vector3_set_y(lua_State *L) {
  9376. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  9377. Vector3 *inst = (Vector3*)lua_topointer(L, 1);
  9378. Number param = lua_tonumber(L, 2);
  9379. inst->y = param;
  9380. return 0;
  9381. }
  9382. static int Polycore_Vector3_set_z(lua_State *L) {
  9383. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  9384. Vector3 *inst = (Vector3*)lua_topointer(L, 1);
  9385. Number param = lua_tonumber(L, 2);
  9386. inst->z = param;
  9387. return 0;
  9388. }
  9389. static int Polycore_Vector3(lua_State *L) {
  9390. luaL_checktype(L, 1, LUA_TNUMBER);
  9391. Number x = lua_tonumber(L, 1);
  9392. luaL_checktype(L, 2, LUA_TNUMBER);
  9393. Number y = lua_tonumber(L, 2);
  9394. luaL_checktype(L, 3, LUA_TNUMBER);
  9395. Number z = lua_tonumber(L, 3);
  9396. Vector3 *inst = new Vector3(x, y, z);
  9397. lua_pushlightuserdata(L, (void*)inst);
  9398. return 1;
  9399. }
  9400. static int Polycore_Vector3_set(lua_State *L) {
  9401. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  9402. Vector3 *inst = (Vector3*)lua_topointer(L, 1);
  9403. luaL_checktype(L, 2, LUA_TNUMBER);
  9404. Number x = lua_tonumber(L, 2);
  9405. luaL_checktype(L, 3, LUA_TNUMBER);
  9406. Number y = lua_tonumber(L, 3);
  9407. luaL_checktype(L, 4, LUA_TNUMBER);
  9408. Number z = lua_tonumber(L, 4);
  9409. inst->set(x, y, z);
  9410. return 0;
  9411. }
  9412. static int Polycore_Vector3_distance(lua_State *L) {
  9413. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  9414. Vector3 *inst = (Vector3*)lua_topointer(L, 1);
  9415. luaL_checktype(L, 2, LUA_TLIGHTUSERDATA);
  9416. const Vector3 & vec2 = *( Vector3 *)lua_topointer(L, 2);
  9417. lua_pushnumber(L, inst->distance(vec2));
  9418. return 1;
  9419. }
  9420. static int Polycore_Vector3_length(lua_State *L) {
  9421. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  9422. Vector3 *inst = (Vector3*)lua_topointer(L, 1);
  9423. lua_pushnumber(L, inst->length());
  9424. return 1;
  9425. }
  9426. static int Polycore_Vector3_dot(lua_State *L) {
  9427. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  9428. Vector3 *inst = (Vector3*)lua_topointer(L, 1);
  9429. luaL_checktype(L, 2, LUA_TLIGHTUSERDATA);
  9430. Vector3 & u = *(Vector3 *)lua_topointer(L, 2);
  9431. lua_pushnumber(L, inst->dot(u));
  9432. return 1;
  9433. }
  9434. static int Polycore_Vector3_crossProduct(lua_State *L) {
  9435. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  9436. Vector3 *inst = (Vector3*)lua_topointer(L, 1);
  9437. luaL_checktype(L, 2, LUA_TLIGHTUSERDATA);
  9438. const Vector3 & vec2 = *( Vector3 *)lua_topointer(L, 2);
  9439. Vector3 *retInst = new Vector3();
  9440. *retInst = inst->crossProduct(vec2);
  9441. lua_pushlightuserdata(L, retInst);
  9442. return 1;
  9443. }
  9444. static int Polycore_Vector3_Normalize(lua_State *L) {
  9445. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  9446. Vector3 *inst = (Vector3*)lua_topointer(L, 1);
  9447. inst->Normalize();
  9448. return 0;
  9449. }
  9450. static int Polycore_delete_Vector3(lua_State *L) {
  9451. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  9452. Vector3 *inst = (Vector3*)lua_topointer(L, 1);
  9453. delete inst;
  9454. return 0;
  9455. }
  9456. static int Polycore_Vertex_get_restNormal(lua_State *L) {
  9457. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  9458. Vertex *inst = (Vertex*)lua_topointer(L, 1);
  9459. lua_pushlightuserdata(L, &inst->restNormal);
  9460. return 1;
  9461. }
  9462. static int Polycore_Vertex_get_restPosition(lua_State *L) {
  9463. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  9464. Vertex *inst = (Vertex*)lua_topointer(L, 1);
  9465. lua_pushlightuserdata(L, &inst->restPosition);
  9466. return 1;
  9467. }
  9468. static int Polycore_Vertex_get_normal(lua_State *L) {
  9469. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  9470. Vertex *inst = (Vertex*)lua_topointer(L, 1);
  9471. lua_pushlightuserdata(L, &inst->normal);
  9472. return 1;
  9473. }
  9474. static int Polycore_Vertex_get_vertexColor(lua_State *L) {
  9475. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  9476. Vertex *inst = (Vertex*)lua_topointer(L, 1);
  9477. lua_pushlightuserdata(L, &inst->vertexColor);
  9478. return 1;
  9479. }
  9480. static int Polycore_Vertex_get_useVertexColor(lua_State *L) {
  9481. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  9482. Vertex *inst = (Vertex*)lua_topointer(L, 1);
  9483. lua_pushboolean(L, inst->useVertexColor);
  9484. return 1;
  9485. }
  9486. static int Polycore_Vertex_set_useVertexColor(lua_State *L) {
  9487. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  9488. Vertex *inst = (Vertex*)lua_topointer(L, 1);
  9489. bool param = lua_toboolean(L, 2);
  9490. inst->useVertexColor = param;
  9491. return 0;
  9492. }
  9493. static int Polycore_Vertex(lua_State *L) {
  9494. Vertex *inst = new Vertex();
  9495. lua_pushlightuserdata(L, (void*)inst);
  9496. return 1;
  9497. }
  9498. static int Polycore_Vertex_addBoneAssignment(lua_State *L) {
  9499. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  9500. Vertex *inst = (Vertex*)lua_topointer(L, 1);
  9501. luaL_checktype(L, 2, LUA_TNUMBER);
  9502. unsigned int boneID = lua_tointeger(L, 2);
  9503. luaL_checktype(L, 3, LUA_TNUMBER);
  9504. Number boneWeight = lua_tonumber(L, 3);
  9505. inst->addBoneAssignment(boneID, boneWeight);
  9506. return 0;
  9507. }
  9508. static int Polycore_Vertex_getNumBoneAssignments(lua_State *L) {
  9509. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  9510. Vertex *inst = (Vertex*)lua_topointer(L, 1);
  9511. lua_pushinteger(L, inst->getNumBoneAssignments());
  9512. return 1;
  9513. }
  9514. static int Polycore_Vertex_getBoneAssignment(lua_State *L) {
  9515. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  9516. Vertex *inst = (Vertex*)lua_topointer(L, 1);
  9517. luaL_checktype(L, 2, LUA_TNUMBER);
  9518. unsigned int index = lua_tointeger(L, 2);
  9519. void *ptrRetVal = (void*)inst->getBoneAssignment(index);
  9520. if(ptrRetVal == NULL) {
  9521. lua_pushnil(L);
  9522. } else {
  9523. lua_pushlightuserdata(L, ptrRetVal);
  9524. }
  9525. return 1;
  9526. }
  9527. static int Polycore_Vertex_normalizeWeights(lua_State *L) {
  9528. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  9529. Vertex *inst = (Vertex*)lua_topointer(L, 1);
  9530. inst->normalizeWeights();
  9531. return 0;
  9532. }
  9533. static int Polycore_Vertex_getTexCoord(lua_State *L) {
  9534. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  9535. Vertex *inst = (Vertex*)lua_topointer(L, 1);
  9536. Vector2 *retInst = new Vector2();
  9537. *retInst = inst->getTexCoord();
  9538. lua_pushlightuserdata(L, retInst);
  9539. return 1;
  9540. }
  9541. static int Polycore_Vertex_setTexCoord(lua_State *L) {
  9542. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  9543. Vertex *inst = (Vertex*)lua_topointer(L, 1);
  9544. luaL_checktype(L, 2, LUA_TNUMBER);
  9545. Number u = lua_tonumber(L, 2);
  9546. luaL_checktype(L, 3, LUA_TNUMBER);
  9547. Number v = lua_tonumber(L, 3);
  9548. inst->setTexCoord(u, v);
  9549. return 0;
  9550. }
  9551. static int Polycore_Vertex_setNormal(lua_State *L) {
  9552. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  9553. Vertex *inst = (Vertex*)lua_topointer(L, 1);
  9554. luaL_checktype(L, 2, LUA_TNUMBER);
  9555. Number x = lua_tonumber(L, 2);
  9556. luaL_checktype(L, 3, LUA_TNUMBER);
  9557. Number y = lua_tonumber(L, 3);
  9558. luaL_checktype(L, 4, LUA_TNUMBER);
  9559. Number z = lua_tonumber(L, 4);
  9560. inst->setNormal(x, y, z);
  9561. return 0;
  9562. }
  9563. static int Polycore_delete_Vertex(lua_State *L) {
  9564. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  9565. Vertex *inst = (Vertex*)lua_topointer(L, 1);
  9566. delete inst;
  9567. return 0;
  9568. }
  9569. }