PolycodeLUAWrappers.h 334 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394
  1. #pragma once
  2. extern "C" {
  3. #include <stdio.h>
  4. #include "lua.h"
  5. #include "lualib.h"
  6. #include "lauxlib.h"
  7. } // extern "C"
  8. #include "OSBasics.h"
  9. #include "PolyBasics.h"
  10. #include "PolyBezierCurve.h"
  11. #include "PolyBone.h"
  12. #include "PolyCamera.h"
  13. #include "Polycode.h"
  14. #include "PolyColor.h"
  15. #include "PolyConfig.h"
  16. #include "PolyCore.h"
  17. #include "PolyCoreInput.h"
  18. #include "PolyCoreServices.h"
  19. #include "PolyCubemap.h"
  20. #include "PolyData.h"
  21. #include "PolyEntity.h"
  22. #include "PolyEvent.h"
  23. #include "PolyEventDispatcher.h"
  24. #include "PolyEventHandler.h"
  25. #include "PolyFixedShader.h"
  26. #include "PolyFont.h"
  27. #include "PolyFontManager.h"
  28. #include "PolyGLCubemap.h"
  29. #include "PolyGlobals.h"
  30. #include "PolyImage.h"
  31. #include "PolyInputEvent.h"
  32. #include "PolyInputKeys.h"
  33. #include "PolyLabel.h"
  34. #include "PolyLogger.h"
  35. #include "PolyMaterial.h"
  36. #include "PolyMaterialManager.h"
  37. #include "PolyMatrix4.h"
  38. #include "PolyMesh.h"
  39. #include "PolyModule.h"
  40. #include "PolyObject.h"
  41. #include "PolyParticle.h"
  42. #include "PolyParticleEmitter.h"
  43. #include "PolyPerlin.h"
  44. #include "PolyPolygon.h"
  45. #include "PolyQuaternion.h"
  46. #include "PolyQuaternionCurve.h"
  47. #include "PolyRectangle.h"
  48. #include "PolyRenderer.h"
  49. #include "PolyResource.h"
  50. #include "PolyResourceManager.h"
  51. #include "PolyScene.h"
  52. #include "PolySceneEntity.h"
  53. #include "PolySceneLabel.h"
  54. #include "PolySceneLight.h"
  55. #include "PolySceneLine.h"
  56. #include "PolySceneManager.h"
  57. #include "PolySceneMesh.h"
  58. #include "PolyScenePrimitive.h"
  59. #include "PolySceneRenderTexture.h"
  60. #include "PolySceneSound.h"
  61. #include "PolyScreen.h"
  62. #include "PolyScreenCurve.h"
  63. #include "PolyScreenEntity.h"
  64. #include "PolyScreenEvent.h"
  65. #include "PolyScreenImage.h"
  66. #include "PolyScreenLabel.h"
  67. #include "PolyScreenLine.h"
  68. #include "PolyScreenManager.h"
  69. #include "PolyScreenMesh.h"
  70. #include "PolyScreenShape.h"
  71. #include "PolyScreenSound.h"
  72. #include "PolyScreenSprite.h"
  73. #include "PolyShader.h"
  74. #include "PolySkeleton.h"
  75. #include "PolySound.h"
  76. #include "PolySoundManager.h"
  77. #include "PolyString.h"
  78. #include "PolyTexture.h"
  79. #include "PolyTimer.h"
  80. #include "PolyTimerManager.h"
  81. #include "PolyTween.h"
  82. #include "PolyTweenManager.h"
  83. #include "PolyVector2.h"
  84. #include "PolyVector3.h"
  85. #include "PolyVertex.h"
  86. namespace Polycode {
  87. class LuaEventHandler : public EventHandler {
  88. public:
  89. LuaEventHandler() : EventHandler() {}
  90. ~LuaEventHandler();
  91. void handleEvent(Event *e) {
  92. lua_rawgeti( L, LUA_REGISTRYINDEX, wrapperIndex );
  93. lua_getfield(L, -1, "__handleEvent");
  94. lua_rawgeti( L, LUA_REGISTRYINDEX, wrapperIndex );
  95. lua_pushlightuserdata(L, e);
  96. lua_call(L, 2, 0);
  97. }
  98. int wrapperIndex;
  99. lua_State *L;
  100. };
  101. static int Polycore_OSFILE_get_fileType(lua_State *L) {
  102. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  103. OSFILE *inst = (OSFILE*)lua_topointer(L, 1);
  104. lua_pushinteger(L, inst->fileType);
  105. return 1;
  106. }
  107. static int Polycore_OSFILE_set_fileType(lua_State *L) {
  108. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  109. OSFILE *inst = (OSFILE*)lua_topointer(L, 1);
  110. int param = lua_tointeger(L, 2);
  111. inst->fileType = param;
  112. return 0;
  113. }
  114. static int Polycore_OSFILE(lua_State *L) {
  115. OSFILE *inst = new OSFILE();
  116. lua_pushlightuserdata(L, (void*)inst);
  117. return 1;
  118. }
  119. static int Polycore_OSFILE_debugDump(lua_State *L) {
  120. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  121. OSFILE *inst = (OSFILE*)lua_topointer(L, 1);
  122. inst->debugDump();
  123. return 0;
  124. }
  125. static int Polycore_delete_OSFILE(lua_State *L) {
  126. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  127. OSFILE *inst = (OSFILE*)lua_topointer(L, 1);
  128. delete inst;
  129. return 0;
  130. }
  131. static int Polycore_OSFileEntry_get_name(lua_State *L) {
  132. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  133. OSFileEntry *inst = (OSFileEntry*)lua_topointer(L, 1);
  134. lua_pushstring(L, inst->name.c_str());
  135. return 1;
  136. }
  137. static int Polycore_OSFileEntry_get_extension(lua_State *L) {
  138. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  139. OSFileEntry *inst = (OSFileEntry*)lua_topointer(L, 1);
  140. lua_pushstring(L, inst->extension.c_str());
  141. return 1;
  142. }
  143. static int Polycore_OSFileEntry_get_nameWithoutExtension(lua_State *L) {
  144. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  145. OSFileEntry *inst = (OSFileEntry*)lua_topointer(L, 1);
  146. lua_pushstring(L, inst->nameWithoutExtension.c_str());
  147. return 1;
  148. }
  149. static int Polycore_OSFileEntry_get_basePath(lua_State *L) {
  150. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  151. OSFileEntry *inst = (OSFileEntry*)lua_topointer(L, 1);
  152. lua_pushstring(L, inst->basePath.c_str());
  153. return 1;
  154. }
  155. static int Polycore_OSFileEntry_get_fullPath(lua_State *L) {
  156. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  157. OSFileEntry *inst = (OSFileEntry*)lua_topointer(L, 1);
  158. lua_pushstring(L, inst->fullPath.c_str());
  159. return 1;
  160. }
  161. static int Polycore_OSFileEntry_get_type(lua_State *L) {
  162. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  163. OSFileEntry *inst = (OSFileEntry*)lua_topointer(L, 1);
  164. lua_pushinteger(L, inst->type);
  165. return 1;
  166. }
  167. static int Polycore_OSFileEntry_set_name(lua_State *L) {
  168. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  169. OSFileEntry *inst = (OSFileEntry*)lua_topointer(L, 1);
  170. String param = lua_tostring(L, 2);
  171. inst->name = param;
  172. return 0;
  173. }
  174. static int Polycore_OSFileEntry_set_extension(lua_State *L) {
  175. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  176. OSFileEntry *inst = (OSFileEntry*)lua_topointer(L, 1);
  177. String param = lua_tostring(L, 2);
  178. inst->extension = param;
  179. return 0;
  180. }
  181. static int Polycore_OSFileEntry_set_nameWithoutExtension(lua_State *L) {
  182. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  183. OSFileEntry *inst = (OSFileEntry*)lua_topointer(L, 1);
  184. String param = lua_tostring(L, 2);
  185. inst->nameWithoutExtension = param;
  186. return 0;
  187. }
  188. static int Polycore_OSFileEntry_set_basePath(lua_State *L) {
  189. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  190. OSFileEntry *inst = (OSFileEntry*)lua_topointer(L, 1);
  191. String param = lua_tostring(L, 2);
  192. inst->basePath = param;
  193. return 0;
  194. }
  195. static int Polycore_OSFileEntry_set_fullPath(lua_State *L) {
  196. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  197. OSFileEntry *inst = (OSFileEntry*)lua_topointer(L, 1);
  198. String param = lua_tostring(L, 2);
  199. inst->fullPath = param;
  200. return 0;
  201. }
  202. static int Polycore_OSFileEntry_set_type(lua_State *L) {
  203. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  204. OSFileEntry *inst = (OSFileEntry*)lua_topointer(L, 1);
  205. int param = lua_tointeger(L, 2);
  206. inst->type = param;
  207. return 0;
  208. }
  209. static int Polycore_OSFileEntry(lua_State *L) {
  210. OSFileEntry *inst = new OSFileEntry();
  211. lua_pushlightuserdata(L, (void*)inst);
  212. return 1;
  213. }
  214. static int Polycore_delete_OSFileEntry(lua_State *L) {
  215. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  216. OSFileEntry *inst = (OSFileEntry*)lua_topointer(L, 1);
  217. delete inst;
  218. return 0;
  219. }
  220. static int Polycore_OSBasics_open(lua_State *L) {
  221. luaL_checktype(L, 2, LUA_TSTRING);
  222. String filename = String(lua_tostring(L, 2));
  223. luaL_checktype(L, 3, LUA_TSTRING);
  224. String opts = String(lua_tostring(L, 3));
  225. void *ptrRetVal = (void*)OSBasics::open(filename, opts);
  226. if(ptrRetVal == NULL) {
  227. lua_pushnil(L);
  228. } else {
  229. lua_pushlightuserdata(L, ptrRetVal);
  230. }
  231. return 1;
  232. }
  233. static int Polycore_OSBasics_close(lua_State *L) {
  234. luaL_checktype(L, 2, LUA_TLIGHTUSERDATA);
  235. OSFILE* file = (OSFILE*)lua_topointer(L, 2);
  236. lua_pushinteger(L, OSBasics::close(file));
  237. return 1;
  238. }
  239. static int Polycore_OSBasics_read(lua_State *L) {
  240. luaL_checktype(L, 2, LUA_TLIGHTUSERDATA);
  241. void* ptr = (void*)lua_topointer(L, 2);
  242. luaL_checktype(L, 3, LUA_TLIGHTUSERDATA);
  243. size_t size = *(size_t*)lua_topointer(L, 3);
  244. luaL_checktype(L, 4, LUA_TLIGHTUSERDATA);
  245. size_t count = *(size_t*)lua_topointer(L, 4);
  246. luaL_checktype(L, 5, LUA_TLIGHTUSERDATA);
  247. OSFILE* stream = (OSFILE*)lua_topointer(L, 5);
  248. lua_pushinteger(L, OSBasics::read(ptr, size, count, stream));
  249. return 1;
  250. }
  251. static int Polycore_OSBasics_write(lua_State *L) {
  252. luaL_checktype(L, 2, LUA_TLIGHTUSERDATA);
  253. void* ptr = (void*)lua_topointer(L, 2);
  254. luaL_checktype(L, 3, LUA_TLIGHTUSERDATA);
  255. size_t size = *(size_t*)lua_topointer(L, 3);
  256. luaL_checktype(L, 4, LUA_TLIGHTUSERDATA);
  257. size_t count = *(size_t*)lua_topointer(L, 4);
  258. luaL_checktype(L, 5, LUA_TLIGHTUSERDATA);
  259. OSFILE* stream = (OSFILE*)lua_topointer(L, 5);
  260. lua_pushinteger(L, OSBasics::write(ptr, size, count, stream));
  261. return 1;
  262. }
  263. static int Polycore_OSBasics_seek(lua_State *L) {
  264. luaL_checktype(L, 2, LUA_TLIGHTUSERDATA);
  265. OSFILE* stream = (OSFILE*)lua_topointer(L, 2);
  266. luaL_checktype(L, 3, LUA_TLIGHTUSERDATA);
  267. long int offset = *(long int*)lua_topointer(L, 3);
  268. luaL_checktype(L, 4, LUA_TNUMBER);
  269. int origin = lua_tointeger(L, 4);
  270. lua_pushinteger(L, OSBasics::seek(stream, offset, origin));
  271. return 1;
  272. }
  273. static int Polycore_OSBasics_tell(lua_State *L) {
  274. luaL_checktype(L, 2, LUA_TLIGHTUSERDATA);
  275. OSFILE* stream = (OSFILE*)lua_topointer(L, 2);
  276. lua_pushinteger(L, OSBasics::tell(stream));
  277. return 1;
  278. }
  279. static int Polycore_OSBasics_isFolder(lua_State *L) {
  280. luaL_checktype(L, 2, LUA_TSTRING);
  281. String pathString = String(lua_tostring(L, 2));
  282. lua_pushboolean(L, OSBasics::isFolder(pathString));
  283. return 1;
  284. }
  285. static int Polycore_OSBasics_createFolder(lua_State *L) {
  286. luaL_checktype(L, 2, LUA_TSTRING);
  287. String pathString = String(lua_tostring(L, 2));
  288. OSBasics::createFolder(pathString);
  289. return 0;
  290. }
  291. static int Polycore_OSBasics_removeItem(lua_State *L) {
  292. luaL_checktype(L, 2, LUA_TSTRING);
  293. String pathString = String(lua_tostring(L, 2));
  294. OSBasics::removeItem(pathString);
  295. return 0;
  296. }
  297. static int Polycore_delete_OSBasics(lua_State *L) {
  298. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  299. OSBasics *inst = (OSBasics*)lua_topointer(L, 1);
  300. delete inst;
  301. return 0;
  302. }
  303. static int Polycore_BezierCurve(lua_State *L) {
  304. BezierCurve *inst = new BezierCurve();
  305. lua_pushlightuserdata(L, (void*)inst);
  306. return 1;
  307. }
  308. static int Polycore_BezierCurve_getControlPoint(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. unsigned int index = lua_tointeger(L, 2);
  313. void *ptrRetVal = (void*)inst->getControlPoint(index);
  314. if(ptrRetVal == NULL) {
  315. lua_pushnil(L);
  316. } else {
  317. lua_pushlightuserdata(L, ptrRetVal);
  318. }
  319. return 1;
  320. }
  321. static int Polycore_BezierCurve_getNumControlPoints(lua_State *L) {
  322. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  323. BezierCurve *inst = (BezierCurve*)lua_topointer(L, 1);
  324. lua_pushinteger(L, inst->getNumControlPoints());
  325. return 1;
  326. }
  327. static int Polycore_BezierCurve_addControlPoint(lua_State *L) {
  328. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  329. BezierCurve *inst = (BezierCurve*)lua_topointer(L, 1);
  330. luaL_checktype(L, 2, LUA_TNUMBER);
  331. Number p1x = lua_tonumber(L, 2);
  332. luaL_checktype(L, 3, LUA_TNUMBER);
  333. Number p1y = lua_tonumber(L, 3);
  334. luaL_checktype(L, 4, LUA_TNUMBER);
  335. Number p1z = lua_tonumber(L, 4);
  336. luaL_checktype(L, 5, LUA_TNUMBER);
  337. Number p2x = lua_tonumber(L, 5);
  338. luaL_checktype(L, 6, LUA_TNUMBER);
  339. Number p2y = lua_tonumber(L, 6);
  340. luaL_checktype(L, 7, LUA_TNUMBER);
  341. Number p2z = lua_tonumber(L, 7);
  342. luaL_checktype(L, 8, LUA_TNUMBER);
  343. Number p3x = lua_tonumber(L, 8);
  344. luaL_checktype(L, 9, LUA_TNUMBER);
  345. Number p3y = lua_tonumber(L, 9);
  346. luaL_checktype(L, 10, LUA_TNUMBER);
  347. Number p3z = lua_tonumber(L, 10);
  348. inst->addControlPoint(p1x, p1y, p1z, p2x, p2y, p2z, p3x, p3y, p3z);
  349. return 0;
  350. }
  351. static int Polycore_BezierCurve_addControlPoint3dWithHandles(lua_State *L) {
  352. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  353. BezierCurve *inst = (BezierCurve*)lua_topointer(L, 1);
  354. luaL_checktype(L, 2, LUA_TNUMBER);
  355. Number p1x = lua_tonumber(L, 2);
  356. luaL_checktype(L, 3, LUA_TNUMBER);
  357. Number p1y = lua_tonumber(L, 3);
  358. luaL_checktype(L, 4, LUA_TNUMBER);
  359. Number p1z = lua_tonumber(L, 4);
  360. luaL_checktype(L, 5, LUA_TNUMBER);
  361. Number p2x = lua_tonumber(L, 5);
  362. luaL_checktype(L, 6, LUA_TNUMBER);
  363. Number p2y = lua_tonumber(L, 6);
  364. luaL_checktype(L, 7, LUA_TNUMBER);
  365. Number p2z = lua_tonumber(L, 7);
  366. luaL_checktype(L, 8, LUA_TNUMBER);
  367. Number p3x = lua_tonumber(L, 8);
  368. luaL_checktype(L, 9, LUA_TNUMBER);
  369. Number p3y = lua_tonumber(L, 9);
  370. luaL_checktype(L, 10, LUA_TNUMBER);
  371. Number p3z = lua_tonumber(L, 10);
  372. inst->addControlPoint3dWithHandles(p1x, p1y, p1z, p2x, p2y, p2z, p3x, p3y, p3z);
  373. return 0;
  374. }
  375. static int Polycore_BezierCurve_addControlPoint3d(lua_State *L) {
  376. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  377. BezierCurve *inst = (BezierCurve*)lua_topointer(L, 1);
  378. luaL_checktype(L, 2, LUA_TNUMBER);
  379. Number x = lua_tonumber(L, 2);
  380. luaL_checktype(L, 3, LUA_TNUMBER);
  381. Number y = lua_tonumber(L, 3);
  382. luaL_checktype(L, 4, LUA_TNUMBER);
  383. Number z = lua_tonumber(L, 4);
  384. inst->addControlPoint3d(x, y, z);
  385. return 0;
  386. }
  387. static int Polycore_BezierCurve_addControlPoint2dWithHandles(lua_State *L) {
  388. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  389. BezierCurve *inst = (BezierCurve*)lua_topointer(L, 1);
  390. luaL_checktype(L, 2, LUA_TNUMBER);
  391. Number p1x = lua_tonumber(L, 2);
  392. luaL_checktype(L, 3, LUA_TNUMBER);
  393. Number p1y = lua_tonumber(L, 3);
  394. luaL_checktype(L, 4, LUA_TNUMBER);
  395. Number p2x = lua_tonumber(L, 4);
  396. luaL_checktype(L, 5, LUA_TNUMBER);
  397. Number p2y = lua_tonumber(L, 5);
  398. luaL_checktype(L, 6, LUA_TNUMBER);
  399. Number p3x = lua_tonumber(L, 6);
  400. luaL_checktype(L, 7, LUA_TNUMBER);
  401. Number p3y = lua_tonumber(L, 7);
  402. inst->addControlPoint2dWithHandles(p1x, p1y, p2x, p2y, p3x, p3y);
  403. return 0;
  404. }
  405. static int Polycore_BezierCurve_addControlPoint2d(lua_State *L) {
  406. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  407. BezierCurve *inst = (BezierCurve*)lua_topointer(L, 1);
  408. luaL_checktype(L, 2, LUA_TNUMBER);
  409. Number x = lua_tonumber(L, 2);
  410. luaL_checktype(L, 3, LUA_TNUMBER);
  411. Number y = lua_tonumber(L, 3);
  412. inst->addControlPoint2d(x, y);
  413. return 0;
  414. }
  415. static int Polycore_BezierCurve_getHeightAt(lua_State *L) {
  416. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  417. BezierCurve *inst = (BezierCurve*)lua_topointer(L, 1);
  418. luaL_checktype(L, 2, LUA_TNUMBER);
  419. Number a = lua_tonumber(L, 2);
  420. lua_pushnumber(L, inst->getHeightAt(a));
  421. return 1;
  422. }
  423. static int Polycore_BezierCurve_getPointAt(lua_State *L) {
  424. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  425. BezierCurve *inst = (BezierCurve*)lua_topointer(L, 1);
  426. luaL_checktype(L, 2, LUA_TNUMBER);
  427. Number a = lua_tonumber(L, 2);
  428. Vector3 *retInst = new Vector3();
  429. *retInst = inst->getPointAt(a);
  430. lua_pushlightuserdata(L, retInst);
  431. return 1;
  432. }
  433. static int Polycore_BezierCurve_getPointBetween(lua_State *L) {
  434. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  435. BezierCurve *inst = (BezierCurve*)lua_topointer(L, 1);
  436. luaL_checktype(L, 2, LUA_TNUMBER);
  437. Number a = lua_tonumber(L, 2);
  438. luaL_checktype(L, 3, LUA_TLIGHTUSERDATA);
  439. BezierPoint* bp1 = (BezierPoint*)lua_topointer(L, 3);
  440. luaL_checktype(L, 4, LUA_TLIGHTUSERDATA);
  441. BezierPoint* bp2 = (BezierPoint*)lua_topointer(L, 4);
  442. Vector3 *retInst = new Vector3();
  443. *retInst = inst->getPointBetween(a, bp1, bp2);
  444. lua_pushlightuserdata(L, retInst);
  445. return 1;
  446. }
  447. static int Polycore_BezierCurve_rebuildBuffers(lua_State *L) {
  448. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  449. BezierCurve *inst = (BezierCurve*)lua_topointer(L, 1);
  450. inst->rebuildBuffers();
  451. return 0;
  452. }
  453. static int Polycore_delete_BezierCurve(lua_State *L) {
  454. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  455. BezierCurve *inst = (BezierCurve*)lua_topointer(L, 1);
  456. delete inst;
  457. return 0;
  458. }
  459. static int Polycore_Bone_get_parentBoneId(lua_State *L) {
  460. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  461. Bone *inst = (Bone*)lua_topointer(L, 1);
  462. lua_pushinteger(L, inst->parentBoneId);
  463. return 1;
  464. }
  465. static int Polycore_Bone_get_boneMatrix(lua_State *L) {
  466. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  467. Bone *inst = (Bone*)lua_topointer(L, 1);
  468. lua_pushlightuserdata(L, &inst->boneMatrix);
  469. return 1;
  470. }
  471. static int Polycore_Bone_get_restMatrix(lua_State *L) {
  472. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  473. Bone *inst = (Bone*)lua_topointer(L, 1);
  474. lua_pushlightuserdata(L, &inst->restMatrix);
  475. return 1;
  476. }
  477. static int Polycore_Bone_get_baseMatrix(lua_State *L) {
  478. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  479. Bone *inst = (Bone*)lua_topointer(L, 1);
  480. lua_pushlightuserdata(L, &inst->baseMatrix);
  481. return 1;
  482. }
  483. static int Polycore_Bone_set_parentBoneId(lua_State *L) {
  484. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  485. Bone *inst = (Bone*)lua_topointer(L, 1);
  486. int param = lua_tointeger(L, 2);
  487. inst->parentBoneId = param;
  488. return 0;
  489. }
  490. static int Polycore_Bone(lua_State *L) {
  491. luaL_checktype(L, 1, LUA_TSTRING);
  492. String boneName = String(lua_tostring(L, 1));
  493. Bone *inst = new Bone(boneName);
  494. lua_pushlightuserdata(L, (void*)inst);
  495. return 1;
  496. }
  497. static int Polycore_Bone_enableBoneLabel(lua_State *L) {
  498. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  499. Bone *inst = (Bone*)lua_topointer(L, 1);
  500. luaL_checktype(L, 2, LUA_TSTRING);
  501. String labelFont = String(lua_tostring(L, 2));
  502. luaL_checktype(L, 3, LUA_TNUMBER);
  503. Number size = lua_tonumber(L, 3);
  504. luaL_checktype(L, 4, LUA_TNUMBER);
  505. Number scale = lua_tonumber(L, 4);
  506. luaL_checktype(L, 5, LUA_TLIGHTUSERDATA);
  507. Color labelColor = *(Color*)lua_topointer(L, 5);
  508. inst->enableBoneLabel(labelFont, size, scale, labelColor);
  509. return 0;
  510. }
  511. static int Polycore_Bone_getName(lua_State *L) {
  512. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  513. Bone *inst = (Bone*)lua_topointer(L, 1);
  514. String *retInst = new String ();
  515. *retInst = inst->getName();
  516. lua_pushlightuserdata(L, retInst);
  517. return 1;
  518. }
  519. static int Polycore_Bone_Render(lua_State *L) {
  520. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  521. Bone *inst = (Bone*)lua_topointer(L, 1);
  522. inst->Render();
  523. return 0;
  524. }
  525. static int Polycore_Bone_setParentBone(lua_State *L) {
  526. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  527. Bone *inst = (Bone*)lua_topointer(L, 1);
  528. luaL_checktype(L, 2, LUA_TLIGHTUSERDATA);
  529. Bone* bone = (Bone*)lua_topointer(L, 2);
  530. inst->setParentBone(bone);
  531. return 0;
  532. }
  533. static int Polycore_Bone_addChildBone(lua_State *L) {
  534. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  535. Bone *inst = (Bone*)lua_topointer(L, 1);
  536. luaL_checktype(L, 2, LUA_TLIGHTUSERDATA);
  537. Bone* bone = (Bone*)lua_topointer(L, 2);
  538. inst->addChildBone(bone);
  539. return 0;
  540. }
  541. static int Polycore_Bone_getParentBone(lua_State *L) {
  542. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  543. Bone *inst = (Bone*)lua_topointer(L, 1);
  544. void *ptrRetVal = (void*)inst->getParentBone();
  545. if(ptrRetVal == NULL) {
  546. lua_pushnil(L);
  547. } else {
  548. lua_pushlightuserdata(L, ptrRetVal);
  549. }
  550. return 1;
  551. }
  552. static int Polycore_Bone_getNumChildBones(lua_State *L) {
  553. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  554. Bone *inst = (Bone*)lua_topointer(L, 1);
  555. lua_pushinteger(L, inst->getNumChildBones());
  556. return 1;
  557. }
  558. static int Polycore_Bone_getChildBone(lua_State *L) {
  559. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  560. Bone *inst = (Bone*)lua_topointer(L, 1);
  561. luaL_checktype(L, 2, LUA_TNUMBER);
  562. unsigned int index = lua_tointeger(L, 2);
  563. void *ptrRetVal = (void*)inst->getChildBone(index);
  564. if(ptrRetVal == NULL) {
  565. lua_pushnil(L);
  566. } else {
  567. lua_pushlightuserdata(L, ptrRetVal);
  568. }
  569. return 1;
  570. }
  571. static int Polycore_Bone_getBoneMatrix(lua_State *L) {
  572. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  573. Bone *inst = (Bone*)lua_topointer(L, 1);
  574. Matrix4 *retInst = new Matrix4();
  575. *retInst = inst->getBoneMatrix();
  576. lua_pushlightuserdata(L, retInst);
  577. return 1;
  578. }
  579. static int Polycore_Bone_setBoneMatrix(lua_State *L) {
  580. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  581. Bone *inst = (Bone*)lua_topointer(L, 1);
  582. luaL_checktype(L, 2, LUA_TLIGHTUSERDATA);
  583. Matrix4 matrix = *(Matrix4*)lua_topointer(L, 2);
  584. inst->setBoneMatrix(matrix);
  585. return 0;
  586. }
  587. static int Polycore_Bone_getRestMatrix(lua_State *L) {
  588. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  589. Bone *inst = (Bone*)lua_topointer(L, 1);
  590. Matrix4 *retInst = new Matrix4();
  591. *retInst = inst->getRestMatrix();
  592. lua_pushlightuserdata(L, retInst);
  593. return 1;
  594. }
  595. static int Polycore_Bone_getFullRestMatrix(lua_State *L) {
  596. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  597. Bone *inst = (Bone*)lua_topointer(L, 1);
  598. Matrix4 *retInst = new Matrix4();
  599. *retInst = inst->getFullRestMatrix();
  600. lua_pushlightuserdata(L, retInst);
  601. return 1;
  602. }
  603. static int Polycore_Bone_getParentRestMatrix(lua_State *L) {
  604. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  605. Bone *inst = (Bone*)lua_topointer(L, 1);
  606. Matrix4 *retInst = new Matrix4();
  607. *retInst = inst->getParentRestMatrix();
  608. lua_pushlightuserdata(L, retInst);
  609. return 1;
  610. }
  611. static int Polycore_Bone_getFinalMatrix(lua_State *L) {
  612. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  613. Bone *inst = (Bone*)lua_topointer(L, 1);
  614. Matrix4 *retInst = new Matrix4();
  615. *retInst = inst->getFinalMatrix();
  616. lua_pushlightuserdata(L, retInst);
  617. return 1;
  618. }
  619. static int Polycore_Bone_setRestMatrix(lua_State *L) {
  620. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  621. Bone *inst = (Bone*)lua_topointer(L, 1);
  622. luaL_checktype(L, 2, LUA_TLIGHTUSERDATA);
  623. Matrix4 matrix = *(Matrix4*)lua_topointer(L, 2);
  624. inst->setRestMatrix(matrix);
  625. return 0;
  626. }
  627. static int Polycore_Bone_setBaseMatrix(lua_State *L) {
  628. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  629. Bone *inst = (Bone*)lua_topointer(L, 1);
  630. luaL_checktype(L, 2, LUA_TLIGHTUSERDATA);
  631. Matrix4 matrix = *(Matrix4*)lua_topointer(L, 2);
  632. inst->setBaseMatrix(matrix);
  633. return 0;
  634. }
  635. static int Polycore_Bone_getBaseMatrix(lua_State *L) {
  636. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  637. Bone *inst = (Bone*)lua_topointer(L, 1);
  638. Matrix4 *retInst = new Matrix4 ();
  639. *retInst = inst->getBaseMatrix();
  640. lua_pushlightuserdata(L, retInst);
  641. return 1;
  642. }
  643. static int Polycore_Bone_getFullBaseMatrix(lua_State *L) {
  644. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  645. Bone *inst = (Bone*)lua_topointer(L, 1);
  646. Matrix4 *retInst = new Matrix4();
  647. *retInst = inst->getFullBaseMatrix();
  648. lua_pushlightuserdata(L, retInst);
  649. return 1;
  650. }
  651. static int Polycore_delete_Bone(lua_State *L) {
  652. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  653. Bone *inst = (Bone*)lua_topointer(L, 1);
  654. delete inst;
  655. return 0;
  656. }
  657. static int Polycore_Camera(lua_State *L) {
  658. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  659. Scene* parentScene = (Scene*)lua_topointer(L, 1);
  660. Camera *inst = new Camera(parentScene);
  661. lua_pushlightuserdata(L, (void*)inst);
  662. return 1;
  663. }
  664. static int Polycore_Camera_buildFrustrumPlanes(lua_State *L) {
  665. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  666. Camera *inst = (Camera*)lua_topointer(L, 1);
  667. inst->buildFrustrumPlanes();
  668. return 0;
  669. }
  670. static int Polycore_Camera_isSphereInFrustrum(lua_State *L) {
  671. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  672. Camera *inst = (Camera*)lua_topointer(L, 1);
  673. luaL_checktype(L, 2, LUA_TLIGHTUSERDATA);
  674. Vector3 pos = *(Vector3*)lua_topointer(L, 2);
  675. luaL_checktype(L, 3, LUA_TNUMBER);
  676. Number fRadius = lua_tonumber(L, 3);
  677. lua_pushboolean(L, inst->isSphereInFrustrum(pos, fRadius));
  678. return 1;
  679. }
  680. static int Polycore_Camera_canSee(lua_State *L) {
  681. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  682. Camera *inst = (Camera*)lua_topointer(L, 1);
  683. luaL_checktype(L, 2, LUA_TLIGHTUSERDATA);
  684. SceneEntity* entity = (SceneEntity*)lua_topointer(L, 2);
  685. lua_pushboolean(L, inst->canSee(entity));
  686. return 1;
  687. }
  688. static int Polycore_Camera_setOrthoMode(lua_State *L) {
  689. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  690. Camera *inst = (Camera*)lua_topointer(L, 1);
  691. luaL_checktype(L, 2, LUA_TBOOLEAN);
  692. bool mode = lua_toboolean(L, 2);
  693. inst->setOrthoMode(mode);
  694. return 0;
  695. }
  696. static int Polycore_Camera_getOrthoMode(lua_State *L) {
  697. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  698. Camera *inst = (Camera*)lua_topointer(L, 1);
  699. lua_pushboolean(L, inst->getOrthoMode());
  700. return 1;
  701. }
  702. static int Polycore_Camera_setFOV(lua_State *L) {
  703. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  704. Camera *inst = (Camera*)lua_topointer(L, 1);
  705. luaL_checktype(L, 2, LUA_TNUMBER);
  706. Number fov = lua_tonumber(L, 2);
  707. inst->setFOV(fov);
  708. return 0;
  709. }
  710. static int Polycore_Camera_getFOV(lua_State *L) {
  711. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  712. Camera *inst = (Camera*)lua_topointer(L, 1);
  713. lua_pushnumber(L, inst->getFOV());
  714. return 1;
  715. }
  716. static int Polycore_Camera_setParentScene(lua_State *L) {
  717. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  718. Camera *inst = (Camera*)lua_topointer(L, 1);
  719. luaL_checktype(L, 2, LUA_TLIGHTUSERDATA);
  720. Scene* parentScene = (Scene*)lua_topointer(L, 2);
  721. inst->setParentScene(parentScene);
  722. return 0;
  723. }
  724. static int Polycore_Camera_doCameraTransform(lua_State *L) {
  725. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  726. Camera *inst = (Camera*)lua_topointer(L, 1);
  727. inst->doCameraTransform();
  728. return 0;
  729. }
  730. static int Polycore_Camera_setLightDepthTexture(lua_State *L) {
  731. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  732. Camera *inst = (Camera*)lua_topointer(L, 1);
  733. luaL_checktype(L, 2, LUA_TLIGHTUSERDATA);
  734. Texture* texture = (Texture*)lua_topointer(L, 2);
  735. inst->setLightDepthTexture(texture);
  736. return 0;
  737. }
  738. static int Polycore_Camera_hasFilterShader(lua_State *L) {
  739. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  740. Camera *inst = (Camera*)lua_topointer(L, 1);
  741. lua_pushboolean(L, inst->hasFilterShader());
  742. return 1;
  743. }
  744. static int Polycore_Camera_drawFilter(lua_State *L) {
  745. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  746. Camera *inst = (Camera*)lua_topointer(L, 1);
  747. Texture* targetTexture;
  748. if(lua_islightuserdata(L, 2)) {
  749. targetTexture = (Texture*)lua_topointer(L, 2);
  750. } else {
  751. targetTexture = NULL;
  752. }
  753. Number targetTextureWidth;
  754. if(lua_isnumber(L, 3)) {
  755. targetTextureWidth = lua_tonumber(L, 3);
  756. } else {
  757. targetTextureWidth = 0.0;
  758. }
  759. Number targetTextureHeight;
  760. if(lua_isnumber(L, 4)) {
  761. targetTextureHeight = lua_tonumber(L, 4);
  762. } else {
  763. targetTextureHeight = 0.0;
  764. }
  765. inst->drawFilter(targetTexture, targetTextureWidth, targetTextureHeight);
  766. return 0;
  767. }
  768. static int Polycore_Camera_setExposureLevel(lua_State *L) {
  769. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  770. Camera *inst = (Camera*)lua_topointer(L, 1);
  771. luaL_checktype(L, 2, LUA_TNUMBER);
  772. Number level = lua_tonumber(L, 2);
  773. inst->setExposureLevel(level);
  774. return 0;
  775. }
  776. static int Polycore_Camera_getExposureLevel(lua_State *L) {
  777. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  778. Camera *inst = (Camera*)lua_topointer(L, 1);
  779. lua_pushnumber(L, inst->getExposureLevel());
  780. return 1;
  781. }
  782. static int Polycore_Camera_createPostFilter(lua_State *L) {
  783. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  784. Camera *inst = (Camera*)lua_topointer(L, 1);
  785. luaL_checktype(L, 2, LUA_TLIGHTUSERDATA);
  786. Material* shaderMaterial = (Material*)lua_topointer(L, 2);
  787. inst->createPostFilter(shaderMaterial);
  788. return 0;
  789. }
  790. static int Polycore_Camera_setPostFilter(lua_State *L) {
  791. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  792. Camera *inst = (Camera*)lua_topointer(L, 1);
  793. luaL_checktype(L, 2, LUA_TSTRING);
  794. String shaderName = String(lua_tostring(L, 2));
  795. inst->setPostFilter(shaderName);
  796. return 0;
  797. }
  798. static int Polycore_Camera_removePostFilter(lua_State *L) {
  799. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  800. Camera *inst = (Camera*)lua_topointer(L, 1);
  801. inst->removePostFilter();
  802. return 0;
  803. }
  804. static int Polycore_Camera_getScreenShaderMaterial(lua_State *L) {
  805. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  806. Camera *inst = (Camera*)lua_topointer(L, 1);
  807. void *ptrRetVal = (void*)inst->getScreenShaderMaterial();
  808. if(ptrRetVal == NULL) {
  809. lua_pushnil(L);
  810. } else {
  811. lua_pushlightuserdata(L, ptrRetVal);
  812. }
  813. return 1;
  814. }
  815. static int Polycore_delete_Camera(lua_State *L) {
  816. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  817. Camera *inst = (Camera*)lua_topointer(L, 1);
  818. delete inst;
  819. return 0;
  820. }
  821. static int Polycore_Color_get_r(lua_State *L) {
  822. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  823. Color *inst = (Color*)lua_topointer(L, 1);
  824. lua_pushnumber(L, inst->r);
  825. return 1;
  826. }
  827. static int Polycore_Color_get_g(lua_State *L) {
  828. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  829. Color *inst = (Color*)lua_topointer(L, 1);
  830. lua_pushnumber(L, inst->g);
  831. return 1;
  832. }
  833. static int Polycore_Color_get_b(lua_State *L) {
  834. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  835. Color *inst = (Color*)lua_topointer(L, 1);
  836. lua_pushnumber(L, inst->b);
  837. return 1;
  838. }
  839. static int Polycore_Color_get_a(lua_State *L) {
  840. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  841. Color *inst = (Color*)lua_topointer(L, 1);
  842. lua_pushnumber(L, inst->a);
  843. return 1;
  844. }
  845. static int Polycore_Color_set_r(lua_State *L) {
  846. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  847. Color *inst = (Color*)lua_topointer(L, 1);
  848. Number param = lua_tonumber(L, 2);
  849. inst->r = param;
  850. return 0;
  851. }
  852. static int Polycore_Color_set_g(lua_State *L) {
  853. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  854. Color *inst = (Color*)lua_topointer(L, 1);
  855. Number param = lua_tonumber(L, 2);
  856. inst->g = param;
  857. return 0;
  858. }
  859. static int Polycore_Color_set_b(lua_State *L) {
  860. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  861. Color *inst = (Color*)lua_topointer(L, 1);
  862. Number param = lua_tonumber(L, 2);
  863. inst->b = param;
  864. return 0;
  865. }
  866. static int Polycore_Color_set_a(lua_State *L) {
  867. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  868. Color *inst = (Color*)lua_topointer(L, 1);
  869. Number param = lua_tonumber(L, 2);
  870. inst->a = param;
  871. return 0;
  872. }
  873. static int Polycore_Color(lua_State *L) {
  874. Color *inst = new Color();
  875. lua_pushlightuserdata(L, (void*)inst);
  876. return 1;
  877. }
  878. static int Polycore_Color_setColorHex(lua_State *L) {
  879. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  880. Color *inst = (Color*)lua_topointer(L, 1);
  881. luaL_checktype(L, 2, LUA_TNUMBER);
  882. unsigned int hex = lua_tointeger(L, 2);
  883. inst->setColorHex(hex);
  884. return 0;
  885. }
  886. static int Polycore_Color_setColorHexRGB(lua_State *L) {
  887. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  888. Color *inst = (Color*)lua_topointer(L, 1);
  889. luaL_checktype(L, 2, LUA_TNUMBER);
  890. unsigned int hex = lua_tointeger(L, 2);
  891. inst->setColorHexRGB(hex);
  892. return 0;
  893. }
  894. static int Polycore_Color_setColorHSV(lua_State *L) {
  895. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  896. Color *inst = (Color*)lua_topointer(L, 1);
  897. luaL_checktype(L, 2, LUA_TNUMBER);
  898. Number h = lua_tonumber(L, 2);
  899. luaL_checktype(L, 3, LUA_TNUMBER);
  900. Number s = lua_tonumber(L, 3);
  901. luaL_checktype(L, 4, LUA_TNUMBER);
  902. Number v = lua_tonumber(L, 4);
  903. inst->setColorHSV(h, s, v);
  904. return 0;
  905. }
  906. static int Polycore_Color_setColorRGBA(lua_State *L) {
  907. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  908. Color *inst = (Color*)lua_topointer(L, 1);
  909. luaL_checktype(L, 2, LUA_TNUMBER);
  910. int r = lua_tointeger(L, 2);
  911. luaL_checktype(L, 3, LUA_TNUMBER);
  912. int g = lua_tointeger(L, 3);
  913. luaL_checktype(L, 4, LUA_TNUMBER);
  914. int b = lua_tointeger(L, 4);
  915. luaL_checktype(L, 5, LUA_TNUMBER);
  916. int a = lua_tointeger(L, 5);
  917. inst->setColorRGBA(r, g, b, a);
  918. return 0;
  919. }
  920. static int Polycore_Color_setColorRGB(lua_State *L) {
  921. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  922. Color *inst = (Color*)lua_topointer(L, 1);
  923. luaL_checktype(L, 2, LUA_TNUMBER);
  924. int r = lua_tointeger(L, 2);
  925. luaL_checktype(L, 3, LUA_TNUMBER);
  926. int g = lua_tointeger(L, 3);
  927. luaL_checktype(L, 4, LUA_TNUMBER);
  928. int b = lua_tointeger(L, 4);
  929. inst->setColorRGB(r, g, b);
  930. return 0;
  931. }
  932. static int Polycore_Color_setColor(lua_State *L) {
  933. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  934. Color *inst = (Color*)lua_topointer(L, 1);
  935. luaL_checktype(L, 2, LUA_TNUMBER);
  936. Number r = lua_tonumber(L, 2);
  937. luaL_checktype(L, 3, LUA_TNUMBER);
  938. Number g = lua_tonumber(L, 3);
  939. luaL_checktype(L, 4, LUA_TNUMBER);
  940. Number b = lua_tonumber(L, 4);
  941. luaL_checktype(L, 5, LUA_TNUMBER);
  942. Number a = lua_tonumber(L, 5);
  943. inst->setColor(r, g, b, a);
  944. return 0;
  945. }
  946. static int Polycore_Color_Random(lua_State *L) {
  947. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  948. Color *inst = (Color*)lua_topointer(L, 1);
  949. inst->Random();
  950. return 0;
  951. }
  952. static int Polycore_Color_getBrightness(lua_State *L) {
  953. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  954. Color *inst = (Color*)lua_topointer(L, 1);
  955. lua_pushnumber(L, inst->getBrightness());
  956. return 1;
  957. }
  958. static int Polycore_Color_getUint(lua_State *L) {
  959. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  960. Color *inst = (Color*)lua_topointer(L, 1);
  961. lua_pushinteger(L, inst->getUint());
  962. return 1;
  963. }
  964. static int Polycore_delete_Color(lua_State *L) {
  965. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  966. Color *inst = (Color*)lua_topointer(L, 1);
  967. delete inst;
  968. return 0;
  969. }
  970. static int Polycore_Config(lua_State *L) {
  971. Config *inst = new Config();
  972. lua_pushlightuserdata(L, (void*)inst);
  973. return 1;
  974. }
  975. static int Polycore_Config_loadConfig(lua_State *L) {
  976. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  977. Config *inst = (Config*)lua_topointer(L, 1);
  978. luaL_checktype(L, 2, LUA_TSTRING);
  979. String configNamespace = String(lua_tostring(L, 2));
  980. luaL_checktype(L, 3, LUA_TSTRING);
  981. String fileName = String(lua_tostring(L, 3));
  982. inst->loadConfig(configNamespace, fileName);
  983. return 0;
  984. }
  985. static int Polycore_Config_saveConfig(lua_State *L) {
  986. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  987. Config *inst = (Config*)lua_topointer(L, 1);
  988. luaL_checktype(L, 2, LUA_TSTRING);
  989. String configNamespace = String(lua_tostring(L, 2));
  990. luaL_checktype(L, 3, LUA_TSTRING);
  991. String fileName = String(lua_tostring(L, 3));
  992. inst->saveConfig(configNamespace, fileName);
  993. return 0;
  994. }
  995. static int Polycore_Config_getEntry(lua_State *L) {
  996. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  997. Config *inst = (Config*)lua_topointer(L, 1);
  998. luaL_checktype(L, 2, LUA_TSTRING);
  999. String configNamespace = String(lua_tostring(L, 2));
  1000. luaL_checktype(L, 3, LUA_TSTRING);
  1001. String key = String(lua_tostring(L, 3));
  1002. void *ptrRetVal = (void*)inst->getEntry(configNamespace, key);
  1003. if(ptrRetVal == NULL) {
  1004. lua_pushnil(L);
  1005. } else {
  1006. lua_pushlightuserdata(L, ptrRetVal);
  1007. }
  1008. return 1;
  1009. }
  1010. static int Polycore_Config_setStringValue(lua_State *L) {
  1011. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  1012. Config *inst = (Config*)lua_topointer(L, 1);
  1013. luaL_checktype(L, 2, LUA_TSTRING);
  1014. String configNamespace = String(lua_tostring(L, 2));
  1015. luaL_checktype(L, 3, LUA_TSTRING);
  1016. String key = String(lua_tostring(L, 3));
  1017. luaL_checktype(L, 4, LUA_TSTRING);
  1018. String value = String(lua_tostring(L, 4));
  1019. inst->setStringValue(configNamespace, key, value);
  1020. return 0;
  1021. }
  1022. static int Polycore_Config_setNumericValue(lua_State *L) {
  1023. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  1024. Config *inst = (Config*)lua_topointer(L, 1);
  1025. luaL_checktype(L, 2, LUA_TSTRING);
  1026. String configNamespace = String(lua_tostring(L, 2));
  1027. luaL_checktype(L, 3, LUA_TSTRING);
  1028. String key = String(lua_tostring(L, 3));
  1029. luaL_checktype(L, 4, LUA_TNUMBER);
  1030. Number value = lua_tonumber(L, 4);
  1031. inst->setNumericValue(configNamespace, key, value);
  1032. return 0;
  1033. }
  1034. static int Polycore_Config_getNumericValue(lua_State *L) {
  1035. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  1036. Config *inst = (Config*)lua_topointer(L, 1);
  1037. luaL_checktype(L, 2, LUA_TSTRING);
  1038. String configNamespace = String(lua_tostring(L, 2));
  1039. luaL_checktype(L, 3, LUA_TSTRING);
  1040. String key = String(lua_tostring(L, 3));
  1041. lua_pushnumber(L, inst->getNumericValue(configNamespace, key));
  1042. return 1;
  1043. }
  1044. static int Polycore_Config_getStringValue(lua_State *L) {
  1045. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  1046. Config *inst = (Config*)lua_topointer(L, 1);
  1047. luaL_checktype(L, 2, LUA_TSTRING);
  1048. String configNamespace = String(lua_tostring(L, 2));
  1049. luaL_checktype(L, 3, LUA_TSTRING);
  1050. String key = String(lua_tostring(L, 3));
  1051. String *retInst = new String ();
  1052. *retInst = inst->getStringValue(configNamespace, key);
  1053. lua_pushlightuserdata(L, retInst);
  1054. return 1;
  1055. }
  1056. static int Polycore_delete_Config(lua_State *L) {
  1057. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  1058. Config *inst = (Config*)lua_topointer(L, 1);
  1059. delete inst;
  1060. return 0;
  1061. }
  1062. static int Polycore_PolycodeViewBase(lua_State *L) {
  1063. PolycodeViewBase *inst = new PolycodeViewBase();
  1064. lua_pushlightuserdata(L, (void*)inst);
  1065. return 1;
  1066. }
  1067. static int Polycore_delete_PolycodeViewBase(lua_State *L) {
  1068. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  1069. PolycodeViewBase *inst = (PolycodeViewBase*)lua_topointer(L, 1);
  1070. delete inst;
  1071. return 0;
  1072. }
  1073. static int Polycore_Core_Update(lua_State *L) {
  1074. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  1075. Core *inst = (Core*)lua_topointer(L, 1);
  1076. lua_pushboolean(L, inst->Update());
  1077. return 1;
  1078. }
  1079. static int Polycore_Core_enableMouse(lua_State *L) {
  1080. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  1081. Core *inst = (Core*)lua_topointer(L, 1);
  1082. luaL_checktype(L, 2, LUA_TBOOLEAN);
  1083. bool newval = lua_toboolean(L, 2);
  1084. inst->enableMouse(newval);
  1085. return 0;
  1086. }
  1087. static int Polycore_Core_setCursor(lua_State *L) {
  1088. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  1089. Core *inst = (Core*)lua_topointer(L, 1);
  1090. luaL_checktype(L, 2, LUA_TNUMBER);
  1091. int cursorType = lua_tointeger(L, 2);
  1092. inst->setCursor(cursorType);
  1093. return 0;
  1094. }
  1095. static int Polycore_Core_createThread(lua_State *L) {
  1096. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  1097. Core *inst = (Core*)lua_topointer(L, 1);
  1098. luaL_checktype(L, 2, LUA_TLIGHTUSERDATA);
  1099. Threaded* target = (Threaded*)lua_topointer(L, 2);
  1100. inst->createThread(target);
  1101. return 0;
  1102. }
  1103. static int Polycore_Core_lockMutex(lua_State *L) {
  1104. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  1105. Core *inst = (Core*)lua_topointer(L, 1);
  1106. luaL_checktype(L, 2, LUA_TLIGHTUSERDATA);
  1107. CoreMutex* mutex = (CoreMutex*)lua_topointer(L, 2);
  1108. inst->lockMutex(mutex);
  1109. return 0;
  1110. }
  1111. static int Polycore_Core_unlockMutex(lua_State *L) {
  1112. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  1113. Core *inst = (Core*)lua_topointer(L, 1);
  1114. luaL_checktype(L, 2, LUA_TLIGHTUSERDATA);
  1115. CoreMutex* mutex = (CoreMutex*)lua_topointer(L, 2);
  1116. inst->unlockMutex(mutex);
  1117. return 0;
  1118. }
  1119. static int Polycore_Core_createMutex(lua_State *L) {
  1120. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  1121. Core *inst = (Core*)lua_topointer(L, 1);
  1122. void *ptrRetVal = (void*)inst->createMutex();
  1123. if(ptrRetVal == NULL) {
  1124. lua_pushnil(L);
  1125. } else {
  1126. lua_pushlightuserdata(L, ptrRetVal);
  1127. }
  1128. return 1;
  1129. }
  1130. static int Polycore_Core_copyStringToClipboard(lua_State *L) {
  1131. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  1132. Core *inst = (Core*)lua_topointer(L, 1);
  1133. luaL_checktype(L, 2, LUA_TSTRING);
  1134. String str = String(lua_tostring(L, 2));
  1135. inst->copyStringToClipboard(str);
  1136. return 0;
  1137. }
  1138. static int Polycore_Core_getClipboardString(lua_State *L) {
  1139. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  1140. Core *inst = (Core*)lua_topointer(L, 1);
  1141. String *retInst = new String();
  1142. *retInst = inst->getClipboardString();
  1143. lua_pushlightuserdata(L, retInst);
  1144. return 1;
  1145. }
  1146. static int Polycore_Core_getServices(lua_State *L) {
  1147. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  1148. Core *inst = (Core*)lua_topointer(L, 1);
  1149. void *ptrRetVal = (void*)inst->getServices();
  1150. if(ptrRetVal == NULL) {
  1151. lua_pushnil(L);
  1152. } else {
  1153. lua_pushlightuserdata(L, ptrRetVal);
  1154. }
  1155. return 1;
  1156. }
  1157. static int Polycore_Core_getFPS(lua_State *L) {
  1158. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  1159. Core *inst = (Core*)lua_topointer(L, 1);
  1160. lua_pushnumber(L, inst->getFPS());
  1161. return 1;
  1162. }
  1163. static int Polycore_Core_Shutdown(lua_State *L) {
  1164. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  1165. Core *inst = (Core*)lua_topointer(L, 1);
  1166. inst->Shutdown();
  1167. return 0;
  1168. }
  1169. static int Polycore_Core_isFullscreen(lua_State *L) {
  1170. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  1171. Core *inst = (Core*)lua_topointer(L, 1);
  1172. lua_pushboolean(L, inst->isFullscreen());
  1173. return 1;
  1174. }
  1175. static int Polycore_Core_getAALevel(lua_State *L) {
  1176. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  1177. Core *inst = (Core*)lua_topointer(L, 1);
  1178. lua_pushinteger(L, inst->getAALevel());
  1179. return 1;
  1180. }
  1181. static int Polycore_Core_getInput(lua_State *L) {
  1182. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  1183. Core *inst = (Core*)lua_topointer(L, 1);
  1184. void *ptrRetVal = (void*)inst->getInput();
  1185. if(ptrRetVal == NULL) {
  1186. lua_pushnil(L);
  1187. } else {
  1188. lua_pushlightuserdata(L, ptrRetVal);
  1189. }
  1190. return 1;
  1191. }
  1192. static int Polycore_Core_getXRes(lua_State *L) {
  1193. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  1194. Core *inst = (Core*)lua_topointer(L, 1);
  1195. lua_pushnumber(L, inst->getXRes());
  1196. return 1;
  1197. }
  1198. static int Polycore_Core_getYRes(lua_State *L) {
  1199. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  1200. Core *inst = (Core*)lua_topointer(L, 1);
  1201. lua_pushnumber(L, inst->getYRes());
  1202. return 1;
  1203. }
  1204. static int Polycore_Core_getNumVideoModes(lua_State *L) {
  1205. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  1206. Core *inst = (Core*)lua_topointer(L, 1);
  1207. lua_pushinteger(L, inst->getNumVideoModes());
  1208. return 1;
  1209. }
  1210. static int Polycore_Core_createFolder(lua_State *L) {
  1211. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  1212. Core *inst = (Core*)lua_topointer(L, 1);
  1213. luaL_checktype(L, 2, LUA_TSTRING);
  1214. String folderPath = String(lua_tostring(L, 2));
  1215. inst->createFolder(folderPath);
  1216. return 0;
  1217. }
  1218. static int Polycore_Core_copyDiskItem(lua_State *L) {
  1219. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  1220. Core *inst = (Core*)lua_topointer(L, 1);
  1221. luaL_checktype(L, 2, LUA_TSTRING);
  1222. String itemPath = String(lua_tostring(L, 2));
  1223. luaL_checktype(L, 3, LUA_TSTRING);
  1224. String destItemPath = String(lua_tostring(L, 3));
  1225. inst->copyDiskItem(itemPath, destItemPath);
  1226. return 0;
  1227. }
  1228. static int Polycore_Core_moveDiskItem(lua_State *L) {
  1229. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  1230. Core *inst = (Core*)lua_topointer(L, 1);
  1231. luaL_checktype(L, 2, LUA_TSTRING);
  1232. String itemPath = String(lua_tostring(L, 2));
  1233. luaL_checktype(L, 3, LUA_TSTRING);
  1234. String destItemPath = String(lua_tostring(L, 3));
  1235. inst->moveDiskItem(itemPath, destItemPath);
  1236. return 0;
  1237. }
  1238. static int Polycore_Core_removeDiskItem(lua_State *L) {
  1239. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  1240. Core *inst = (Core*)lua_topointer(L, 1);
  1241. luaL_checktype(L, 2, LUA_TSTRING);
  1242. String itemPath = String(lua_tostring(L, 2));
  1243. inst->removeDiskItem(itemPath);
  1244. return 0;
  1245. }
  1246. static int Polycore_Core_openFolderPicker(lua_State *L) {
  1247. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  1248. Core *inst = (Core*)lua_topointer(L, 1);
  1249. String *retInst = new String();
  1250. *retInst = inst->openFolderPicker();
  1251. lua_pushlightuserdata(L, retInst);
  1252. return 1;
  1253. }
  1254. static int Polycore_Core_setVideoModeIndex(lua_State *L) {
  1255. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  1256. Core *inst = (Core*)lua_topointer(L, 1);
  1257. luaL_checktype(L, 2, LUA_TNUMBER);
  1258. int index = lua_tointeger(L, 2);
  1259. luaL_checktype(L, 3, LUA_TBOOLEAN);
  1260. bool fullScreen = lua_toboolean(L, 3);
  1261. luaL_checktype(L, 4, LUA_TBOOLEAN);
  1262. bool vSync = lua_toboolean(L, 4);
  1263. luaL_checktype(L, 5, LUA_TNUMBER);
  1264. int aaLevel = lua_tointeger(L, 5);
  1265. luaL_checktype(L, 6, LUA_TNUMBER);
  1266. int anisotropyLevel = lua_tointeger(L, 6);
  1267. inst->setVideoModeIndex(index, fullScreen, vSync, aaLevel, anisotropyLevel);
  1268. return 0;
  1269. }
  1270. static int Polycore_Core_setVideoMode(lua_State *L) {
  1271. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  1272. Core *inst = (Core*)lua_topointer(L, 1);
  1273. luaL_checktype(L, 2, LUA_TNUMBER);
  1274. int xRes = lua_tointeger(L, 2);
  1275. luaL_checktype(L, 3, LUA_TNUMBER);
  1276. int yRes = lua_tointeger(L, 3);
  1277. luaL_checktype(L, 4, LUA_TBOOLEAN);
  1278. bool fullScreen = lua_toboolean(L, 4);
  1279. luaL_checktype(L, 5, LUA_TBOOLEAN);
  1280. bool vSync = lua_toboolean(L, 5);
  1281. luaL_checktype(L, 6, LUA_TNUMBER);
  1282. int aaLevel = lua_tointeger(L, 6);
  1283. luaL_checktype(L, 7, LUA_TNUMBER);
  1284. int anisotropyLevel = lua_tointeger(L, 7);
  1285. inst->setVideoMode(xRes, yRes, fullScreen, vSync, aaLevel, anisotropyLevel);
  1286. return 0;
  1287. }
  1288. static int Polycore_Core_resizeTo(lua_State *L) {
  1289. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  1290. Core *inst = (Core*)lua_topointer(L, 1);
  1291. luaL_checktype(L, 2, LUA_TNUMBER);
  1292. int xRes = lua_tointeger(L, 2);
  1293. luaL_checktype(L, 3, LUA_TNUMBER);
  1294. int yRes = lua_tointeger(L, 3);
  1295. inst->resizeTo(xRes, yRes);
  1296. return 0;
  1297. }
  1298. static int Polycore_Core_doSleep(lua_State *L) {
  1299. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  1300. Core *inst = (Core*)lua_topointer(L, 1);
  1301. inst->doSleep();
  1302. return 0;
  1303. }
  1304. static int Polycore_Core_getElapsed(lua_State *L) {
  1305. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  1306. Core *inst = (Core*)lua_topointer(L, 1);
  1307. lua_pushnumber(L, inst->getElapsed());
  1308. return 1;
  1309. }
  1310. static int Polycore_Core_getTicks(lua_State *L) {
  1311. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  1312. Core *inst = (Core*)lua_topointer(L, 1);
  1313. unsigned int *retInst = new unsigned int();
  1314. *retInst = inst->getTicks();
  1315. lua_pushlightuserdata(L, retInst);
  1316. return 1;
  1317. }
  1318. static int Polycore_Core_getTicksFloat(lua_State *L) {
  1319. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  1320. Core *inst = (Core*)lua_topointer(L, 1);
  1321. lua_pushnumber(L, inst->getTicksFloat());
  1322. return 1;
  1323. }
  1324. static int Polycore_Core_setUserPointer(lua_State *L) {
  1325. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  1326. Core *inst = (Core*)lua_topointer(L, 1);
  1327. luaL_checktype(L, 2, LUA_TLIGHTUSERDATA);
  1328. void* ptr = (void*)lua_topointer(L, 2);
  1329. inst->setUserPointer(ptr);
  1330. return 0;
  1331. }
  1332. static int Polycore_Core_getUserPointer(lua_State *L) {
  1333. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  1334. Core *inst = (Core*)lua_topointer(L, 1);
  1335. void *ptrRetVal = (void*)inst->getUserPointer();
  1336. if(ptrRetVal == NULL) {
  1337. lua_pushnil(L);
  1338. } else {
  1339. lua_pushlightuserdata(L, ptrRetVal);
  1340. }
  1341. return 1;
  1342. }
  1343. static int Polycore_delete_Core(lua_State *L) {
  1344. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  1345. Core *inst = (Core*)lua_topointer(L, 1);
  1346. delete inst;
  1347. return 0;
  1348. }
  1349. static int Polycore_CoreInput(lua_State *L) {
  1350. CoreInput *inst = new CoreInput();
  1351. lua_pushlightuserdata(L, (void*)inst);
  1352. return 1;
  1353. }
  1354. static int Polycore_CoreInput_getMousePosition(lua_State *L) {
  1355. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  1356. CoreInput *inst = (CoreInput*)lua_topointer(L, 1);
  1357. Vector2 *retInst = new Vector2();
  1358. *retInst = inst->getMousePosition();
  1359. lua_pushlightuserdata(L, retInst);
  1360. return 1;
  1361. }
  1362. static int Polycore_CoreInput_getKeyState(lua_State *L) {
  1363. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  1364. CoreInput *inst = (CoreInput*)lua_topointer(L, 1);
  1365. luaL_checktype(L, 2, LUA_TLIGHTUSERDATA);
  1366. PolyKEY keyCode = *(PolyKEY*)lua_topointer(L, 2);
  1367. lua_pushboolean(L, inst->getKeyState(keyCode));
  1368. return 1;
  1369. }
  1370. static int Polycore_CoreInput_getMouseDelta(lua_State *L) {
  1371. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  1372. CoreInput *inst = (CoreInput*)lua_topointer(L, 1);
  1373. Vector2 *retInst = new Vector2();
  1374. *retInst = inst->getMouseDelta();
  1375. lua_pushlightuserdata(L, retInst);
  1376. return 1;
  1377. }
  1378. static int Polycore_CoreInput_getMouseButtonState(lua_State *L) {
  1379. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  1380. CoreInput *inst = (CoreInput*)lua_topointer(L, 1);
  1381. luaL_checktype(L, 2, LUA_TNUMBER);
  1382. int mouseButton = lua_tointeger(L, 2);
  1383. lua_pushboolean(L, inst->getMouseButtonState(mouseButton));
  1384. return 1;
  1385. }
  1386. static int Polycore_CoreInput_getNumJoysticks(lua_State *L) {
  1387. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  1388. CoreInput *inst = (CoreInput*)lua_topointer(L, 1);
  1389. lua_pushinteger(L, inst->getNumJoysticks());
  1390. return 1;
  1391. }
  1392. static int Polycore_CoreInput_getJoystickInfoByIndex(lua_State *L) {
  1393. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  1394. CoreInput *inst = (CoreInput*)lua_topointer(L, 1);
  1395. luaL_checktype(L, 2, LUA_TNUMBER);
  1396. unsigned int index = lua_tointeger(L, 2);
  1397. void *ptrRetVal = (void*)inst->getJoystickInfoByIndex(index);
  1398. if(ptrRetVal == NULL) {
  1399. lua_pushnil(L);
  1400. } else {
  1401. lua_pushlightuserdata(L, ptrRetVal);
  1402. }
  1403. return 1;
  1404. }
  1405. static int Polycore_CoreInput_getJoystickInfoByID(lua_State *L) {
  1406. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  1407. CoreInput *inst = (CoreInput*)lua_topointer(L, 1);
  1408. luaL_checktype(L, 2, LUA_TNUMBER);
  1409. unsigned int deviceID = lua_tointeger(L, 2);
  1410. void *ptrRetVal = (void*)inst->getJoystickInfoByID(deviceID);
  1411. if(ptrRetVal == NULL) {
  1412. lua_pushnil(L);
  1413. } else {
  1414. lua_pushlightuserdata(L, ptrRetVal);
  1415. }
  1416. return 1;
  1417. }
  1418. static int Polycore_CoreInput_addJoystick(lua_State *L) {
  1419. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  1420. CoreInput *inst = (CoreInput*)lua_topointer(L, 1);
  1421. luaL_checktype(L, 2, LUA_TNUMBER);
  1422. unsigned int deviceID = lua_tointeger(L, 2);
  1423. inst->addJoystick(deviceID);
  1424. return 0;
  1425. }
  1426. static int Polycore_CoreInput_removeJoystick(lua_State *L) {
  1427. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  1428. CoreInput *inst = (CoreInput*)lua_topointer(L, 1);
  1429. luaL_checktype(L, 2, LUA_TNUMBER);
  1430. unsigned int deviceID = lua_tointeger(L, 2);
  1431. inst->removeJoystick(deviceID);
  1432. return 0;
  1433. }
  1434. static int Polycore_CoreInput_joystickAxisMoved(lua_State *L) {
  1435. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  1436. CoreInput *inst = (CoreInput*)lua_topointer(L, 1);
  1437. luaL_checktype(L, 2, LUA_TNUMBER);
  1438. unsigned int axisID = lua_tointeger(L, 2);
  1439. luaL_checktype(L, 3, LUA_TNUMBER);
  1440. float value = lua_tonumber(L, 3);
  1441. luaL_checktype(L, 4, LUA_TNUMBER);
  1442. unsigned int deviceID = lua_tointeger(L, 4);
  1443. inst->joystickAxisMoved(axisID, value, deviceID);
  1444. return 0;
  1445. }
  1446. static int Polycore_CoreInput_joystickButtonDown(lua_State *L) {
  1447. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  1448. CoreInput *inst = (CoreInput*)lua_topointer(L, 1);
  1449. luaL_checktype(L, 2, LUA_TNUMBER);
  1450. unsigned int buttonID = lua_tointeger(L, 2);
  1451. luaL_checktype(L, 3, LUA_TNUMBER);
  1452. unsigned int deviceID = lua_tointeger(L, 3);
  1453. inst->joystickButtonDown(buttonID, deviceID);
  1454. return 0;
  1455. }
  1456. static int Polycore_CoreInput_joystickButtonUp(lua_State *L) {
  1457. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  1458. CoreInput *inst = (CoreInput*)lua_topointer(L, 1);
  1459. luaL_checktype(L, 2, LUA_TNUMBER);
  1460. unsigned int buttonID = lua_tointeger(L, 2);
  1461. luaL_checktype(L, 3, LUA_TNUMBER);
  1462. unsigned int deviceID = lua_tointeger(L, 3);
  1463. inst->joystickButtonUp(buttonID, deviceID);
  1464. return 0;
  1465. }
  1466. static int Polycore_CoreInput_mouseWheelUp(lua_State *L) {
  1467. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  1468. CoreInput *inst = (CoreInput*)lua_topointer(L, 1);
  1469. luaL_checktype(L, 2, LUA_TNUMBER);
  1470. int ticks = lua_tointeger(L, 2);
  1471. inst->mouseWheelUp(ticks);
  1472. return 0;
  1473. }
  1474. static int Polycore_CoreInput_mouseWheelDown(lua_State *L) {
  1475. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  1476. CoreInput *inst = (CoreInput*)lua_topointer(L, 1);
  1477. luaL_checktype(L, 2, LUA_TNUMBER);
  1478. int ticks = lua_tointeger(L, 2);
  1479. inst->mouseWheelDown(ticks);
  1480. return 0;
  1481. }
  1482. static int Polycore_CoreInput_setMouseButtonState(lua_State *L) {
  1483. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  1484. CoreInput *inst = (CoreInput*)lua_topointer(L, 1);
  1485. luaL_checktype(L, 2, LUA_TNUMBER);
  1486. int mouseButton = lua_tointeger(L, 2);
  1487. luaL_checktype(L, 3, LUA_TBOOLEAN);
  1488. bool state = lua_toboolean(L, 3);
  1489. luaL_checktype(L, 4, LUA_TNUMBER);
  1490. int ticks = lua_tointeger(L, 4);
  1491. inst->setMouseButtonState(mouseButton, state, ticks);
  1492. return 0;
  1493. }
  1494. static int Polycore_CoreInput_setMousePosition(lua_State *L) {
  1495. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  1496. CoreInput *inst = (CoreInput*)lua_topointer(L, 1);
  1497. luaL_checktype(L, 2, LUA_TNUMBER);
  1498. int x = lua_tointeger(L, 2);
  1499. luaL_checktype(L, 3, LUA_TNUMBER);
  1500. int y = lua_tointeger(L, 3);
  1501. luaL_checktype(L, 4, LUA_TNUMBER);
  1502. int ticks = lua_tointeger(L, 4);
  1503. inst->setMousePosition(x, y, ticks);
  1504. return 0;
  1505. }
  1506. static int Polycore_CoreInput_setKeyState(lua_State *L) {
  1507. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  1508. CoreInput *inst = (CoreInput*)lua_topointer(L, 1);
  1509. luaL_checktype(L, 2, LUA_TLIGHTUSERDATA);
  1510. PolyKEY keyCode = *(PolyKEY*)lua_topointer(L, 2);
  1511. luaL_checktype(L, 3, LUA_TLIGHTUSERDATA);
  1512. wchar_t code = *(wchar_t*)lua_topointer(L, 3);
  1513. luaL_checktype(L, 4, LUA_TBOOLEAN);
  1514. bool newState = lua_toboolean(L, 4);
  1515. luaL_checktype(L, 5, LUA_TNUMBER);
  1516. int ticks = lua_tointeger(L, 5);
  1517. inst->setKeyState(keyCode, code, newState, ticks);
  1518. return 0;
  1519. }
  1520. static int Polycore_CoreInput_setDeltaPosition(lua_State *L) {
  1521. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  1522. CoreInput *inst = (CoreInput*)lua_topointer(L, 1);
  1523. luaL_checktype(L, 2, LUA_TNUMBER);
  1524. int x = lua_tointeger(L, 2);
  1525. luaL_checktype(L, 3, LUA_TNUMBER);
  1526. int y = lua_tointeger(L, 3);
  1527. inst->setDeltaPosition(x, y);
  1528. return 0;
  1529. }
  1530. static int Polycore_CoreInput_createEvent(lua_State *L) {
  1531. luaL_checktype(L, 2, LUA_TLIGHTUSERDATA);
  1532. Event* event = (Event*)lua_topointer(L, 2);
  1533. void *ptrRetVal = (void*)CoreInput::createEvent(event);
  1534. if(ptrRetVal == NULL) {
  1535. lua_pushnil(L);
  1536. } else {
  1537. lua_pushlightuserdata(L, ptrRetVal);
  1538. }
  1539. return 1;
  1540. }
  1541. static int Polycore_delete_CoreInput(lua_State *L) {
  1542. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  1543. CoreInput *inst = (CoreInput*)lua_topointer(L, 1);
  1544. delete inst;
  1545. return 0;
  1546. }
  1547. static int Polycore_CoreServices_getInstance(lua_State *L) {
  1548. void *ptrRetVal = (void*)CoreServices::getInstance();
  1549. if(ptrRetVal == NULL) {
  1550. lua_pushnil(L);
  1551. } else {
  1552. lua_pushlightuserdata(L, ptrRetVal);
  1553. }
  1554. return 1;
  1555. }
  1556. static int Polycore_CoreServices_setInstance(lua_State *L) {
  1557. luaL_checktype(L, 2, LUA_TLIGHTUSERDATA);
  1558. CoreServices* _instance = (CoreServices*)lua_topointer(L, 2);
  1559. CoreServices::setInstance(_instance);
  1560. return 0;
  1561. }
  1562. static int Polycore_CoreServices_getRenderMutex(lua_State *L) {
  1563. void *ptrRetVal = (void*)CoreServices::getRenderMutex();
  1564. if(ptrRetVal == NULL) {
  1565. lua_pushnil(L);
  1566. } else {
  1567. lua_pushlightuserdata(L, ptrRetVal);
  1568. }
  1569. return 1;
  1570. }
  1571. static int Polycore_CoreServices_setRenderer(lua_State *L) {
  1572. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  1573. CoreServices *inst = (CoreServices*)lua_topointer(L, 1);
  1574. luaL_checktype(L, 2, LUA_TLIGHTUSERDATA);
  1575. Renderer* r_enderer = (Renderer*)lua_topointer(L, 2);
  1576. inst->setRenderer(r_enderer);
  1577. return 0;
  1578. }
  1579. static int Polycore_CoreServices_getRenderer(lua_State *L) {
  1580. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  1581. CoreServices *inst = (CoreServices*)lua_topointer(L, 1);
  1582. void *ptrRetVal = (void*)inst->getRenderer();
  1583. if(ptrRetVal == NULL) {
  1584. lua_pushnil(L);
  1585. } else {
  1586. lua_pushlightuserdata(L, ptrRetVal);
  1587. }
  1588. return 1;
  1589. }
  1590. static int Polycore_CoreServices_Update(lua_State *L) {
  1591. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  1592. CoreServices *inst = (CoreServices*)lua_topointer(L, 1);
  1593. luaL_checktype(L, 2, LUA_TNUMBER);
  1594. int elapsed = lua_tointeger(L, 2);
  1595. inst->Update(elapsed);
  1596. return 0;
  1597. }
  1598. static int Polycore_CoreServices_setCore(lua_State *L) {
  1599. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  1600. CoreServices *inst = (CoreServices*)lua_topointer(L, 1);
  1601. luaL_checktype(L, 2, LUA_TLIGHTUSERDATA);
  1602. Core* core = (Core*)lua_topointer(L, 2);
  1603. inst->setCore(core);
  1604. return 0;
  1605. }
  1606. static int Polycore_CoreServices_getCore(lua_State *L) {
  1607. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  1608. CoreServices *inst = (CoreServices*)lua_topointer(L, 1);
  1609. void *ptrRetVal = (void*)inst->getCore();
  1610. if(ptrRetVal == NULL) {
  1611. lua_pushnil(L);
  1612. } else {
  1613. lua_pushlightuserdata(L, ptrRetVal);
  1614. }
  1615. return 1;
  1616. }
  1617. static int Polycore_CoreServices_installModule(lua_State *L) {
  1618. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  1619. CoreServices *inst = (CoreServices*)lua_topointer(L, 1);
  1620. luaL_checktype(L, 2, LUA_TLIGHTUSERDATA);
  1621. PolycodeModule* module = (PolycodeModule*)lua_topointer(L, 2);
  1622. inst->installModule(module);
  1623. return 0;
  1624. }
  1625. static int Polycore_CoreServices_getMaterialManager(lua_State *L) {
  1626. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  1627. CoreServices *inst = (CoreServices*)lua_topointer(L, 1);
  1628. void *ptrRetVal = (void*)inst->getMaterialManager();
  1629. if(ptrRetVal == NULL) {
  1630. lua_pushnil(L);
  1631. } else {
  1632. lua_pushlightuserdata(L, ptrRetVal);
  1633. }
  1634. return 1;
  1635. }
  1636. static int Polycore_CoreServices_getScreenManager(lua_State *L) {
  1637. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  1638. CoreServices *inst = (CoreServices*)lua_topointer(L, 1);
  1639. void *ptrRetVal = (void*)inst->getScreenManager();
  1640. if(ptrRetVal == NULL) {
  1641. lua_pushnil(L);
  1642. } else {
  1643. lua_pushlightuserdata(L, ptrRetVal);
  1644. }
  1645. return 1;
  1646. }
  1647. static int Polycore_CoreServices_getSceneManager(lua_State *L) {
  1648. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  1649. CoreServices *inst = (CoreServices*)lua_topointer(L, 1);
  1650. void *ptrRetVal = (void*)inst->getSceneManager();
  1651. if(ptrRetVal == NULL) {
  1652. lua_pushnil(L);
  1653. } else {
  1654. lua_pushlightuserdata(L, ptrRetVal);
  1655. }
  1656. return 1;
  1657. }
  1658. static int Polycore_CoreServices_getTimerManager(lua_State *L) {
  1659. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  1660. CoreServices *inst = (CoreServices*)lua_topointer(L, 1);
  1661. void *ptrRetVal = (void*)inst->getTimerManager();
  1662. if(ptrRetVal == NULL) {
  1663. lua_pushnil(L);
  1664. } else {
  1665. lua_pushlightuserdata(L, ptrRetVal);
  1666. }
  1667. return 1;
  1668. }
  1669. static int Polycore_CoreServices_getTweenManager(lua_State *L) {
  1670. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  1671. CoreServices *inst = (CoreServices*)lua_topointer(L, 1);
  1672. void *ptrRetVal = (void*)inst->getTweenManager();
  1673. if(ptrRetVal == NULL) {
  1674. lua_pushnil(L);
  1675. } else {
  1676. lua_pushlightuserdata(L, ptrRetVal);
  1677. }
  1678. return 1;
  1679. }
  1680. static int Polycore_CoreServices_getResourceManager(lua_State *L) {
  1681. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  1682. CoreServices *inst = (CoreServices*)lua_topointer(L, 1);
  1683. void *ptrRetVal = (void*)inst->getResourceManager();
  1684. if(ptrRetVal == NULL) {
  1685. lua_pushnil(L);
  1686. } else {
  1687. lua_pushlightuserdata(L, ptrRetVal);
  1688. }
  1689. return 1;
  1690. }
  1691. static int Polycore_CoreServices_getSoundManager(lua_State *L) {
  1692. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  1693. CoreServices *inst = (CoreServices*)lua_topointer(L, 1);
  1694. void *ptrRetVal = (void*)inst->getSoundManager();
  1695. if(ptrRetVal == NULL) {
  1696. lua_pushnil(L);
  1697. } else {
  1698. lua_pushlightuserdata(L, ptrRetVal);
  1699. }
  1700. return 1;
  1701. }
  1702. static int Polycore_CoreServices_getFontManager(lua_State *L) {
  1703. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  1704. CoreServices *inst = (CoreServices*)lua_topointer(L, 1);
  1705. void *ptrRetVal = (void*)inst->getFontManager();
  1706. if(ptrRetVal == NULL) {
  1707. lua_pushnil(L);
  1708. } else {
  1709. lua_pushlightuserdata(L, ptrRetVal);
  1710. }
  1711. return 1;
  1712. }
  1713. static int Polycore_CoreServices_getConfig(lua_State *L) {
  1714. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  1715. CoreServices *inst = (CoreServices*)lua_topointer(L, 1);
  1716. void *ptrRetVal = (void*)inst->getConfig();
  1717. if(ptrRetVal == NULL) {
  1718. lua_pushnil(L);
  1719. } else {
  1720. lua_pushlightuserdata(L, ptrRetVal);
  1721. }
  1722. return 1;
  1723. }
  1724. static int Polycore_delete_CoreServices(lua_State *L) {
  1725. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  1726. CoreServices *inst = (CoreServices*)lua_topointer(L, 1);
  1727. delete inst;
  1728. return 0;
  1729. }
  1730. static int Polycore_Cubemap(lua_State *L) {
  1731. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  1732. Texture* t0 = (Texture*)lua_topointer(L, 1);
  1733. luaL_checktype(L, 2, LUA_TLIGHTUSERDATA);
  1734. Texture* t1 = (Texture*)lua_topointer(L, 2);
  1735. luaL_checktype(L, 3, LUA_TLIGHTUSERDATA);
  1736. Texture* t2 = (Texture*)lua_topointer(L, 3);
  1737. luaL_checktype(L, 4, LUA_TLIGHTUSERDATA);
  1738. Texture* t3 = (Texture*)lua_topointer(L, 4);
  1739. luaL_checktype(L, 5, LUA_TLIGHTUSERDATA);
  1740. Texture* t4 = (Texture*)lua_topointer(L, 5);
  1741. luaL_checktype(L, 6, LUA_TLIGHTUSERDATA);
  1742. Texture* t5 = (Texture*)lua_topointer(L, 6);
  1743. Cubemap *inst = new Cubemap(t0, t1, t2, t3, t4, t5);
  1744. lua_pushlightuserdata(L, (void*)inst);
  1745. return 1;
  1746. }
  1747. static int Polycore_delete_Cubemap(lua_State *L) {
  1748. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  1749. Cubemap *inst = (Cubemap*)lua_topointer(L, 1);
  1750. delete inst;
  1751. return 0;
  1752. }
  1753. static int Polycore_Data(lua_State *L) {
  1754. Data *inst = new Data();
  1755. lua_pushlightuserdata(L, (void*)inst);
  1756. return 1;
  1757. }
  1758. static int Polycore_Data_loadFromFile(lua_State *L) {
  1759. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  1760. Data *inst = (Data*)lua_topointer(L, 1);
  1761. luaL_checktype(L, 2, LUA_TSTRING);
  1762. String fileName = String(lua_tostring(L, 2));
  1763. inst->loadFromFile(fileName);
  1764. return 0;
  1765. }
  1766. static int Polycore_Data_getAsString(lua_State *L) {
  1767. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  1768. Data *inst = (Data*)lua_topointer(L, 1);
  1769. luaL_checktype(L, 2, LUA_TNUMBER);
  1770. int encoding = lua_tointeger(L, 2);
  1771. lua_pushstring(L, inst->getAsString(encoding).c_str());
  1772. return 1;
  1773. }
  1774. static int Polycore_Data_setFromString(lua_State *L) {
  1775. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  1776. Data *inst = (Data*)lua_topointer(L, 1);
  1777. luaL_checktype(L, 2, LUA_TSTRING);
  1778. String str = String(lua_tostring(L, 2));
  1779. luaL_checktype(L, 3, LUA_TNUMBER);
  1780. int encoding = lua_tointeger(L, 3);
  1781. inst->setFromString(str, encoding);
  1782. return 0;
  1783. }
  1784. static int Polycore_Data_saveToFile(lua_State *L) {
  1785. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  1786. Data *inst = (Data*)lua_topointer(L, 1);
  1787. luaL_checktype(L, 2, LUA_TSTRING);
  1788. String fileName = String(lua_tostring(L, 2));
  1789. lua_pushboolean(L, inst->saveToFile(fileName));
  1790. return 1;
  1791. }
  1792. static int Polycore_Data_getData(lua_State *L) {
  1793. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  1794. Data *inst = (Data*)lua_topointer(L, 1);
  1795. void *ptrRetVal = (void*)inst->getData();
  1796. if(ptrRetVal == NULL) {
  1797. lua_pushnil(L);
  1798. } else {
  1799. lua_pushlightuserdata(L, ptrRetVal);
  1800. }
  1801. return 1;
  1802. }
  1803. static int Polycore_delete_Data(lua_State *L) {
  1804. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  1805. Data *inst = (Data*)lua_topointer(L, 1);
  1806. delete inst;
  1807. return 0;
  1808. }
  1809. static int Polycore_Entity_get_custEntityType(lua_State *L) {
  1810. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  1811. Entity *inst = (Entity*)lua_topointer(L, 1);
  1812. lua_pushstring(L, inst->custEntityType.c_str());
  1813. return 1;
  1814. }
  1815. static int Polycore_Entity_get_billboardMode(lua_State *L) {
  1816. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  1817. Entity *inst = (Entity*)lua_topointer(L, 1);
  1818. lua_pushboolean(L, inst->billboardMode);
  1819. return 1;
  1820. }
  1821. static int Polycore_Entity_get_billboardRoll(lua_State *L) {
  1822. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  1823. Entity *inst = (Entity*)lua_topointer(L, 1);
  1824. lua_pushboolean(L, inst->billboardRoll);
  1825. return 1;
  1826. }
  1827. static int Polycore_Entity_get_alphaTest(lua_State *L) {
  1828. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  1829. Entity *inst = (Entity*)lua_topointer(L, 1);
  1830. lua_pushboolean(L, inst->alphaTest);
  1831. return 1;
  1832. }
  1833. static int Polycore_Entity_get_backfaceCulled(lua_State *L) {
  1834. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  1835. Entity *inst = (Entity*)lua_topointer(L, 1);
  1836. lua_pushboolean(L, inst->backfaceCulled);
  1837. return 1;
  1838. }
  1839. static int Polycore_Entity_get_renderWireframe(lua_State *L) {
  1840. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  1841. Entity *inst = (Entity*)lua_topointer(L, 1);
  1842. lua_pushboolean(L, inst->renderWireframe);
  1843. return 1;
  1844. }
  1845. static int Polycore_Entity_get_color(lua_State *L) {
  1846. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  1847. Entity *inst = (Entity*)lua_topointer(L, 1);
  1848. lua_pushlightuserdata(L, &inst->color);
  1849. return 1;
  1850. }
  1851. static int Polycore_Entity_get_enabled(lua_State *L) {
  1852. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  1853. Entity *inst = (Entity*)lua_topointer(L, 1);
  1854. lua_pushboolean(L, inst->enabled);
  1855. return 1;
  1856. }
  1857. static int Polycore_Entity_get_visible(lua_State *L) {
  1858. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  1859. Entity *inst = (Entity*)lua_topointer(L, 1);
  1860. lua_pushboolean(L, inst->visible);
  1861. return 1;
  1862. }
  1863. static int Polycore_Entity_get_depthWrite(lua_State *L) {
  1864. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  1865. Entity *inst = (Entity*)lua_topointer(L, 1);
  1866. lua_pushboolean(L, inst->depthWrite);
  1867. return 1;
  1868. }
  1869. static int Polycore_Entity_get_depthTest(lua_State *L) {
  1870. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  1871. Entity *inst = (Entity*)lua_topointer(L, 1);
  1872. lua_pushboolean(L, inst->depthTest);
  1873. return 1;
  1874. }
  1875. static int Polycore_Entity_get_blendingMode(lua_State *L) {
  1876. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  1877. Entity *inst = (Entity*)lua_topointer(L, 1);
  1878. lua_pushinteger(L, inst->blendingMode);
  1879. return 1;
  1880. }
  1881. static int Polycore_Entity_get_colorAffectsChildren(lua_State *L) {
  1882. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  1883. Entity *inst = (Entity*)lua_topointer(L, 1);
  1884. lua_pushboolean(L, inst->colorAffectsChildren);
  1885. return 1;
  1886. }
  1887. static int Polycore_Entity_get_visibilityAffectsChildren(lua_State *L) {
  1888. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  1889. Entity *inst = (Entity*)lua_topointer(L, 1);
  1890. lua_pushboolean(L, inst->visibilityAffectsChildren);
  1891. return 1;
  1892. }
  1893. static int Polycore_Entity_get_depthOnly(lua_State *L) {
  1894. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  1895. Entity *inst = (Entity*)lua_topointer(L, 1);
  1896. lua_pushboolean(L, inst->depthOnly);
  1897. return 1;
  1898. }
  1899. static int Polycore_Entity_get_bBox(lua_State *L) {
  1900. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  1901. Entity *inst = (Entity*)lua_topointer(L, 1);
  1902. lua_pushlightuserdata(L, &inst->bBox);
  1903. return 1;
  1904. }
  1905. static int Polycore_Entity_get_ignoreParentMatrix(lua_State *L) {
  1906. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  1907. Entity *inst = (Entity*)lua_topointer(L, 1);
  1908. lua_pushboolean(L, inst->ignoreParentMatrix);
  1909. return 1;
  1910. }
  1911. static int Polycore_Entity_get_isMask(lua_State *L) {
  1912. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  1913. Entity *inst = (Entity*)lua_topointer(L, 1);
  1914. lua_pushboolean(L, inst->isMask);
  1915. return 1;
  1916. }
  1917. static int Polycore_Entity_set_custEntityType(lua_State *L) {
  1918. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  1919. Entity *inst = (Entity*)lua_topointer(L, 1);
  1920. String param = lua_tostring(L, 2);
  1921. inst->custEntityType = param;
  1922. return 0;
  1923. }
  1924. static int Polycore_Entity_set_billboardMode(lua_State *L) {
  1925. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  1926. Entity *inst = (Entity*)lua_topointer(L, 1);
  1927. bool param = lua_toboolean(L, 2);
  1928. inst->billboardMode = param;
  1929. return 0;
  1930. }
  1931. static int Polycore_Entity_set_billboardRoll(lua_State *L) {
  1932. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  1933. Entity *inst = (Entity*)lua_topointer(L, 1);
  1934. bool param = lua_toboolean(L, 2);
  1935. inst->billboardRoll = param;
  1936. return 0;
  1937. }
  1938. static int Polycore_Entity_set_alphaTest(lua_State *L) {
  1939. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  1940. Entity *inst = (Entity*)lua_topointer(L, 1);
  1941. bool param = lua_toboolean(L, 2);
  1942. inst->alphaTest = param;
  1943. return 0;
  1944. }
  1945. static int Polycore_Entity_set_backfaceCulled(lua_State *L) {
  1946. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  1947. Entity *inst = (Entity*)lua_topointer(L, 1);
  1948. bool param = lua_toboolean(L, 2);
  1949. inst->backfaceCulled = param;
  1950. return 0;
  1951. }
  1952. static int Polycore_Entity_set_renderWireframe(lua_State *L) {
  1953. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  1954. Entity *inst = (Entity*)lua_topointer(L, 1);
  1955. bool param = lua_toboolean(L, 2);
  1956. inst->renderWireframe = param;
  1957. return 0;
  1958. }
  1959. static int Polycore_Entity_set_enabled(lua_State *L) {
  1960. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  1961. Entity *inst = (Entity*)lua_topointer(L, 1);
  1962. bool param = lua_toboolean(L, 2);
  1963. inst->enabled = param;
  1964. return 0;
  1965. }
  1966. static int Polycore_Entity_set_visible(lua_State *L) {
  1967. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  1968. Entity *inst = (Entity*)lua_topointer(L, 1);
  1969. bool param = lua_toboolean(L, 2);
  1970. inst->visible = param;
  1971. return 0;
  1972. }
  1973. static int Polycore_Entity_set_depthWrite(lua_State *L) {
  1974. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  1975. Entity *inst = (Entity*)lua_topointer(L, 1);
  1976. bool param = lua_toboolean(L, 2);
  1977. inst->depthWrite = param;
  1978. return 0;
  1979. }
  1980. static int Polycore_Entity_set_depthTest(lua_State *L) {
  1981. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  1982. Entity *inst = (Entity*)lua_topointer(L, 1);
  1983. bool param = lua_toboolean(L, 2);
  1984. inst->depthTest = param;
  1985. return 0;
  1986. }
  1987. static int Polycore_Entity_set_blendingMode(lua_State *L) {
  1988. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  1989. Entity *inst = (Entity*)lua_topointer(L, 1);
  1990. int param = lua_tointeger(L, 2);
  1991. inst->blendingMode = param;
  1992. return 0;
  1993. }
  1994. static int Polycore_Entity_set_colorAffectsChildren(lua_State *L) {
  1995. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  1996. Entity *inst = (Entity*)lua_topointer(L, 1);
  1997. bool param = lua_toboolean(L, 2);
  1998. inst->colorAffectsChildren = param;
  1999. return 0;
  2000. }
  2001. static int Polycore_Entity_set_visibilityAffectsChildren(lua_State *L) {
  2002. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  2003. Entity *inst = (Entity*)lua_topointer(L, 1);
  2004. bool param = lua_toboolean(L, 2);
  2005. inst->visibilityAffectsChildren = param;
  2006. return 0;
  2007. }
  2008. static int Polycore_Entity_set_depthOnly(lua_State *L) {
  2009. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  2010. Entity *inst = (Entity*)lua_topointer(L, 1);
  2011. bool param = lua_toboolean(L, 2);
  2012. inst->depthOnly = param;
  2013. return 0;
  2014. }
  2015. static int Polycore_Entity_set_ignoreParentMatrix(lua_State *L) {
  2016. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  2017. Entity *inst = (Entity*)lua_topointer(L, 1);
  2018. bool param = lua_toboolean(L, 2);
  2019. inst->ignoreParentMatrix = param;
  2020. return 0;
  2021. }
  2022. static int Polycore_Entity_set_isMask(lua_State *L) {
  2023. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  2024. Entity *inst = (Entity*)lua_topointer(L, 1);
  2025. bool param = lua_toboolean(L, 2);
  2026. inst->isMask = param;
  2027. return 0;
  2028. }
  2029. static int Polycore_Entity(lua_State *L) {
  2030. Entity *inst = new Entity();
  2031. lua_pushlightuserdata(L, (void*)inst);
  2032. return 1;
  2033. }
  2034. static int Polycore_Entity_Render(lua_State *L) {
  2035. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  2036. Entity *inst = (Entity*)lua_topointer(L, 1);
  2037. inst->Render();
  2038. return 0;
  2039. }
  2040. static int Polycore_Entity_Update(lua_State *L) {
  2041. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  2042. Entity *inst = (Entity*)lua_topointer(L, 1);
  2043. inst->Update();
  2044. return 0;
  2045. }
  2046. static int Polycore_Entity_transformAndRender(lua_State *L) {
  2047. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  2048. Entity *inst = (Entity*)lua_topointer(L, 1);
  2049. inst->transformAndRender();
  2050. return 0;
  2051. }
  2052. static int Polycore_Entity_renderChildren(lua_State *L) {
  2053. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  2054. Entity *inst = (Entity*)lua_topointer(L, 1);
  2055. inst->renderChildren();
  2056. return 0;
  2057. }
  2058. static int Polycore_Entity_dirtyMatrix(lua_State *L) {
  2059. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  2060. Entity *inst = (Entity*)lua_topointer(L, 1);
  2061. luaL_checktype(L, 2, LUA_TBOOLEAN);
  2062. bool val = lua_toboolean(L, 2);
  2063. inst->dirtyMatrix(val);
  2064. return 0;
  2065. }
  2066. static int Polycore_Entity_rebuildTransformMatrix(lua_State *L) {
  2067. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  2068. Entity *inst = (Entity*)lua_topointer(L, 1);
  2069. inst->rebuildTransformMatrix();
  2070. return 0;
  2071. }
  2072. static int Polycore_Entity_updateEntityMatrix(lua_State *L) {
  2073. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  2074. Entity *inst = (Entity*)lua_topointer(L, 1);
  2075. inst->updateEntityMatrix();
  2076. return 0;
  2077. }
  2078. static int Polycore_Entity_getTransformMatrix(lua_State *L) {
  2079. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  2080. Entity *inst = (Entity*)lua_topointer(L, 1);
  2081. Matrix4 *retInst = new Matrix4 ();
  2082. *retInst = inst->getTransformMatrix();
  2083. lua_pushlightuserdata(L, retInst);
  2084. return 1;
  2085. }
  2086. static int Polycore_Entity_getConcatenatedMatrix(lua_State *L) {
  2087. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  2088. Entity *inst = (Entity*)lua_topointer(L, 1);
  2089. Matrix4 *retInst = new Matrix4();
  2090. *retInst = inst->getConcatenatedMatrix();
  2091. lua_pushlightuserdata(L, retInst);
  2092. return 1;
  2093. }
  2094. static int Polycore_Entity_getConcatenatedRollMatrix(lua_State *L) {
  2095. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  2096. Entity *inst = (Entity*)lua_topointer(L, 1);
  2097. Matrix4 *retInst = new Matrix4();
  2098. *retInst = inst->getConcatenatedRollMatrix();
  2099. lua_pushlightuserdata(L, retInst);
  2100. return 1;
  2101. }
  2102. static int Polycore_Entity_setTransformByMatrix(lua_State *L) {
  2103. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  2104. Entity *inst = (Entity*)lua_topointer(L, 1);
  2105. luaL_checktype(L, 2, LUA_TLIGHTUSERDATA);
  2106. Matrix4 matrix = *(Matrix4*)lua_topointer(L, 2);
  2107. inst->setTransformByMatrix(matrix);
  2108. return 0;
  2109. }
  2110. static int Polycore_Entity_setTransformByMatrixPure(lua_State *L) {
  2111. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  2112. Entity *inst = (Entity*)lua_topointer(L, 1);
  2113. luaL_checktype(L, 2, LUA_TLIGHTUSERDATA);
  2114. Matrix4 matrix = *(Matrix4*)lua_topointer(L, 2);
  2115. inst->setTransformByMatrixPure(matrix);
  2116. return 0;
  2117. }
  2118. static int Polycore_Entity_getLookAtMatrix(lua_State *L) {
  2119. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  2120. Entity *inst = (Entity*)lua_topointer(L, 1);
  2121. luaL_checktype(L, 2, LUA_TLIGHTUSERDATA);
  2122. Vector3 loc = *(Vector3*)lua_topointer(L, 2);
  2123. luaL_checktype(L, 3, LUA_TLIGHTUSERDATA);
  2124. Vector3 upVector = *(Vector3*)lua_topointer(L, 3);
  2125. Matrix4 *retInst = new Matrix4();
  2126. *retInst = inst->getLookAtMatrix(loc, upVector);
  2127. lua_pushlightuserdata(L, retInst);
  2128. return 1;
  2129. }
  2130. static int Polycore_Entity_addEntity(lua_State *L) {
  2131. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  2132. Entity *inst = (Entity*)lua_topointer(L, 1);
  2133. luaL_checktype(L, 2, LUA_TLIGHTUSERDATA);
  2134. Entity* newChild = (Entity*)lua_topointer(L, 2);
  2135. inst->addEntity(newChild);
  2136. return 0;
  2137. }
  2138. static int Polycore_Entity_addChild(lua_State *L) {
  2139. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  2140. Entity *inst = (Entity*)lua_topointer(L, 1);
  2141. luaL_checktype(L, 2, LUA_TLIGHTUSERDATA);
  2142. Entity* newChild = (Entity*)lua_topointer(L, 2);
  2143. inst->addChild(newChild);
  2144. return 0;
  2145. }
  2146. static int Polycore_Entity_removeChild(lua_State *L) {
  2147. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  2148. Entity *inst = (Entity*)lua_topointer(L, 1);
  2149. luaL_checktype(L, 2, LUA_TLIGHTUSERDATA);
  2150. Entity* entityToRemove = (Entity*)lua_topointer(L, 2);
  2151. inst->removeChild(entityToRemove);
  2152. return 0;
  2153. }
  2154. static int Polycore_Entity_setParentEntity(lua_State *L) {
  2155. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  2156. Entity *inst = (Entity*)lua_topointer(L, 1);
  2157. luaL_checktype(L, 2, LUA_TLIGHTUSERDATA);
  2158. Entity* entity = (Entity*)lua_topointer(L, 2);
  2159. inst->setParentEntity(entity);
  2160. return 0;
  2161. }
  2162. static int Polycore_Entity_getParentEntity(lua_State *L) {
  2163. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  2164. Entity *inst = (Entity*)lua_topointer(L, 1);
  2165. void *ptrRetVal = (void*)inst->getParentEntity();
  2166. if(ptrRetVal == NULL) {
  2167. lua_pushnil(L);
  2168. } else {
  2169. lua_pushlightuserdata(L, ptrRetVal);
  2170. }
  2171. return 1;
  2172. }
  2173. static int Polycore_Entity_getPosition(lua_State *L) {
  2174. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  2175. Entity *inst = (Entity*)lua_topointer(L, 1);
  2176. Vector3 *retInst = new Vector3();
  2177. *retInst = inst->getPosition();
  2178. lua_pushlightuserdata(L, retInst);
  2179. return 1;
  2180. }
  2181. static int Polycore_Entity_getCombinedPosition(lua_State *L) {
  2182. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  2183. Entity *inst = (Entity*)lua_topointer(L, 1);
  2184. Vector3 *retInst = new Vector3();
  2185. *retInst = inst->getCombinedPosition();
  2186. lua_pushlightuserdata(L, retInst);
  2187. return 1;
  2188. }
  2189. static int Polycore_Entity_setPosition(lua_State *L) {
  2190. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  2191. Entity *inst = (Entity*)lua_topointer(L, 1);
  2192. luaL_checktype(L, 2, LUA_TNUMBER);
  2193. Number x = lua_tonumber(L, 2);
  2194. luaL_checktype(L, 3, LUA_TNUMBER);
  2195. Number y = lua_tonumber(L, 3);
  2196. luaL_checktype(L, 4, LUA_TNUMBER);
  2197. Number z = lua_tonumber(L, 4);
  2198. inst->setPosition(x, y, z);
  2199. return 0;
  2200. }
  2201. static int Polycore_Entity_setPositionX(lua_State *L) {
  2202. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  2203. Entity *inst = (Entity*)lua_topointer(L, 1);
  2204. luaL_checktype(L, 2, LUA_TNUMBER);
  2205. Number x = lua_tonumber(L, 2);
  2206. inst->setPositionX(x);
  2207. return 0;
  2208. }
  2209. static int Polycore_Entity_setPositionY(lua_State *L) {
  2210. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  2211. Entity *inst = (Entity*)lua_topointer(L, 1);
  2212. luaL_checktype(L, 2, LUA_TNUMBER);
  2213. Number y = lua_tonumber(L, 2);
  2214. inst->setPositionY(y);
  2215. return 0;
  2216. }
  2217. static int Polycore_Entity_Translate(lua_State *L) {
  2218. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  2219. Entity *inst = (Entity*)lua_topointer(L, 1);
  2220. luaL_checktype(L, 2, LUA_TNUMBER);
  2221. Number x = lua_tonumber(L, 2);
  2222. luaL_checktype(L, 3, LUA_TNUMBER);
  2223. Number y = lua_tonumber(L, 3);
  2224. luaL_checktype(L, 4, LUA_TNUMBER);
  2225. Number z = lua_tonumber(L, 4);
  2226. inst->Translate(x, y, z);
  2227. return 0;
  2228. }
  2229. static int Polycore_Entity_setPositionZ(lua_State *L) {
  2230. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  2231. Entity *inst = (Entity*)lua_topointer(L, 1);
  2232. luaL_checktype(L, 2, LUA_TNUMBER);
  2233. Number z = lua_tonumber(L, 2);
  2234. inst->setPositionZ(z);
  2235. return 0;
  2236. }
  2237. static int Polycore_Entity_setScaleX(lua_State *L) {
  2238. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  2239. Entity *inst = (Entity*)lua_topointer(L, 1);
  2240. luaL_checktype(L, 2, LUA_TNUMBER);
  2241. Number x = lua_tonumber(L, 2);
  2242. inst->setScaleX(x);
  2243. return 0;
  2244. }
  2245. static int Polycore_Entity_setScaleY(lua_State *L) {
  2246. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  2247. Entity *inst = (Entity*)lua_topointer(L, 1);
  2248. luaL_checktype(L, 2, LUA_TNUMBER);
  2249. Number y = lua_tonumber(L, 2);
  2250. inst->setScaleY(y);
  2251. return 0;
  2252. }
  2253. static int Polycore_Entity_setScaleZ(lua_State *L) {
  2254. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  2255. Entity *inst = (Entity*)lua_topointer(L, 1);
  2256. luaL_checktype(L, 2, LUA_TNUMBER);
  2257. Number z = lua_tonumber(L, 2);
  2258. inst->setScaleZ(z);
  2259. return 0;
  2260. }
  2261. static int Polycore_Entity_Scale(lua_State *L) {
  2262. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  2263. Entity *inst = (Entity*)lua_topointer(L, 1);
  2264. luaL_checktype(L, 2, LUA_TNUMBER);
  2265. Number x = lua_tonumber(L, 2);
  2266. luaL_checktype(L, 3, LUA_TNUMBER);
  2267. Number y = lua_tonumber(L, 3);
  2268. luaL_checktype(L, 4, LUA_TNUMBER);
  2269. Number z = lua_tonumber(L, 4);
  2270. inst->Scale(x, y, z);
  2271. return 0;
  2272. }
  2273. static int Polycore_Entity_setScale(lua_State *L) {
  2274. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  2275. Entity *inst = (Entity*)lua_topointer(L, 1);
  2276. luaL_checktype(L, 2, LUA_TNUMBER);
  2277. Number x = lua_tonumber(L, 2);
  2278. luaL_checktype(L, 3, LUA_TNUMBER);
  2279. Number y = lua_tonumber(L, 3);
  2280. luaL_checktype(L, 4, LUA_TNUMBER);
  2281. Number z = lua_tonumber(L, 4);
  2282. inst->setScale(x, y, z);
  2283. return 0;
  2284. }
  2285. static int Polycore_Entity_getCompoundScale(lua_State *L) {
  2286. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  2287. Entity *inst = (Entity*)lua_topointer(L, 1);
  2288. Vector3 *retInst = new Vector3();
  2289. *retInst = inst->getCompoundScale();
  2290. lua_pushlightuserdata(L, retInst);
  2291. return 1;
  2292. }
  2293. static int Polycore_Entity_getScale(lua_State *L) {
  2294. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  2295. Entity *inst = (Entity*)lua_topointer(L, 1);
  2296. Vector3 *retInst = new Vector3();
  2297. *retInst = inst->getScale();
  2298. lua_pushlightuserdata(L, retInst);
  2299. return 1;
  2300. }
  2301. static int Polycore_Entity_getCombinedPitch(lua_State *L) {
  2302. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  2303. Entity *inst = (Entity*)lua_topointer(L, 1);
  2304. lua_pushnumber(L, inst->getCombinedPitch());
  2305. return 1;
  2306. }
  2307. static int Polycore_Entity_getCombinedYaw(lua_State *L) {
  2308. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  2309. Entity *inst = (Entity*)lua_topointer(L, 1);
  2310. lua_pushnumber(L, inst->getCombinedYaw());
  2311. return 1;
  2312. }
  2313. static int Polycore_Entity_getCombinedRoll(lua_State *L) {
  2314. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  2315. Entity *inst = (Entity*)lua_topointer(L, 1);
  2316. lua_pushnumber(L, inst->getCombinedRoll());
  2317. return 1;
  2318. }
  2319. static int Polycore_Entity_rebuildRotation(lua_State *L) {
  2320. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  2321. Entity *inst = (Entity*)lua_topointer(L, 1);
  2322. inst->rebuildRotation();
  2323. return 0;
  2324. }
  2325. static int Polycore_Entity_setPitch(lua_State *L) {
  2326. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  2327. Entity *inst = (Entity*)lua_topointer(L, 1);
  2328. luaL_checktype(L, 2, LUA_TNUMBER);
  2329. Number pitch = lua_tonumber(L, 2);
  2330. inst->setPitch(pitch);
  2331. return 0;
  2332. }
  2333. static int Polycore_Entity_setYaw(lua_State *L) {
  2334. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  2335. Entity *inst = (Entity*)lua_topointer(L, 1);
  2336. luaL_checktype(L, 2, LUA_TNUMBER);
  2337. Number yaw = lua_tonumber(L, 2);
  2338. inst->setYaw(yaw);
  2339. return 0;
  2340. }
  2341. static int Polycore_Entity_setRoll(lua_State *L) {
  2342. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  2343. Entity *inst = (Entity*)lua_topointer(L, 1);
  2344. luaL_checktype(L, 2, LUA_TNUMBER);
  2345. Number roll = lua_tonumber(L, 2);
  2346. inst->setRoll(roll);
  2347. return 0;
  2348. }
  2349. static int Polycore_Entity_Roll(lua_State *L) {
  2350. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  2351. Entity *inst = (Entity*)lua_topointer(L, 1);
  2352. luaL_checktype(L, 2, LUA_TNUMBER);
  2353. Number roll = lua_tonumber(L, 2);
  2354. inst->Roll(roll);
  2355. return 0;
  2356. }
  2357. static int Polycore_Entity_Yaw(lua_State *L) {
  2358. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  2359. Entity *inst = (Entity*)lua_topointer(L, 1);
  2360. luaL_checktype(L, 2, LUA_TNUMBER);
  2361. Number yaw = lua_tonumber(L, 2);
  2362. inst->Yaw(yaw);
  2363. return 0;
  2364. }
  2365. static int Polycore_Entity_Pitch(lua_State *L) {
  2366. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  2367. Entity *inst = (Entity*)lua_topointer(L, 1);
  2368. luaL_checktype(L, 2, LUA_TNUMBER);
  2369. Number pitch = lua_tonumber(L, 2);
  2370. inst->Pitch(pitch);
  2371. return 0;
  2372. }
  2373. static int Polycore_Entity_getPitch(lua_State *L) {
  2374. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  2375. Entity *inst = (Entity*)lua_topointer(L, 1);
  2376. lua_pushnumber(L, inst->getPitch());
  2377. return 1;
  2378. }
  2379. static int Polycore_Entity_getYaw(lua_State *L) {
  2380. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  2381. Entity *inst = (Entity*)lua_topointer(L, 1);
  2382. lua_pushnumber(L, inst->getYaw());
  2383. return 1;
  2384. }
  2385. static int Polycore_Entity_getRoll(lua_State *L) {
  2386. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  2387. Entity *inst = (Entity*)lua_topointer(L, 1);
  2388. lua_pushnumber(L, inst->getRoll());
  2389. return 1;
  2390. }
  2391. static int Polycore_Entity_setRotationQuat(lua_State *L) {
  2392. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  2393. Entity *inst = (Entity*)lua_topointer(L, 1);
  2394. luaL_checktype(L, 2, LUA_TNUMBER);
  2395. Number w = lua_tonumber(L, 2);
  2396. luaL_checktype(L, 3, LUA_TNUMBER);
  2397. Number x = lua_tonumber(L, 3);
  2398. luaL_checktype(L, 4, LUA_TNUMBER);
  2399. Number y = lua_tonumber(L, 4);
  2400. luaL_checktype(L, 5, LUA_TNUMBER);
  2401. Number z = lua_tonumber(L, 5);
  2402. inst->setRotationQuat(w, x, y, z);
  2403. return 0;
  2404. }
  2405. static int Polycore_Entity_getRotationQuat(lua_State *L) {
  2406. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  2407. Entity *inst = (Entity*)lua_topointer(L, 1);
  2408. Quaternion *retInst = new Quaternion();
  2409. *retInst = inst->getRotationQuat();
  2410. lua_pushlightuserdata(L, retInst);
  2411. return 1;
  2412. }
  2413. static int Polycore_Entity_lookAt(lua_State *L) {
  2414. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  2415. Entity *inst = (Entity*)lua_topointer(L, 1);
  2416. luaL_checktype(L, 2, LUA_TLIGHTUSERDATA);
  2417. Vector3 loc = *(Vector3*)lua_topointer(L, 2);
  2418. luaL_checktype(L, 3, LUA_TLIGHTUSERDATA);
  2419. Vector3 upVector = *(Vector3*)lua_topointer(L, 3);
  2420. inst->lookAt(loc, upVector);
  2421. return 0;
  2422. }
  2423. static int Polycore_Entity_lookAtEntity(lua_State *L) {
  2424. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  2425. Entity *inst = (Entity*)lua_topointer(L, 1);
  2426. luaL_checktype(L, 2, LUA_TLIGHTUSERDATA);
  2427. Entity* entity = (Entity*)lua_topointer(L, 2);
  2428. luaL_checktype(L, 3, LUA_TLIGHTUSERDATA);
  2429. Vector3 upVector = *(Vector3*)lua_topointer(L, 3);
  2430. inst->lookAtEntity(entity, upVector);
  2431. return 0;
  2432. }
  2433. static int Polycore_Entity_getCombinedColor(lua_State *L) {
  2434. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  2435. Entity *inst = (Entity*)lua_topointer(L, 1);
  2436. Color *retInst = new Color();
  2437. *retInst = inst->getCombinedColor();
  2438. lua_pushlightuserdata(L, retInst);
  2439. return 1;
  2440. }
  2441. static int Polycore_Entity_setColor(lua_State *L) {
  2442. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  2443. Entity *inst = (Entity*)lua_topointer(L, 1);
  2444. luaL_checktype(L, 2, LUA_TNUMBER);
  2445. Number r = lua_tonumber(L, 2);
  2446. luaL_checktype(L, 3, LUA_TNUMBER);
  2447. Number g = lua_tonumber(L, 3);
  2448. luaL_checktype(L, 4, LUA_TNUMBER);
  2449. Number b = lua_tonumber(L, 4);
  2450. luaL_checktype(L, 5, LUA_TNUMBER);
  2451. Number a = lua_tonumber(L, 5);
  2452. inst->setColor(r, g, b, a);
  2453. return 0;
  2454. }
  2455. static int Polycore_Entity_setColorInt(lua_State *L) {
  2456. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  2457. Entity *inst = (Entity*)lua_topointer(L, 1);
  2458. luaL_checktype(L, 2, LUA_TNUMBER);
  2459. int r = lua_tointeger(L, 2);
  2460. luaL_checktype(L, 3, LUA_TNUMBER);
  2461. int g = lua_tointeger(L, 3);
  2462. luaL_checktype(L, 4, LUA_TNUMBER);
  2463. int b = lua_tointeger(L, 4);
  2464. luaL_checktype(L, 5, LUA_TNUMBER);
  2465. int a = lua_tointeger(L, 5);
  2466. inst->setColorInt(r, g, b, a);
  2467. return 0;
  2468. }
  2469. static int Polycore_Entity_recalculateBBox(lua_State *L) {
  2470. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  2471. Entity *inst = (Entity*)lua_topointer(L, 1);
  2472. inst->recalculateBBox();
  2473. return 0;
  2474. }
  2475. static int Polycore_Entity_getBBoxRadius(lua_State *L) {
  2476. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  2477. Entity *inst = (Entity*)lua_topointer(L, 1);
  2478. lua_pushnumber(L, inst->getBBoxRadius());
  2479. return 1;
  2480. }
  2481. static int Polycore_Entity_getCompoundBBoxRadius(lua_State *L) {
  2482. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  2483. Entity *inst = (Entity*)lua_topointer(L, 1);
  2484. lua_pushnumber(L, inst->getCompoundBBoxRadius());
  2485. return 1;
  2486. }
  2487. static int Polycore_Entity_setBBoxRadius(lua_State *L) {
  2488. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  2489. Entity *inst = (Entity*)lua_topointer(L, 1);
  2490. luaL_checktype(L, 2, LUA_TNUMBER);
  2491. Number rad = lua_tonumber(L, 2);
  2492. inst->setBBoxRadius(rad);
  2493. return 0;
  2494. }
  2495. static int Polycore_Entity_setMask(lua_State *L) {
  2496. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  2497. Entity *inst = (Entity*)lua_topointer(L, 1);
  2498. luaL_checktype(L, 2, LUA_TLIGHTUSERDATA);
  2499. Entity* mask = (Entity*)lua_topointer(L, 2);
  2500. inst->setMask(mask);
  2501. return 0;
  2502. }
  2503. static int Polycore_Entity_clearMask(lua_State *L) {
  2504. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  2505. Entity *inst = (Entity*)lua_topointer(L, 1);
  2506. inst->clearMask();
  2507. return 0;
  2508. }
  2509. static int Polycore_Entity_setBlendingMode(lua_State *L) {
  2510. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  2511. Entity *inst = (Entity*)lua_topointer(L, 1);
  2512. luaL_checktype(L, 2, LUA_TNUMBER);
  2513. int newBl_endingMode = lua_tointeger(L, 2);
  2514. inst->setBlendingMode(newBl_endingMode);
  2515. return 0;
  2516. }
  2517. static int Polycore_Entity_getChildCenter(lua_State *L) {
  2518. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  2519. Entity *inst = (Entity*)lua_topointer(L, 1);
  2520. Vector3 *retInst = new Vector3();
  2521. *retInst = inst->getChildCenter();
  2522. lua_pushlightuserdata(L, retInst);
  2523. return 1;
  2524. }
  2525. static int Polycore_Entity_getEntityProp(lua_State *L) {
  2526. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  2527. Entity *inst = (Entity*)lua_topointer(L, 1);
  2528. luaL_checktype(L, 2, LUA_TSTRING);
  2529. String propName = String(lua_tostring(L, 2));
  2530. lua_pushstring(L, inst->getEntityProp(propName).c_str());
  2531. return 1;
  2532. }
  2533. static int Polycore_Entity_doUpdates(lua_State *L) {
  2534. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  2535. Entity *inst = (Entity*)lua_topointer(L, 1);
  2536. inst->doUpdates();
  2537. return 0;
  2538. }
  2539. static int Polycore_Entity_buildPositionMatrix(lua_State *L) {
  2540. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  2541. Entity *inst = (Entity*)lua_topointer(L, 1);
  2542. Matrix4 *retInst = new Matrix4();
  2543. *retInst = inst->buildPositionMatrix();
  2544. lua_pushlightuserdata(L, retInst);
  2545. return 1;
  2546. }
  2547. static int Polycore_Entity_adjustMatrixForChildren(lua_State *L) {
  2548. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  2549. Entity *inst = (Entity*)lua_topointer(L, 1);
  2550. inst->adjustMatrixForChildren();
  2551. return 0;
  2552. }
  2553. static int Polycore_Entity_setRenderer(lua_State *L) {
  2554. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  2555. Entity *inst = (Entity*)lua_topointer(L, 1);
  2556. luaL_checktype(L, 2, LUA_TLIGHTUSERDATA);
  2557. Renderer* r_enderer = (Renderer*)lua_topointer(L, 2);
  2558. inst->setRenderer(r_enderer);
  2559. return 0;
  2560. }
  2561. static int Polycore_delete_Entity(lua_State *L) {
  2562. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  2563. Entity *inst = (Entity*)lua_topointer(L, 1);
  2564. delete inst;
  2565. return 0;
  2566. }
  2567. static int Polycore_Event(lua_State *L) {
  2568. Event *inst = new Event();
  2569. lua_pushlightuserdata(L, (void*)inst);
  2570. return 1;
  2571. }
  2572. static int Polycore_Event_getEventCode(lua_State *L) {
  2573. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  2574. Event *inst = (Event*)lua_topointer(L, 1);
  2575. lua_pushinteger(L, inst->getEventCode());
  2576. return 1;
  2577. }
  2578. static int Polycore_Event_getDispatcher(lua_State *L) {
  2579. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  2580. Event *inst = (Event*)lua_topointer(L, 1);
  2581. void *ptrRetVal = (void*)inst->getDispatcher();
  2582. if(ptrRetVal == NULL) {
  2583. lua_pushnil(L);
  2584. } else {
  2585. lua_pushlightuserdata(L, ptrRetVal);
  2586. }
  2587. return 1;
  2588. }
  2589. static int Polycore_Event_setEventCode(lua_State *L) {
  2590. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  2591. Event *inst = (Event*)lua_topointer(L, 1);
  2592. luaL_checktype(L, 2, LUA_TNUMBER);
  2593. int eventCode = lua_tointeger(L, 2);
  2594. inst->setEventCode(eventCode);
  2595. return 0;
  2596. }
  2597. static int Polycore_Event_setDispatcher(lua_State *L) {
  2598. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  2599. Event *inst = (Event*)lua_topointer(L, 1);
  2600. luaL_checktype(L, 2, LUA_TLIGHTUSERDATA);
  2601. EventDispatcher* dispatcher = (EventDispatcher*)lua_topointer(L, 2);
  2602. inst->setDispatcher(dispatcher);
  2603. return 0;
  2604. }
  2605. static int Polycore_Event_getEventType(lua_State *L) {
  2606. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  2607. Event *inst = (Event*)lua_topointer(L, 1);
  2608. String *retInst = new String ();
  2609. *retInst = inst->getEventType();
  2610. lua_pushlightuserdata(L, retInst);
  2611. return 1;
  2612. }
  2613. static int Polycore_delete_Event(lua_State *L) {
  2614. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  2615. Event *inst = (Event*)lua_topointer(L, 1);
  2616. delete inst;
  2617. return 0;
  2618. }
  2619. static int Polycore_EventDispatcher(lua_State *L) {
  2620. EventDispatcher *inst = new EventDispatcher();
  2621. lua_pushlightuserdata(L, (void*)inst);
  2622. return 1;
  2623. }
  2624. static int Polycore_EventDispatcher_removeAllHandlers(lua_State *L) {
  2625. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  2626. EventDispatcher *inst = (EventDispatcher*)lua_topointer(L, 1);
  2627. inst->removeAllHandlers();
  2628. return 0;
  2629. }
  2630. static int Polycore_EventDispatcher_removeAllHandlersForListener(lua_State *L) {
  2631. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  2632. EventDispatcher *inst = (EventDispatcher*)lua_topointer(L, 1);
  2633. luaL_checktype(L, 2, LUA_TLIGHTUSERDATA);
  2634. void* listener = (void*)lua_topointer(L, 2);
  2635. inst->removeAllHandlersForListener(listener);
  2636. return 0;
  2637. }
  2638. static int Polycore_EventDispatcher_addEventListener(lua_State *L) {
  2639. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  2640. EventDispatcher *inst = (EventDispatcher*)lua_topointer(L, 1);
  2641. luaL_checktype(L, 2, LUA_TLIGHTUSERDATA);
  2642. EventHandler* handler = (EventHandler*)lua_topointer(L, 2);
  2643. luaL_checktype(L, 3, LUA_TNUMBER);
  2644. int eventCode = lua_tointeger(L, 3);
  2645. inst->addEventListener(handler, eventCode);
  2646. return 0;
  2647. }
  2648. static int Polycore_EventDispatcher_removeEventListener(lua_State *L) {
  2649. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  2650. EventDispatcher *inst = (EventDispatcher*)lua_topointer(L, 1);
  2651. luaL_checktype(L, 2, LUA_TLIGHTUSERDATA);
  2652. EventHandler* handler = (EventHandler*)lua_topointer(L, 2);
  2653. luaL_checktype(L, 3, LUA_TNUMBER);
  2654. int eventCode = lua_tointeger(L, 3);
  2655. inst->removeEventListener(handler, eventCode);
  2656. return 0;
  2657. }
  2658. static int Polycore_EventDispatcher___dispatchEvent(lua_State *L) {
  2659. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  2660. EventDispatcher *inst = (EventDispatcher*)lua_topointer(L, 1);
  2661. luaL_checktype(L, 2, LUA_TLIGHTUSERDATA);
  2662. Event* event = (Event*)lua_topointer(L, 2);
  2663. luaL_checktype(L, 3, LUA_TNUMBER);
  2664. int eventCode = lua_tointeger(L, 3);
  2665. inst->__dispatchEvent(event, eventCode);
  2666. return 0;
  2667. }
  2668. static int Polycore_EventDispatcher_dispatchEvent(lua_State *L) {
  2669. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  2670. EventDispatcher *inst = (EventDispatcher*)lua_topointer(L, 1);
  2671. luaL_checktype(L, 2, LUA_TLIGHTUSERDATA);
  2672. Event* event = (Event*)lua_topointer(L, 2);
  2673. luaL_checktype(L, 3, LUA_TNUMBER);
  2674. int eventCode = lua_tointeger(L, 3);
  2675. inst->dispatchEvent(event, eventCode);
  2676. return 0;
  2677. }
  2678. static int Polycore_EventDispatcher_dispatchEventNoDelete(lua_State *L) {
  2679. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  2680. EventDispatcher *inst = (EventDispatcher*)lua_topointer(L, 1);
  2681. luaL_checktype(L, 2, LUA_TLIGHTUSERDATA);
  2682. Event* event = (Event*)lua_topointer(L, 2);
  2683. luaL_checktype(L, 3, LUA_TNUMBER);
  2684. int eventCode = lua_tointeger(L, 3);
  2685. inst->dispatchEventNoDelete(event, eventCode);
  2686. return 0;
  2687. }
  2688. static int Polycore_delete_EventDispatcher(lua_State *L) {
  2689. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  2690. EventDispatcher *inst = (EventDispatcher*)lua_topointer(L, 1);
  2691. delete inst;
  2692. return 0;
  2693. }
  2694. static int Polycore_EventHandler(lua_State *L) {
  2695. LuaEventHandler *inst = new LuaEventHandler();
  2696. inst->wrapperIndex = luaL_ref(L, LUA_REGISTRYINDEX );
  2697. inst->L = L;
  2698. lua_pushlightuserdata(L, (void*)inst);
  2699. return 1;
  2700. }
  2701. static int Polycore_delete_EventHandler(lua_State *L) {
  2702. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  2703. EventHandler *inst = (EventHandler*)lua_topointer(L, 1);
  2704. delete inst;
  2705. return 0;
  2706. }
  2707. static int Polycore_FixedShader(lua_State *L) {
  2708. FixedShader *inst = new FixedShader();
  2709. lua_pushlightuserdata(L, (void*)inst);
  2710. return 1;
  2711. }
  2712. static int Polycore_FixedShader_createBinding(lua_State *L) {
  2713. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  2714. FixedShader *inst = (FixedShader*)lua_topointer(L, 1);
  2715. void *ptrRetVal = (void*)inst->createBinding();
  2716. if(ptrRetVal == NULL) {
  2717. lua_pushnil(L);
  2718. } else {
  2719. lua_pushlightuserdata(L, ptrRetVal);
  2720. }
  2721. return 1;
  2722. }
  2723. static int Polycore_delete_FixedShader(lua_State *L) {
  2724. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  2725. FixedShader *inst = (FixedShader*)lua_topointer(L, 1);
  2726. delete inst;
  2727. return 0;
  2728. }
  2729. static int Polycore_FixedShaderBinding(lua_State *L) {
  2730. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  2731. FixedShader* shader = (FixedShader*)lua_topointer(L, 1);
  2732. FixedShaderBinding *inst = new FixedShaderBinding(shader);
  2733. lua_pushlightuserdata(L, (void*)inst);
  2734. return 1;
  2735. }
  2736. static int Polycore_FixedShaderBinding_addTexture(lua_State *L) {
  2737. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  2738. FixedShaderBinding *inst = (FixedShaderBinding*)lua_topointer(L, 1);
  2739. luaL_checktype(L, 2, LUA_TSTRING);
  2740. String name = String(lua_tostring(L, 2));
  2741. luaL_checktype(L, 3, LUA_TLIGHTUSERDATA);
  2742. Texture* texture = (Texture*)lua_topointer(L, 3);
  2743. inst->addTexture(name, texture);
  2744. return 0;
  2745. }
  2746. static int Polycore_FixedShaderBinding_addCubemap(lua_State *L) {
  2747. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  2748. FixedShaderBinding *inst = (FixedShaderBinding*)lua_topointer(L, 1);
  2749. luaL_checktype(L, 2, LUA_TSTRING);
  2750. String name = String(lua_tostring(L, 2));
  2751. luaL_checktype(L, 3, LUA_TLIGHTUSERDATA);
  2752. Cubemap* cubemap = (Cubemap*)lua_topointer(L, 3);
  2753. inst->addCubemap(name, cubemap);
  2754. return 0;
  2755. }
  2756. static int Polycore_FixedShaderBinding_addParam(lua_State *L) {
  2757. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  2758. FixedShaderBinding *inst = (FixedShaderBinding*)lua_topointer(L, 1);
  2759. luaL_checktype(L, 2, LUA_TSTRING);
  2760. String type = String(lua_tostring(L, 2));
  2761. luaL_checktype(L, 3, LUA_TSTRING);
  2762. String name = String(lua_tostring(L, 3));
  2763. luaL_checktype(L, 4, LUA_TSTRING);
  2764. String value = String(lua_tostring(L, 4));
  2765. inst->addParam(type, name, value);
  2766. return 0;
  2767. }
  2768. static int Polycore_FixedShaderBinding_getDiffuseTexture(lua_State *L) {
  2769. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  2770. FixedShaderBinding *inst = (FixedShaderBinding*)lua_topointer(L, 1);
  2771. void *ptrRetVal = (void*)inst->getDiffuseTexture();
  2772. if(ptrRetVal == NULL) {
  2773. lua_pushnil(L);
  2774. } else {
  2775. lua_pushlightuserdata(L, ptrRetVal);
  2776. }
  2777. return 1;
  2778. }
  2779. static int Polycore_delete_FixedShaderBinding(lua_State *L) {
  2780. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  2781. FixedShaderBinding *inst = (FixedShaderBinding*)lua_topointer(L, 1);
  2782. delete inst;
  2783. return 0;
  2784. }
  2785. static int Polycore_Font_get_loaded(lua_State *L) {
  2786. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  2787. Font *inst = (Font*)lua_topointer(L, 1);
  2788. lua_pushboolean(L, inst->loaded);
  2789. return 1;
  2790. }
  2791. static int Polycore_Font_set_loaded(lua_State *L) {
  2792. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  2793. Font *inst = (Font*)lua_topointer(L, 1);
  2794. bool param = lua_toboolean(L, 2);
  2795. inst->loaded = param;
  2796. return 0;
  2797. }
  2798. static int Polycore_Font(lua_State *L) {
  2799. luaL_checktype(L, 1, LUA_TSTRING);
  2800. String fileName = String(lua_tostring(L, 1));
  2801. Font *inst = new Font(fileName);
  2802. lua_pushlightuserdata(L, (void*)inst);
  2803. return 1;
  2804. }
  2805. static int Polycore_Font_getFace(lua_State *L) {
  2806. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  2807. Font *inst = (Font*)lua_topointer(L, 1);
  2808. FT_Face *retInst = new FT_Face();
  2809. *retInst = inst->getFace();
  2810. lua_pushlightuserdata(L, retInst);
  2811. return 1;
  2812. }
  2813. static int Polycore_Font_isValid(lua_State *L) {
  2814. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  2815. Font *inst = (Font*)lua_topointer(L, 1);
  2816. lua_pushboolean(L, inst->isValid());
  2817. return 1;
  2818. }
  2819. static int Polycore_delete_Font(lua_State *L) {
  2820. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  2821. Font *inst = (Font*)lua_topointer(L, 1);
  2822. delete inst;
  2823. return 0;
  2824. }
  2825. static int Polycore_FontManager(lua_State *L) {
  2826. FontManager *inst = new FontManager();
  2827. lua_pushlightuserdata(L, (void*)inst);
  2828. return 1;
  2829. }
  2830. static int Polycore_FontManager_registerFont(lua_State *L) {
  2831. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  2832. FontManager *inst = (FontManager*)lua_topointer(L, 1);
  2833. luaL_checktype(L, 2, LUA_TSTRING);
  2834. String fontName = String(lua_tostring(L, 2));
  2835. luaL_checktype(L, 3, LUA_TSTRING);
  2836. String fontPath = String(lua_tostring(L, 3));
  2837. inst->registerFont(fontName, fontPath);
  2838. return 0;
  2839. }
  2840. static int Polycore_FontManager_getFontByName(lua_State *L) {
  2841. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  2842. FontManager *inst = (FontManager*)lua_topointer(L, 1);
  2843. luaL_checktype(L, 2, LUA_TSTRING);
  2844. String fontName = String(lua_tostring(L, 2));
  2845. void *ptrRetVal = (void*)inst->getFontByName(fontName);
  2846. if(ptrRetVal == NULL) {
  2847. lua_pushnil(L);
  2848. } else {
  2849. lua_pushlightuserdata(L, ptrRetVal);
  2850. }
  2851. return 1;
  2852. }
  2853. static int Polycore_delete_FontManager(lua_State *L) {
  2854. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  2855. FontManager *inst = (FontManager*)lua_topointer(L, 1);
  2856. delete inst;
  2857. return 0;
  2858. }
  2859. static int Polycore_Image(lua_State *L) {
  2860. luaL_checktype(L, 1, LUA_TSTRING);
  2861. String fileName = String(lua_tostring(L, 1));
  2862. Image *inst = new Image(fileName);
  2863. lua_pushlightuserdata(L, (void*)inst);
  2864. return 1;
  2865. }
  2866. static int Polycore_Image_loadImage(lua_State *L) {
  2867. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  2868. Image *inst = (Image*)lua_topointer(L, 1);
  2869. luaL_checktype(L, 2, LUA_TSTRING);
  2870. String fileName = String(lua_tostring(L, 2));
  2871. lua_pushboolean(L, inst->loadImage(fileName));
  2872. return 1;
  2873. }
  2874. static int Polycore_Image_loadPNG(lua_State *L) {
  2875. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  2876. Image *inst = (Image*)lua_topointer(L, 1);
  2877. luaL_checktype(L, 2, LUA_TSTRING);
  2878. String fileName = String(lua_tostring(L, 2));
  2879. lua_pushboolean(L, inst->loadPNG(fileName));
  2880. return 1;
  2881. }
  2882. static int Polycore_Image_createEmpty(lua_State *L) {
  2883. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  2884. Image *inst = (Image*)lua_topointer(L, 1);
  2885. luaL_checktype(L, 2, LUA_TNUMBER);
  2886. unsigned int width = lua_tointeger(L, 2);
  2887. luaL_checktype(L, 3, LUA_TNUMBER);
  2888. unsigned int height = lua_tointeger(L, 3);
  2889. inst->createEmpty(width, height);
  2890. return 0;
  2891. }
  2892. static int Polycore_Image_fill(lua_State *L) {
  2893. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  2894. Image *inst = (Image*)lua_topointer(L, 1);
  2895. luaL_checktype(L, 2, LUA_TNUMBER);
  2896. Number r = lua_tonumber(L, 2);
  2897. luaL_checktype(L, 3, LUA_TNUMBER);
  2898. Number g = lua_tonumber(L, 3);
  2899. luaL_checktype(L, 4, LUA_TNUMBER);
  2900. Number b = lua_tonumber(L, 4);
  2901. luaL_checktype(L, 5, LUA_TNUMBER);
  2902. Number a = lua_tonumber(L, 5);
  2903. inst->fill(r, g, b, a);
  2904. return 0;
  2905. }
  2906. static int Polycore_Image_setPixel(lua_State *L) {
  2907. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  2908. Image *inst = (Image*)lua_topointer(L, 1);
  2909. luaL_checktype(L, 2, LUA_TNUMBER);
  2910. int x = lua_tointeger(L, 2);
  2911. luaL_checktype(L, 3, LUA_TNUMBER);
  2912. int y = lua_tointeger(L, 3);
  2913. luaL_checktype(L, 4, LUA_TNUMBER);
  2914. Number r = lua_tonumber(L, 4);
  2915. luaL_checktype(L, 5, LUA_TNUMBER);
  2916. Number g = lua_tonumber(L, 5);
  2917. luaL_checktype(L, 6, LUA_TNUMBER);
  2918. Number b = lua_tonumber(L, 6);
  2919. luaL_checktype(L, 7, LUA_TNUMBER);
  2920. Number a = lua_tonumber(L, 7);
  2921. inst->setPixel(x, y, r, g, b, a);
  2922. return 0;
  2923. }
  2924. static int Polycore_Image_getPixel(lua_State *L) {
  2925. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  2926. Image *inst = (Image*)lua_topointer(L, 1);
  2927. luaL_checktype(L, 2, LUA_TNUMBER);
  2928. int x = lua_tointeger(L, 2);
  2929. luaL_checktype(L, 3, LUA_TNUMBER);
  2930. int y = lua_tointeger(L, 3);
  2931. Color *retInst = new Color();
  2932. *retInst = inst->getPixel(x, y);
  2933. lua_pushlightuserdata(L, retInst);
  2934. return 1;
  2935. }
  2936. static int Polycore_Image_swap(lua_State *L) {
  2937. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  2938. Image *inst = (Image*)lua_topointer(L, 1);
  2939. luaL_checktype(L, 2, LUA_TLIGHTUSERDATA);
  2940. int* v1 = (int*)lua_topointer(L, 2);
  2941. luaL_checktype(L, 3, LUA_TLIGHTUSERDATA);
  2942. int* v2 = (int*)lua_topointer(L, 3);
  2943. inst->swap(v1, v2);
  2944. return 0;
  2945. }
  2946. static int Polycore_Image_line(lua_State *L) {
  2947. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  2948. Image *inst = (Image*)lua_topointer(L, 1);
  2949. luaL_checktype(L, 2, LUA_TNUMBER);
  2950. int x0 = lua_tointeger(L, 2);
  2951. luaL_checktype(L, 3, LUA_TNUMBER);
  2952. int y0 = lua_tointeger(L, 3);
  2953. luaL_checktype(L, 4, LUA_TNUMBER);
  2954. int x1 = lua_tointeger(L, 4);
  2955. luaL_checktype(L, 5, LUA_TNUMBER);
  2956. int y1 = lua_tointeger(L, 5);
  2957. luaL_checktype(L, 6, LUA_TLIGHTUSERDATA);
  2958. Color col = *(Color*)lua_topointer(L, 6);
  2959. inst->line(x0, y0, x1, y1, col);
  2960. return 0;
  2961. }
  2962. static int Polycore_Image_moveTo(lua_State *L) {
  2963. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  2964. Image *inst = (Image*)lua_topointer(L, 1);
  2965. luaL_checktype(L, 2, LUA_TNUMBER);
  2966. int x = lua_tointeger(L, 2);
  2967. luaL_checktype(L, 3, LUA_TNUMBER);
  2968. int y = lua_tointeger(L, 3);
  2969. inst->moveTo(x, y);
  2970. return 0;
  2971. }
  2972. static int Polycore_Image_move(lua_State *L) {
  2973. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  2974. Image *inst = (Image*)lua_topointer(L, 1);
  2975. luaL_checktype(L, 2, LUA_TNUMBER);
  2976. int x = lua_tointeger(L, 2);
  2977. luaL_checktype(L, 3, LUA_TNUMBER);
  2978. int y = lua_tointeger(L, 3);
  2979. inst->move(x, y);
  2980. return 0;
  2981. }
  2982. static int Polycore_Image_lineTo(lua_State *L) {
  2983. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  2984. Image *inst = (Image*)lua_topointer(L, 1);
  2985. luaL_checktype(L, 2, LUA_TNUMBER);
  2986. int x = lua_tointeger(L, 2);
  2987. luaL_checktype(L, 3, LUA_TNUMBER);
  2988. int y = lua_tointeger(L, 3);
  2989. luaL_checktype(L, 4, LUA_TLIGHTUSERDATA);
  2990. Color col = *(Color*)lua_topointer(L, 4);
  2991. inst->lineTo(x, y, col);
  2992. return 0;
  2993. }
  2994. static int Polycore_Image_drawRect(lua_State *L) {
  2995. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  2996. Image *inst = (Image*)lua_topointer(L, 1);
  2997. luaL_checktype(L, 2, LUA_TNUMBER);
  2998. int x = lua_tointeger(L, 2);
  2999. luaL_checktype(L, 3, LUA_TNUMBER);
  3000. int y = lua_tointeger(L, 3);
  3001. luaL_checktype(L, 4, LUA_TNUMBER);
  3002. int w = lua_tointeger(L, 4);
  3003. luaL_checktype(L, 5, LUA_TNUMBER);
  3004. int h = lua_tointeger(L, 5);
  3005. luaL_checktype(L, 6, LUA_TLIGHTUSERDATA);
  3006. Color col = *(Color*)lua_topointer(L, 6);
  3007. inst->drawRect(x, y, w, h, col);
  3008. return 0;
  3009. }
  3010. static int Polycore_Image_perlinNoise(lua_State *L) {
  3011. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  3012. Image *inst = (Image*)lua_topointer(L, 1);
  3013. luaL_checktype(L, 2, LUA_TNUMBER);
  3014. int seed = lua_tointeger(L, 2);
  3015. luaL_checktype(L, 3, LUA_TBOOLEAN);
  3016. bool alpha = lua_toboolean(L, 3);
  3017. inst->perlinNoise(seed, alpha);
  3018. return 0;
  3019. }
  3020. static int Polycore_Image_fastBlur(lua_State *L) {
  3021. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  3022. Image *inst = (Image*)lua_topointer(L, 1);
  3023. luaL_checktype(L, 2, LUA_TNUMBER);
  3024. int blurSize = lua_tointeger(L, 2);
  3025. inst->fastBlur(blurSize);
  3026. return 0;
  3027. }
  3028. static int Polycore_Image_fastBlurVert(lua_State *L) {
  3029. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  3030. Image *inst = (Image*)lua_topointer(L, 1);
  3031. luaL_checktype(L, 2, LUA_TNUMBER);
  3032. int blurSize = lua_tointeger(L, 2);
  3033. inst->fastBlurVert(blurSize);
  3034. return 0;
  3035. }
  3036. static int Polycore_Image_fastBlurHor(lua_State *L) {
  3037. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  3038. Image *inst = (Image*)lua_topointer(L, 1);
  3039. luaL_checktype(L, 2, LUA_TNUMBER);
  3040. int blurSize = lua_tointeger(L, 2);
  3041. inst->fastBlurHor(blurSize);
  3042. return 0;
  3043. }
  3044. static int Polycore_Image_darken(lua_State *L) {
  3045. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  3046. Image *inst = (Image*)lua_topointer(L, 1);
  3047. luaL_checktype(L, 2, LUA_TNUMBER);
  3048. Number amt = lua_tonumber(L, 2);
  3049. luaL_checktype(L, 3, LUA_TBOOLEAN);
  3050. bool color = lua_toboolean(L, 3);
  3051. luaL_checktype(L, 4, LUA_TBOOLEAN);
  3052. bool alpha = lua_toboolean(L, 4);
  3053. inst->darken(amt, color, alpha);
  3054. return 0;
  3055. }
  3056. static int Polycore_Image_lighten(lua_State *L) {
  3057. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  3058. Image *inst = (Image*)lua_topointer(L, 1);
  3059. luaL_checktype(L, 2, LUA_TNUMBER);
  3060. Number amt = lua_tonumber(L, 2);
  3061. luaL_checktype(L, 3, LUA_TBOOLEAN);
  3062. bool color = lua_toboolean(L, 3);
  3063. luaL_checktype(L, 4, LUA_TBOOLEAN);
  3064. bool alpha = lua_toboolean(L, 4);
  3065. inst->lighten(amt, color, alpha);
  3066. return 0;
  3067. }
  3068. static int Polycore_Image_multiply(lua_State *L) {
  3069. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  3070. Image *inst = (Image*)lua_topointer(L, 1);
  3071. luaL_checktype(L, 2, LUA_TNUMBER);
  3072. Number amt = lua_tonumber(L, 2);
  3073. luaL_checktype(L, 3, LUA_TBOOLEAN);
  3074. bool color = lua_toboolean(L, 3);
  3075. luaL_checktype(L, 4, LUA_TBOOLEAN);
  3076. bool alpha = lua_toboolean(L, 4);
  3077. inst->multiply(amt, color, alpha);
  3078. return 0;
  3079. }
  3080. static int Polycore_Image_getBrushX(lua_State *L) {
  3081. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  3082. Image *inst = (Image*)lua_topointer(L, 1);
  3083. lua_pushinteger(L, inst->getBrushX());
  3084. return 1;
  3085. }
  3086. static int Polycore_Image_getBrushY(lua_State *L) {
  3087. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  3088. Image *inst = (Image*)lua_topointer(L, 1);
  3089. lua_pushinteger(L, inst->getBrushY());
  3090. return 1;
  3091. }
  3092. static int Polycore_Image_isLoaded(lua_State *L) {
  3093. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  3094. Image *inst = (Image*)lua_topointer(L, 1);
  3095. lua_pushboolean(L, inst->isLoaded());
  3096. return 1;
  3097. }
  3098. static int Polycore_Image_getType(lua_State *L) {
  3099. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  3100. Image *inst = (Image*)lua_topointer(L, 1);
  3101. lua_pushinteger(L, inst->getType());
  3102. return 1;
  3103. }
  3104. static int Polycore_Image_writeBMP(lua_State *L) {
  3105. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  3106. Image *inst = (Image*)lua_topointer(L, 1);
  3107. luaL_checktype(L, 2, LUA_TSTRING);
  3108. String fileName = String(lua_tostring(L, 2));
  3109. inst->writeBMP(fileName);
  3110. return 0;
  3111. }
  3112. static int Polycore_Image_getWidth(lua_State *L) {
  3113. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  3114. Image *inst = (Image*)lua_topointer(L, 1);
  3115. lua_pushinteger(L, inst->getWidth());
  3116. return 1;
  3117. }
  3118. static int Polycore_Image_getHeight(lua_State *L) {
  3119. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  3120. Image *inst = (Image*)lua_topointer(L, 1);
  3121. lua_pushinteger(L, inst->getHeight());
  3122. return 1;
  3123. }
  3124. static int Polycore_Image_getPixels(lua_State *L) {
  3125. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  3126. Image *inst = (Image*)lua_topointer(L, 1);
  3127. void *ptrRetVal = (void*)inst->getPixels();
  3128. if(ptrRetVal == NULL) {
  3129. lua_pushnil(L);
  3130. } else {
  3131. lua_pushlightuserdata(L, ptrRetVal);
  3132. }
  3133. return 1;
  3134. }
  3135. static int Polycore_delete_Image(lua_State *L) {
  3136. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  3137. Image *inst = (Image*)lua_topointer(L, 1);
  3138. delete inst;
  3139. return 0;
  3140. }
  3141. static int Polycore_InputEvent_get_mouseButton(lua_State *L) {
  3142. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  3143. InputEvent *inst = (InputEvent*)lua_topointer(L, 1);
  3144. lua_pushinteger(L, inst->mouseButton);
  3145. return 1;
  3146. }
  3147. static int Polycore_InputEvent_get_mousePosition(lua_State *L) {
  3148. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  3149. InputEvent *inst = (InputEvent*)lua_topointer(L, 1);
  3150. lua_pushlightuserdata(L, &inst->mousePosition);
  3151. return 1;
  3152. }
  3153. static int Polycore_InputEvent_get_key(lua_State *L) {
  3154. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  3155. InputEvent *inst = (InputEvent*)lua_topointer(L, 1);
  3156. lua_pushlightuserdata(L, &inst->key);
  3157. return 1;
  3158. }
  3159. static int Polycore_InputEvent_get_charCode(lua_State *L) {
  3160. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  3161. InputEvent *inst = (InputEvent*)lua_topointer(L, 1);
  3162. lua_pushlightuserdata(L, &inst->charCode);
  3163. return 1;
  3164. }
  3165. static int Polycore_InputEvent_get_timestamp(lua_State *L) {
  3166. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  3167. InputEvent *inst = (InputEvent*)lua_topointer(L, 1);
  3168. lua_pushinteger(L, inst->timestamp);
  3169. return 1;
  3170. }
  3171. static int Polycore_InputEvent_get_joystickDeviceID(lua_State *L) {
  3172. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  3173. InputEvent *inst = (InputEvent*)lua_topointer(L, 1);
  3174. lua_pushlightuserdata(L, &inst->joystickDeviceID);
  3175. return 1;
  3176. }
  3177. static int Polycore_InputEvent_get_joystickAxisValue(lua_State *L) {
  3178. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  3179. InputEvent *inst = (InputEvent*)lua_topointer(L, 1);
  3180. lua_pushlightuserdata(L, &inst->joystickAxisValue);
  3181. return 1;
  3182. }
  3183. static int Polycore_InputEvent_get_joystickButton(lua_State *L) {
  3184. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  3185. InputEvent *inst = (InputEvent*)lua_topointer(L, 1);
  3186. lua_pushlightuserdata(L, &inst->joystickButton);
  3187. return 1;
  3188. }
  3189. static int Polycore_InputEvent_get_joystickAxis(lua_State *L) {
  3190. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  3191. InputEvent *inst = (InputEvent*)lua_topointer(L, 1);
  3192. lua_pushlightuserdata(L, &inst->joystickAxis);
  3193. return 1;
  3194. }
  3195. static int Polycore_InputEvent_set_mouseButton(lua_State *L) {
  3196. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  3197. InputEvent *inst = (InputEvent*)lua_topointer(L, 1);
  3198. int param = lua_tointeger(L, 2);
  3199. inst->mouseButton = param;
  3200. return 0;
  3201. }
  3202. static int Polycore_InputEvent_set_timestamp(lua_State *L) {
  3203. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  3204. InputEvent *inst = (InputEvent*)lua_topointer(L, 1);
  3205. int param = lua_tointeger(L, 2);
  3206. inst->timestamp = param;
  3207. return 0;
  3208. }
  3209. static int Polycore_InputEvent(lua_State *L) {
  3210. InputEvent *inst = new InputEvent();
  3211. lua_pushlightuserdata(L, (void*)inst);
  3212. return 1;
  3213. }
  3214. static int Polycore_InputEvent_getMousePosition(lua_State *L) {
  3215. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  3216. InputEvent *inst = (InputEvent*)lua_topointer(L, 1);
  3217. Vector2 *retInst = new Vector2();
  3218. *retInst = inst->getMousePosition();
  3219. lua_pushlightuserdata(L, retInst);
  3220. return 1;
  3221. }
  3222. static int Polycore_InputEvent_getKey(lua_State *L) {
  3223. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  3224. InputEvent *inst = (InputEvent*)lua_topointer(L, 1);
  3225. PolyKEY *retInst = new PolyKEY();
  3226. *retInst = inst->getKey();
  3227. lua_pushlightuserdata(L, retInst);
  3228. return 1;
  3229. }
  3230. static int Polycore_InputEvent_getMouseButton(lua_State *L) {
  3231. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  3232. InputEvent *inst = (InputEvent*)lua_topointer(L, 1);
  3233. lua_pushinteger(L, inst->getMouseButton());
  3234. return 1;
  3235. }
  3236. static int Polycore_InputEvent_keyCode(lua_State *L) {
  3237. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  3238. InputEvent *inst = (InputEvent*)lua_topointer(L, 1);
  3239. lua_pushinteger(L, inst->keyCode());
  3240. return 1;
  3241. }
  3242. static int Polycore_delete_InputEvent(lua_State *L) {
  3243. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  3244. InputEvent *inst = (InputEvent*)lua_topointer(L, 1);
  3245. delete inst;
  3246. return 0;
  3247. }
  3248. static int Polycore_Label(lua_State *L) {
  3249. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  3250. Font* font = (Font*)lua_topointer(L, 1);
  3251. luaL_checktype(L, 2, LUA_TSTRING);
  3252. String text = String(lua_tostring(L, 2));
  3253. luaL_checktype(L, 3, LUA_TNUMBER);
  3254. int size = lua_tointeger(L, 3);
  3255. luaL_checktype(L, 4, LUA_TNUMBER);
  3256. int antiAliasMode = lua_tointeger(L, 4);
  3257. Label *inst = new Label(font, text, size, antiAliasMode);
  3258. lua_pushlightuserdata(L, (void*)inst);
  3259. return 1;
  3260. }
  3261. static int Polycore_Label_setText(lua_State *L) {
  3262. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  3263. Label *inst = (Label*)lua_topointer(L, 1);
  3264. luaL_checktype(L, 2, LUA_TSTRING);
  3265. String text = String(lua_tostring(L, 2));
  3266. inst->setText(text);
  3267. return 0;
  3268. }
  3269. static int Polycore_Label_getText(lua_State *L) {
  3270. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  3271. Label *inst = (Label*)lua_topointer(L, 1);
  3272. String *retInst = new String ();
  3273. *retInst = inst->getText();
  3274. lua_pushlightuserdata(L, retInst);
  3275. return 1;
  3276. }
  3277. static int Polycore_Label_getTextWidth(lua_State *L) {
  3278. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  3279. Label *inst = (Label*)lua_topointer(L, 1);
  3280. luaL_checktype(L, 2, LUA_TLIGHTUSERDATA);
  3281. Font* font = (Font*)lua_topointer(L, 2);
  3282. luaL_checktype(L, 3, LUA_TSTRING);
  3283. String text = String(lua_tostring(L, 3));
  3284. luaL_checktype(L, 4, LUA_TNUMBER);
  3285. int size = lua_tointeger(L, 4);
  3286. lua_pushinteger(L, inst->getTextWidth(font, text, size));
  3287. return 1;
  3288. }
  3289. static int Polycore_Label_getTextHeight(lua_State *L) {
  3290. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  3291. Label *inst = (Label*)lua_topointer(L, 1);
  3292. luaL_checktype(L, 2, LUA_TLIGHTUSERDATA);
  3293. Font* font = (Font*)lua_topointer(L, 2);
  3294. luaL_checktype(L, 3, LUA_TSTRING);
  3295. String text = String(lua_tostring(L, 3));
  3296. luaL_checktype(L, 4, LUA_TNUMBER);
  3297. int size = lua_tointeger(L, 4);
  3298. lua_pushinteger(L, inst->getTextHeight(font, text, size));
  3299. return 1;
  3300. }
  3301. static int Polycore_Label_getFont(lua_State *L) {
  3302. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  3303. Label *inst = (Label*)lua_topointer(L, 1);
  3304. void *ptrRetVal = (void*)inst->getFont();
  3305. if(ptrRetVal == NULL) {
  3306. lua_pushnil(L);
  3307. } else {
  3308. lua_pushlightuserdata(L, ptrRetVal);
  3309. }
  3310. return 1;
  3311. }
  3312. static int Polycore_delete_Label(lua_State *L) {
  3313. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  3314. Label *inst = (Label*)lua_topointer(L, 1);
  3315. delete inst;
  3316. return 0;
  3317. }
  3318. static int Polycore_Logger(lua_State *L) {
  3319. Logger *inst = new Logger();
  3320. lua_pushlightuserdata(L, (void*)inst);
  3321. return 1;
  3322. }
  3323. static int Polycore_Logger_log(lua_State *L) {
  3324. luaL_checktype(L, 2, LUA_TLIGHTUSERDATA);
  3325. char* format = (char*)lua_topointer(L, 2);
  3326. Logger::log(format);
  3327. return 0;
  3328. }
  3329. static int Polycore_Logger_logw(lua_State *L) {
  3330. luaL_checktype(L, 2, LUA_TLIGHTUSERDATA);
  3331. char* str = (char*)lua_topointer(L, 2);
  3332. Logger::logw(str);
  3333. return 0;
  3334. }
  3335. static int Polycore_delete_Logger(lua_State *L) {
  3336. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  3337. Logger *inst = (Logger*)lua_topointer(L, 1);
  3338. delete inst;
  3339. return 0;
  3340. }
  3341. static int Polycore_Material_get_specularValue(lua_State *L) {
  3342. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  3343. Material *inst = (Material*)lua_topointer(L, 1);
  3344. lua_pushnumber(L, inst->specularValue);
  3345. return 1;
  3346. }
  3347. static int Polycore_Material_get_specularStrength(lua_State *L) {
  3348. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  3349. Material *inst = (Material*)lua_topointer(L, 1);
  3350. lua_pushnumber(L, inst->specularStrength);
  3351. return 1;
  3352. }
  3353. static int Polycore_Material_get_specularColor(lua_State *L) {
  3354. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  3355. Material *inst = (Material*)lua_topointer(L, 1);
  3356. lua_pushlightuserdata(L, &inst->specularColor);
  3357. return 1;
  3358. }
  3359. static int Polycore_Material_get_diffuseColor(lua_State *L) {
  3360. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  3361. Material *inst = (Material*)lua_topointer(L, 1);
  3362. lua_pushlightuserdata(L, &inst->diffuseColor);
  3363. return 1;
  3364. }
  3365. static int Polycore_Material_set_specularValue(lua_State *L) {
  3366. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  3367. Material *inst = (Material*)lua_topointer(L, 1);
  3368. Number param = lua_tonumber(L, 2);
  3369. inst->specularValue = param;
  3370. return 0;
  3371. }
  3372. static int Polycore_Material_set_specularStrength(lua_State *L) {
  3373. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  3374. Material *inst = (Material*)lua_topointer(L, 1);
  3375. Number param = lua_tonumber(L, 2);
  3376. inst->specularStrength = param;
  3377. return 0;
  3378. }
  3379. static int Polycore_Material(lua_State *L) {
  3380. luaL_checktype(L, 1, LUA_TSTRING);
  3381. String name = String(lua_tostring(L, 1));
  3382. Material *inst = new Material(name);
  3383. lua_pushlightuserdata(L, (void*)inst);
  3384. return 1;
  3385. }
  3386. static int Polycore_Material_addShader(lua_State *L) {
  3387. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  3388. Material *inst = (Material*)lua_topointer(L, 1);
  3389. luaL_checktype(L, 2, LUA_TLIGHTUSERDATA);
  3390. Shader* shader = (Shader*)lua_topointer(L, 2);
  3391. luaL_checktype(L, 3, LUA_TLIGHTUSERDATA);
  3392. ShaderBinding* shaderBinding = (ShaderBinding*)lua_topointer(L, 3);
  3393. inst->addShader(shader, shaderBinding);
  3394. return 0;
  3395. }
  3396. static int Polycore_Material_getNumShaders(lua_State *L) {
  3397. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  3398. Material *inst = (Material*)lua_topointer(L, 1);
  3399. lua_pushinteger(L, inst->getNumShaders());
  3400. return 1;
  3401. }
  3402. static int Polycore_Material_addShaderRenderTarget(lua_State *L) {
  3403. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  3404. Material *inst = (Material*)lua_topointer(L, 1);
  3405. luaL_checktype(L, 2, LUA_TLIGHTUSERDATA);
  3406. ShaderRenderTarget* newTarget = (ShaderRenderTarget*)lua_topointer(L, 2);
  3407. inst->addShaderRenderTarget(newTarget);
  3408. return 0;
  3409. }
  3410. static int Polycore_Material_getNumShaderRenderTargets(lua_State *L) {
  3411. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  3412. Material *inst = (Material*)lua_topointer(L, 1);
  3413. lua_pushinteger(L, inst->getNumShaderRenderTargets());
  3414. return 1;
  3415. }
  3416. static int Polycore_Material_getShaderRenderTarget(lua_State *L) {
  3417. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  3418. Material *inst = (Material*)lua_topointer(L, 1);
  3419. luaL_checktype(L, 2, LUA_TNUMBER);
  3420. unsigned int index = lua_tointeger(L, 2);
  3421. void *ptrRetVal = (void*)inst->getShaderRenderTarget(index);
  3422. if(ptrRetVal == NULL) {
  3423. lua_pushnil(L);
  3424. } else {
  3425. lua_pushlightuserdata(L, ptrRetVal);
  3426. }
  3427. return 1;
  3428. }
  3429. static int Polycore_Material_getName(lua_State *L) {
  3430. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  3431. Material *inst = (Material*)lua_topointer(L, 1);
  3432. String *retInst = new String ();
  3433. *retInst = inst->getName();
  3434. lua_pushlightuserdata(L, retInst);
  3435. return 1;
  3436. }
  3437. static int Polycore_Material_getShader(lua_State *L) {
  3438. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  3439. Material *inst = (Material*)lua_topointer(L, 1);
  3440. luaL_checktype(L, 2, LUA_TNUMBER);
  3441. unsigned int index = lua_tointeger(L, 2);
  3442. void *ptrRetVal = (void*)inst->getShader(index);
  3443. if(ptrRetVal == NULL) {
  3444. lua_pushnil(L);
  3445. } else {
  3446. lua_pushlightuserdata(L, ptrRetVal);
  3447. }
  3448. return 1;
  3449. }
  3450. static int Polycore_Material_getShaderBinding(lua_State *L) {
  3451. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  3452. Material *inst = (Material*)lua_topointer(L, 1);
  3453. luaL_checktype(L, 2, LUA_TNUMBER);
  3454. unsigned int index = lua_tointeger(L, 2);
  3455. void *ptrRetVal = (void*)inst->getShaderBinding(index);
  3456. if(ptrRetVal == NULL) {
  3457. lua_pushnil(L);
  3458. } else {
  3459. lua_pushlightuserdata(L, ptrRetVal);
  3460. }
  3461. return 1;
  3462. }
  3463. static int Polycore_Material_loadMaterial(lua_State *L) {
  3464. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  3465. Material *inst = (Material*)lua_topointer(L, 1);
  3466. luaL_checktype(L, 2, LUA_TSTRING);
  3467. String fileName = String(lua_tostring(L, 2));
  3468. inst->loadMaterial(fileName);
  3469. return 0;
  3470. }
  3471. static int Polycore_delete_Material(lua_State *L) {
  3472. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  3473. Material *inst = (Material*)lua_topointer(L, 1);
  3474. delete inst;
  3475. return 0;
  3476. }
  3477. static int Polycore_MaterialManager(lua_State *L) {
  3478. MaterialManager *inst = new MaterialManager();
  3479. lua_pushlightuserdata(L, (void*)inst);
  3480. return 1;
  3481. }
  3482. static int Polycore_MaterialManager_Update(lua_State *L) {
  3483. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  3484. MaterialManager *inst = (MaterialManager*)lua_topointer(L, 1);
  3485. luaL_checktype(L, 2, LUA_TNUMBER);
  3486. int elapsed = lua_tointeger(L, 2);
  3487. inst->Update(elapsed);
  3488. return 0;
  3489. }
  3490. static int Polycore_MaterialManager_createFramebufferTexture(lua_State *L) {
  3491. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  3492. MaterialManager *inst = (MaterialManager*)lua_topointer(L, 1);
  3493. luaL_checktype(L, 2, LUA_TNUMBER);
  3494. int width = lua_tointeger(L, 2);
  3495. luaL_checktype(L, 3, LUA_TNUMBER);
  3496. int height = lua_tointeger(L, 3);
  3497. luaL_checktype(L, 4, LUA_TNUMBER);
  3498. int type = lua_tointeger(L, 4);
  3499. void *ptrRetVal = (void*)inst->createFramebufferTexture(width, height, type);
  3500. if(ptrRetVal == NULL) {
  3501. lua_pushnil(L);
  3502. } else {
  3503. lua_pushlightuserdata(L, ptrRetVal);
  3504. }
  3505. return 1;
  3506. }
  3507. static int Polycore_MaterialManager_createTexture(lua_State *L) {
  3508. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  3509. MaterialManager *inst = (MaterialManager*)lua_topointer(L, 1);
  3510. luaL_checktype(L, 2, LUA_TNUMBER);
  3511. int width = lua_tointeger(L, 2);
  3512. luaL_checktype(L, 3, LUA_TNUMBER);
  3513. int height = lua_tointeger(L, 3);
  3514. luaL_checktype(L, 4, LUA_TLIGHTUSERDATA);
  3515. char* imageData = (char*)lua_topointer(L, 4);
  3516. bool clamp;
  3517. if(lua_isboolean(L, 5)) {
  3518. clamp = lua_toboolean(L, 5);
  3519. } else {
  3520. clamp = true;
  3521. }
  3522. int type;
  3523. if(lua_isnumber(L, 6)) {
  3524. type = lua_tointeger(L, 6);
  3525. } else {
  3526. type = Image :: IMAGE_RGBA;
  3527. }
  3528. void *ptrRetVal = (void*)inst->createTexture(width, height, imageData, clamp, type);
  3529. if(ptrRetVal == NULL) {
  3530. lua_pushnil(L);
  3531. } else {
  3532. lua_pushlightuserdata(L, ptrRetVal);
  3533. }
  3534. return 1;
  3535. }
  3536. static int Polycore_MaterialManager_createNewTexture(lua_State *L) {
  3537. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  3538. MaterialManager *inst = (MaterialManager*)lua_topointer(L, 1);
  3539. luaL_checktype(L, 2, LUA_TNUMBER);
  3540. int width = lua_tointeger(L, 2);
  3541. luaL_checktype(L, 3, LUA_TNUMBER);
  3542. int height = lua_tointeger(L, 3);
  3543. bool clamp;
  3544. if(lua_isboolean(L, 4)) {
  3545. clamp = lua_toboolean(L, 4);
  3546. } else {
  3547. clamp = true;
  3548. }
  3549. int type;
  3550. if(lua_isnumber(L, 5)) {
  3551. type = lua_tointeger(L, 5);
  3552. } else {
  3553. type = Image :: IMAGE_RGBA;
  3554. }
  3555. void *ptrRetVal = (void*)inst->createNewTexture(width, height, clamp, type);
  3556. if(ptrRetVal == NULL) {
  3557. lua_pushnil(L);
  3558. } else {
  3559. lua_pushlightuserdata(L, ptrRetVal);
  3560. }
  3561. return 1;
  3562. }
  3563. static int Polycore_MaterialManager_createTextureFromImage(lua_State *L) {
  3564. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  3565. MaterialManager *inst = (MaterialManager*)lua_topointer(L, 1);
  3566. luaL_checktype(L, 2, LUA_TLIGHTUSERDATA);
  3567. Image* image = (Image*)lua_topointer(L, 2);
  3568. bool clamp;
  3569. if(lua_isboolean(L, 3)) {
  3570. clamp = lua_toboolean(L, 3);
  3571. } else {
  3572. clamp = true;
  3573. }
  3574. void *ptrRetVal = (void*)inst->createTextureFromImage(image, clamp);
  3575. if(ptrRetVal == NULL) {
  3576. lua_pushnil(L);
  3577. } else {
  3578. lua_pushlightuserdata(L, ptrRetVal);
  3579. }
  3580. return 1;
  3581. }
  3582. static int Polycore_MaterialManager_createTextureFromFile(lua_State *L) {
  3583. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  3584. MaterialManager *inst = (MaterialManager*)lua_topointer(L, 1);
  3585. luaL_checktype(L, 2, LUA_TSTRING);
  3586. String fileName = String(lua_tostring(L, 2));
  3587. bool clamp;
  3588. if(lua_isboolean(L, 3)) {
  3589. clamp = lua_toboolean(L, 3);
  3590. } else {
  3591. clamp = true;
  3592. }
  3593. void *ptrRetVal = (void*)inst->createTextureFromFile(fileName, clamp);
  3594. if(ptrRetVal == NULL) {
  3595. lua_pushnil(L);
  3596. } else {
  3597. lua_pushlightuserdata(L, ptrRetVal);
  3598. }
  3599. return 1;
  3600. }
  3601. static int Polycore_MaterialManager_deleteTexture(lua_State *L) {
  3602. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  3603. MaterialManager *inst = (MaterialManager*)lua_topointer(L, 1);
  3604. luaL_checktype(L, 2, LUA_TLIGHTUSERDATA);
  3605. Texture* texture = (Texture*)lua_topointer(L, 2);
  3606. inst->deleteTexture(texture);
  3607. return 0;
  3608. }
  3609. static int Polycore_MaterialManager_reloadTextures(lua_State *L) {
  3610. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  3611. MaterialManager *inst = (MaterialManager*)lua_topointer(L, 1);
  3612. inst->reloadTextures();
  3613. return 0;
  3614. }
  3615. static int Polycore_MaterialManager_reloadProgramsAndTextures(lua_State *L) {
  3616. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  3617. MaterialManager *inst = (MaterialManager*)lua_topointer(L, 1);
  3618. inst->reloadProgramsAndTextures();
  3619. return 0;
  3620. }
  3621. static int Polycore_MaterialManager_reloadPrograms(lua_State *L) {
  3622. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  3623. MaterialManager *inst = (MaterialManager*)lua_topointer(L, 1);
  3624. inst->reloadPrograms();
  3625. return 0;
  3626. }
  3627. static int Polycore_MaterialManager_addShaderModule(lua_State *L) {
  3628. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  3629. MaterialManager *inst = (MaterialManager*)lua_topointer(L, 1);
  3630. luaL_checktype(L, 2, LUA_TLIGHTUSERDATA);
  3631. PolycodeShaderModule* module = (PolycodeShaderModule*)lua_topointer(L, 2);
  3632. inst->addShaderModule(module);
  3633. return 0;
  3634. }
  3635. static int Polycore_MaterialManager_getTextureByResourcePath(lua_State *L) {
  3636. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  3637. MaterialManager *inst = (MaterialManager*)lua_topointer(L, 1);
  3638. luaL_checktype(L, 2, LUA_TSTRING);
  3639. String resourcePath = String(lua_tostring(L, 2));
  3640. void *ptrRetVal = (void*)inst->getTextureByResourcePath(resourcePath);
  3641. if(ptrRetVal == NULL) {
  3642. lua_pushnil(L);
  3643. } else {
  3644. lua_pushlightuserdata(L, ptrRetVal);
  3645. }
  3646. return 1;
  3647. }
  3648. static int Polycore_MaterialManager_cubemapFromXMLNode(lua_State *L) {
  3649. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  3650. MaterialManager *inst = (MaterialManager*)lua_topointer(L, 1);
  3651. luaL_checktype(L, 2, LUA_TLIGHTUSERDATA);
  3652. TiXmlNode* node = (TiXmlNode*)lua_topointer(L, 2);
  3653. void *ptrRetVal = (void*)inst->cubemapFromXMLNode(node);
  3654. if(ptrRetVal == NULL) {
  3655. lua_pushnil(L);
  3656. } else {
  3657. lua_pushlightuserdata(L, ptrRetVal);
  3658. }
  3659. return 1;
  3660. }
  3661. static int Polycore_MaterialManager_loadMaterialsFromFile(lua_State *L) {
  3662. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  3663. MaterialManager *inst = (MaterialManager*)lua_topointer(L, 1);
  3664. luaL_checktype(L, 2, LUA_TSTRING);
  3665. String fileName = String(lua_tostring(L, 2));
  3666. inst->loadMaterialsFromFile(fileName);
  3667. return 0;
  3668. }
  3669. static int Polycore_MaterialManager_materialFromXMLNode(lua_State *L) {
  3670. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  3671. MaterialManager *inst = (MaterialManager*)lua_topointer(L, 1);
  3672. luaL_checktype(L, 2, LUA_TLIGHTUSERDATA);
  3673. TiXmlNode* node = (TiXmlNode*)lua_topointer(L, 2);
  3674. void *ptrRetVal = (void*)inst->materialFromXMLNode(node);
  3675. if(ptrRetVal == NULL) {
  3676. lua_pushnil(L);
  3677. } else {
  3678. lua_pushlightuserdata(L, ptrRetVal);
  3679. }
  3680. return 1;
  3681. }
  3682. static int Polycore_MaterialManager_setShaderFromXMLNode(lua_State *L) {
  3683. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  3684. MaterialManager *inst = (MaterialManager*)lua_topointer(L, 1);
  3685. luaL_checktype(L, 2, LUA_TLIGHTUSERDATA);
  3686. TiXmlNode* node = (TiXmlNode*)lua_topointer(L, 2);
  3687. void *ptrRetVal = (void*)inst->setShaderFromXMLNode(node);
  3688. if(ptrRetVal == NULL) {
  3689. lua_pushnil(L);
  3690. } else {
  3691. lua_pushlightuserdata(L, ptrRetVal);
  3692. }
  3693. return 1;
  3694. }
  3695. static int Polycore_MaterialManager_createShaderFromXMLNode(lua_State *L) {
  3696. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  3697. MaterialManager *inst = (MaterialManager*)lua_topointer(L, 1);
  3698. luaL_checktype(L, 2, LUA_TLIGHTUSERDATA);
  3699. TiXmlNode* node = (TiXmlNode*)lua_topointer(L, 2);
  3700. void *ptrRetVal = (void*)inst->createShaderFromXMLNode(node);
  3701. if(ptrRetVal == NULL) {
  3702. lua_pushnil(L);
  3703. } else {
  3704. lua_pushlightuserdata(L, ptrRetVal);
  3705. }
  3706. return 1;
  3707. }
  3708. static int Polycore_delete_MaterialManager(lua_State *L) {
  3709. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  3710. MaterialManager *inst = (MaterialManager*)lua_topointer(L, 1);
  3711. delete inst;
  3712. return 0;
  3713. }
  3714. static int Polycore_Matrix4(lua_State *L) {
  3715. Matrix4 *inst = new Matrix4();
  3716. lua_pushlightuserdata(L, (void*)inst);
  3717. return 1;
  3718. }
  3719. static int Polycore_Matrix4_identity(lua_State *L) {
  3720. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  3721. Matrix4 *inst = (Matrix4*)lua_topointer(L, 1);
  3722. inst->identity();
  3723. return 0;
  3724. }
  3725. static int Polycore_Matrix4_rotateVector(lua_State *L) {
  3726. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  3727. Matrix4 *inst = (Matrix4*)lua_topointer(L, 1);
  3728. luaL_checktype(L, 2, LUA_TLIGHTUSERDATA);
  3729. Vector3 v2 = *(Vector3*)lua_topointer(L, 2);
  3730. Vector3 *retInst = new Vector3();
  3731. *retInst = inst->rotateVector(v2);
  3732. lua_pushlightuserdata(L, retInst);
  3733. return 1;
  3734. }
  3735. static int Polycore_Matrix4_getPosition(lua_State *L) {
  3736. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  3737. Matrix4 *inst = (Matrix4*)lua_topointer(L, 1);
  3738. Vector3 *retInst = new Vector3();
  3739. *retInst = inst->getPosition();
  3740. lua_pushlightuserdata(L, retInst);
  3741. return 1;
  3742. }
  3743. static int Polycore_Matrix4_setPosition(lua_State *L) {
  3744. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  3745. Matrix4 *inst = (Matrix4*)lua_topointer(L, 1);
  3746. luaL_checktype(L, 2, LUA_TNUMBER);
  3747. Number x = lua_tonumber(L, 2);
  3748. luaL_checktype(L, 3, LUA_TNUMBER);
  3749. Number y = lua_tonumber(L, 3);
  3750. luaL_checktype(L, 4, LUA_TNUMBER);
  3751. Number z = lua_tonumber(L, 4);
  3752. inst->setPosition(x, y, z);
  3753. return 0;
  3754. }
  3755. static int Polycore_Matrix4_setScale(lua_State *L) {
  3756. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  3757. Matrix4 *inst = (Matrix4*)lua_topointer(L, 1);
  3758. luaL_checktype(L, 2, LUA_TLIGHTUSERDATA);
  3759. Vector3 scale = *(Vector3*)lua_topointer(L, 2);
  3760. inst->setScale(scale);
  3761. return 0;
  3762. }
  3763. static int Polycore_Matrix4_getEulerAngles(lua_State *L) {
  3764. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  3765. Matrix4 *inst = (Matrix4*)lua_topointer(L, 1);
  3766. luaL_checktype(L, 2, LUA_TLIGHTUSERDATA);
  3767. Number* ax = (Number*)lua_topointer(L, 2);
  3768. luaL_checktype(L, 3, LUA_TLIGHTUSERDATA);
  3769. Number* ay = (Number*)lua_topointer(L, 3);
  3770. luaL_checktype(L, 4, LUA_TLIGHTUSERDATA);
  3771. Number* az = (Number*)lua_topointer(L, 4);
  3772. inst->getEulerAngles(ax, ay, az);
  3773. return 0;
  3774. }
  3775. static int Polycore_Matrix4_inverse(lua_State *L) {
  3776. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  3777. Matrix4 *inst = (Matrix4*)lua_topointer(L, 1);
  3778. Matrix4 *retInst = new Matrix4();
  3779. *retInst = inst->inverse();
  3780. lua_pushlightuserdata(L, retInst);
  3781. return 1;
  3782. }
  3783. static int Polycore_Matrix4_inverseAffine(lua_State *L) {
  3784. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  3785. Matrix4 *inst = (Matrix4*)lua_topointer(L, 1);
  3786. Matrix4 *retInst = new Matrix4();
  3787. *retInst = inst->inverseAffine();
  3788. lua_pushlightuserdata(L, retInst);
  3789. return 1;
  3790. }
  3791. static int Polycore_delete_Matrix4(lua_State *L) {
  3792. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  3793. Matrix4 *inst = (Matrix4*)lua_topointer(L, 1);
  3794. delete inst;
  3795. return 0;
  3796. }
  3797. static int Polycore_VertexBuffer_get_verticesPerFace(lua_State *L) {
  3798. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  3799. VertexBuffer *inst = (VertexBuffer*)lua_topointer(L, 1);
  3800. lua_pushinteger(L, inst->verticesPerFace);
  3801. return 1;
  3802. }
  3803. static int Polycore_VertexBuffer_get_meshType(lua_State *L) {
  3804. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  3805. VertexBuffer *inst = (VertexBuffer*)lua_topointer(L, 1);
  3806. lua_pushinteger(L, inst->meshType);
  3807. return 1;
  3808. }
  3809. static int Polycore_VertexBuffer_set_verticesPerFace(lua_State *L) {
  3810. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  3811. VertexBuffer *inst = (VertexBuffer*)lua_topointer(L, 1);
  3812. int param = lua_tointeger(L, 2);
  3813. inst->verticesPerFace = param;
  3814. return 0;
  3815. }
  3816. static int Polycore_VertexBuffer_set_meshType(lua_State *L) {
  3817. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  3818. VertexBuffer *inst = (VertexBuffer*)lua_topointer(L, 1);
  3819. int param = lua_tointeger(L, 2);
  3820. inst->meshType = param;
  3821. return 0;
  3822. }
  3823. static int Polycore_VertexBuffer(lua_State *L) {
  3824. VertexBuffer *inst = new VertexBuffer();
  3825. lua_pushlightuserdata(L, (void*)inst);
  3826. return 1;
  3827. }
  3828. static int Polycore_VertexBuffer_getVertexCount(lua_State *L) {
  3829. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  3830. VertexBuffer *inst = (VertexBuffer*)lua_topointer(L, 1);
  3831. lua_pushinteger(L, inst->getVertexCount());
  3832. return 1;
  3833. }
  3834. static int Polycore_delete_VertexBuffer(lua_State *L) {
  3835. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  3836. VertexBuffer *inst = (VertexBuffer*)lua_topointer(L, 1);
  3837. delete inst;
  3838. return 0;
  3839. }
  3840. static int Polycore_Mesh_get_useVertexColors(lua_State *L) {
  3841. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  3842. Mesh *inst = (Mesh*)lua_topointer(L, 1);
  3843. lua_pushboolean(L, inst->useVertexColors);
  3844. return 1;
  3845. }
  3846. static int Polycore_Mesh_set_useVertexColors(lua_State *L) {
  3847. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  3848. Mesh *inst = (Mesh*)lua_topointer(L, 1);
  3849. bool param = lua_toboolean(L, 2);
  3850. inst->useVertexColors = param;
  3851. return 0;
  3852. }
  3853. static int Polycore_Mesh(lua_State *L) {
  3854. luaL_checktype(L, 1, LUA_TNUMBER);
  3855. int meshType = lua_tointeger(L, 1);
  3856. Mesh *inst = new Mesh(meshType);
  3857. lua_pushlightuserdata(L, (void*)inst);
  3858. return 1;
  3859. }
  3860. static int Polycore_Mesh_addPolygon(lua_State *L) {
  3861. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  3862. Mesh *inst = (Mesh*)lua_topointer(L, 1);
  3863. luaL_checktype(L, 2, LUA_TLIGHTUSERDATA);
  3864. Polycode::Polygon* newPolygon = (Polycode::Polygon*)lua_topointer(L, 2);
  3865. inst->addPolygon(newPolygon);
  3866. return 0;
  3867. }
  3868. static int Polycore_Mesh_loadMesh(lua_State *L) {
  3869. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  3870. Mesh *inst = (Mesh*)lua_topointer(L, 1);
  3871. luaL_checktype(L, 2, LUA_TSTRING);
  3872. String fileName = String(lua_tostring(L, 2));
  3873. inst->loadMesh(fileName);
  3874. return 0;
  3875. }
  3876. static int Polycore_Mesh_clearMesh(lua_State *L) {
  3877. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  3878. Mesh *inst = (Mesh*)lua_topointer(L, 1);
  3879. inst->clearMesh();
  3880. return 0;
  3881. }
  3882. static int Polycore_Mesh_saveToFile(lua_State *L) {
  3883. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  3884. Mesh *inst = (Mesh*)lua_topointer(L, 1);
  3885. luaL_checktype(L, 2, LUA_TSTRING);
  3886. String fileName = String(lua_tostring(L, 2));
  3887. inst->saveToFile(fileName);
  3888. return 0;
  3889. }
  3890. static int Polycore_Mesh_loadFromFile(lua_State *L) {
  3891. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  3892. Mesh *inst = (Mesh*)lua_topointer(L, 1);
  3893. luaL_checktype(L, 2, LUA_TLIGHTUSERDATA);
  3894. OSFILE* inFile = (OSFILE*)lua_topointer(L, 2);
  3895. inst->loadFromFile(inFile);
  3896. return 0;
  3897. }
  3898. static int Polycore_Mesh_getPolygonCount(lua_State *L) {
  3899. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  3900. Mesh *inst = (Mesh*)lua_topointer(L, 1);
  3901. lua_pushinteger(L, inst->getPolygonCount());
  3902. return 1;
  3903. }
  3904. static int Polycore_Mesh_getVertexCount(lua_State *L) {
  3905. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  3906. Mesh *inst = (Mesh*)lua_topointer(L, 1);
  3907. lua_pushinteger(L, inst->getVertexCount());
  3908. return 1;
  3909. }
  3910. static int Polycore_Mesh_getPolygon(lua_State *L) {
  3911. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  3912. Mesh *inst = (Mesh*)lua_topointer(L, 1);
  3913. luaL_checktype(L, 2, LUA_TNUMBER);
  3914. unsigned int index = lua_tointeger(L, 2);
  3915. void *ptrRetVal = (void*)inst->getPolygon(index);
  3916. if(ptrRetVal == NULL) {
  3917. lua_pushnil(L);
  3918. } else {
  3919. lua_pushlightuserdata(L, ptrRetVal);
  3920. }
  3921. return 1;
  3922. }
  3923. static int Polycore_Mesh_createPlane(lua_State *L) {
  3924. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  3925. Mesh *inst = (Mesh*)lua_topointer(L, 1);
  3926. luaL_checktype(L, 2, LUA_TNUMBER);
  3927. Number w = lua_tonumber(L, 2);
  3928. luaL_checktype(L, 3, LUA_TNUMBER);
  3929. Number h = lua_tonumber(L, 3);
  3930. inst->createPlane(w, h);
  3931. return 0;
  3932. }
  3933. static int Polycore_Mesh_createVPlane(lua_State *L) {
  3934. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  3935. Mesh *inst = (Mesh*)lua_topointer(L, 1);
  3936. luaL_checktype(L, 2, LUA_TNUMBER);
  3937. Number w = lua_tonumber(L, 2);
  3938. luaL_checktype(L, 3, LUA_TNUMBER);
  3939. Number h = lua_tonumber(L, 3);
  3940. inst->createVPlane(w, h);
  3941. return 0;
  3942. }
  3943. static int Polycore_Mesh_createTorus(lua_State *L) {
  3944. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  3945. Mesh *inst = (Mesh*)lua_topointer(L, 1);
  3946. luaL_checktype(L, 2, LUA_TNUMBER);
  3947. Number radius = lua_tonumber(L, 2);
  3948. luaL_checktype(L, 3, LUA_TNUMBER);
  3949. Number tubeRadius = lua_tonumber(L, 3);
  3950. luaL_checktype(L, 4, LUA_TNUMBER);
  3951. int rSegments = lua_tointeger(L, 4);
  3952. luaL_checktype(L, 5, LUA_TNUMBER);
  3953. int tSegments = lua_tointeger(L, 5);
  3954. inst->createTorus(radius, tubeRadius, rSegments, tSegments);
  3955. return 0;
  3956. }
  3957. static int Polycore_Mesh_createBox(lua_State *L) {
  3958. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  3959. Mesh *inst = (Mesh*)lua_topointer(L, 1);
  3960. luaL_checktype(L, 2, LUA_TNUMBER);
  3961. Number w = lua_tonumber(L, 2);
  3962. luaL_checktype(L, 3, LUA_TNUMBER);
  3963. Number d = lua_tonumber(L, 3);
  3964. luaL_checktype(L, 4, LUA_TNUMBER);
  3965. Number h = lua_tonumber(L, 4);
  3966. inst->createBox(w, d, h);
  3967. return 0;
  3968. }
  3969. static int Polycore_Mesh_createSphere(lua_State *L) {
  3970. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  3971. Mesh *inst = (Mesh*)lua_topointer(L, 1);
  3972. luaL_checktype(L, 2, LUA_TNUMBER);
  3973. Number radius = lua_tonumber(L, 2);
  3974. luaL_checktype(L, 3, LUA_TNUMBER);
  3975. int numRings = lua_tointeger(L, 3);
  3976. luaL_checktype(L, 4, LUA_TNUMBER);
  3977. int numSegments = lua_tointeger(L, 4);
  3978. inst->createSphere(radius, numRings, numSegments);
  3979. return 0;
  3980. }
  3981. static int Polycore_Mesh_createCylinder(lua_State *L) {
  3982. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  3983. Mesh *inst = (Mesh*)lua_topointer(L, 1);
  3984. luaL_checktype(L, 2, LUA_TNUMBER);
  3985. Number height = lua_tonumber(L, 2);
  3986. luaL_checktype(L, 3, LUA_TNUMBER);
  3987. Number radius = lua_tonumber(L, 3);
  3988. luaL_checktype(L, 4, LUA_TNUMBER);
  3989. int numSegments = lua_tointeger(L, 4);
  3990. inst->createCylinder(height, radius, numSegments);
  3991. return 0;
  3992. }
  3993. static int Polycore_Mesh_createCone(lua_State *L) {
  3994. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  3995. Mesh *inst = (Mesh*)lua_topointer(L, 1);
  3996. luaL_checktype(L, 2, LUA_TNUMBER);
  3997. Number height = lua_tonumber(L, 2);
  3998. luaL_checktype(L, 3, LUA_TNUMBER);
  3999. Number radius = lua_tonumber(L, 3);
  4000. luaL_checktype(L, 4, LUA_TNUMBER);
  4001. int numSegments = lua_tointeger(L, 4);
  4002. inst->createCone(height, radius, numSegments);
  4003. return 0;
  4004. }
  4005. static int Polycore_Mesh_recenterMesh(lua_State *L) {
  4006. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  4007. Mesh *inst = (Mesh*)lua_topointer(L, 1);
  4008. Vector3 *retInst = new Vector3();
  4009. *retInst = inst->recenterMesh();
  4010. lua_pushlightuserdata(L, retInst);
  4011. return 1;
  4012. }
  4013. static int Polycore_Mesh_useVertexNormals(lua_State *L) {
  4014. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  4015. Mesh *inst = (Mesh*)lua_topointer(L, 1);
  4016. luaL_checktype(L, 2, LUA_TBOOLEAN);
  4017. bool val = lua_toboolean(L, 2);
  4018. inst->useVertexNormals(val);
  4019. return 0;
  4020. }
  4021. static int Polycore_Mesh_setVertexBuffer(lua_State *L) {
  4022. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  4023. Mesh *inst = (Mesh*)lua_topointer(L, 1);
  4024. luaL_checktype(L, 2, LUA_TLIGHTUSERDATA);
  4025. VertexBuffer* buffer = (VertexBuffer*)lua_topointer(L, 2);
  4026. inst->setVertexBuffer(buffer);
  4027. return 0;
  4028. }
  4029. static int Polycore_Mesh_getVertexBuffer(lua_State *L) {
  4030. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  4031. Mesh *inst = (Mesh*)lua_topointer(L, 1);
  4032. void *ptrRetVal = (void*)inst->getVertexBuffer();
  4033. if(ptrRetVal == NULL) {
  4034. lua_pushnil(L);
  4035. } else {
  4036. lua_pushlightuserdata(L, ptrRetVal);
  4037. }
  4038. return 1;
  4039. }
  4040. static int Polycore_Mesh_getRadius(lua_State *L) {
  4041. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  4042. Mesh *inst = (Mesh*)lua_topointer(L, 1);
  4043. lua_pushnumber(L, inst->getRadius());
  4044. return 1;
  4045. }
  4046. static int Polycore_Mesh_calculateNormals(lua_State *L) {
  4047. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  4048. Mesh *inst = (Mesh*)lua_topointer(L, 1);
  4049. bool smooth;
  4050. if(lua_isboolean(L, 2)) {
  4051. smooth = lua_toboolean(L, 2);
  4052. } else {
  4053. smooth = true;
  4054. }
  4055. Number smoothAngle;
  4056. if(lua_isnumber(L, 3)) {
  4057. smoothAngle = lua_tonumber(L, 3);
  4058. } else {
  4059. smoothAngle = 90.0;
  4060. }
  4061. inst->calculateNormals(smooth, smoothAngle);
  4062. return 0;
  4063. }
  4064. static int Polycore_Mesh_calculateTangents(lua_State *L) {
  4065. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  4066. Mesh *inst = (Mesh*)lua_topointer(L, 1);
  4067. inst->calculateTangents();
  4068. return 0;
  4069. }
  4070. static int Polycore_Mesh_getMeshType(lua_State *L) {
  4071. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  4072. Mesh *inst = (Mesh*)lua_topointer(L, 1);
  4073. lua_pushinteger(L, inst->getMeshType());
  4074. return 1;
  4075. }
  4076. static int Polycore_Mesh_setMeshType(lua_State *L) {
  4077. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  4078. Mesh *inst = (Mesh*)lua_topointer(L, 1);
  4079. luaL_checktype(L, 2, LUA_TNUMBER);
  4080. int newType = lua_tointeger(L, 2);
  4081. inst->setMeshType(newType);
  4082. return 0;
  4083. }
  4084. static int Polycore_Mesh_calculateBBox(lua_State *L) {
  4085. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  4086. Mesh *inst = (Mesh*)lua_topointer(L, 1);
  4087. Vector3 *retInst = new Vector3();
  4088. *retInst = inst->calculateBBox();
  4089. lua_pushlightuserdata(L, retInst);
  4090. return 1;
  4091. }
  4092. static int Polycore_Mesh_hasVertexBuffer(lua_State *L) {
  4093. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  4094. Mesh *inst = (Mesh*)lua_topointer(L, 1);
  4095. lua_pushboolean(L, inst->hasVertexBuffer());
  4096. return 1;
  4097. }
  4098. static int Polycore_delete_Mesh(lua_State *L) {
  4099. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  4100. Mesh *inst = (Mesh*)lua_topointer(L, 1);
  4101. delete inst;
  4102. return 0;
  4103. }
  4104. static int Polycore_PolycodeModule(lua_State *L) {
  4105. PolycodeModule *inst = new PolycodeModule();
  4106. lua_pushlightuserdata(L, (void*)inst);
  4107. return 1;
  4108. }
  4109. static int Polycore_PolycodeModule_getType(lua_State *L) {
  4110. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  4111. PolycodeModule *inst = (PolycodeModule*)lua_topointer(L, 1);
  4112. lua_pushinteger(L, inst->getType());
  4113. return 1;
  4114. }
  4115. static int Polycore_delete_PolycodeModule(lua_State *L) {
  4116. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  4117. PolycodeModule *inst = (PolycodeModule*)lua_topointer(L, 1);
  4118. delete inst;
  4119. return 0;
  4120. }
  4121. static int Polycore_ObjectEntry_get_type(lua_State *L) {
  4122. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  4123. ObjectEntry *inst = (ObjectEntry*)lua_topointer(L, 1);
  4124. lua_pushinteger(L, inst->type);
  4125. return 1;
  4126. }
  4127. static int Polycore_ObjectEntry_get_name(lua_State *L) {
  4128. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  4129. ObjectEntry *inst = (ObjectEntry*)lua_topointer(L, 1);
  4130. lua_pushstring(L, inst->name.c_str());
  4131. return 1;
  4132. }
  4133. static int Polycore_ObjectEntry_get_NumberVal(lua_State *L) {
  4134. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  4135. ObjectEntry *inst = (ObjectEntry*)lua_topointer(L, 1);
  4136. lua_pushnumber(L, inst->NumberVal);
  4137. return 1;
  4138. }
  4139. static int Polycore_ObjectEntry_get_intVal(lua_State *L) {
  4140. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  4141. ObjectEntry *inst = (ObjectEntry*)lua_topointer(L, 1);
  4142. lua_pushinteger(L, inst->intVal);
  4143. return 1;
  4144. }
  4145. static int Polycore_ObjectEntry_get_stringVal(lua_State *L) {
  4146. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  4147. ObjectEntry *inst = (ObjectEntry*)lua_topointer(L, 1);
  4148. lua_pushstring(L, inst->stringVal.c_str());
  4149. return 1;
  4150. }
  4151. static int Polycore_ObjectEntry_get_boolVal(lua_State *L) {
  4152. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  4153. ObjectEntry *inst = (ObjectEntry*)lua_topointer(L, 1);
  4154. lua_pushboolean(L, inst->boolVal);
  4155. return 1;
  4156. }
  4157. static int Polycore_ObjectEntry_get_length(lua_State *L) {
  4158. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  4159. ObjectEntry *inst = (ObjectEntry*)lua_topointer(L, 1);
  4160. lua_pushinteger(L, inst->length);
  4161. return 1;
  4162. }
  4163. static int Polycore_ObjectEntry_set_type(lua_State *L) {
  4164. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  4165. ObjectEntry *inst = (ObjectEntry*)lua_topointer(L, 1);
  4166. int param = lua_tointeger(L, 2);
  4167. inst->type = param;
  4168. return 0;
  4169. }
  4170. static int Polycore_ObjectEntry_set_name(lua_State *L) {
  4171. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  4172. ObjectEntry *inst = (ObjectEntry*)lua_topointer(L, 1);
  4173. String param = lua_tostring(L, 2);
  4174. inst->name = param;
  4175. return 0;
  4176. }
  4177. static int Polycore_ObjectEntry_set_NumberVal(lua_State *L) {
  4178. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  4179. ObjectEntry *inst = (ObjectEntry*)lua_topointer(L, 1);
  4180. Number param = lua_tonumber(L, 2);
  4181. inst->NumberVal = param;
  4182. return 0;
  4183. }
  4184. static int Polycore_ObjectEntry_set_intVal(lua_State *L) {
  4185. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  4186. ObjectEntry *inst = (ObjectEntry*)lua_topointer(L, 1);
  4187. int param = lua_tointeger(L, 2);
  4188. inst->intVal = param;
  4189. return 0;
  4190. }
  4191. static int Polycore_ObjectEntry_set_stringVal(lua_State *L) {
  4192. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  4193. ObjectEntry *inst = (ObjectEntry*)lua_topointer(L, 1);
  4194. String param = lua_tostring(L, 2);
  4195. inst->stringVal = param;
  4196. return 0;
  4197. }
  4198. static int Polycore_ObjectEntry_set_boolVal(lua_State *L) {
  4199. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  4200. ObjectEntry *inst = (ObjectEntry*)lua_topointer(L, 1);
  4201. bool param = lua_toboolean(L, 2);
  4202. inst->boolVal = param;
  4203. return 0;
  4204. }
  4205. static int Polycore_ObjectEntry_set_length(lua_State *L) {
  4206. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  4207. ObjectEntry *inst = (ObjectEntry*)lua_topointer(L, 1);
  4208. int param = lua_tointeger(L, 2);
  4209. inst->length = param;
  4210. return 0;
  4211. }
  4212. static int Polycore_ObjectEntry(lua_State *L) {
  4213. ObjectEntry *inst = new ObjectEntry();
  4214. lua_pushlightuserdata(L, (void*)inst);
  4215. return 1;
  4216. }
  4217. static int Polycore_ObjectEntry_addChild(lua_State *L) {
  4218. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  4219. ObjectEntry *inst = (ObjectEntry*)lua_topointer(L, 1);
  4220. luaL_checktype(L, 2, LUA_TSTRING);
  4221. String name = String(lua_tostring(L, 2));
  4222. void *ptrRetVal = (void*)inst->addChild(name);
  4223. if(ptrRetVal == NULL) {
  4224. lua_pushnil(L);
  4225. } else {
  4226. lua_pushlightuserdata(L, ptrRetVal);
  4227. }
  4228. return 1;
  4229. }
  4230. static int Polycore_delete_ObjectEntry(lua_State *L) {
  4231. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  4232. ObjectEntry *inst = (ObjectEntry*)lua_topointer(L, 1);
  4233. delete inst;
  4234. return 0;
  4235. }
  4236. static int Polycore_Particle_get_velVector(lua_State *L) {
  4237. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  4238. Particle *inst = (Particle*)lua_topointer(L, 1);
  4239. lua_pushlightuserdata(L, &inst->velVector);
  4240. return 1;
  4241. }
  4242. static int Polycore_Particle_get_dirVector(lua_State *L) {
  4243. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  4244. Particle *inst = (Particle*)lua_topointer(L, 1);
  4245. lua_pushlightuserdata(L, &inst->dirVector);
  4246. return 1;
  4247. }
  4248. static int Polycore_Particle_get_deviation(lua_State *L) {
  4249. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  4250. Particle *inst = (Particle*)lua_topointer(L, 1);
  4251. lua_pushlightuserdata(L, &inst->deviation);
  4252. return 1;
  4253. }
  4254. static int Polycore_Particle_get_life(lua_State *L) {
  4255. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  4256. Particle *inst = (Particle*)lua_topointer(L, 1);
  4257. lua_pushnumber(L, inst->life);
  4258. return 1;
  4259. }
  4260. static int Polycore_Particle_get_lifespan(lua_State *L) {
  4261. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  4262. Particle *inst = (Particle*)lua_topointer(L, 1);
  4263. lua_pushnumber(L, inst->lifespan);
  4264. return 1;
  4265. }
  4266. static int Polycore_Particle_get_brightnessDeviation(lua_State *L) {
  4267. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  4268. Particle *inst = (Particle*)lua_topointer(L, 1);
  4269. lua_pushnumber(L, inst->brightnessDeviation);
  4270. return 1;
  4271. }
  4272. static int Polycore_Particle_get_perlinPosX(lua_State *L) {
  4273. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  4274. Particle *inst = (Particle*)lua_topointer(L, 1);
  4275. lua_pushnumber(L, inst->perlinPosX);
  4276. return 1;
  4277. }
  4278. static int Polycore_Particle_get_perlinPosY(lua_State *L) {
  4279. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  4280. Particle *inst = (Particle*)lua_topointer(L, 1);
  4281. lua_pushnumber(L, inst->perlinPosY);
  4282. return 1;
  4283. }
  4284. static int Polycore_Particle_get_perlinPosZ(lua_State *L) {
  4285. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  4286. Particle *inst = (Particle*)lua_topointer(L, 1);
  4287. lua_pushnumber(L, inst->perlinPosZ);
  4288. return 1;
  4289. }
  4290. static int Polycore_Particle_set_life(lua_State *L) {
  4291. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  4292. Particle *inst = (Particle*)lua_topointer(L, 1);
  4293. Number param = lua_tonumber(L, 2);
  4294. inst->life = param;
  4295. return 0;
  4296. }
  4297. static int Polycore_Particle_set_lifespan(lua_State *L) {
  4298. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  4299. Particle *inst = (Particle*)lua_topointer(L, 1);
  4300. Number param = lua_tonumber(L, 2);
  4301. inst->lifespan = param;
  4302. return 0;
  4303. }
  4304. static int Polycore_Particle_set_brightnessDeviation(lua_State *L) {
  4305. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  4306. Particle *inst = (Particle*)lua_topointer(L, 1);
  4307. Number param = lua_tonumber(L, 2);
  4308. inst->brightnessDeviation = param;
  4309. return 0;
  4310. }
  4311. static int Polycore_Particle_set_perlinPosX(lua_State *L) {
  4312. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  4313. Particle *inst = (Particle*)lua_topointer(L, 1);
  4314. Number param = lua_tonumber(L, 2);
  4315. inst->perlinPosX = param;
  4316. return 0;
  4317. }
  4318. static int Polycore_Particle_set_perlinPosY(lua_State *L) {
  4319. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  4320. Particle *inst = (Particle*)lua_topointer(L, 1);
  4321. Number param = lua_tonumber(L, 2);
  4322. inst->perlinPosY = param;
  4323. return 0;
  4324. }
  4325. static int Polycore_Particle_set_perlinPosZ(lua_State *L) {
  4326. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  4327. Particle *inst = (Particle*)lua_topointer(L, 1);
  4328. Number param = lua_tonumber(L, 2);
  4329. inst->perlinPosZ = param;
  4330. return 0;
  4331. }
  4332. static int Polycore_Particle(lua_State *L) {
  4333. luaL_checktype(L, 1, LUA_TNUMBER);
  4334. int particleType = lua_tointeger(L, 1);
  4335. luaL_checktype(L, 2, LUA_TBOOLEAN);
  4336. bool isScreenParticle = lua_toboolean(L, 2);
  4337. luaL_checktype(L, 3, LUA_TLIGHTUSERDATA);
  4338. Material* material = (Material*)lua_topointer(L, 3);
  4339. luaL_checktype(L, 4, LUA_TLIGHTUSERDATA);
  4340. Texture* texture = (Texture*)lua_topointer(L, 4);
  4341. luaL_checktype(L, 5, LUA_TLIGHTUSERDATA);
  4342. Mesh* particleMesh = (Mesh*)lua_topointer(L, 5);
  4343. Particle *inst = new Particle(particleType, isScreenParticle, material, texture, particleMesh);
  4344. lua_pushlightuserdata(L, (void*)inst);
  4345. return 1;
  4346. }
  4347. static int Polycore_Particle_Reset(lua_State *L) {
  4348. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  4349. Particle *inst = (Particle*)lua_topointer(L, 1);
  4350. luaL_checktype(L, 2, LUA_TBOOLEAN);
  4351. bool continuious = lua_toboolean(L, 2);
  4352. inst->Reset(continuious);
  4353. return 0;
  4354. }
  4355. static int Polycore_Particle_createSceneParticle(lua_State *L) {
  4356. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  4357. Particle *inst = (Particle*)lua_topointer(L, 1);
  4358. luaL_checktype(L, 2, LUA_TNUMBER);
  4359. int particleType = lua_tointeger(L, 2);
  4360. luaL_checktype(L, 3, LUA_TLIGHTUSERDATA);
  4361. Material* material = (Material*)lua_topointer(L, 3);
  4362. luaL_checktype(L, 4, LUA_TLIGHTUSERDATA);
  4363. Mesh* particleMesh = (Mesh*)lua_topointer(L, 4);
  4364. inst->createSceneParticle(particleType, material, particleMesh);
  4365. return 0;
  4366. }
  4367. static int Polycore_Particle_createScreenParticle(lua_State *L) {
  4368. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  4369. Particle *inst = (Particle*)lua_topointer(L, 1);
  4370. luaL_checktype(L, 2, LUA_TNUMBER);
  4371. int particleType = lua_tointeger(L, 2);
  4372. luaL_checktype(L, 3, LUA_TLIGHTUSERDATA);
  4373. Texture* texture = (Texture*)lua_topointer(L, 3);
  4374. luaL_checktype(L, 4, LUA_TLIGHTUSERDATA);
  4375. Mesh* particleMesh = (Mesh*)lua_topointer(L, 4);
  4376. inst->createScreenParticle(particleType, texture, particleMesh);
  4377. return 0;
  4378. }
  4379. static int Polycore_delete_Particle(lua_State *L) {
  4380. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  4381. Particle *inst = (Particle*)lua_topointer(L, 1);
  4382. delete inst;
  4383. return 0;
  4384. }
  4385. static int Polycore_ScreenParticleEmitter(lua_State *L) {
  4386. luaL_checktype(L, 1, LUA_TSTRING);
  4387. String imageFile = String(lua_tostring(L, 1));
  4388. luaL_checktype(L, 2, LUA_TLIGHTUSERDATA);
  4389. Screen* particleParentScreen = (Screen*)lua_topointer(L, 2);
  4390. luaL_checktype(L, 3, LUA_TNUMBER);
  4391. int particleType = lua_tointeger(L, 3);
  4392. luaL_checktype(L, 4, LUA_TNUMBER);
  4393. int emitterType = lua_tointeger(L, 4);
  4394. luaL_checktype(L, 5, LUA_TNUMBER);
  4395. Number lifespan = lua_tonumber(L, 5);
  4396. luaL_checktype(L, 6, LUA_TNUMBER);
  4397. unsigned int numParticles = lua_tointeger(L, 6);
  4398. luaL_checktype(L, 7, LUA_TLIGHTUSERDATA);
  4399. Vector3 direction = *(Vector3*)lua_topointer(L, 7);
  4400. luaL_checktype(L, 8, LUA_TLIGHTUSERDATA);
  4401. Vector3 gravity = *(Vector3*)lua_topointer(L, 8);
  4402. luaL_checktype(L, 9, LUA_TLIGHTUSERDATA);
  4403. Vector3 deviation = *(Vector3*)lua_topointer(L, 9);
  4404. Mesh* particleMesh;
  4405. if(lua_islightuserdata(L, 10)) {
  4406. particleMesh = (Mesh*)lua_topointer(L, 10);
  4407. } else {
  4408. particleMesh = NULL;
  4409. }
  4410. ScreenMesh* emitter;
  4411. if(lua_islightuserdata(L, 11)) {
  4412. emitter = (ScreenMesh*)lua_topointer(L, 11);
  4413. } else {
  4414. emitter = NULL;
  4415. }
  4416. ScreenParticleEmitter *inst = new ScreenParticleEmitter(imageFile, particleParentScreen, particleType, emitterType, lifespan, numParticles, direction, gravity, deviation, particleMesh, emitter);
  4417. lua_pushlightuserdata(L, (void*)inst);
  4418. return 1;
  4419. }
  4420. static int Polycore_ScreenParticleEmitter_getEmitter(lua_State *L) {
  4421. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  4422. ScreenParticleEmitter *inst = (ScreenParticleEmitter*)lua_topointer(L, 1);
  4423. void *ptrRetVal = (void*)inst->getEmitter();
  4424. if(ptrRetVal == NULL) {
  4425. lua_pushnil(L);
  4426. } else {
  4427. lua_pushlightuserdata(L, ptrRetVal);
  4428. }
  4429. return 1;
  4430. }
  4431. static int Polycore_ScreenParticleEmitter_addParticleBody(lua_State *L) {
  4432. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  4433. ScreenParticleEmitter *inst = (ScreenParticleEmitter*)lua_topointer(L, 1);
  4434. luaL_checktype(L, 2, LUA_TLIGHTUSERDATA);
  4435. Entity* particleBody = (Entity*)lua_topointer(L, 2);
  4436. inst->addParticleBody(particleBody);
  4437. return 0;
  4438. }
  4439. static int Polycore_ScreenParticleEmitter_getBaseMatrix(lua_State *L) {
  4440. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  4441. ScreenParticleEmitter *inst = (ScreenParticleEmitter*)lua_topointer(L, 1);
  4442. Matrix4 *retInst = new Matrix4();
  4443. *retInst = inst->getBaseMatrix();
  4444. lua_pushlightuserdata(L, retInst);
  4445. return 1;
  4446. }
  4447. static int Polycore_ScreenParticleEmitter_Update(lua_State *L) {
  4448. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  4449. ScreenParticleEmitter *inst = (ScreenParticleEmitter*)lua_topointer(L, 1);
  4450. inst->Update();
  4451. return 0;
  4452. }
  4453. static int Polycore_delete_ScreenParticleEmitter(lua_State *L) {
  4454. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  4455. ScreenParticleEmitter *inst = (ScreenParticleEmitter*)lua_topointer(L, 1);
  4456. delete inst;
  4457. return 0;
  4458. }
  4459. static int Polycore_SceneParticleEmitter(lua_State *L) {
  4460. luaL_checktype(L, 1, LUA_TSTRING);
  4461. String materialName = String(lua_tostring(L, 1));
  4462. luaL_checktype(L, 2, LUA_TLIGHTUSERDATA);
  4463. Scene* particleParentScene = (Scene*)lua_topointer(L, 2);
  4464. luaL_checktype(L, 3, LUA_TNUMBER);
  4465. int particleType = lua_tointeger(L, 3);
  4466. luaL_checktype(L, 4, LUA_TNUMBER);
  4467. int emitterType = lua_tointeger(L, 4);
  4468. luaL_checktype(L, 5, LUA_TNUMBER);
  4469. Number lifespan = lua_tonumber(L, 5);
  4470. luaL_checktype(L, 6, LUA_TNUMBER);
  4471. unsigned int numParticles = lua_tointeger(L, 6);
  4472. luaL_checktype(L, 7, LUA_TLIGHTUSERDATA);
  4473. Vector3 direction = *(Vector3*)lua_topointer(L, 7);
  4474. luaL_checktype(L, 8, LUA_TLIGHTUSERDATA);
  4475. Vector3 gravity = *(Vector3*)lua_topointer(L, 8);
  4476. luaL_checktype(L, 9, LUA_TLIGHTUSERDATA);
  4477. Vector3 deviation = *(Vector3*)lua_topointer(L, 9);
  4478. Mesh* particleMesh;
  4479. if(lua_islightuserdata(L, 10)) {
  4480. particleMesh = (Mesh*)lua_topointer(L, 10);
  4481. } else {
  4482. particleMesh = NULL;
  4483. }
  4484. SceneMesh* emitter;
  4485. if(lua_islightuserdata(L, 11)) {
  4486. emitter = (SceneMesh*)lua_topointer(L, 11);
  4487. } else {
  4488. emitter = NULL;
  4489. }
  4490. SceneParticleEmitter *inst = new SceneParticleEmitter(materialName, particleParentScene, particleType, emitterType, lifespan, numParticles, direction, gravity, deviation, particleMesh, emitter);
  4491. lua_pushlightuserdata(L, (void*)inst);
  4492. return 1;
  4493. }
  4494. static int Polycore_SceneParticleEmitter_getEmitter(lua_State *L) {
  4495. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  4496. SceneParticleEmitter *inst = (SceneParticleEmitter*)lua_topointer(L, 1);
  4497. void *ptrRetVal = (void*)inst->getEmitter();
  4498. if(ptrRetVal == NULL) {
  4499. lua_pushnil(L);
  4500. } else {
  4501. lua_pushlightuserdata(L, ptrRetVal);
  4502. }
  4503. return 1;
  4504. }
  4505. static int Polycore_SceneParticleEmitter_respawnSceneParticles(lua_State *L) {
  4506. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  4507. SceneParticleEmitter *inst = (SceneParticleEmitter*)lua_topointer(L, 1);
  4508. inst->respawnSceneParticles();
  4509. return 0;
  4510. }
  4511. static int Polycore_SceneParticleEmitter_addParticleBody(lua_State *L) {
  4512. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  4513. SceneParticleEmitter *inst = (SceneParticleEmitter*)lua_topointer(L, 1);
  4514. luaL_checktype(L, 2, LUA_TLIGHTUSERDATA);
  4515. Entity* particleBody = (Entity*)lua_topointer(L, 2);
  4516. inst->addParticleBody(particleBody);
  4517. return 0;
  4518. }
  4519. static int Polycore_SceneParticleEmitter_getBaseMatrix(lua_State *L) {
  4520. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  4521. SceneParticleEmitter *inst = (SceneParticleEmitter*)lua_topointer(L, 1);
  4522. Matrix4 *retInst = new Matrix4();
  4523. *retInst = inst->getBaseMatrix();
  4524. lua_pushlightuserdata(L, retInst);
  4525. return 1;
  4526. }
  4527. static int Polycore_SceneParticleEmitter_Update(lua_State *L) {
  4528. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  4529. SceneParticleEmitter *inst = (SceneParticleEmitter*)lua_topointer(L, 1);
  4530. inst->Update();
  4531. return 0;
  4532. }
  4533. static int Polycore_delete_SceneParticleEmitter(lua_State *L) {
  4534. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  4535. SceneParticleEmitter *inst = (SceneParticleEmitter*)lua_topointer(L, 1);
  4536. delete inst;
  4537. return 0;
  4538. }
  4539. static int Polycore_ParticleEmitter_get_particleSpeedMod(lua_State *L) {
  4540. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  4541. ParticleEmitter *inst = (ParticleEmitter*)lua_topointer(L, 1);
  4542. lua_pushnumber(L, inst->particleSpeedMod);
  4543. return 1;
  4544. }
  4545. static int Polycore_ParticleEmitter_get_brightnessDeviation(lua_State *L) {
  4546. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  4547. ParticleEmitter *inst = (ParticleEmitter*)lua_topointer(L, 1);
  4548. lua_pushnumber(L, inst->brightnessDeviation);
  4549. return 1;
  4550. }
  4551. static int Polycore_ParticleEmitter_get_deviation(lua_State *L) {
  4552. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  4553. ParticleEmitter *inst = (ParticleEmitter*)lua_topointer(L, 1);
  4554. lua_pushlightuserdata(L, &inst->deviation);
  4555. return 1;
  4556. }
  4557. static int Polycore_ParticleEmitter_get_dirVector(lua_State *L) {
  4558. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  4559. ParticleEmitter *inst = (ParticleEmitter*)lua_topointer(L, 1);
  4560. lua_pushlightuserdata(L, &inst->dirVector);
  4561. return 1;
  4562. }
  4563. static int Polycore_ParticleEmitter_get_gravVector(lua_State *L) {
  4564. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  4565. ParticleEmitter *inst = (ParticleEmitter*)lua_topointer(L, 1);
  4566. lua_pushlightuserdata(L, &inst->gravVector);
  4567. return 1;
  4568. }
  4569. static int Polycore_ParticleEmitter_get_lifespan(lua_State *L) {
  4570. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  4571. ParticleEmitter *inst = (ParticleEmitter*)lua_topointer(L, 1);
  4572. lua_pushnumber(L, inst->lifespan);
  4573. return 1;
  4574. }
  4575. static int Polycore_ParticleEmitter_get_rotationFollowsPath(lua_State *L) {
  4576. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  4577. ParticleEmitter *inst = (ParticleEmitter*)lua_topointer(L, 1);
  4578. lua_pushboolean(L, inst->rotationFollowsPath);
  4579. return 1;
  4580. }
  4581. static int Polycore_ParticleEmitter_get_scaleCurve(lua_State *L) {
  4582. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  4583. ParticleEmitter *inst = (ParticleEmitter*)lua_topointer(L, 1);
  4584. lua_pushlightuserdata(L, &inst->scaleCurve);
  4585. return 1;
  4586. }
  4587. static int Polycore_ParticleEmitter_get_colorCurveR(lua_State *L) {
  4588. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  4589. ParticleEmitter *inst = (ParticleEmitter*)lua_topointer(L, 1);
  4590. lua_pushlightuserdata(L, &inst->colorCurveR);
  4591. return 1;
  4592. }
  4593. static int Polycore_ParticleEmitter_get_colorCurveG(lua_State *L) {
  4594. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  4595. ParticleEmitter *inst = (ParticleEmitter*)lua_topointer(L, 1);
  4596. lua_pushlightuserdata(L, &inst->colorCurveG);
  4597. return 1;
  4598. }
  4599. static int Polycore_ParticleEmitter_get_colorCurveB(lua_State *L) {
  4600. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  4601. ParticleEmitter *inst = (ParticleEmitter*)lua_topointer(L, 1);
  4602. lua_pushlightuserdata(L, &inst->colorCurveB);
  4603. return 1;
  4604. }
  4605. static int Polycore_ParticleEmitter_get_colorCurveA(lua_State *L) {
  4606. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  4607. ParticleEmitter *inst = (ParticleEmitter*)lua_topointer(L, 1);
  4608. lua_pushlightuserdata(L, &inst->colorCurveA);
  4609. return 1;
  4610. }
  4611. static int Polycore_ParticleEmitter_get_useColorCurves(lua_State *L) {
  4612. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  4613. ParticleEmitter *inst = (ParticleEmitter*)lua_topointer(L, 1);
  4614. lua_pushboolean(L, inst->useColorCurves);
  4615. return 1;
  4616. }
  4617. static int Polycore_ParticleEmitter_get_useScaleCurves(lua_State *L) {
  4618. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  4619. ParticleEmitter *inst = (ParticleEmitter*)lua_topointer(L, 1);
  4620. lua_pushboolean(L, inst->useScaleCurves);
  4621. return 1;
  4622. }
  4623. static int Polycore_ParticleEmitter_set_particleSpeedMod(lua_State *L) {
  4624. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  4625. ParticleEmitter *inst = (ParticleEmitter*)lua_topointer(L, 1);
  4626. Number param = lua_tonumber(L, 2);
  4627. inst->particleSpeedMod = param;
  4628. return 0;
  4629. }
  4630. static int Polycore_ParticleEmitter_set_brightnessDeviation(lua_State *L) {
  4631. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  4632. ParticleEmitter *inst = (ParticleEmitter*)lua_topointer(L, 1);
  4633. Number param = lua_tonumber(L, 2);
  4634. inst->brightnessDeviation = param;
  4635. return 0;
  4636. }
  4637. static int Polycore_ParticleEmitter_set_lifespan(lua_State *L) {
  4638. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  4639. ParticleEmitter *inst = (ParticleEmitter*)lua_topointer(L, 1);
  4640. Number param = lua_tonumber(L, 2);
  4641. inst->lifespan = param;
  4642. return 0;
  4643. }
  4644. static int Polycore_ParticleEmitter_set_rotationFollowsPath(lua_State *L) {
  4645. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  4646. ParticleEmitter *inst = (ParticleEmitter*)lua_topointer(L, 1);
  4647. bool param = lua_toboolean(L, 2);
  4648. inst->rotationFollowsPath = param;
  4649. return 0;
  4650. }
  4651. static int Polycore_ParticleEmitter_set_useColorCurves(lua_State *L) {
  4652. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  4653. ParticleEmitter *inst = (ParticleEmitter*)lua_topointer(L, 1);
  4654. bool param = lua_toboolean(L, 2);
  4655. inst->useColorCurves = param;
  4656. return 0;
  4657. }
  4658. static int Polycore_ParticleEmitter_set_useScaleCurves(lua_State *L) {
  4659. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  4660. ParticleEmitter *inst = (ParticleEmitter*)lua_topointer(L, 1);
  4661. bool param = lua_toboolean(L, 2);
  4662. inst->useScaleCurves = param;
  4663. return 0;
  4664. }
  4665. static int Polycore_ParticleEmitter(lua_State *L) {
  4666. luaL_checktype(L, 1, LUA_TSTRING);
  4667. String imageFile = String(lua_tostring(L, 1));
  4668. luaL_checktype(L, 2, LUA_TLIGHTUSERDATA);
  4669. Mesh* particleMesh = (Mesh*)lua_topointer(L, 2);
  4670. luaL_checktype(L, 3, LUA_TNUMBER);
  4671. int particleType = lua_tointeger(L, 3);
  4672. luaL_checktype(L, 4, LUA_TNUMBER);
  4673. int emitterType = lua_tointeger(L, 4);
  4674. luaL_checktype(L, 5, LUA_TNUMBER);
  4675. Number lifespan = lua_tonumber(L, 5);
  4676. luaL_checktype(L, 6, LUA_TNUMBER);
  4677. unsigned int numParticles = lua_tointeger(L, 6);
  4678. luaL_checktype(L, 7, LUA_TLIGHTUSERDATA);
  4679. Vector3 direction = *(Vector3*)lua_topointer(L, 7);
  4680. luaL_checktype(L, 8, LUA_TLIGHTUSERDATA);
  4681. Vector3 gravity = *(Vector3*)lua_topointer(L, 8);
  4682. luaL_checktype(L, 9, LUA_TLIGHTUSERDATA);
  4683. Vector3 deviation = *(Vector3*)lua_topointer(L, 9);
  4684. ParticleEmitter *inst = new ParticleEmitter(imageFile, particleMesh, particleType, emitterType, lifespan, numParticles, direction, gravity, deviation);
  4685. lua_pushlightuserdata(L, (void*)inst);
  4686. return 1;
  4687. }
  4688. static int Polycore_ParticleEmitter_createParticles(lua_State *L) {
  4689. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  4690. ParticleEmitter *inst = (ParticleEmitter*)lua_topointer(L, 1);
  4691. inst->createParticles();
  4692. return 0;
  4693. }
  4694. static int Polycore_ParticleEmitter_setRotationSpeed(lua_State *L) {
  4695. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  4696. ParticleEmitter *inst = (ParticleEmitter*)lua_topointer(L, 1);
  4697. luaL_checktype(L, 2, LUA_TNUMBER);
  4698. Number speed = lua_tonumber(L, 2);
  4699. inst->setRotationSpeed(speed);
  4700. return 0;
  4701. }
  4702. static int Polycore_ParticleEmitter_setParticleBlendingMode(lua_State *L) {
  4703. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  4704. ParticleEmitter *inst = (ParticleEmitter*)lua_topointer(L, 1);
  4705. luaL_checktype(L, 2, LUA_TNUMBER);
  4706. int mode = lua_tointeger(L, 2);
  4707. inst->setParticleBlendingMode(mode);
  4708. return 0;
  4709. }
  4710. static int Polycore_ParticleEmitter_setDepthWrite(lua_State *L) {
  4711. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  4712. ParticleEmitter *inst = (ParticleEmitter*)lua_topointer(L, 1);
  4713. luaL_checktype(L, 2, LUA_TBOOLEAN);
  4714. bool val = lua_toboolean(L, 2);
  4715. inst->setDepthWrite(val);
  4716. return 0;
  4717. }
  4718. static int Polycore_ParticleEmitter_setDepthTest(lua_State *L) {
  4719. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  4720. ParticleEmitter *inst = (ParticleEmitter*)lua_topointer(L, 1);
  4721. luaL_checktype(L, 2, LUA_TBOOLEAN);
  4722. bool val = lua_toboolean(L, 2);
  4723. inst->setDepthTest(val);
  4724. return 0;
  4725. }
  4726. static int Polycore_ParticleEmitter_setAlphaTest(lua_State *L) {
  4727. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  4728. ParticleEmitter *inst = (ParticleEmitter*)lua_topointer(L, 1);
  4729. luaL_checktype(L, 2, LUA_TBOOLEAN);
  4730. bool val = lua_toboolean(L, 2);
  4731. inst->setAlphaTest(val);
  4732. return 0;
  4733. }
  4734. static int Polycore_ParticleEmitter_enablePerlin(lua_State *L) {
  4735. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  4736. ParticleEmitter *inst = (ParticleEmitter*)lua_topointer(L, 1);
  4737. luaL_checktype(L, 2, LUA_TBOOLEAN);
  4738. bool val = lua_toboolean(L, 2);
  4739. inst->enablePerlin(val);
  4740. return 0;
  4741. }
  4742. static int Polycore_ParticleEmitter_setParticleVisibility(lua_State *L) {
  4743. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  4744. ParticleEmitter *inst = (ParticleEmitter*)lua_topointer(L, 1);
  4745. luaL_checktype(L, 2, LUA_TBOOLEAN);
  4746. bool val = lua_toboolean(L, 2);
  4747. inst->setParticleVisibility(val);
  4748. return 0;
  4749. }
  4750. static int Polycore_ParticleEmitter_setPerlinModSize(lua_State *L) {
  4751. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  4752. ParticleEmitter *inst = (ParticleEmitter*)lua_topointer(L, 1);
  4753. luaL_checktype(L, 2, LUA_TNUMBER);
  4754. Number size = lua_tonumber(L, 2);
  4755. inst->setPerlinModSize(size);
  4756. return 0;
  4757. }
  4758. static int Polycore_ParticleEmitter_setBillboardMode(lua_State *L) {
  4759. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  4760. ParticleEmitter *inst = (ParticleEmitter*)lua_topointer(L, 1);
  4761. luaL_checktype(L, 2, LUA_TBOOLEAN);
  4762. bool mode = lua_toboolean(L, 2);
  4763. inst->setBillboardMode(mode);
  4764. return 0;
  4765. }
  4766. static int Polycore_ParticleEmitter_enableEmitter(lua_State *L) {
  4767. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  4768. ParticleEmitter *inst = (ParticleEmitter*)lua_topointer(L, 1);
  4769. luaL_checktype(L, 2, LUA_TBOOLEAN);
  4770. bool val = lua_toboolean(L, 2);
  4771. inst->enableEmitter(val);
  4772. return 0;
  4773. }
  4774. static int Polycore_ParticleEmitter_emitterEnabled(lua_State *L) {
  4775. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  4776. ParticleEmitter *inst = (ParticleEmitter*)lua_topointer(L, 1);
  4777. lua_pushboolean(L, inst->emitterEnabled());
  4778. return 1;
  4779. }
  4780. static int Polycore_ParticleEmitter_setEmitterRadius(lua_State *L) {
  4781. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  4782. ParticleEmitter *inst = (ParticleEmitter*)lua_topointer(L, 1);
  4783. luaL_checktype(L, 2, LUA_TLIGHTUSERDATA);
  4784. Vector3 rad = *(Vector3*)lua_topointer(L, 2);
  4785. inst->setEmitterRadius(rad);
  4786. return 0;
  4787. }
  4788. static int Polycore_ParticleEmitter_setAllAtOnce(lua_State *L) {
  4789. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  4790. ParticleEmitter *inst = (ParticleEmitter*)lua_topointer(L, 1);
  4791. luaL_checktype(L, 2, LUA_TBOOLEAN);
  4792. bool val = lua_toboolean(L, 2);
  4793. inst->setAllAtOnce(val);
  4794. return 0;
  4795. }
  4796. static int Polycore_ParticleEmitter_Trigger(lua_State *L) {
  4797. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  4798. ParticleEmitter *inst = (ParticleEmitter*)lua_topointer(L, 1);
  4799. inst->Trigger();
  4800. return 0;
  4801. }
  4802. static int Polycore_ParticleEmitter_resetParticle(lua_State *L) {
  4803. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  4804. ParticleEmitter *inst = (ParticleEmitter*)lua_topointer(L, 1);
  4805. luaL_checktype(L, 2, LUA_TLIGHTUSERDATA);
  4806. Particle* particle = (Particle*)lua_topointer(L, 2);
  4807. inst->resetParticle(particle);
  4808. return 0;
  4809. }
  4810. static int Polycore_ParticleEmitter_setParticleCount(lua_State *L) {
  4811. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  4812. ParticleEmitter *inst = (ParticleEmitter*)lua_topointer(L, 1);
  4813. luaL_checktype(L, 2, LUA_TNUMBER);
  4814. int count = lua_tointeger(L, 2);
  4815. inst->setParticleCount(count);
  4816. return 0;
  4817. }
  4818. static int Polycore_ParticleEmitter_addParticleBody(lua_State *L) {
  4819. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  4820. ParticleEmitter *inst = (ParticleEmitter*)lua_topointer(L, 1);
  4821. luaL_checktype(L, 2, LUA_TLIGHTUSERDATA);
  4822. Entity* particleBody = (Entity*)lua_topointer(L, 2);
  4823. inst->addParticleBody(particleBody);
  4824. return 0;
  4825. }
  4826. static int Polycore_ParticleEmitter_getBaseMatrix(lua_State *L) {
  4827. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  4828. ParticleEmitter *inst = (ParticleEmitter*)lua_topointer(L, 1);
  4829. Matrix4 *retInst = new Matrix4();
  4830. *retInst = inst->getBaseMatrix();
  4831. lua_pushlightuserdata(L, retInst);
  4832. return 1;
  4833. }
  4834. static int Polycore_ParticleEmitter_updateEmitter(lua_State *L) {
  4835. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  4836. ParticleEmitter *inst = (ParticleEmitter*)lua_topointer(L, 1);
  4837. inst->updateEmitter();
  4838. return 0;
  4839. }
  4840. static int Polycore_delete_ParticleEmitter(lua_State *L) {
  4841. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  4842. ParticleEmitter *inst = (ParticleEmitter*)lua_topointer(L, 1);
  4843. delete inst;
  4844. return 0;
  4845. }
  4846. static int Polycore_Perlin(lua_State *L) {
  4847. luaL_checktype(L, 1, LUA_TNUMBER);
  4848. int octaves = lua_tointeger(L, 1);
  4849. luaL_checktype(L, 2, LUA_TNUMBER);
  4850. Number freq = lua_tonumber(L, 2);
  4851. luaL_checktype(L, 3, LUA_TNUMBER);
  4852. Number amp = lua_tonumber(L, 3);
  4853. luaL_checktype(L, 4, LUA_TNUMBER);
  4854. int seed = lua_tointeger(L, 4);
  4855. Perlin *inst = new Perlin(octaves, freq, amp, seed);
  4856. lua_pushlightuserdata(L, (void*)inst);
  4857. return 1;
  4858. }
  4859. static int Polycore_Perlin_Get(lua_State *L) {
  4860. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  4861. Perlin *inst = (Perlin*)lua_topointer(L, 1);
  4862. luaL_checktype(L, 2, LUA_TNUMBER);
  4863. Number x = lua_tonumber(L, 2);
  4864. luaL_checktype(L, 3, LUA_TNUMBER);
  4865. Number y = lua_tonumber(L, 3);
  4866. lua_pushnumber(L, inst->Get(x, y));
  4867. return 1;
  4868. }
  4869. static int Polycore_delete_Perlin(lua_State *L) {
  4870. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  4871. Perlin *inst = (Perlin*)lua_topointer(L, 1);
  4872. delete inst;
  4873. return 0;
  4874. }
  4875. static int Polycore_Polygon_get_useVertexNormals(lua_State *L) {
  4876. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  4877. Polygon *inst = (Polygon*)lua_topointer(L, 1);
  4878. lua_pushboolean(L, inst->useVertexNormals);
  4879. return 1;
  4880. }
  4881. static int Polycore_Polygon_set_useVertexNormals(lua_State *L) {
  4882. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  4883. Polygon *inst = (Polygon*)lua_topointer(L, 1);
  4884. bool param = lua_toboolean(L, 2);
  4885. inst->useVertexNormals = param;
  4886. return 0;
  4887. }
  4888. static int Polycore_Polygon(lua_State *L) {
  4889. Polygon *inst = new Polygon();
  4890. lua_pushlightuserdata(L, (void*)inst);
  4891. return 1;
  4892. }
  4893. static int Polycore_Polygon_getVertexCount(lua_State *L) {
  4894. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  4895. Polygon *inst = (Polygon*)lua_topointer(L, 1);
  4896. lua_pushinteger(L, inst->getVertexCount());
  4897. return 1;
  4898. }
  4899. static int Polycore_Polygon_getVertex(lua_State *L) {
  4900. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  4901. Polygon *inst = (Polygon*)lua_topointer(L, 1);
  4902. luaL_checktype(L, 2, LUA_TNUMBER);
  4903. unsigned int index = lua_tointeger(L, 2);
  4904. void *ptrRetVal = (void*)inst->getVertex(index);
  4905. if(ptrRetVal == NULL) {
  4906. lua_pushnil(L);
  4907. } else {
  4908. lua_pushlightuserdata(L, ptrRetVal);
  4909. }
  4910. return 1;
  4911. }
  4912. static int Polycore_Polygon_addVertex(lua_State *L) {
  4913. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  4914. Polygon *inst = (Polygon*)lua_topointer(L, 1);
  4915. luaL_checktype(L, 2, LUA_TNUMBER);
  4916. Number x = lua_tonumber(L, 2);
  4917. luaL_checktype(L, 3, LUA_TNUMBER);
  4918. Number y = lua_tonumber(L, 3);
  4919. luaL_checktype(L, 4, LUA_TNUMBER);
  4920. Number z = lua_tonumber(L, 4);
  4921. void *ptrRetVal = (void*)inst->addVertex(x, y, z);
  4922. if(ptrRetVal == NULL) {
  4923. lua_pushnil(L);
  4924. } else {
  4925. lua_pushlightuserdata(L, ptrRetVal);
  4926. }
  4927. return 1;
  4928. }
  4929. static int Polycore_Polygon_removeVertex(lua_State *L) {
  4930. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  4931. Polygon *inst = (Polygon*)lua_topointer(L, 1);
  4932. luaL_checktype(L, 2, LUA_TNUMBER);
  4933. int index = lua_tointeger(L, 2);
  4934. inst->removeVertex(index);
  4935. return 0;
  4936. }
  4937. static int Polycore_Polygon_calculateNormal(lua_State *L) {
  4938. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  4939. Polygon *inst = (Polygon*)lua_topointer(L, 1);
  4940. inst->calculateNormal();
  4941. return 0;
  4942. }
  4943. static int Polycore_Polygon_calculateTangent(lua_State *L) {
  4944. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  4945. Polygon *inst = (Polygon*)lua_topointer(L, 1);
  4946. inst->calculateTangent();
  4947. return 0;
  4948. }
  4949. static int Polycore_Polygon_getFaceNormal(lua_State *L) {
  4950. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  4951. Polygon *inst = (Polygon*)lua_topointer(L, 1);
  4952. Vector3 *retInst = new Vector3();
  4953. *retInst = inst->getFaceNormal();
  4954. lua_pushlightuserdata(L, retInst);
  4955. return 1;
  4956. }
  4957. static int Polycore_Polygon_getFaceTangent(lua_State *L) {
  4958. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  4959. Polygon *inst = (Polygon*)lua_topointer(L, 1);
  4960. Vector3 *retInst = new Vector3();
  4961. *retInst = inst->getFaceTangent();
  4962. lua_pushlightuserdata(L, retInst);
  4963. return 1;
  4964. }
  4965. static int Polycore_Polygon_getBounds2D(lua_State *L) {
  4966. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  4967. Polygon *inst = (Polygon*)lua_topointer(L, 1);
  4968. Polycode::Rectangle *retInst = new Polycode::Rectangle();
  4969. *retInst = inst->getBounds2D();
  4970. lua_pushlightuserdata(L, retInst);
  4971. return 1;
  4972. }
  4973. static int Polycore_Polygon_setNormal(lua_State *L) {
  4974. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  4975. Polygon *inst = (Polygon*)lua_topointer(L, 1);
  4976. luaL_checktype(L, 2, LUA_TLIGHTUSERDATA);
  4977. Vector3 normal = *(Vector3*)lua_topointer(L, 2);
  4978. inst->setNormal(normal);
  4979. return 0;
  4980. }
  4981. static int Polycore_Polygon_flipUVY(lua_State *L) {
  4982. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  4983. Polygon *inst = (Polygon*)lua_topointer(L, 1);
  4984. inst->flipUVY();
  4985. return 0;
  4986. }
  4987. static int Polycore_delete_Polygon(lua_State *L) {
  4988. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  4989. Polygon *inst = (Polygon*)lua_topointer(L, 1);
  4990. delete inst;
  4991. return 0;
  4992. }
  4993. static int Polycore_Quaternion_get_x(lua_State *L) {
  4994. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  4995. Quaternion *inst = (Quaternion*)lua_topointer(L, 1);
  4996. lua_pushnumber(L, inst->x);
  4997. return 1;
  4998. }
  4999. static int Polycore_Quaternion_get_y(lua_State *L) {
  5000. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  5001. Quaternion *inst = (Quaternion*)lua_topointer(L, 1);
  5002. lua_pushnumber(L, inst->y);
  5003. return 1;
  5004. }
  5005. static int Polycore_Quaternion_get_z(lua_State *L) {
  5006. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  5007. Quaternion *inst = (Quaternion*)lua_topointer(L, 1);
  5008. lua_pushnumber(L, inst->z);
  5009. return 1;
  5010. }
  5011. static int Polycore_Quaternion_get_w(lua_State *L) {
  5012. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  5013. Quaternion *inst = (Quaternion*)lua_topointer(L, 1);
  5014. lua_pushnumber(L, inst->w);
  5015. return 1;
  5016. }
  5017. static int Polycore_Quaternion_set_x(lua_State *L) {
  5018. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  5019. Quaternion *inst = (Quaternion*)lua_topointer(L, 1);
  5020. Number param = lua_tonumber(L, 2);
  5021. inst->x = param;
  5022. return 0;
  5023. }
  5024. static int Polycore_Quaternion_set_y(lua_State *L) {
  5025. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  5026. Quaternion *inst = (Quaternion*)lua_topointer(L, 1);
  5027. Number param = lua_tonumber(L, 2);
  5028. inst->y = param;
  5029. return 0;
  5030. }
  5031. static int Polycore_Quaternion_set_z(lua_State *L) {
  5032. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  5033. Quaternion *inst = (Quaternion*)lua_topointer(L, 1);
  5034. Number param = lua_tonumber(L, 2);
  5035. inst->z = param;
  5036. return 0;
  5037. }
  5038. static int Polycore_Quaternion_set_w(lua_State *L) {
  5039. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  5040. Quaternion *inst = (Quaternion*)lua_topointer(L, 1);
  5041. Number param = lua_tonumber(L, 2);
  5042. inst->w = param;
  5043. return 0;
  5044. }
  5045. static int Polycore_Quaternion(lua_State *L) {
  5046. luaL_checktype(L, 1, LUA_TNUMBER);
  5047. Number w = lua_tonumber(L, 1);
  5048. luaL_checktype(L, 2, LUA_TNUMBER);
  5049. Number x = lua_tonumber(L, 2);
  5050. luaL_checktype(L, 3, LUA_TNUMBER);
  5051. Number y = lua_tonumber(L, 3);
  5052. luaL_checktype(L, 4, LUA_TNUMBER);
  5053. Number z = lua_tonumber(L, 4);
  5054. Quaternion *inst = new Quaternion(w, x, y, z);
  5055. lua_pushlightuserdata(L, (void*)inst);
  5056. return 1;
  5057. }
  5058. static int Polycore_Quaternion_setFromMatrix(lua_State *L) {
  5059. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  5060. Quaternion *inst = (Quaternion*)lua_topointer(L, 1);
  5061. luaL_checktype(L, 2, LUA_TLIGHTUSERDATA);
  5062. Matrix4 _mat = *(Matrix4*)lua_topointer(L, 2);
  5063. inst->setFromMatrix(_mat);
  5064. return 0;
  5065. }
  5066. static int Polycore_Quaternion_Slerp(lua_State *L) {
  5067. luaL_checktype(L, 2, LUA_TNUMBER);
  5068. Number fT = lua_tonumber(L, 2);
  5069. luaL_checktype(L, 3, LUA_TLIGHTUSERDATA);
  5070. Quaternion rkP = *(Quaternion*)lua_topointer(L, 3);
  5071. luaL_checktype(L, 4, LUA_TLIGHTUSERDATA);
  5072. Quaternion rkQ = *(Quaternion*)lua_topointer(L, 4);
  5073. bool shortestPath;
  5074. if(lua_isboolean(L, 5)) {
  5075. shortestPath = lua_toboolean(L, 5);
  5076. } else {
  5077. shortestPath = false;
  5078. }
  5079. Quaternion *retInst = new Quaternion();
  5080. *retInst = Quaternion::Slerp(fT, rkP, rkQ, shortestPath);
  5081. lua_pushlightuserdata(L, retInst);
  5082. return 1;
  5083. }
  5084. static int Polycore_Quaternion_Dot(lua_State *L) {
  5085. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  5086. Quaternion *inst = (Quaternion*)lua_topointer(L, 1);
  5087. luaL_checktype(L, 2, LUA_TLIGHTUSERDATA);
  5088. Quaternion rkQ = *(Quaternion*)lua_topointer(L, 2);
  5089. lua_pushnumber(L, inst->Dot(rkQ));
  5090. return 1;
  5091. }
  5092. static int Polycore_Quaternion_Log(lua_State *L) {
  5093. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  5094. Quaternion *inst = (Quaternion*)lua_topointer(L, 1);
  5095. Quaternion *retInst = new Quaternion();
  5096. *retInst = inst->Log();
  5097. lua_pushlightuserdata(L, retInst);
  5098. return 1;
  5099. }
  5100. static int Polycore_Quaternion_Exp(lua_State *L) {
  5101. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  5102. Quaternion *inst = (Quaternion*)lua_topointer(L, 1);
  5103. Quaternion *retInst = new Quaternion();
  5104. *retInst = inst->Exp();
  5105. lua_pushlightuserdata(L, retInst);
  5106. return 1;
  5107. }
  5108. static int Polycore_Quaternion_Norm(lua_State *L) {
  5109. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  5110. Quaternion *inst = (Quaternion*)lua_topointer(L, 1);
  5111. lua_pushnumber(L, inst->Norm());
  5112. return 1;
  5113. }
  5114. static int Polycore_Quaternion_normalize(lua_State *L) {
  5115. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  5116. Quaternion *inst = (Quaternion*)lua_topointer(L, 1);
  5117. lua_pushnumber(L, inst->normalize());
  5118. return 1;
  5119. }
  5120. static int Polycore_Quaternion_lookAt(lua_State *L) {
  5121. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  5122. Quaternion *inst = (Quaternion*)lua_topointer(L, 1);
  5123. luaL_checktype(L, 2, LUA_TLIGHTUSERDATA);
  5124. Vector3 D = *(Vector3*)lua_topointer(L, 2);
  5125. luaL_checktype(L, 3, LUA_TLIGHTUSERDATA);
  5126. Vector3 upVector = *(Vector3*)lua_topointer(L, 3);
  5127. inst->lookAt(D, upVector);
  5128. return 0;
  5129. }
  5130. static int Polycore_Quaternion_createFromMatrix(lua_State *L) {
  5131. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  5132. Quaternion *inst = (Quaternion*)lua_topointer(L, 1);
  5133. luaL_checktype(L, 2, LUA_TLIGHTUSERDATA);
  5134. Matrix4 matrix = *(Matrix4*)lua_topointer(L, 2);
  5135. inst->createFromMatrix(matrix);
  5136. return 0;
  5137. }
  5138. static int Polycore_Quaternion_Squad(lua_State *L) {
  5139. luaL_checktype(L, 2, LUA_TNUMBER);
  5140. Number fT = lua_tonumber(L, 2);
  5141. luaL_checktype(L, 3, LUA_TLIGHTUSERDATA);
  5142. Quaternion rkP = *(Quaternion*)lua_topointer(L, 3);
  5143. luaL_checktype(L, 4, LUA_TLIGHTUSERDATA);
  5144. Quaternion rkA = *(Quaternion*)lua_topointer(L, 4);
  5145. luaL_checktype(L, 5, LUA_TLIGHTUSERDATA);
  5146. Quaternion rkB = *(Quaternion*)lua_topointer(L, 5);
  5147. luaL_checktype(L, 6, LUA_TLIGHTUSERDATA);
  5148. Quaternion rkQ = *(Quaternion*)lua_topointer(L, 6);
  5149. luaL_checktype(L, 7, LUA_TBOOLEAN);
  5150. bool shortestPath = lua_toboolean(L, 7);
  5151. Quaternion *retInst = new Quaternion();
  5152. *retInst = Quaternion::Squad(fT, rkP, rkA, rkB, rkQ, shortestPath);
  5153. lua_pushlightuserdata(L, retInst);
  5154. return 1;
  5155. }
  5156. static int Polycore_Quaternion_Inverse(lua_State *L) {
  5157. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  5158. Quaternion *inst = (Quaternion*)lua_topointer(L, 1);
  5159. Quaternion *retInst = new Quaternion();
  5160. *retInst = inst->Inverse();
  5161. lua_pushlightuserdata(L, retInst);
  5162. return 1;
  5163. }
  5164. static int Polycore_Quaternion_set(lua_State *L) {
  5165. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  5166. Quaternion *inst = (Quaternion*)lua_topointer(L, 1);
  5167. luaL_checktype(L, 2, LUA_TNUMBER);
  5168. Number w = lua_tonumber(L, 2);
  5169. luaL_checktype(L, 3, LUA_TNUMBER);
  5170. Number x = lua_tonumber(L, 3);
  5171. luaL_checktype(L, 4, LUA_TNUMBER);
  5172. Number y = lua_tonumber(L, 4);
  5173. luaL_checktype(L, 5, LUA_TNUMBER);
  5174. Number z = lua_tonumber(L, 5);
  5175. inst->set(w, x, y, z);
  5176. return 0;
  5177. }
  5178. static int Polycore_Quaternion_inverse(lua_State *L) {
  5179. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  5180. Quaternion *inst = (Quaternion*)lua_topointer(L, 1);
  5181. Quaternion *retInst = new Quaternion();
  5182. *retInst = inst->inverse();
  5183. lua_pushlightuserdata(L, retInst);
  5184. return 1;
  5185. }
  5186. static int Polycore_Quaternion_InvSqrt(lua_State *L) {
  5187. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  5188. Quaternion *inst = (Quaternion*)lua_topointer(L, 1);
  5189. luaL_checktype(L, 2, LUA_TNUMBER);
  5190. Number x = lua_tonumber(L, 2);
  5191. lua_pushnumber(L, inst->InvSqrt(x));
  5192. return 1;
  5193. }
  5194. static int Polycore_Quaternion_fromAxes(lua_State *L) {
  5195. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  5196. Quaternion *inst = (Quaternion*)lua_topointer(L, 1);
  5197. luaL_checktype(L, 2, LUA_TNUMBER);
  5198. Number az = lua_tonumber(L, 2);
  5199. luaL_checktype(L, 3, LUA_TNUMBER);
  5200. Number ay = lua_tonumber(L, 3);
  5201. luaL_checktype(L, 4, LUA_TNUMBER);
  5202. Number ax = lua_tonumber(L, 4);
  5203. inst->fromAxes(az, ay, ax);
  5204. return 0;
  5205. }
  5206. static int Polycore_Quaternion_FromAngleAxis(lua_State *L) {
  5207. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  5208. Quaternion *inst = (Quaternion*)lua_topointer(L, 1);
  5209. luaL_checktype(L, 2, LUA_TNUMBER);
  5210. Number rfAngle = lua_tonumber(L, 2);
  5211. luaL_checktype(L, 3, LUA_TLIGHTUSERDATA);
  5212. Vector3 rkAxis = *(Vector3*)lua_topointer(L, 3);
  5213. inst->FromAngleAxis(rfAngle, rkAxis);
  5214. return 0;
  5215. }
  5216. static int Polycore_Quaternion_ToAngleAxis(lua_State *L) {
  5217. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  5218. Quaternion *inst = (Quaternion*)lua_topointer(L, 1);
  5219. luaL_checktype(L, 2, LUA_TNUMBER);
  5220. Number rfAngle = lua_tonumber(L, 2);
  5221. luaL_checktype(L, 3, LUA_TLIGHTUSERDATA);
  5222. Vector3 rkAxis = *(Vector3*)lua_topointer(L, 3);
  5223. inst->ToAngleAxis(rfAngle, rkAxis);
  5224. return 0;
  5225. }
  5226. static int Polycore_Quaternion_createFromAxisAngle(lua_State *L) {
  5227. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  5228. Quaternion *inst = (Quaternion*)lua_topointer(L, 1);
  5229. luaL_checktype(L, 2, LUA_TNUMBER);
  5230. Number x = lua_tonumber(L, 2);
  5231. luaL_checktype(L, 3, LUA_TNUMBER);
  5232. Number y = lua_tonumber(L, 3);
  5233. luaL_checktype(L, 4, LUA_TNUMBER);
  5234. Number z = lua_tonumber(L, 4);
  5235. luaL_checktype(L, 5, LUA_TNUMBER);
  5236. Number degrees = lua_tonumber(L, 5);
  5237. inst->createFromAxisAngle(x, y, z, degrees);
  5238. return 0;
  5239. }
  5240. static int Polycore_Quaternion_createMatrix(lua_State *L) {
  5241. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  5242. Quaternion *inst = (Quaternion*)lua_topointer(L, 1);
  5243. Matrix4 *retInst = new Matrix4();
  5244. *retInst = inst->createMatrix();
  5245. lua_pushlightuserdata(L, retInst);
  5246. return 1;
  5247. }
  5248. static int Polycore_delete_Quaternion(lua_State *L) {
  5249. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  5250. Quaternion *inst = (Quaternion*)lua_topointer(L, 1);
  5251. delete inst;
  5252. return 0;
  5253. }
  5254. static int Polycore_QuaternionCurve(lua_State *L) {
  5255. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  5256. BezierCurve* wCurve = (BezierCurve*)lua_topointer(L, 1);
  5257. luaL_checktype(L, 2, LUA_TLIGHTUSERDATA);
  5258. BezierCurve* xCurve = (BezierCurve*)lua_topointer(L, 2);
  5259. luaL_checktype(L, 3, LUA_TLIGHTUSERDATA);
  5260. BezierCurve* yCurve = (BezierCurve*)lua_topointer(L, 3);
  5261. luaL_checktype(L, 4, LUA_TLIGHTUSERDATA);
  5262. BezierCurve* zCurve = (BezierCurve*)lua_topointer(L, 4);
  5263. QuaternionCurve *inst = new QuaternionCurve(wCurve, xCurve, yCurve, zCurve);
  5264. lua_pushlightuserdata(L, (void*)inst);
  5265. return 1;
  5266. }
  5267. static int Polycore_QuaternionCurve_interpolate(lua_State *L) {
  5268. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  5269. QuaternionCurve *inst = (QuaternionCurve*)lua_topointer(L, 1);
  5270. luaL_checktype(L, 2, LUA_TNUMBER);
  5271. Number t = lua_tonumber(L, 2);
  5272. luaL_checktype(L, 3, LUA_TBOOLEAN);
  5273. bool useShortestPath = lua_toboolean(L, 3);
  5274. Quaternion *retInst = new Quaternion();
  5275. *retInst = inst->interpolate(t, useShortestPath);
  5276. lua_pushlightuserdata(L, retInst);
  5277. return 1;
  5278. }
  5279. static int Polycore_QuaternionCurve_generatePointsFromCurves(lua_State *L) {
  5280. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  5281. QuaternionCurve *inst = (QuaternionCurve*)lua_topointer(L, 1);
  5282. luaL_checktype(L, 2, LUA_TLIGHTUSERDATA);
  5283. BezierCurve* wCurve = (BezierCurve*)lua_topointer(L, 2);
  5284. luaL_checktype(L, 3, LUA_TLIGHTUSERDATA);
  5285. BezierCurve* xCurve = (BezierCurve*)lua_topointer(L, 3);
  5286. luaL_checktype(L, 4, LUA_TLIGHTUSERDATA);
  5287. BezierCurve* yCurve = (BezierCurve*)lua_topointer(L, 4);
  5288. luaL_checktype(L, 5, LUA_TLIGHTUSERDATA);
  5289. BezierCurve* zCurve = (BezierCurve*)lua_topointer(L, 5);
  5290. inst->generatePointsFromCurves(wCurve, xCurve, yCurve, zCurve);
  5291. return 0;
  5292. }
  5293. static int Polycore_QuaternionCurve_recalcTangents(lua_State *L) {
  5294. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  5295. QuaternionCurve *inst = (QuaternionCurve*)lua_topointer(L, 1);
  5296. inst->recalcTangents();
  5297. return 0;
  5298. }
  5299. static int Polycore_delete_QuaternionCurve(lua_State *L) {
  5300. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  5301. QuaternionCurve *inst = (QuaternionCurve*)lua_topointer(L, 1);
  5302. delete inst;
  5303. return 0;
  5304. }
  5305. static int Polycore_Rectangle_get_x(lua_State *L) {
  5306. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  5307. Rectangle *inst = (Rectangle*)lua_topointer(L, 1);
  5308. lua_pushnumber(L, inst->x);
  5309. return 1;
  5310. }
  5311. static int Polycore_Rectangle_get_y(lua_State *L) {
  5312. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  5313. Rectangle *inst = (Rectangle*)lua_topointer(L, 1);
  5314. lua_pushnumber(L, inst->y);
  5315. return 1;
  5316. }
  5317. static int Polycore_Rectangle_get_w(lua_State *L) {
  5318. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  5319. Rectangle *inst = (Rectangle*)lua_topointer(L, 1);
  5320. lua_pushnumber(L, inst->w);
  5321. return 1;
  5322. }
  5323. static int Polycore_Rectangle_get_h(lua_State *L) {
  5324. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  5325. Rectangle *inst = (Rectangle*)lua_topointer(L, 1);
  5326. lua_pushnumber(L, inst->h);
  5327. return 1;
  5328. }
  5329. static int Polycore_Rectangle_set_x(lua_State *L) {
  5330. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  5331. Rectangle *inst = (Rectangle*)lua_topointer(L, 1);
  5332. Number param = lua_tonumber(L, 2);
  5333. inst->x = param;
  5334. return 0;
  5335. }
  5336. static int Polycore_Rectangle_set_y(lua_State *L) {
  5337. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  5338. Rectangle *inst = (Rectangle*)lua_topointer(L, 1);
  5339. Number param = lua_tonumber(L, 2);
  5340. inst->y = param;
  5341. return 0;
  5342. }
  5343. static int Polycore_Rectangle_set_w(lua_State *L) {
  5344. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  5345. Rectangle *inst = (Rectangle*)lua_topointer(L, 1);
  5346. Number param = lua_tonumber(L, 2);
  5347. inst->w = param;
  5348. return 0;
  5349. }
  5350. static int Polycore_Rectangle_set_h(lua_State *L) {
  5351. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  5352. Rectangle *inst = (Rectangle*)lua_topointer(L, 1);
  5353. Number param = lua_tonumber(L, 2);
  5354. inst->h = param;
  5355. return 0;
  5356. }
  5357. static int Polycore_Rectangle(lua_State *L) {
  5358. Rectangle *inst = new Rectangle();
  5359. lua_pushlightuserdata(L, (void*)inst);
  5360. return 1;
  5361. }
  5362. static int Polycore_Rectangle_setRect(lua_State *L) {
  5363. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  5364. Rectangle *inst = (Rectangle*)lua_topointer(L, 1);
  5365. luaL_checktype(L, 2, LUA_TNUMBER);
  5366. Number x = lua_tonumber(L, 2);
  5367. luaL_checktype(L, 3, LUA_TNUMBER);
  5368. Number y = lua_tonumber(L, 3);
  5369. luaL_checktype(L, 4, LUA_TNUMBER);
  5370. Number w = lua_tonumber(L, 4);
  5371. luaL_checktype(L, 5, LUA_TNUMBER);
  5372. Number h = lua_tonumber(L, 5);
  5373. inst->setRect(x, y, w, h);
  5374. return 0;
  5375. }
  5376. static int Polycore_delete_Rectangle(lua_State *L) {
  5377. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  5378. Rectangle *inst = (Rectangle*)lua_topointer(L, 1);
  5379. delete inst;
  5380. return 0;
  5381. }
  5382. static int Polycore_Renderer_get_ambientColor(lua_State *L) {
  5383. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  5384. Renderer *inst = (Renderer*)lua_topointer(L, 1);
  5385. lua_pushlightuserdata(L, &inst->ambientColor);
  5386. return 1;
  5387. }
  5388. static int Polycore_Renderer_get_clearColor(lua_State *L) {
  5389. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  5390. Renderer *inst = (Renderer*)lua_topointer(L, 1);
  5391. lua_pushlightuserdata(L, &inst->clearColor);
  5392. return 1;
  5393. }
  5394. static int Polycore_Renderer_get_exposureLevel(lua_State *L) {
  5395. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  5396. Renderer *inst = (Renderer*)lua_topointer(L, 1);
  5397. lua_pushnumber(L, inst->exposureLevel);
  5398. return 1;
  5399. }
  5400. static int Polycore_Renderer_get_cameraPosition(lua_State *L) {
  5401. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  5402. Renderer *inst = (Renderer*)lua_topointer(L, 1);
  5403. lua_pushlightuserdata(L, &inst->cameraPosition);
  5404. return 1;
  5405. }
  5406. static int Polycore_Renderer_set_exposureLevel(lua_State *L) {
  5407. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  5408. Renderer *inst = (Renderer*)lua_topointer(L, 1);
  5409. Number param = lua_tonumber(L, 2);
  5410. inst->exposureLevel = param;
  5411. return 0;
  5412. }
  5413. static int Polycore_Renderer_Resize(lua_State *L) {
  5414. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  5415. Renderer *inst = (Renderer*)lua_topointer(L, 1);
  5416. luaL_checktype(L, 2, LUA_TNUMBER);
  5417. int xRes = lua_tointeger(L, 2);
  5418. luaL_checktype(L, 3, LUA_TNUMBER);
  5419. int yRes = lua_tointeger(L, 3);
  5420. inst->Resize(xRes, yRes);
  5421. return 0;
  5422. }
  5423. static int Polycore_Renderer_BeginRender(lua_State *L) {
  5424. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  5425. Renderer *inst = (Renderer*)lua_topointer(L, 1);
  5426. inst->BeginRender();
  5427. return 0;
  5428. }
  5429. static int Polycore_Renderer_EndRender(lua_State *L) {
  5430. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  5431. Renderer *inst = (Renderer*)lua_topointer(L, 1);
  5432. inst->EndRender();
  5433. return 0;
  5434. }
  5435. static int Polycore_Renderer_createCubemap(lua_State *L) {
  5436. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  5437. Renderer *inst = (Renderer*)lua_topointer(L, 1);
  5438. luaL_checktype(L, 2, LUA_TLIGHTUSERDATA);
  5439. Texture* t0 = (Texture*)lua_topointer(L, 2);
  5440. luaL_checktype(L, 3, LUA_TLIGHTUSERDATA);
  5441. Texture* t1 = (Texture*)lua_topointer(L, 3);
  5442. luaL_checktype(L, 4, LUA_TLIGHTUSERDATA);
  5443. Texture* t2 = (Texture*)lua_topointer(L, 4);
  5444. luaL_checktype(L, 5, LUA_TLIGHTUSERDATA);
  5445. Texture* t3 = (Texture*)lua_topointer(L, 5);
  5446. luaL_checktype(L, 6, LUA_TLIGHTUSERDATA);
  5447. Texture* t4 = (Texture*)lua_topointer(L, 6);
  5448. luaL_checktype(L, 7, LUA_TLIGHTUSERDATA);
  5449. Texture* t5 = (Texture*)lua_topointer(L, 7);
  5450. void *ptrRetVal = (void*)inst->createCubemap(t0, t1, t2, t3, t4, t5);
  5451. if(ptrRetVal == NULL) {
  5452. lua_pushnil(L);
  5453. } else {
  5454. lua_pushlightuserdata(L, ptrRetVal);
  5455. }
  5456. return 1;
  5457. }
  5458. static int Polycore_Renderer_createTexture(lua_State *L) {
  5459. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  5460. Renderer *inst = (Renderer*)lua_topointer(L, 1);
  5461. luaL_checktype(L, 2, LUA_TNUMBER);
  5462. unsigned int width = lua_tointeger(L, 2);
  5463. luaL_checktype(L, 3, LUA_TNUMBER);
  5464. unsigned int height = lua_tointeger(L, 3);
  5465. luaL_checktype(L, 4, LUA_TLIGHTUSERDATA);
  5466. char* textureData = (char*)lua_topointer(L, 4);
  5467. luaL_checktype(L, 5, LUA_TBOOLEAN);
  5468. bool clamp = lua_toboolean(L, 5);
  5469. int type;
  5470. if(lua_isnumber(L, 6)) {
  5471. type = lua_tointeger(L, 6);
  5472. } else {
  5473. type = Image :: IMAGE_RGBA;
  5474. }
  5475. void *ptrRetVal = (void*)inst->createTexture(width, height, textureData, clamp, type);
  5476. if(ptrRetVal == NULL) {
  5477. lua_pushnil(L);
  5478. } else {
  5479. lua_pushlightuserdata(L, ptrRetVal);
  5480. }
  5481. return 1;
  5482. }
  5483. static int Polycore_Renderer_destroyTexture(lua_State *L) {
  5484. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  5485. Renderer *inst = (Renderer*)lua_topointer(L, 1);
  5486. luaL_checktype(L, 2, LUA_TLIGHTUSERDATA);
  5487. Texture* texture = (Texture*)lua_topointer(L, 2);
  5488. inst->destroyTexture(texture);
  5489. return 0;
  5490. }
  5491. static int Polycore_Renderer_createRenderTextures(lua_State *L) {
  5492. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  5493. Renderer *inst = (Renderer*)lua_topointer(L, 1);
  5494. luaL_checktype(L, 2, LUA_TLIGHTUSERDATA);
  5495. Texture** colorBuffer = (Texture**)lua_topointer(L, 2);
  5496. luaL_checktype(L, 3, LUA_TLIGHTUSERDATA);
  5497. Texture** depthBuffer = (Texture**)lua_topointer(L, 3);
  5498. luaL_checktype(L, 4, LUA_TNUMBER);
  5499. int width = lua_tointeger(L, 4);
  5500. luaL_checktype(L, 5, LUA_TNUMBER);
  5501. int height = lua_tointeger(L, 5);
  5502. inst->createRenderTextures(colorBuffer, depthBuffer, width, height);
  5503. return 0;
  5504. }
  5505. static int Polycore_Renderer_createFramebufferTexture(lua_State *L) {
  5506. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  5507. Renderer *inst = (Renderer*)lua_topointer(L, 1);
  5508. luaL_checktype(L, 2, LUA_TNUMBER);
  5509. unsigned int width = lua_tointeger(L, 2);
  5510. luaL_checktype(L, 3, LUA_TNUMBER);
  5511. unsigned int height = lua_tointeger(L, 3);
  5512. void *ptrRetVal = (void*)inst->createFramebufferTexture(width, height);
  5513. if(ptrRetVal == NULL) {
  5514. lua_pushnil(L);
  5515. } else {
  5516. lua_pushlightuserdata(L, ptrRetVal);
  5517. }
  5518. return 1;
  5519. }
  5520. static int Polycore_Renderer_bindFrameBufferTexture(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. Texture* texture = (Texture*)lua_topointer(L, 2);
  5525. inst->bindFrameBufferTexture(texture);
  5526. return 0;
  5527. }
  5528. static int Polycore_Renderer_unbindFramebuffers(lua_State *L) {
  5529. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  5530. Renderer *inst = (Renderer*)lua_topointer(L, 1);
  5531. inst->unbindFramebuffers();
  5532. return 0;
  5533. }
  5534. static int Polycore_Renderer_renderToTexture(lua_State *L) {
  5535. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  5536. Renderer *inst = (Renderer*)lua_topointer(L, 1);
  5537. luaL_checktype(L, 2, LUA_TLIGHTUSERDATA);
  5538. Texture* targetTexture = (Texture*)lua_topointer(L, 2);
  5539. inst->renderToTexture(targetTexture);
  5540. return 0;
  5541. }
  5542. static int Polycore_Renderer_renderZBufferToTexture(lua_State *L) {
  5543. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  5544. Renderer *inst = (Renderer*)lua_topointer(L, 1);
  5545. luaL_checktype(L, 2, LUA_TLIGHTUSERDATA);
  5546. Texture* targetTexture = (Texture*)lua_topointer(L, 2);
  5547. inst->renderZBufferToTexture(targetTexture);
  5548. return 0;
  5549. }
  5550. static int Polycore_Renderer_setFOV(lua_State *L) {
  5551. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  5552. Renderer *inst = (Renderer*)lua_topointer(L, 1);
  5553. luaL_checktype(L, 2, LUA_TNUMBER);
  5554. Number fov = lua_tonumber(L, 2);
  5555. inst->setFOV(fov);
  5556. return 0;
  5557. }
  5558. static int Polycore_Renderer_setViewportSize(lua_State *L) {
  5559. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  5560. Renderer *inst = (Renderer*)lua_topointer(L, 1);
  5561. luaL_checktype(L, 2, LUA_TNUMBER);
  5562. int w = lua_tointeger(L, 2);
  5563. luaL_checktype(L, 3, LUA_TNUMBER);
  5564. int h = lua_tointeger(L, 3);
  5565. inst->setViewportSize(w, h);
  5566. return 0;
  5567. }
  5568. static int Polycore_Renderer_setViewportSizeAndFOV(lua_State *L) {
  5569. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  5570. Renderer *inst = (Renderer*)lua_topointer(L, 1);
  5571. luaL_checktype(L, 2, LUA_TNUMBER);
  5572. int w = lua_tointeger(L, 2);
  5573. luaL_checktype(L, 3, LUA_TNUMBER);
  5574. int h = lua_tointeger(L, 3);
  5575. luaL_checktype(L, 4, LUA_TNUMBER);
  5576. Number fov = lua_tonumber(L, 4);
  5577. inst->setViewportSizeAndFOV(w, h, fov);
  5578. return 0;
  5579. }
  5580. static int Polycore_Renderer_resetViewport(lua_State *L) {
  5581. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  5582. Renderer *inst = (Renderer*)lua_topointer(L, 1);
  5583. inst->resetViewport();
  5584. return 0;
  5585. }
  5586. static int Polycore_Renderer_loadIdentity(lua_State *L) {
  5587. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  5588. Renderer *inst = (Renderer*)lua_topointer(L, 1);
  5589. inst->loadIdentity();
  5590. return 0;
  5591. }
  5592. static int Polycore_Renderer_setOrthoMode(lua_State *L) {
  5593. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  5594. Renderer *inst = (Renderer*)lua_topointer(L, 1);
  5595. Number xSize;
  5596. if(lua_isnumber(L, 2)) {
  5597. xSize = lua_tonumber(L, 2);
  5598. } else {
  5599. xSize = 0.0f;
  5600. }
  5601. Number ySize;
  5602. if(lua_isnumber(L, 3)) {
  5603. ySize = lua_tonumber(L, 3);
  5604. } else {
  5605. ySize = 0.0f;
  5606. }
  5607. inst->setOrthoMode(xSize, ySize);
  5608. return 0;
  5609. }
  5610. static int Polycore_Renderer__setOrthoMode(lua_State *L) {
  5611. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  5612. Renderer *inst = (Renderer*)lua_topointer(L, 1);
  5613. inst->_setOrthoMode();
  5614. return 0;
  5615. }
  5616. static int Polycore_Renderer_setPerspectiveMode(lua_State *L) {
  5617. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  5618. Renderer *inst = (Renderer*)lua_topointer(L, 1);
  5619. inst->setPerspectiveMode();
  5620. return 0;
  5621. }
  5622. static int Polycore_Renderer_setTexture(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. Texture* texture = (Texture*)lua_topointer(L, 2);
  5627. inst->setTexture(texture);
  5628. return 0;
  5629. }
  5630. static int Polycore_Renderer_enableBackfaceCulling(lua_State *L) {
  5631. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  5632. Renderer *inst = (Renderer*)lua_topointer(L, 1);
  5633. luaL_checktype(L, 2, LUA_TBOOLEAN);
  5634. bool val = lua_toboolean(L, 2);
  5635. inst->enableBackfaceCulling(val);
  5636. return 0;
  5637. }
  5638. static int Polycore_Renderer_setClearColor(lua_State *L) {
  5639. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  5640. Renderer *inst = (Renderer*)lua_topointer(L, 1);
  5641. luaL_checktype(L, 2, LUA_TNUMBER);
  5642. Number r = lua_tonumber(L, 2);
  5643. luaL_checktype(L, 3, LUA_TNUMBER);
  5644. Number g = lua_tonumber(L, 3);
  5645. luaL_checktype(L, 4, LUA_TNUMBER);
  5646. Number b = lua_tonumber(L, 4);
  5647. inst->setClearColor(r, g, b);
  5648. return 0;
  5649. }
  5650. static int Polycore_Renderer_setAmbientColor(lua_State *L) {
  5651. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  5652. Renderer *inst = (Renderer*)lua_topointer(L, 1);
  5653. luaL_checktype(L, 2, LUA_TNUMBER);
  5654. Number r = lua_tonumber(L, 2);
  5655. luaL_checktype(L, 3, LUA_TNUMBER);
  5656. Number g = lua_tonumber(L, 3);
  5657. luaL_checktype(L, 4, LUA_TNUMBER);
  5658. Number b = lua_tonumber(L, 4);
  5659. inst->setAmbientColor(r, g, b);
  5660. return 0;
  5661. }
  5662. static int Polycore_Renderer_clearScreen(lua_State *L) {
  5663. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  5664. Renderer *inst = (Renderer*)lua_topointer(L, 1);
  5665. inst->clearScreen();
  5666. return 0;
  5667. }
  5668. static int Polycore_Renderer_translate2D(lua_State *L) {
  5669. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  5670. Renderer *inst = (Renderer*)lua_topointer(L, 1);
  5671. luaL_checktype(L, 2, LUA_TNUMBER);
  5672. Number x = lua_tonumber(L, 2);
  5673. luaL_checktype(L, 3, LUA_TNUMBER);
  5674. Number y = lua_tonumber(L, 3);
  5675. inst->translate2D(x, y);
  5676. return 0;
  5677. }
  5678. static int Polycore_Renderer_rotate2D(lua_State *L) {
  5679. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  5680. Renderer *inst = (Renderer*)lua_topointer(L, 1);
  5681. luaL_checktype(L, 2, LUA_TNUMBER);
  5682. Number angle = lua_tonumber(L, 2);
  5683. inst->rotate2D(angle);
  5684. return 0;
  5685. }
  5686. static int Polycore_Renderer_scale2D(lua_State *L) {
  5687. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  5688. Renderer *inst = (Renderer*)lua_topointer(L, 1);
  5689. luaL_checktype(L, 2, LUA_TLIGHTUSERDATA);
  5690. Vector2* scale = (Vector2*)lua_topointer(L, 2);
  5691. inst->scale2D(scale);
  5692. return 0;
  5693. }
  5694. static int Polycore_Renderer_setVertexColor(lua_State *L) {
  5695. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  5696. Renderer *inst = (Renderer*)lua_topointer(L, 1);
  5697. luaL_checktype(L, 2, LUA_TNUMBER);
  5698. Number r = lua_tonumber(L, 2);
  5699. luaL_checktype(L, 3, LUA_TNUMBER);
  5700. Number g = lua_tonumber(L, 3);
  5701. luaL_checktype(L, 4, LUA_TNUMBER);
  5702. Number b = lua_tonumber(L, 4);
  5703. luaL_checktype(L, 5, LUA_TNUMBER);
  5704. Number a = lua_tonumber(L, 5);
  5705. inst->setVertexColor(r, g, b, a);
  5706. return 0;
  5707. }
  5708. static int Polycore_Renderer_pushDataArrayForMesh(lua_State *L) {
  5709. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  5710. Renderer *inst = (Renderer*)lua_topointer(L, 1);
  5711. luaL_checktype(L, 2, LUA_TLIGHTUSERDATA);
  5712. Mesh* mesh = (Mesh*)lua_topointer(L, 2);
  5713. luaL_checktype(L, 3, LUA_TNUMBER);
  5714. int arrayType = lua_tointeger(L, 3);
  5715. inst->pushDataArrayForMesh(mesh, arrayType);
  5716. return 0;
  5717. }
  5718. static int Polycore_Renderer_pushRenderDataArray(lua_State *L) {
  5719. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  5720. Renderer *inst = (Renderer*)lua_topointer(L, 1);
  5721. luaL_checktype(L, 2, LUA_TLIGHTUSERDATA);
  5722. RenderDataArray* array = (RenderDataArray*)lua_topointer(L, 2);
  5723. inst->pushRenderDataArray(array);
  5724. return 0;
  5725. }
  5726. static int Polycore_Renderer_createRenderDataArrayForMesh(lua_State *L) {
  5727. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  5728. Renderer *inst = (Renderer*)lua_topointer(L, 1);
  5729. luaL_checktype(L, 2, LUA_TLIGHTUSERDATA);
  5730. Mesh* mesh = (Mesh*)lua_topointer(L, 2);
  5731. luaL_checktype(L, 3, LUA_TNUMBER);
  5732. int arrayType = lua_tointeger(L, 3);
  5733. void *ptrRetVal = (void*)inst->createRenderDataArrayForMesh(mesh, arrayType);
  5734. if(ptrRetVal == NULL) {
  5735. lua_pushnil(L);
  5736. } else {
  5737. lua_pushlightuserdata(L, ptrRetVal);
  5738. }
  5739. return 1;
  5740. }
  5741. static int Polycore_Renderer_createRenderDataArray(lua_State *L) {
  5742. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  5743. Renderer *inst = (Renderer*)lua_topointer(L, 1);
  5744. luaL_checktype(L, 2, LUA_TNUMBER);
  5745. int arrayType = lua_tointeger(L, 2);
  5746. void *ptrRetVal = (void*)inst->createRenderDataArray(arrayType);
  5747. if(ptrRetVal == NULL) {
  5748. lua_pushnil(L);
  5749. } else {
  5750. lua_pushlightuserdata(L, ptrRetVal);
  5751. }
  5752. return 1;
  5753. }
  5754. static int Polycore_Renderer_setRenderArrayData(lua_State *L) {
  5755. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  5756. Renderer *inst = (Renderer*)lua_topointer(L, 1);
  5757. luaL_checktype(L, 2, LUA_TLIGHTUSERDATA);
  5758. RenderDataArray* array = (RenderDataArray*)lua_topointer(L, 2);
  5759. luaL_checktype(L, 3, LUA_TLIGHTUSERDATA);
  5760. Number* arrayData = (Number*)lua_topointer(L, 3);
  5761. inst->setRenderArrayData(array, arrayData);
  5762. return 0;
  5763. }
  5764. static int Polycore_Renderer_drawArrays(lua_State *L) {
  5765. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  5766. Renderer *inst = (Renderer*)lua_topointer(L, 1);
  5767. luaL_checktype(L, 2, LUA_TNUMBER);
  5768. int drawType = lua_tointeger(L, 2);
  5769. inst->drawArrays(drawType);
  5770. return 0;
  5771. }
  5772. static int Polycore_Renderer_translate3D(lua_State *L) {
  5773. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  5774. Renderer *inst = (Renderer*)lua_topointer(L, 1);
  5775. luaL_checktype(L, 2, LUA_TLIGHTUSERDATA);
  5776. Vector3* position = (Vector3*)lua_topointer(L, 2);
  5777. inst->translate3D(position);
  5778. return 0;
  5779. }
  5780. static int Polycore_Renderer_scale3D(lua_State *L) {
  5781. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  5782. Renderer *inst = (Renderer*)lua_topointer(L, 1);
  5783. luaL_checktype(L, 2, LUA_TLIGHTUSERDATA);
  5784. Vector3* scale = (Vector3*)lua_topointer(L, 2);
  5785. inst->scale3D(scale);
  5786. return 0;
  5787. }
  5788. static int Polycore_Renderer_pushMatrix(lua_State *L) {
  5789. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  5790. Renderer *inst = (Renderer*)lua_topointer(L, 1);
  5791. inst->pushMatrix();
  5792. return 0;
  5793. }
  5794. static int Polycore_Renderer_popMatrix(lua_State *L) {
  5795. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  5796. Renderer *inst = (Renderer*)lua_topointer(L, 1);
  5797. inst->popMatrix();
  5798. return 0;
  5799. }
  5800. static int Polycore_Renderer_setLineSmooth(lua_State *L) {
  5801. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  5802. Renderer *inst = (Renderer*)lua_topointer(L, 1);
  5803. luaL_checktype(L, 2, LUA_TBOOLEAN);
  5804. bool val = lua_toboolean(L, 2);
  5805. inst->setLineSmooth(val);
  5806. return 0;
  5807. }
  5808. static int Polycore_Renderer_setLineSize(lua_State *L) {
  5809. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  5810. Renderer *inst = (Renderer*)lua_topointer(L, 1);
  5811. luaL_checktype(L, 2, LUA_TNUMBER);
  5812. Number lineSize = lua_tonumber(L, 2);
  5813. inst->setLineSize(lineSize);
  5814. return 0;
  5815. }
  5816. static int Polycore_Renderer_enableLighting(lua_State *L) {
  5817. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  5818. Renderer *inst = (Renderer*)lua_topointer(L, 1);
  5819. luaL_checktype(L, 2, LUA_TBOOLEAN);
  5820. bool enable = lua_toboolean(L, 2);
  5821. inst->enableLighting(enable);
  5822. return 0;
  5823. }
  5824. static int Polycore_Renderer_enableFog(lua_State *L) {
  5825. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  5826. Renderer *inst = (Renderer*)lua_topointer(L, 1);
  5827. luaL_checktype(L, 2, LUA_TBOOLEAN);
  5828. bool enable = lua_toboolean(L, 2);
  5829. inst->enableFog(enable);
  5830. return 0;
  5831. }
  5832. static int Polycore_Renderer_setFogProperties(lua_State *L) {
  5833. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  5834. Renderer *inst = (Renderer*)lua_topointer(L, 1);
  5835. luaL_checktype(L, 2, LUA_TNUMBER);
  5836. int fogMode = lua_tointeger(L, 2);
  5837. luaL_checktype(L, 3, LUA_TLIGHTUSERDATA);
  5838. Color color = *(Color*)lua_topointer(L, 3);
  5839. luaL_checktype(L, 4, LUA_TNUMBER);
  5840. Number density = lua_tonumber(L, 4);
  5841. luaL_checktype(L, 5, LUA_TNUMBER);
  5842. Number startDepth = lua_tonumber(L, 5);
  5843. luaL_checktype(L, 6, LUA_TNUMBER);
  5844. Number _endDepth = lua_tonumber(L, 6);
  5845. inst->setFogProperties(fogMode, color, density, startDepth, _endDepth);
  5846. return 0;
  5847. }
  5848. static int Polycore_Renderer_multModelviewMatrix(lua_State *L) {
  5849. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  5850. Renderer *inst = (Renderer*)lua_topointer(L, 1);
  5851. luaL_checktype(L, 2, LUA_TLIGHTUSERDATA);
  5852. Matrix4 m = *(Matrix4*)lua_topointer(L, 2);
  5853. inst->multModelviewMatrix(m);
  5854. return 0;
  5855. }
  5856. static int Polycore_Renderer_setModelviewMatrix(lua_State *L) {
  5857. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  5858. Renderer *inst = (Renderer*)lua_topointer(L, 1);
  5859. luaL_checktype(L, 2, LUA_TLIGHTUSERDATA);
  5860. Matrix4 m = *(Matrix4*)lua_topointer(L, 2);
  5861. inst->setModelviewMatrix(m);
  5862. return 0;
  5863. }
  5864. static int Polycore_Renderer_setCurrentModelMatrix(lua_State *L) {
  5865. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  5866. Renderer *inst = (Renderer*)lua_topointer(L, 1);
  5867. luaL_checktype(L, 2, LUA_TLIGHTUSERDATA);
  5868. Matrix4 m = *(Matrix4*)lua_topointer(L, 2);
  5869. inst->setCurrentModelMatrix(m);
  5870. return 0;
  5871. }
  5872. static int Polycore_Renderer_getCurrentModelMatrix(lua_State *L) {
  5873. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  5874. Renderer *inst = (Renderer*)lua_topointer(L, 1);
  5875. Matrix4 *retInst = new Matrix4();
  5876. *retInst = inst->getCurrentModelMatrix();
  5877. lua_pushlightuserdata(L, retInst);
  5878. return 1;
  5879. }
  5880. static int Polycore_Renderer_setBlendingMode(lua_State *L) {
  5881. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  5882. Renderer *inst = (Renderer*)lua_topointer(L, 1);
  5883. luaL_checktype(L, 2, LUA_TNUMBER);
  5884. int bl_endingMode = lua_tointeger(L, 2);
  5885. inst->setBlendingMode(bl_endingMode);
  5886. return 0;
  5887. }
  5888. static int Polycore_Renderer_applyMaterial(lua_State *L) {
  5889. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  5890. Renderer *inst = (Renderer*)lua_topointer(L, 1);
  5891. luaL_checktype(L, 2, LUA_TLIGHTUSERDATA);
  5892. Material* material = (Material*)lua_topointer(L, 2);
  5893. luaL_checktype(L, 3, LUA_TLIGHTUSERDATA);
  5894. ShaderBinding* localOptions = (ShaderBinding*)lua_topointer(L, 3);
  5895. luaL_checktype(L, 4, LUA_TNUMBER);
  5896. unsigned int shaderIndex = lua_tointeger(L, 4);
  5897. inst->applyMaterial(material, localOptions, shaderIndex);
  5898. return 0;
  5899. }
  5900. static int Polycore_Renderer_clearShader(lua_State *L) {
  5901. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  5902. Renderer *inst = (Renderer*)lua_topointer(L, 1);
  5903. inst->clearShader();
  5904. return 0;
  5905. }
  5906. static int Polycore_Renderer_setDepthFunction(lua_State *L) {
  5907. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  5908. Renderer *inst = (Renderer*)lua_topointer(L, 1);
  5909. luaL_checktype(L, 2, LUA_TNUMBER);
  5910. int depthFunction = lua_tointeger(L, 2);
  5911. inst->setDepthFunction(depthFunction);
  5912. return 0;
  5913. }
  5914. static int Polycore_Renderer_createVertexBufferForMesh(lua_State *L) {
  5915. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  5916. Renderer *inst = (Renderer*)lua_topointer(L, 1);
  5917. luaL_checktype(L, 2, LUA_TLIGHTUSERDATA);
  5918. Mesh* mesh = (Mesh*)lua_topointer(L, 2);
  5919. inst->createVertexBufferForMesh(mesh);
  5920. return 0;
  5921. }
  5922. static int Polycore_Renderer_drawVertexBuffer(lua_State *L) {
  5923. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  5924. Renderer *inst = (Renderer*)lua_topointer(L, 1);
  5925. luaL_checktype(L, 2, LUA_TLIGHTUSERDATA);
  5926. VertexBuffer* buffer = (VertexBuffer*)lua_topointer(L, 2);
  5927. inst->drawVertexBuffer(buffer);
  5928. return 0;
  5929. }
  5930. static int Polycore_Renderer_setRenderMode(lua_State *L) {
  5931. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  5932. Renderer *inst = (Renderer*)lua_topointer(L, 1);
  5933. luaL_checktype(L, 2, LUA_TNUMBER);
  5934. int newR_enderMode = lua_tointeger(L, 2);
  5935. inst->setRenderMode(newR_enderMode);
  5936. return 0;
  5937. }
  5938. static int Polycore_Renderer_getRenderMode(lua_State *L) {
  5939. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  5940. Renderer *inst = (Renderer*)lua_topointer(L, 1);
  5941. lua_pushinteger(L, inst->getRenderMode());
  5942. return 1;
  5943. }
  5944. static int Polycore_Renderer_enableDepthTest(lua_State *L) {
  5945. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  5946. Renderer *inst = (Renderer*)lua_topointer(L, 1);
  5947. luaL_checktype(L, 2, LUA_TBOOLEAN);
  5948. bool val = lua_toboolean(L, 2);
  5949. inst->enableDepthTest(val);
  5950. return 0;
  5951. }
  5952. static int Polycore_Renderer_enableDepthWrite(lua_State *L) {
  5953. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  5954. Renderer *inst = (Renderer*)lua_topointer(L, 1);
  5955. luaL_checktype(L, 2, LUA_TBOOLEAN);
  5956. bool val = lua_toboolean(L, 2);
  5957. inst->enableDepthWrite(val);
  5958. return 0;
  5959. }
  5960. static int Polycore_Renderer_billboardMatrix(lua_State *L) {
  5961. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  5962. Renderer *inst = (Renderer*)lua_topointer(L, 1);
  5963. inst->billboardMatrix();
  5964. return 0;
  5965. }
  5966. static int Polycore_Renderer_billboardMatrixWithScale(lua_State *L) {
  5967. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  5968. Renderer *inst = (Renderer*)lua_topointer(L, 1);
  5969. luaL_checktype(L, 2, LUA_TLIGHTUSERDATA);
  5970. Vector3 scale = *(Vector3*)lua_topointer(L, 2);
  5971. inst->billboardMatrixWithScale(scale);
  5972. return 0;
  5973. }
  5974. static int Polycore_Renderer_setTextureFilteringMode(lua_State *L) {
  5975. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  5976. Renderer *inst = (Renderer*)lua_topointer(L, 1);
  5977. luaL_checktype(L, 2, LUA_TNUMBER);
  5978. int mode = lua_tointeger(L, 2);
  5979. inst->setTextureFilteringMode(mode);
  5980. return 0;
  5981. }
  5982. static int Polycore_Renderer_setClippingPlanes(lua_State *L) {
  5983. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  5984. Renderer *inst = (Renderer*)lua_topointer(L, 1);
  5985. luaL_checktype(L, 2, LUA_TNUMBER);
  5986. Number near = lua_tonumber(L, 2);
  5987. luaL_checktype(L, 3, LUA_TNUMBER);
  5988. Number far = lua_tonumber(L, 3);
  5989. inst->setClippingPlanes(near, far);
  5990. return 0;
  5991. }
  5992. static int Polycore_Renderer_enableAlphaTest(lua_State *L) {
  5993. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  5994. Renderer *inst = (Renderer*)lua_topointer(L, 1);
  5995. luaL_checktype(L, 2, LUA_TBOOLEAN);
  5996. bool val = lua_toboolean(L, 2);
  5997. inst->enableAlphaTest(val);
  5998. return 0;
  5999. }
  6000. static int Polycore_Renderer_clearBuffer(lua_State *L) {
  6001. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  6002. Renderer *inst = (Renderer*)lua_topointer(L, 1);
  6003. luaL_checktype(L, 2, LUA_TBOOLEAN);
  6004. bool colorBuffer = lua_toboolean(L, 2);
  6005. luaL_checktype(L, 3, LUA_TBOOLEAN);
  6006. bool depthBuffer = lua_toboolean(L, 3);
  6007. inst->clearBuffer(colorBuffer, depthBuffer);
  6008. return 0;
  6009. }
  6010. static int Polycore_Renderer_drawToColorBuffer(lua_State *L) {
  6011. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  6012. Renderer *inst = (Renderer*)lua_topointer(L, 1);
  6013. luaL_checktype(L, 2, LUA_TBOOLEAN);
  6014. bool val = lua_toboolean(L, 2);
  6015. inst->drawToColorBuffer(val);
  6016. return 0;
  6017. }
  6018. static int Polycore_Renderer_getCameraMatrix(lua_State *L) {
  6019. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  6020. Renderer *inst = (Renderer*)lua_topointer(L, 1);
  6021. Matrix4 *retInst = new Matrix4 ();
  6022. *retInst = inst->getCameraMatrix();
  6023. lua_pushlightuserdata(L, retInst);
  6024. return 1;
  6025. }
  6026. static int Polycore_Renderer_setCameraMatrix(lua_State *L) {
  6027. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  6028. Renderer *inst = (Renderer*)lua_topointer(L, 1);
  6029. luaL_checktype(L, 2, LUA_TLIGHTUSERDATA);
  6030. Matrix4 matrix = *(Matrix4*)lua_topointer(L, 2);
  6031. inst->setCameraMatrix(matrix);
  6032. return 0;
  6033. }
  6034. static int Polycore_Renderer_setCameraPosition(lua_State *L) {
  6035. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  6036. Renderer *inst = (Renderer*)lua_topointer(L, 1);
  6037. luaL_checktype(L, 2, LUA_TLIGHTUSERDATA);
  6038. Vector3 pos = *(Vector3*)lua_topointer(L, 2);
  6039. inst->setCameraPosition(pos);
  6040. return 0;
  6041. }
  6042. static int Polycore_Renderer_drawScreenQuad(lua_State *L) {
  6043. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  6044. Renderer *inst = (Renderer*)lua_topointer(L, 1);
  6045. luaL_checktype(L, 2, LUA_TNUMBER);
  6046. Number qx = lua_tonumber(L, 2);
  6047. luaL_checktype(L, 3, LUA_TNUMBER);
  6048. Number qy = lua_tonumber(L, 3);
  6049. inst->drawScreenQuad(qx, qy);
  6050. return 0;
  6051. }
  6052. static int Polycore_Renderer_getXRes(lua_State *L) {
  6053. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  6054. Renderer *inst = (Renderer*)lua_topointer(L, 1);
  6055. lua_pushinteger(L, inst->getXRes());
  6056. return 1;
  6057. }
  6058. static int Polycore_Renderer_getYRes(lua_State *L) {
  6059. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  6060. Renderer *inst = (Renderer*)lua_topointer(L, 1);
  6061. lua_pushinteger(L, inst->getYRes());
  6062. return 1;
  6063. }
  6064. static int Polycore_Renderer_setAnisotropyAmount(lua_State *L) {
  6065. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  6066. Renderer *inst = (Renderer*)lua_topointer(L, 1);
  6067. luaL_checktype(L, 2, LUA_TNUMBER);
  6068. Number amount = lua_tonumber(L, 2);
  6069. inst->setAnisotropyAmount(amount);
  6070. return 0;
  6071. }
  6072. static int Polycore_Renderer_getAnisotropyAmount(lua_State *L) {
  6073. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  6074. Renderer *inst = (Renderer*)lua_topointer(L, 1);
  6075. lua_pushnumber(L, inst->getAnisotropyAmount());
  6076. return 1;
  6077. }
  6078. static int Polycore_Renderer_cullFrontFaces(lua_State *L) {
  6079. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  6080. Renderer *inst = (Renderer*)lua_topointer(L, 1);
  6081. luaL_checktype(L, 2, LUA_TBOOLEAN);
  6082. bool val = lua_toboolean(L, 2);
  6083. inst->cullFrontFaces(val);
  6084. return 0;
  6085. }
  6086. static int Polycore_Renderer_clearLights(lua_State *L) {
  6087. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  6088. Renderer *inst = (Renderer*)lua_topointer(L, 1);
  6089. inst->clearLights();
  6090. return 0;
  6091. }
  6092. static int Polycore_Renderer_addLight(lua_State *L) {
  6093. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  6094. Renderer *inst = (Renderer*)lua_topointer(L, 1);
  6095. luaL_checktype(L, 2, LUA_TNUMBER);
  6096. int lightImportance = lua_tointeger(L, 2);
  6097. luaL_checktype(L, 3, LUA_TLIGHTUSERDATA);
  6098. Vector3 position = *(Vector3*)lua_topointer(L, 3);
  6099. luaL_checktype(L, 4, LUA_TLIGHTUSERDATA);
  6100. Vector3 direction = *(Vector3*)lua_topointer(L, 4);
  6101. luaL_checktype(L, 5, LUA_TNUMBER);
  6102. int type = lua_tointeger(L, 5);
  6103. luaL_checktype(L, 6, LUA_TLIGHTUSERDATA);
  6104. Color color = *(Color*)lua_topointer(L, 6);
  6105. luaL_checktype(L, 7, LUA_TLIGHTUSERDATA);
  6106. Color specularColor = *(Color*)lua_topointer(L, 7);
  6107. luaL_checktype(L, 8, LUA_TNUMBER);
  6108. Number constantAttenuation = lua_tonumber(L, 8);
  6109. luaL_checktype(L, 9, LUA_TNUMBER);
  6110. Number linearAttenuation = lua_tonumber(L, 9);
  6111. luaL_checktype(L, 10, LUA_TNUMBER);
  6112. Number quadraticAttenuation = lua_tonumber(L, 10);
  6113. luaL_checktype(L, 11, LUA_TNUMBER);
  6114. Number intensity = lua_tonumber(L, 11);
  6115. luaL_checktype(L, 12, LUA_TNUMBER);
  6116. Number spotlightCutoff = lua_tonumber(L, 12);
  6117. luaL_checktype(L, 13, LUA_TNUMBER);
  6118. Number spotlightExponent = lua_tonumber(L, 13);
  6119. luaL_checktype(L, 14, LUA_TBOOLEAN);
  6120. bool shadowsEnabled = lua_toboolean(L, 14);
  6121. luaL_checktype(L, 15, LUA_TLIGHTUSERDATA);
  6122. Matrix4* textureMatrix = (Matrix4*)lua_topointer(L, 15);
  6123. luaL_checktype(L, 16, LUA_TLIGHTUSERDATA);
  6124. Texture* shadowMapTexture = (Texture*)lua_topointer(L, 16);
  6125. inst->addLight(lightImportance, position, direction, type, color, specularColor, constantAttenuation, linearAttenuation, quadraticAttenuation, intensity, spotlightCutoff, spotlightExponent, shadowsEnabled, textureMatrix, shadowMapTexture);
  6126. return 0;
  6127. }
  6128. static int Polycore_Renderer_setExposureLevel(lua_State *L) {
  6129. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  6130. Renderer *inst = (Renderer*)lua_topointer(L, 1);
  6131. luaL_checktype(L, 2, LUA_TNUMBER);
  6132. Number level = lua_tonumber(L, 2);
  6133. inst->setExposureLevel(level);
  6134. return 0;
  6135. }
  6136. static int Polycore_Renderer_rayTriangleIntersect(lua_State *L) {
  6137. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  6138. Renderer *inst = (Renderer*)lua_topointer(L, 1);
  6139. luaL_checktype(L, 2, LUA_TLIGHTUSERDATA);
  6140. Vector3 ray_origin = *(Vector3*)lua_topointer(L, 2);
  6141. luaL_checktype(L, 3, LUA_TLIGHTUSERDATA);
  6142. Vector3 ray_direction = *(Vector3*)lua_topointer(L, 3);
  6143. luaL_checktype(L, 4, LUA_TLIGHTUSERDATA);
  6144. Vector3 vert0 = *(Vector3*)lua_topointer(L, 4);
  6145. luaL_checktype(L, 5, LUA_TLIGHTUSERDATA);
  6146. Vector3 vert1 = *(Vector3*)lua_topointer(L, 5);
  6147. luaL_checktype(L, 6, LUA_TLIGHTUSERDATA);
  6148. Vector3 vert2 = *(Vector3*)lua_topointer(L, 6);
  6149. luaL_checktype(L, 7, LUA_TLIGHTUSERDATA);
  6150. Vector3* hitPoint = (Vector3*)lua_topointer(L, 7);
  6151. lua_pushboolean(L, inst->rayTriangleIntersect(ray_origin, ray_direction, vert0, vert1, vert2, hitPoint));
  6152. return 1;
  6153. }
  6154. static int Polycore_Renderer_projectRayFrom2DCoordinate(lua_State *L) {
  6155. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  6156. Renderer *inst = (Renderer*)lua_topointer(L, 1);
  6157. luaL_checktype(L, 2, LUA_TNUMBER);
  6158. Number x = lua_tonumber(L, 2);
  6159. luaL_checktype(L, 3, LUA_TNUMBER);
  6160. Number y = lua_tonumber(L, 3);
  6161. Vector3 *retInst = new Vector3();
  6162. *retInst = inst->projectRayFrom2DCoordinate(x, y);
  6163. lua_pushlightuserdata(L, retInst);
  6164. return 1;
  6165. }
  6166. static int Polycore_Renderer_enableShaders(lua_State *L) {
  6167. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  6168. Renderer *inst = (Renderer*)lua_topointer(L, 1);
  6169. luaL_checktype(L, 2, LUA_TBOOLEAN);
  6170. bool flag = lua_toboolean(L, 2);
  6171. inst->enableShaders(flag);
  6172. return 0;
  6173. }
  6174. static int Polycore_Renderer_getViewportWidth(lua_State *L) {
  6175. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  6176. Renderer *inst = (Renderer*)lua_topointer(L, 1);
  6177. lua_pushnumber(L, inst->getViewportWidth());
  6178. return 1;
  6179. }
  6180. static int Polycore_Renderer_getViewportHeight(lua_State *L) {
  6181. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  6182. Renderer *inst = (Renderer*)lua_topointer(L, 1);
  6183. lua_pushnumber(L, inst->getViewportHeight());
  6184. return 1;
  6185. }
  6186. static int Polycore_Renderer_initOSSpecific(lua_State *L) {
  6187. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  6188. Renderer *inst = (Renderer*)lua_topointer(L, 1);
  6189. inst->initOSSpecific();
  6190. return 0;
  6191. }
  6192. static int Polycore_Renderer_addShaderModule(lua_State *L) {
  6193. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  6194. Renderer *inst = (Renderer*)lua_topointer(L, 1);
  6195. luaL_checktype(L, 2, LUA_TLIGHTUSERDATA);
  6196. PolycodeShaderModule* module = (PolycodeShaderModule*)lua_topointer(L, 2);
  6197. inst->addShaderModule(module);
  6198. return 0;
  6199. }
  6200. static int Polycore_Renderer_test2DCoordinate(lua_State *L) {
  6201. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  6202. Renderer *inst = (Renderer*)lua_topointer(L, 1);
  6203. luaL_checktype(L, 2, LUA_TNUMBER);
  6204. Number x = lua_tonumber(L, 2);
  6205. luaL_checktype(L, 3, LUA_TNUMBER);
  6206. Number y = lua_tonumber(L, 3);
  6207. luaL_checktype(L, 4, LUA_TLIGHTUSERDATA);
  6208. Polycode::Polygon* poly = (Polycode::Polygon*)lua_topointer(L, 4);
  6209. luaL_checktype(L, 5, LUA_TLIGHTUSERDATA);
  6210. Matrix4 matrix = *(Matrix4*)lua_topointer(L, 5);
  6211. luaL_checktype(L, 6, LUA_TBOOLEAN);
  6212. bool billboardMode = lua_toboolean(L, 6);
  6213. lua_pushboolean(L, inst->test2DCoordinate(x, y, poly, matrix, billboardMode));
  6214. return 1;
  6215. }
  6216. static int Polycore_Renderer_getProjectionMatrix(lua_State *L) {
  6217. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  6218. Renderer *inst = (Renderer*)lua_topointer(L, 1);
  6219. Matrix4 *retInst = new Matrix4();
  6220. *retInst = inst->getProjectionMatrix();
  6221. lua_pushlightuserdata(L, retInst);
  6222. return 1;
  6223. }
  6224. static int Polycore_Renderer_getModelviewMatrix(lua_State *L) {
  6225. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  6226. Renderer *inst = (Renderer*)lua_topointer(L, 1);
  6227. Matrix4 *retInst = new Matrix4();
  6228. *retInst = inst->getModelviewMatrix();
  6229. lua_pushlightuserdata(L, retInst);
  6230. return 1;
  6231. }
  6232. static int Polycore_Renderer_Unproject(lua_State *L) {
  6233. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  6234. Renderer *inst = (Renderer*)lua_topointer(L, 1);
  6235. luaL_checktype(L, 2, LUA_TNUMBER);
  6236. Number x = lua_tonumber(L, 2);
  6237. luaL_checktype(L, 3, LUA_TNUMBER);
  6238. Number y = lua_tonumber(L, 3);
  6239. Vector3 *retInst = new Vector3();
  6240. *retInst = inst->Unproject(x, y);
  6241. lua_pushlightuserdata(L, retInst);
  6242. return 1;
  6243. }
  6244. static int Polycore_Renderer_sortLights(lua_State *L) {
  6245. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  6246. Renderer *inst = (Renderer*)lua_topointer(L, 1);
  6247. inst->sortLights();
  6248. return 0;
  6249. }
  6250. static int Polycore_Renderer_getNumAreaLights(lua_State *L) {
  6251. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  6252. Renderer *inst = (Renderer*)lua_topointer(L, 1);
  6253. lua_pushinteger(L, inst->getNumAreaLights());
  6254. return 1;
  6255. }
  6256. static int Polycore_Renderer_getNumSpotLights(lua_State *L) {
  6257. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  6258. Renderer *inst = (Renderer*)lua_topointer(L, 1);
  6259. lua_pushinteger(L, inst->getNumSpotLights());
  6260. return 1;
  6261. }
  6262. static int Polycore_Renderer_getNumLights(lua_State *L) {
  6263. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  6264. Renderer *inst = (Renderer*)lua_topointer(L, 1);
  6265. lua_pushinteger(L, inst->getNumLights());
  6266. return 1;
  6267. }
  6268. static int Polycore_delete_Renderer(lua_State *L) {
  6269. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  6270. Renderer *inst = (Renderer*)lua_topointer(L, 1);
  6271. delete inst;
  6272. return 0;
  6273. }
  6274. static int Polycore_Resource(lua_State *L) {
  6275. luaL_checktype(L, 1, LUA_TNUMBER);
  6276. int type = lua_tointeger(L, 1);
  6277. Resource *inst = new Resource(type);
  6278. lua_pushlightuserdata(L, (void*)inst);
  6279. return 1;
  6280. }
  6281. static int Polycore_Resource_getResourceName(lua_State *L) {
  6282. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  6283. Resource *inst = (Resource*)lua_topointer(L, 1);
  6284. String *retInst = new String ();
  6285. *retInst = inst->getResourceName();
  6286. lua_pushlightuserdata(L, retInst);
  6287. return 1;
  6288. }
  6289. static int Polycore_Resource_getResourceType(lua_State *L) {
  6290. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  6291. Resource *inst = (Resource*)lua_topointer(L, 1);
  6292. lua_pushinteger(L, inst->getResourceType());
  6293. return 1;
  6294. }
  6295. static int Polycore_Resource_setResourceName(lua_State *L) {
  6296. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  6297. Resource *inst = (Resource*)lua_topointer(L, 1);
  6298. luaL_checktype(L, 2, LUA_TSTRING);
  6299. String newName = String(lua_tostring(L, 2));
  6300. inst->setResourceName(newName);
  6301. return 0;
  6302. }
  6303. static int Polycore_Resource_setResourcePath(lua_State *L) {
  6304. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  6305. Resource *inst = (Resource*)lua_topointer(L, 1);
  6306. luaL_checktype(L, 2, LUA_TSTRING);
  6307. String path = String(lua_tostring(L, 2));
  6308. inst->setResourcePath(path);
  6309. return 0;
  6310. }
  6311. static int Polycore_Resource_getResourcePath(lua_State *L) {
  6312. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  6313. Resource *inst = (Resource*)lua_topointer(L, 1);
  6314. String *retInst = new String ();
  6315. *retInst = inst->getResourcePath();
  6316. lua_pushlightuserdata(L, retInst);
  6317. return 1;
  6318. }
  6319. static int Polycore_delete_Resource(lua_State *L) {
  6320. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  6321. Resource *inst = (Resource*)lua_topointer(L, 1);
  6322. delete inst;
  6323. return 0;
  6324. }
  6325. static int Polycore_ResourceManager(lua_State *L) {
  6326. ResourceManager *inst = new ResourceManager();
  6327. lua_pushlightuserdata(L, (void*)inst);
  6328. return 1;
  6329. }
  6330. static int Polycore_ResourceManager_addResource(lua_State *L) {
  6331. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  6332. ResourceManager *inst = (ResourceManager*)lua_topointer(L, 1);
  6333. luaL_checktype(L, 2, LUA_TLIGHTUSERDATA);
  6334. Resource* resource = (Resource*)lua_topointer(L, 2);
  6335. inst->addResource(resource);
  6336. return 0;
  6337. }
  6338. static int Polycore_ResourceManager_addDirResource(lua_State *L) {
  6339. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  6340. ResourceManager *inst = (ResourceManager*)lua_topointer(L, 1);
  6341. luaL_checktype(L, 2, LUA_TSTRING);
  6342. String dirPath = String(lua_tostring(L, 2));
  6343. bool recursive;
  6344. if(lua_isboolean(L, 3)) {
  6345. recursive = lua_toboolean(L, 3);
  6346. } else {
  6347. recursive = true;
  6348. }
  6349. inst->addDirResource(dirPath, recursive);
  6350. return 0;
  6351. }
  6352. static int Polycore_ResourceManager_addArchive(lua_State *L) {
  6353. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  6354. ResourceManager *inst = (ResourceManager*)lua_topointer(L, 1);
  6355. luaL_checktype(L, 2, LUA_TSTRING);
  6356. String zipPath = String(lua_tostring(L, 2));
  6357. inst->addArchive(zipPath);
  6358. return 0;
  6359. }
  6360. static int Polycore_ResourceManager_readFile(lua_State *L) {
  6361. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  6362. ResourceManager *inst = (ResourceManager*)lua_topointer(L, 1);
  6363. luaL_checktype(L, 2, LUA_TSTRING);
  6364. String fileName = String(lua_tostring(L, 2));
  6365. lua_pushboolean(L, inst->readFile(fileName));
  6366. return 1;
  6367. }
  6368. static int Polycore_ResourceManager_parseTextures(lua_State *L) {
  6369. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  6370. ResourceManager *inst = (ResourceManager*)lua_topointer(L, 1);
  6371. luaL_checktype(L, 2, LUA_TSTRING);
  6372. String dirPath = String(lua_tostring(L, 2));
  6373. luaL_checktype(L, 3, LUA_TBOOLEAN);
  6374. bool recursive = lua_toboolean(L, 3);
  6375. inst->parseTextures(dirPath, recursive);
  6376. return 0;
  6377. }
  6378. static int Polycore_ResourceManager_parseMaterials(lua_State *L) {
  6379. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  6380. ResourceManager *inst = (ResourceManager*)lua_topointer(L, 1);
  6381. luaL_checktype(L, 2, LUA_TSTRING);
  6382. String dirPath = String(lua_tostring(L, 2));
  6383. luaL_checktype(L, 3, LUA_TBOOLEAN);
  6384. bool recursive = lua_toboolean(L, 3);
  6385. inst->parseMaterials(dirPath, recursive);
  6386. return 0;
  6387. }
  6388. static int Polycore_ResourceManager_parseShaders(lua_State *L) {
  6389. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  6390. ResourceManager *inst = (ResourceManager*)lua_topointer(L, 1);
  6391. luaL_checktype(L, 2, LUA_TSTRING);
  6392. String dirPath = String(lua_tostring(L, 2));
  6393. luaL_checktype(L, 3, LUA_TBOOLEAN);
  6394. bool recursive = lua_toboolean(L, 3);
  6395. inst->parseShaders(dirPath, recursive);
  6396. return 0;
  6397. }
  6398. static int Polycore_ResourceManager_parsePrograms(lua_State *L) {
  6399. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  6400. ResourceManager *inst = (ResourceManager*)lua_topointer(L, 1);
  6401. luaL_checktype(L, 2, LUA_TSTRING);
  6402. String dirPath = String(lua_tostring(L, 2));
  6403. luaL_checktype(L, 3, LUA_TBOOLEAN);
  6404. bool recursive = lua_toboolean(L, 3);
  6405. inst->parsePrograms(dirPath, recursive);
  6406. return 0;
  6407. }
  6408. static int Polycore_ResourceManager_parseCubemaps(lua_State *L) {
  6409. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  6410. ResourceManager *inst = (ResourceManager*)lua_topointer(L, 1);
  6411. luaL_checktype(L, 2, LUA_TSTRING);
  6412. String dirPath = String(lua_tostring(L, 2));
  6413. luaL_checktype(L, 3, LUA_TBOOLEAN);
  6414. bool recursive = lua_toboolean(L, 3);
  6415. inst->parseCubemaps(dirPath, recursive);
  6416. return 0;
  6417. }
  6418. static int Polycore_ResourceManager_parseOthers(lua_State *L) {
  6419. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  6420. ResourceManager *inst = (ResourceManager*)lua_topointer(L, 1);
  6421. luaL_checktype(L, 2, LUA_TSTRING);
  6422. String dirPath = String(lua_tostring(L, 2));
  6423. luaL_checktype(L, 3, LUA_TBOOLEAN);
  6424. bool recursive = lua_toboolean(L, 3);
  6425. inst->parseOthers(dirPath, recursive);
  6426. return 0;
  6427. }
  6428. static int Polycore_ResourceManager_getResource(lua_State *L) {
  6429. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  6430. ResourceManager *inst = (ResourceManager*)lua_topointer(L, 1);
  6431. luaL_checktype(L, 2, LUA_TNUMBER);
  6432. int resourceType = lua_tointeger(L, 2);
  6433. luaL_checktype(L, 3, LUA_TSTRING);
  6434. String resourceName = String(lua_tostring(L, 3));
  6435. void *ptrRetVal = (void*)inst->getResource(resourceType, resourceName);
  6436. if(ptrRetVal == NULL) {
  6437. lua_pushnil(L);
  6438. } else {
  6439. lua_pushlightuserdata(L, ptrRetVal);
  6440. }
  6441. return 1;
  6442. }
  6443. static int Polycore_ResourceManager_addShaderModule(lua_State *L) {
  6444. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  6445. ResourceManager *inst = (ResourceManager*)lua_topointer(L, 1);
  6446. luaL_checktype(L, 2, LUA_TLIGHTUSERDATA);
  6447. PolycodeShaderModule* module = (PolycodeShaderModule*)lua_topointer(L, 2);
  6448. inst->addShaderModule(module);
  6449. return 0;
  6450. }
  6451. static int Polycore_delete_ResourceManager(lua_State *L) {
  6452. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  6453. ResourceManager *inst = (ResourceManager*)lua_topointer(L, 1);
  6454. delete inst;
  6455. return 0;
  6456. }
  6457. static int Polycore_Scene_get_clearColor(lua_State *L) {
  6458. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  6459. Scene *inst = (Scene*)lua_topointer(L, 1);
  6460. lua_pushlightuserdata(L, &inst->clearColor);
  6461. return 1;
  6462. }
  6463. static int Polycore_Scene_get_useClearColor(lua_State *L) {
  6464. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  6465. Scene *inst = (Scene*)lua_topointer(L, 1);
  6466. lua_pushboolean(L, inst->useClearColor);
  6467. return 1;
  6468. }
  6469. static int Polycore_Scene_get_ambientColor(lua_State *L) {
  6470. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  6471. Scene *inst = (Scene*)lua_topointer(L, 1);
  6472. lua_pushlightuserdata(L, &inst->ambientColor);
  6473. return 1;
  6474. }
  6475. static int Polycore_Scene_get_fogColor(lua_State *L) {
  6476. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  6477. Scene *inst = (Scene*)lua_topointer(L, 1);
  6478. lua_pushlightuserdata(L, &inst->fogColor);
  6479. return 1;
  6480. }
  6481. static int Polycore_Scene_get_enabled(lua_State *L) {
  6482. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  6483. Scene *inst = (Scene*)lua_topointer(L, 1);
  6484. lua_pushboolean(L, inst->enabled);
  6485. return 1;
  6486. }
  6487. static int Polycore_Scene_set_useClearColor(lua_State *L) {
  6488. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  6489. Scene *inst = (Scene*)lua_topointer(L, 1);
  6490. bool param = lua_toboolean(L, 2);
  6491. inst->useClearColor = param;
  6492. return 0;
  6493. }
  6494. static int Polycore_Scene_set_enabled(lua_State *L) {
  6495. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  6496. Scene *inst = (Scene*)lua_topointer(L, 1);
  6497. bool param = lua_toboolean(L, 2);
  6498. inst->enabled = param;
  6499. return 0;
  6500. }
  6501. static int Polycore_Scene(lua_State *L) {
  6502. Scene *inst = new Scene();
  6503. lua_pushlightuserdata(L, (void*)inst);
  6504. return 1;
  6505. }
  6506. static int Polycore_Scene_addEntity(lua_State *L) {
  6507. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  6508. Scene *inst = (Scene*)lua_topointer(L, 1);
  6509. luaL_checktype(L, 2, LUA_TLIGHTUSERDATA);
  6510. SceneEntity* entity = (SceneEntity*)lua_topointer(L, 2);
  6511. inst->addEntity(entity);
  6512. return 0;
  6513. }
  6514. static int Polycore_Scene_removeEntity(lua_State *L) {
  6515. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  6516. Scene *inst = (Scene*)lua_topointer(L, 1);
  6517. luaL_checktype(L, 2, LUA_TLIGHTUSERDATA);
  6518. SceneEntity* entity = (SceneEntity*)lua_topointer(L, 2);
  6519. inst->removeEntity(entity);
  6520. return 0;
  6521. }
  6522. static int Polycore_Scene_getDefaultCamera(lua_State *L) {
  6523. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  6524. Scene *inst = (Scene*)lua_topointer(L, 1);
  6525. void *ptrRetVal = (void*)inst->getDefaultCamera();
  6526. if(ptrRetVal == NULL) {
  6527. lua_pushnil(L);
  6528. } else {
  6529. lua_pushlightuserdata(L, ptrRetVal);
  6530. }
  6531. return 1;
  6532. }
  6533. static int Polycore_Scene_getActiveCamera(lua_State *L) {
  6534. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  6535. Scene *inst = (Scene*)lua_topointer(L, 1);
  6536. void *ptrRetVal = (void*)inst->getActiveCamera();
  6537. if(ptrRetVal == NULL) {
  6538. lua_pushnil(L);
  6539. } else {
  6540. lua_pushlightuserdata(L, ptrRetVal);
  6541. }
  6542. return 1;
  6543. }
  6544. static int Polycore_Scene_setActiveCamera(lua_State *L) {
  6545. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  6546. Scene *inst = (Scene*)lua_topointer(L, 1);
  6547. luaL_checktype(L, 2, LUA_TLIGHTUSERDATA);
  6548. Camera* camera = (Camera*)lua_topointer(L, 2);
  6549. inst->setActiveCamera(camera);
  6550. return 0;
  6551. }
  6552. static int Polycore_Scene_enableLighting(lua_State *L) {
  6553. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  6554. Scene *inst = (Scene*)lua_topointer(L, 1);
  6555. luaL_checktype(L, 2, LUA_TBOOLEAN);
  6556. bool enable = lua_toboolean(L, 2);
  6557. inst->enableLighting(enable);
  6558. return 0;
  6559. }
  6560. static int Polycore_Scene_enableFog(lua_State *L) {
  6561. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  6562. Scene *inst = (Scene*)lua_topointer(L, 1);
  6563. luaL_checktype(L, 2, LUA_TBOOLEAN);
  6564. bool enable = lua_toboolean(L, 2);
  6565. inst->enableFog(enable);
  6566. return 0;
  6567. }
  6568. static int Polycore_Scene_setFogProperties(lua_State *L) {
  6569. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  6570. Scene *inst = (Scene*)lua_topointer(L, 1);
  6571. luaL_checktype(L, 2, LUA_TNUMBER);
  6572. int fogMode = lua_tointeger(L, 2);
  6573. luaL_checktype(L, 3, LUA_TLIGHTUSERDATA);
  6574. Color color = *(Color*)lua_topointer(L, 3);
  6575. luaL_checktype(L, 4, LUA_TNUMBER);
  6576. Number density = lua_tonumber(L, 4);
  6577. luaL_checktype(L, 5, LUA_TNUMBER);
  6578. Number startDepth = lua_tonumber(L, 5);
  6579. luaL_checktype(L, 6, LUA_TNUMBER);
  6580. Number _endDepth = lua_tonumber(L, 6);
  6581. inst->setFogProperties(fogMode, color, density, startDepth, _endDepth);
  6582. return 0;
  6583. }
  6584. static int Polycore_Scene_Update(lua_State *L) {
  6585. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  6586. Scene *inst = (Scene*)lua_topointer(L, 1);
  6587. inst->Update();
  6588. return 0;
  6589. }
  6590. static int Polycore_Scene_setVirtual(lua_State *L) {
  6591. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  6592. Scene *inst = (Scene*)lua_topointer(L, 1);
  6593. luaL_checktype(L, 2, LUA_TBOOLEAN);
  6594. bool val = lua_toboolean(L, 2);
  6595. inst->setVirtual(val);
  6596. return 0;
  6597. }
  6598. static int Polycore_Scene_isVirtual(lua_State *L) {
  6599. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  6600. Scene *inst = (Scene*)lua_topointer(L, 1);
  6601. lua_pushboolean(L, inst->isVirtual());
  6602. return 1;
  6603. }
  6604. static int Polycore_Scene_isEnabled(lua_State *L) {
  6605. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  6606. Scene *inst = (Scene*)lua_topointer(L, 1);
  6607. lua_pushboolean(L, inst->isEnabled());
  6608. return 1;
  6609. }
  6610. static int Polycore_Scene_setEnabled(lua_State *L) {
  6611. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  6612. Scene *inst = (Scene*)lua_topointer(L, 1);
  6613. luaL_checktype(L, 2, LUA_TBOOLEAN);
  6614. bool enabled = lua_toboolean(L, 2);
  6615. inst->setEnabled(enabled);
  6616. return 0;
  6617. }
  6618. static int Polycore_Scene_getNumEntities(lua_State *L) {
  6619. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  6620. Scene *inst = (Scene*)lua_topointer(L, 1);
  6621. lua_pushinteger(L, inst->getNumEntities());
  6622. return 1;
  6623. }
  6624. static int Polycore_Scene_getEntity(lua_State *L) {
  6625. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  6626. Scene *inst = (Scene*)lua_topointer(L, 1);
  6627. luaL_checktype(L, 2, LUA_TNUMBER);
  6628. int index = lua_tointeger(L, 2);
  6629. void *ptrRetVal = (void*)inst->getEntity(index);
  6630. if(ptrRetVal == NULL) {
  6631. lua_pushnil(L);
  6632. } else {
  6633. lua_pushlightuserdata(L, ptrRetVal);
  6634. }
  6635. return 1;
  6636. }
  6637. static int Polycore_Scene_getEntityAtScreenPosition(lua_State *L) {
  6638. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  6639. Scene *inst = (Scene*)lua_topointer(L, 1);
  6640. luaL_checktype(L, 2, LUA_TNUMBER);
  6641. Number x = lua_tonumber(L, 2);
  6642. luaL_checktype(L, 3, LUA_TNUMBER);
  6643. Number y = lua_tonumber(L, 3);
  6644. void *ptrRetVal = (void*)inst->getEntityAtScreenPosition(x, y);
  6645. if(ptrRetVal == NULL) {
  6646. lua_pushnil(L);
  6647. } else {
  6648. lua_pushlightuserdata(L, ptrRetVal);
  6649. }
  6650. return 1;
  6651. }
  6652. static int Polycore_Scene_Render(lua_State *L) {
  6653. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  6654. Scene *inst = (Scene*)lua_topointer(L, 1);
  6655. Camera* targetCamera;
  6656. if(lua_islightuserdata(L, 2)) {
  6657. targetCamera = (Camera*)lua_topointer(L, 2);
  6658. } else {
  6659. targetCamera = NULL;
  6660. }
  6661. inst->Render(targetCamera);
  6662. return 0;
  6663. }
  6664. static int Polycore_Scene_RenderDepthOnly(lua_State *L) {
  6665. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  6666. Scene *inst = (Scene*)lua_topointer(L, 1);
  6667. luaL_checktype(L, 2, LUA_TLIGHTUSERDATA);
  6668. Camera* targetCamera = (Camera*)lua_topointer(L, 2);
  6669. inst->RenderDepthOnly(targetCamera);
  6670. return 0;
  6671. }
  6672. static int Polycore_Scene_readString(lua_State *L) {
  6673. luaL_checktype(L, 2, LUA_TLIGHTUSERDATA);
  6674. OSFILE* inFile = (OSFILE*)lua_topointer(L, 2);
  6675. lua_pushstring(L, Scene::readString(inFile).c_str());
  6676. return 1;
  6677. }
  6678. static int Polycore_Scene_loadScene(lua_State *L) {
  6679. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  6680. Scene *inst = (Scene*)lua_topointer(L, 1);
  6681. luaL_checktype(L, 2, LUA_TSTRING);
  6682. String fileName = String(lua_tostring(L, 2));
  6683. inst->loadScene(fileName);
  6684. return 0;
  6685. }
  6686. static int Polycore_Scene_generateLightmaps(lua_State *L) {
  6687. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  6688. Scene *inst = (Scene*)lua_topointer(L, 1);
  6689. luaL_checktype(L, 2, LUA_TNUMBER);
  6690. Number lightMapRes = lua_tonumber(L, 2);
  6691. luaL_checktype(L, 3, LUA_TNUMBER);
  6692. Number lightMapQuality = lua_tonumber(L, 3);
  6693. luaL_checktype(L, 4, LUA_TNUMBER);
  6694. int numRadPasses = lua_tointeger(L, 4);
  6695. inst->generateLightmaps(lightMapRes, lightMapQuality, numRadPasses);
  6696. return 0;
  6697. }
  6698. static int Polycore_Scene_addLight(lua_State *L) {
  6699. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  6700. Scene *inst = (Scene*)lua_topointer(L, 1);
  6701. luaL_checktype(L, 2, LUA_TLIGHTUSERDATA);
  6702. SceneLight* light = (SceneLight*)lua_topointer(L, 2);
  6703. inst->addLight(light);
  6704. return 0;
  6705. }
  6706. static int Polycore_Scene_removeLight(lua_State *L) {
  6707. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  6708. Scene *inst = (Scene*)lua_topointer(L, 1);
  6709. luaL_checktype(L, 2, LUA_TLIGHTUSERDATA);
  6710. SceneLight* light = (SceneLight*)lua_topointer(L, 2);
  6711. inst->removeLight(light);
  6712. return 0;
  6713. }
  6714. static int Polycore_Scene_getNearestLight(lua_State *L) {
  6715. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  6716. Scene *inst = (Scene*)lua_topointer(L, 1);
  6717. luaL_checktype(L, 2, LUA_TLIGHTUSERDATA);
  6718. Vector3 pos = *(Vector3*)lua_topointer(L, 2);
  6719. void *ptrRetVal = (void*)inst->getNearestLight(pos);
  6720. if(ptrRetVal == NULL) {
  6721. lua_pushnil(L);
  6722. } else {
  6723. lua_pushlightuserdata(L, ptrRetVal);
  6724. }
  6725. return 1;
  6726. }
  6727. static int Polycore_Scene_writeEntityMatrix(lua_State *L) {
  6728. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  6729. Scene *inst = (Scene*)lua_topointer(L, 1);
  6730. luaL_checktype(L, 2, LUA_TLIGHTUSERDATA);
  6731. SceneEntity* entity = (SceneEntity*)lua_topointer(L, 2);
  6732. luaL_checktype(L, 3, LUA_TLIGHTUSERDATA);
  6733. OSFILE* outFile = (OSFILE*)lua_topointer(L, 3);
  6734. inst->writeEntityMatrix(entity, outFile);
  6735. return 0;
  6736. }
  6737. static int Polycore_Scene_writeString(lua_State *L) {
  6738. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  6739. Scene *inst = (Scene*)lua_topointer(L, 1);
  6740. luaL_checktype(L, 2, LUA_TSTRING);
  6741. String str = String(lua_tostring(L, 2));
  6742. luaL_checktype(L, 3, LUA_TLIGHTUSERDATA);
  6743. OSFILE* outFile = (OSFILE*)lua_topointer(L, 3);
  6744. inst->writeString(str, outFile);
  6745. return 0;
  6746. }
  6747. static int Polycore_Scene_saveScene(lua_State *L) {
  6748. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  6749. Scene *inst = (Scene*)lua_topointer(L, 1);
  6750. luaL_checktype(L, 2, LUA_TSTRING);
  6751. String fileName = String(lua_tostring(L, 2));
  6752. inst->saveScene(fileName);
  6753. return 0;
  6754. }
  6755. static int Polycore_Scene_getNumStaticGeometry(lua_State *L) {
  6756. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  6757. Scene *inst = (Scene*)lua_topointer(L, 1);
  6758. lua_pushinteger(L, inst->getNumStaticGeometry());
  6759. return 1;
  6760. }
  6761. static int Polycore_Scene_getStaticGeometry(lua_State *L) {
  6762. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  6763. Scene *inst = (Scene*)lua_topointer(L, 1);
  6764. luaL_checktype(L, 2, LUA_TNUMBER);
  6765. int index = lua_tointeger(L, 2);
  6766. void *ptrRetVal = (void*)inst->getStaticGeometry(index);
  6767. if(ptrRetVal == NULL) {
  6768. lua_pushnil(L);
  6769. } else {
  6770. lua_pushlightuserdata(L, ptrRetVal);
  6771. }
  6772. return 1;
  6773. }
  6774. static int Polycore_Scene_loadCollisionChild(lua_State *L) {
  6775. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  6776. Scene *inst = (Scene*)lua_topointer(L, 1);
  6777. luaL_checktype(L, 2, LUA_TLIGHTUSERDATA);
  6778. SceneEntity* entity = (SceneEntity*)lua_topointer(L, 2);
  6779. bool autoCollide;
  6780. if(lua_isboolean(L, 3)) {
  6781. autoCollide = lua_toboolean(L, 3);
  6782. } else {
  6783. autoCollide = false;
  6784. }
  6785. int type;
  6786. if(lua_isnumber(L, 4)) {
  6787. type = lua_tointeger(L, 4);
  6788. } else {
  6789. type = 0;
  6790. }
  6791. inst->loadCollisionChild(entity, autoCollide, type);
  6792. return 0;
  6793. }
  6794. static int Polycore_Scene_getNumLights(lua_State *L) {
  6795. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  6796. Scene *inst = (Scene*)lua_topointer(L, 1);
  6797. lua_pushinteger(L, inst->getNumLights());
  6798. return 1;
  6799. }
  6800. static int Polycore_Scene_getLight(lua_State *L) {
  6801. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  6802. Scene *inst = (Scene*)lua_topointer(L, 1);
  6803. luaL_checktype(L, 2, LUA_TNUMBER);
  6804. int index = lua_tointeger(L, 2);
  6805. void *ptrRetVal = (void*)inst->getLight(index);
  6806. if(ptrRetVal == NULL) {
  6807. lua_pushnil(L);
  6808. } else {
  6809. lua_pushlightuserdata(L, ptrRetVal);
  6810. }
  6811. return 1;
  6812. }
  6813. static int Polycore_Scene_getCustomEntityByType(lua_State *L) {
  6814. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  6815. Scene *inst = (Scene*)lua_topointer(L, 1);
  6816. luaL_checktype(L, 2, LUA_TSTRING);
  6817. String type = String(lua_tostring(L, 2));
  6818. void *ptrRetVal = (void*)inst->getCustomEntityByType(type);
  6819. if(ptrRetVal == NULL) {
  6820. lua_pushnil(L);
  6821. } else {
  6822. lua_pushlightuserdata(L, ptrRetVal);
  6823. }
  6824. return 1;
  6825. }
  6826. static int Polycore_delete_Scene(lua_State *L) {
  6827. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  6828. Scene *inst = (Scene*)lua_topointer(L, 1);
  6829. delete inst;
  6830. return 0;
  6831. }
  6832. static int Polycore_SceneEntity_get_castShadows(lua_State *L) {
  6833. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  6834. SceneEntity *inst = (SceneEntity*)lua_topointer(L, 1);
  6835. lua_pushboolean(L, inst->castShadows);
  6836. return 1;
  6837. }
  6838. static int Polycore_SceneEntity_set_castShadows(lua_State *L) {
  6839. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  6840. SceneEntity *inst = (SceneEntity*)lua_topointer(L, 1);
  6841. bool param = lua_toboolean(L, 2);
  6842. inst->castShadows = param;
  6843. return 0;
  6844. }
  6845. static int Polycore_SceneEntity(lua_State *L) {
  6846. SceneEntity *inst = new SceneEntity();
  6847. lua_pushlightuserdata(L, (void*)inst);
  6848. return 1;
  6849. }
  6850. static int Polycore_SceneEntity_testMouseCollision(lua_State *L) {
  6851. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  6852. SceneEntity *inst = (SceneEntity*)lua_topointer(L, 1);
  6853. luaL_checktype(L, 2, LUA_TNUMBER);
  6854. Number x = lua_tonumber(L, 2);
  6855. luaL_checktype(L, 3, LUA_TNUMBER);
  6856. Number y = lua_tonumber(L, 3);
  6857. lua_pushboolean(L, inst->testMouseCollision(x, y));
  6858. return 1;
  6859. }
  6860. static int Polycore_delete_SceneEntity(lua_State *L) {
  6861. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  6862. SceneEntity *inst = (SceneEntity*)lua_topointer(L, 1);
  6863. delete inst;
  6864. return 0;
  6865. }
  6866. static int Polycore_SceneLabel(lua_State *L) {
  6867. luaL_checktype(L, 1, LUA_TSTRING);
  6868. String fontName = String(lua_tostring(L, 1));
  6869. luaL_checktype(L, 2, LUA_TSTRING);
  6870. String text = String(lua_tostring(L, 2));
  6871. luaL_checktype(L, 3, LUA_TNUMBER);
  6872. int size = lua_tointeger(L, 3);
  6873. luaL_checktype(L, 4, LUA_TNUMBER);
  6874. Number scale = lua_tonumber(L, 4);
  6875. luaL_checktype(L, 5, LUA_TNUMBER);
  6876. int amode = lua_tointeger(L, 5);
  6877. SceneLabel *inst = new SceneLabel(fontName, text, size, scale, amode);
  6878. lua_pushlightuserdata(L, (void*)inst);
  6879. return 1;
  6880. }
  6881. static int Polycore_SceneLabel_setText(lua_State *L) {
  6882. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  6883. SceneLabel *inst = (SceneLabel*)lua_topointer(L, 1);
  6884. luaL_checktype(L, 2, LUA_TSTRING);
  6885. String newText = String(lua_tostring(L, 2));
  6886. inst->setText(newText);
  6887. return 0;
  6888. }
  6889. static int Polycore_SceneLabel_getLabel(lua_State *L) {
  6890. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  6891. SceneLabel *inst = (SceneLabel*)lua_topointer(L, 1);
  6892. void *ptrRetVal = (void*)inst->getLabel();
  6893. if(ptrRetVal == NULL) {
  6894. lua_pushnil(L);
  6895. } else {
  6896. lua_pushlightuserdata(L, ptrRetVal);
  6897. }
  6898. return 1;
  6899. }
  6900. static int Polycore_delete_SceneLabel(lua_State *L) {
  6901. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  6902. SceneLabel *inst = (SceneLabel*)lua_topointer(L, 1);
  6903. delete inst;
  6904. return 0;
  6905. }
  6906. static int Polycore_SceneLight_get_specularLightColor(lua_State *L) {
  6907. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  6908. SceneLight *inst = (SceneLight*)lua_topointer(L, 1);
  6909. lua_pushlightuserdata(L, &inst->specularLightColor);
  6910. return 1;
  6911. }
  6912. static int Polycore_SceneLight_get_lightColor(lua_State *L) {
  6913. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  6914. SceneLight *inst = (SceneLight*)lua_topointer(L, 1);
  6915. lua_pushlightuserdata(L, &inst->lightColor);
  6916. return 1;
  6917. }
  6918. static int Polycore_SceneLight(lua_State *L) {
  6919. luaL_checktype(L, 1, LUA_TNUMBER);
  6920. int type = lua_tointeger(L, 1);
  6921. luaL_checktype(L, 2, LUA_TLIGHTUSERDATA);
  6922. Scene* parentScene = (Scene*)lua_topointer(L, 2);
  6923. luaL_checktype(L, 3, LUA_TNUMBER);
  6924. Number intensity = lua_tonumber(L, 3);
  6925. Number constantAttenuation;
  6926. if(lua_isnumber(L, 4)) {
  6927. constantAttenuation = lua_tonumber(L, 4);
  6928. } else {
  6929. constantAttenuation = 1;
  6930. }
  6931. Number linearAttenuation;
  6932. if(lua_isnumber(L, 5)) {
  6933. linearAttenuation = lua_tonumber(L, 5);
  6934. } else {
  6935. linearAttenuation = 1;
  6936. }
  6937. Number quadraticAttenuation;
  6938. if(lua_isnumber(L, 6)) {
  6939. quadraticAttenuation = lua_tonumber(L, 6);
  6940. } else {
  6941. quadraticAttenuation = 1;
  6942. }
  6943. SceneLight *inst = new SceneLight(type, parentScene, intensity, constantAttenuation, linearAttenuation, quadraticAttenuation);
  6944. lua_pushlightuserdata(L, (void*)inst);
  6945. return 1;
  6946. }
  6947. static int Polycore_SceneLight_getIntensity(lua_State *L) {
  6948. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  6949. SceneLight *inst = (SceneLight*)lua_topointer(L, 1);
  6950. lua_pushnumber(L, inst->getIntensity());
  6951. return 1;
  6952. }
  6953. static int Polycore_SceneLight_setIntensity(lua_State *L) {
  6954. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  6955. SceneLight *inst = (SceneLight*)lua_topointer(L, 1);
  6956. luaL_checktype(L, 2, LUA_TNUMBER);
  6957. Number newIntensity = lua_tonumber(L, 2);
  6958. inst->setIntensity(newIntensity);
  6959. return 0;
  6960. }
  6961. static int Polycore_SceneLight_setAttenuation(lua_State *L) {
  6962. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  6963. SceneLight *inst = (SceneLight*)lua_topointer(L, 1);
  6964. luaL_checktype(L, 2, LUA_TNUMBER);
  6965. Number constantAttenuation = lua_tonumber(L, 2);
  6966. luaL_checktype(L, 3, LUA_TNUMBER);
  6967. Number linearAttenuation = lua_tonumber(L, 3);
  6968. luaL_checktype(L, 4, LUA_TNUMBER);
  6969. Number quadraticAttenuation = lua_tonumber(L, 4);
  6970. inst->setAttenuation(constantAttenuation, linearAttenuation, quadraticAttenuation);
  6971. return 0;
  6972. }
  6973. static int Polycore_SceneLight_getConstantAttenuation(lua_State *L) {
  6974. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  6975. SceneLight *inst = (SceneLight*)lua_topointer(L, 1);
  6976. lua_pushnumber(L, inst->getConstantAttenuation());
  6977. return 1;
  6978. }
  6979. static int Polycore_SceneLight_getLinearAttenuation(lua_State *L) {
  6980. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  6981. SceneLight *inst = (SceneLight*)lua_topointer(L, 1);
  6982. lua_pushnumber(L, inst->getLinearAttenuation());
  6983. return 1;
  6984. }
  6985. static int Polycore_SceneLight_getQuadraticAttenuation(lua_State *L) {
  6986. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  6987. SceneLight *inst = (SceneLight*)lua_topointer(L, 1);
  6988. lua_pushnumber(L, inst->getQuadraticAttenuation());
  6989. return 1;
  6990. }
  6991. static int Polycore_SceneLight_getType(lua_State *L) {
  6992. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  6993. SceneLight *inst = (SceneLight*)lua_topointer(L, 1);
  6994. lua_pushinteger(L, inst->getType());
  6995. return 1;
  6996. }
  6997. static int Polycore_SceneLight_renderDepthMap(lua_State *L) {
  6998. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  6999. SceneLight *inst = (SceneLight*)lua_topointer(L, 1);
  7000. luaL_checktype(L, 2, LUA_TLIGHTUSERDATA);
  7001. Scene* scene = (Scene*)lua_topointer(L, 2);
  7002. inst->renderDepthMap(scene);
  7003. return 0;
  7004. }
  7005. static int Polycore_SceneLight_Render(lua_State *L) {
  7006. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  7007. SceneLight *inst = (SceneLight*)lua_topointer(L, 1);
  7008. inst->Render();
  7009. return 0;
  7010. }
  7011. static int Polycore_SceneLight_getLightViewMatrix(lua_State *L) {
  7012. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  7013. SceneLight *inst = (SceneLight*)lua_topointer(L, 1);
  7014. Matrix4 *retInst = new Matrix4 ();
  7015. *retInst = inst->getLightViewMatrix();
  7016. lua_pushlightuserdata(L, retInst);
  7017. return 1;
  7018. }
  7019. static int Polycore_SceneLight_getZBufferTexture(lua_State *L) {
  7020. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  7021. SceneLight *inst = (SceneLight*)lua_topointer(L, 1);
  7022. void *ptrRetVal = (void*)inst->getZBufferTexture();
  7023. if(ptrRetVal == NULL) {
  7024. lua_pushnil(L);
  7025. } else {
  7026. lua_pushlightuserdata(L, ptrRetVal);
  7027. }
  7028. return 1;
  7029. }
  7030. static int Polycore_SceneLight_setSpecularLightColor(lua_State *L) {
  7031. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  7032. SceneLight *inst = (SceneLight*)lua_topointer(L, 1);
  7033. luaL_checktype(L, 2, LUA_TNUMBER);
  7034. Number r = lua_tonumber(L, 2);
  7035. luaL_checktype(L, 3, LUA_TNUMBER);
  7036. Number g = lua_tonumber(L, 3);
  7037. luaL_checktype(L, 4, LUA_TNUMBER);
  7038. Number b = lua_tonumber(L, 4);
  7039. luaL_checktype(L, 5, LUA_TNUMBER);
  7040. Number a = lua_tonumber(L, 5);
  7041. inst->setSpecularLightColor(r, g, b, a);
  7042. return 0;
  7043. }
  7044. static int Polycore_SceneLight_setDiffuseLightColor(lua_State *L) {
  7045. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  7046. SceneLight *inst = (SceneLight*)lua_topointer(L, 1);
  7047. luaL_checktype(L, 2, LUA_TNUMBER);
  7048. Number r = lua_tonumber(L, 2);
  7049. luaL_checktype(L, 3, LUA_TNUMBER);
  7050. Number g = lua_tonumber(L, 3);
  7051. luaL_checktype(L, 4, LUA_TNUMBER);
  7052. Number b = lua_tonumber(L, 4);
  7053. inst->setDiffuseLightColor(r, g, b);
  7054. return 0;
  7055. }
  7056. static int Polycore_SceneLight_setLightColor(lua_State *L) {
  7057. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  7058. SceneLight *inst = (SceneLight*)lua_topointer(L, 1);
  7059. luaL_checktype(L, 2, LUA_TNUMBER);
  7060. Number r = lua_tonumber(L, 2);
  7061. luaL_checktype(L, 3, LUA_TNUMBER);
  7062. Number g = lua_tonumber(L, 3);
  7063. luaL_checktype(L, 4, LUA_TNUMBER);
  7064. Number b = lua_tonumber(L, 4);
  7065. Number a;
  7066. if(lua_isnumber(L, 5)) {
  7067. a = lua_tonumber(L, 5);
  7068. } else {
  7069. a = 1.0;
  7070. }
  7071. inst->setLightColor(r, g, b, a);
  7072. return 0;
  7073. }
  7074. static int Polycore_SceneLight_setSpotlightProperties(lua_State *L) {
  7075. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  7076. SceneLight *inst = (SceneLight*)lua_topointer(L, 1);
  7077. luaL_checktype(L, 2, LUA_TNUMBER);
  7078. Number spotlightCutoff = lua_tonumber(L, 2);
  7079. luaL_checktype(L, 3, LUA_TNUMBER);
  7080. Number spotlightExponent = lua_tonumber(L, 3);
  7081. inst->setSpotlightProperties(spotlightCutoff, spotlightExponent);
  7082. return 0;
  7083. }
  7084. static int Polycore_SceneLight_getSpotlightCutoff(lua_State *L) {
  7085. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  7086. SceneLight *inst = (SceneLight*)lua_topointer(L, 1);
  7087. lua_pushnumber(L, inst->getSpotlightCutoff());
  7088. return 1;
  7089. }
  7090. static int Polycore_SceneLight_getSpotlightExponent(lua_State *L) {
  7091. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  7092. SceneLight *inst = (SceneLight*)lua_topointer(L, 1);
  7093. lua_pushnumber(L, inst->getSpotlightExponent());
  7094. return 1;
  7095. }
  7096. static int Polycore_SceneLight_enableShadows(lua_State *L) {
  7097. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  7098. SceneLight *inst = (SceneLight*)lua_topointer(L, 1);
  7099. luaL_checktype(L, 2, LUA_TBOOLEAN);
  7100. bool val = lua_toboolean(L, 2);
  7101. Number resolution;
  7102. if(lua_isnumber(L, 3)) {
  7103. resolution = lua_tonumber(L, 3);
  7104. } else {
  7105. resolution = 256;
  7106. }
  7107. inst->enableShadows(val, resolution);
  7108. return 0;
  7109. }
  7110. static int Polycore_SceneLight_setShadowMapFOV(lua_State *L) {
  7111. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  7112. SceneLight *inst = (SceneLight*)lua_topointer(L, 1);
  7113. luaL_checktype(L, 2, LUA_TNUMBER);
  7114. Number fov = lua_tonumber(L, 2);
  7115. inst->setShadowMapFOV(fov);
  7116. return 0;
  7117. }
  7118. static int Polycore_SceneLight_areShadowsEnabled(lua_State *L) {
  7119. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  7120. SceneLight *inst = (SceneLight*)lua_topointer(L, 1);
  7121. lua_pushboolean(L, inst->areShadowsEnabled());
  7122. return 1;
  7123. }
  7124. static int Polycore_SceneLight_getLightType(lua_State *L) {
  7125. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  7126. SceneLight *inst = (SceneLight*)lua_topointer(L, 1);
  7127. lua_pushinteger(L, inst->getLightType());
  7128. return 1;
  7129. }
  7130. static int Polycore_SceneLight_enableDebugDraw(lua_State *L) {
  7131. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  7132. SceneLight *inst = (SceneLight*)lua_topointer(L, 1);
  7133. luaL_checktype(L, 2, LUA_TBOOLEAN);
  7134. bool val = lua_toboolean(L, 2);
  7135. inst->enableDebugDraw(val);
  7136. return 0;
  7137. }
  7138. static int Polycore_SceneLight_setLightImportance(lua_State *L) {
  7139. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  7140. SceneLight *inst = (SceneLight*)lua_topointer(L, 1);
  7141. luaL_checktype(L, 2, LUA_TNUMBER);
  7142. int newImportance = lua_tointeger(L, 2);
  7143. inst->setLightImportance(newImportance);
  7144. return 0;
  7145. }
  7146. static int Polycore_SceneLight_getLightImportance(lua_State *L) {
  7147. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  7148. SceneLight *inst = (SceneLight*)lua_topointer(L, 1);
  7149. lua_pushinteger(L, inst->getLightImportance());
  7150. return 1;
  7151. }
  7152. static int Polycore_delete_SceneLight(lua_State *L) {
  7153. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  7154. SceneLight *inst = (SceneLight*)lua_topointer(L, 1);
  7155. delete inst;
  7156. return 0;
  7157. }
  7158. static int Polycore_SceneLine(lua_State *L) {
  7159. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  7160. SceneEntity* ent1 = (SceneEntity*)lua_topointer(L, 1);
  7161. luaL_checktype(L, 2, LUA_TLIGHTUSERDATA);
  7162. SceneEntity* ent2 = (SceneEntity*)lua_topointer(L, 2);
  7163. SceneLine *inst = new SceneLine(ent1, ent2);
  7164. lua_pushlightuserdata(L, (void*)inst);
  7165. return 1;
  7166. }
  7167. static int Polycore_SceneLine_Render(lua_State *L) {
  7168. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  7169. SceneLine *inst = (SceneLine*)lua_topointer(L, 1);
  7170. inst->Render();
  7171. return 0;
  7172. }
  7173. static int Polycore_delete_SceneLine(lua_State *L) {
  7174. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  7175. SceneLine *inst = (SceneLine*)lua_topointer(L, 1);
  7176. delete inst;
  7177. return 0;
  7178. }
  7179. static int Polycore_SceneManager(lua_State *L) {
  7180. SceneManager *inst = new SceneManager();
  7181. lua_pushlightuserdata(L, (void*)inst);
  7182. return 1;
  7183. }
  7184. static int Polycore_SceneManager_addScene(lua_State *L) {
  7185. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  7186. SceneManager *inst = (SceneManager*)lua_topointer(L, 1);
  7187. luaL_checktype(L, 2, LUA_TLIGHTUSERDATA);
  7188. Scene* newScene = (Scene*)lua_topointer(L, 2);
  7189. inst->addScene(newScene);
  7190. return 0;
  7191. }
  7192. static int Polycore_SceneManager_Update(lua_State *L) {
  7193. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  7194. SceneManager *inst = (SceneManager*)lua_topointer(L, 1);
  7195. inst->Update();
  7196. return 0;
  7197. }
  7198. static int Polycore_SceneManager_UpdateVirtual(lua_State *L) {
  7199. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  7200. SceneManager *inst = (SceneManager*)lua_topointer(L, 1);
  7201. inst->UpdateVirtual();
  7202. return 0;
  7203. }
  7204. static int Polycore_SceneManager_removeScene(lua_State *L) {
  7205. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  7206. SceneManager *inst = (SceneManager*)lua_topointer(L, 1);
  7207. luaL_checktype(L, 2, LUA_TLIGHTUSERDATA);
  7208. Scene* scene = (Scene*)lua_topointer(L, 2);
  7209. inst->removeScene(scene);
  7210. return 0;
  7211. }
  7212. static int Polycore_SceneManager_registerRenderTexture(lua_State *L) {
  7213. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  7214. SceneManager *inst = (SceneManager*)lua_topointer(L, 1);
  7215. luaL_checktype(L, 2, LUA_TLIGHTUSERDATA);
  7216. SceneRenderTexture* r_enderTexture = (SceneRenderTexture*)lua_topointer(L, 2);
  7217. inst->registerRenderTexture(r_enderTexture);
  7218. return 0;
  7219. }
  7220. static int Polycore_SceneManager_unregisterRenderTexture(lua_State *L) {
  7221. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  7222. SceneManager *inst = (SceneManager*)lua_topointer(L, 1);
  7223. luaL_checktype(L, 2, LUA_TLIGHTUSERDATA);
  7224. SceneRenderTexture* r_enderTexture = (SceneRenderTexture*)lua_topointer(L, 2);
  7225. inst->unregisterRenderTexture(r_enderTexture);
  7226. return 0;
  7227. }
  7228. static int Polycore_delete_SceneManager(lua_State *L) {
  7229. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  7230. SceneManager *inst = (SceneManager*)lua_topointer(L, 1);
  7231. delete inst;
  7232. return 0;
  7233. }
  7234. static int Polycore_SceneMesh_get_lightmapIndex(lua_State *L) {
  7235. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  7236. SceneMesh *inst = (SceneMesh*)lua_topointer(L, 1);
  7237. lua_pushlightuserdata(L, &inst->lightmapIndex);
  7238. return 1;
  7239. }
  7240. static int Polycore_SceneMesh_get_showVertexNormals(lua_State *L) {
  7241. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  7242. SceneMesh *inst = (SceneMesh*)lua_topointer(L, 1);
  7243. lua_pushboolean(L, inst->showVertexNormals);
  7244. return 1;
  7245. }
  7246. static int Polycore_SceneMesh_set_showVertexNormals(lua_State *L) {
  7247. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  7248. SceneMesh *inst = (SceneMesh*)lua_topointer(L, 1);
  7249. bool param = lua_toboolean(L, 2);
  7250. inst->showVertexNormals = param;
  7251. return 0;
  7252. }
  7253. static int Polycore_SceneMesh(lua_State *L) {
  7254. luaL_checktype(L, 1, LUA_TSTRING);
  7255. String fileName = String(lua_tostring(L, 1));
  7256. SceneMesh *inst = new SceneMesh(fileName);
  7257. lua_pushlightuserdata(L, (void*)inst);
  7258. return 1;
  7259. }
  7260. static int Polycore_SceneMesh_Render(lua_State *L) {
  7261. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  7262. SceneMesh *inst = (SceneMesh*)lua_topointer(L, 1);
  7263. inst->Render();
  7264. return 0;
  7265. }
  7266. static int Polycore_SceneMesh_getLocalShaderOptions(lua_State *L) {
  7267. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  7268. SceneMesh *inst = (SceneMesh*)lua_topointer(L, 1);
  7269. void *ptrRetVal = (void*)inst->getLocalShaderOptions();
  7270. if(ptrRetVal == NULL) {
  7271. lua_pushnil(L);
  7272. } else {
  7273. lua_pushlightuserdata(L, ptrRetVal);
  7274. }
  7275. return 1;
  7276. }
  7277. static int Polycore_SceneMesh_getMesh(lua_State *L) {
  7278. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  7279. SceneMesh *inst = (SceneMesh*)lua_topointer(L, 1);
  7280. void *ptrRetVal = (void*)inst->getMesh();
  7281. if(ptrRetVal == NULL) {
  7282. lua_pushnil(L);
  7283. } else {
  7284. lua_pushlightuserdata(L, ptrRetVal);
  7285. }
  7286. return 1;
  7287. }
  7288. static int Polycore_SceneMesh_getTexture(lua_State *L) {
  7289. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  7290. SceneMesh *inst = (SceneMesh*)lua_topointer(L, 1);
  7291. void *ptrRetVal = (void*)inst->getTexture();
  7292. if(ptrRetVal == NULL) {
  7293. lua_pushnil(L);
  7294. } else {
  7295. lua_pushlightuserdata(L, ptrRetVal);
  7296. }
  7297. return 1;
  7298. }
  7299. static int Polycore_SceneMesh_getMaterial(lua_State *L) {
  7300. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  7301. SceneMesh *inst = (SceneMesh*)lua_topointer(L, 1);
  7302. void *ptrRetVal = (void*)inst->getMaterial();
  7303. if(ptrRetVal == NULL) {
  7304. lua_pushnil(L);
  7305. } else {
  7306. lua_pushlightuserdata(L, ptrRetVal);
  7307. }
  7308. return 1;
  7309. }
  7310. static int Polycore_SceneMesh_loadTexture(lua_State *L) {
  7311. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  7312. SceneMesh *inst = (SceneMesh*)lua_topointer(L, 1);
  7313. luaL_checktype(L, 2, LUA_TSTRING);
  7314. String fileName = String(lua_tostring(L, 2));
  7315. bool clamp;
  7316. if(lua_isboolean(L, 3)) {
  7317. clamp = lua_toboolean(L, 3);
  7318. } else {
  7319. clamp = true;
  7320. }
  7321. inst->loadTexture(fileName, clamp);
  7322. return 0;
  7323. }
  7324. static int Polycore_SceneMesh_loadSkeleton(lua_State *L) {
  7325. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  7326. SceneMesh *inst = (SceneMesh*)lua_topointer(L, 1);
  7327. luaL_checktype(L, 2, LUA_TSTRING);
  7328. String fileName = String(lua_tostring(L, 2));
  7329. inst->loadSkeleton(fileName);
  7330. return 0;
  7331. }
  7332. static int Polycore_SceneMesh_setTexture(lua_State *L) {
  7333. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  7334. SceneMesh *inst = (SceneMesh*)lua_topointer(L, 1);
  7335. luaL_checktype(L, 2, LUA_TLIGHTUSERDATA);
  7336. Texture* texture = (Texture*)lua_topointer(L, 2);
  7337. inst->setTexture(texture);
  7338. return 0;
  7339. }
  7340. static int Polycore_SceneMesh_setMaterial(lua_State *L) {
  7341. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  7342. SceneMesh *inst = (SceneMesh*)lua_topointer(L, 1);
  7343. luaL_checktype(L, 2, LUA_TLIGHTUSERDATA);
  7344. Material* material = (Material*)lua_topointer(L, 2);
  7345. inst->setMaterial(material);
  7346. return 0;
  7347. }
  7348. static int Polycore_SceneMesh_setMaterialByName(lua_State *L) {
  7349. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  7350. SceneMesh *inst = (SceneMesh*)lua_topointer(L, 1);
  7351. luaL_checktype(L, 2, LUA_TSTRING);
  7352. String materialName = String(lua_tostring(L, 2));
  7353. inst->setMaterialByName(materialName);
  7354. return 0;
  7355. }
  7356. static int Polycore_SceneMesh_setMesh(lua_State *L) {
  7357. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  7358. SceneMesh *inst = (SceneMesh*)lua_topointer(L, 1);
  7359. luaL_checktype(L, 2, LUA_TLIGHTUSERDATA);
  7360. Mesh* mesh = (Mesh*)lua_topointer(L, 2);
  7361. inst->setMesh(mesh);
  7362. return 0;
  7363. }
  7364. static int Polycore_SceneMesh_setSkeleton(lua_State *L) {
  7365. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  7366. SceneMesh *inst = (SceneMesh*)lua_topointer(L, 1);
  7367. luaL_checktype(L, 2, LUA_TLIGHTUSERDATA);
  7368. Skeleton* skeleton = (Skeleton*)lua_topointer(L, 2);
  7369. inst->setSkeleton(skeleton);
  7370. return 0;
  7371. }
  7372. static int Polycore_SceneMesh_getSkeleton(lua_State *L) {
  7373. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  7374. SceneMesh *inst = (SceneMesh*)lua_topointer(L, 1);
  7375. void *ptrRetVal = (void*)inst->getSkeleton();
  7376. if(ptrRetVal == NULL) {
  7377. lua_pushnil(L);
  7378. } else {
  7379. lua_pushlightuserdata(L, ptrRetVal);
  7380. }
  7381. return 1;
  7382. }
  7383. static int Polycore_SceneMesh_renderMeshLocally(lua_State *L) {
  7384. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  7385. SceneMesh *inst = (SceneMesh*)lua_topointer(L, 1);
  7386. inst->renderMeshLocally();
  7387. return 0;
  7388. }
  7389. static int Polycore_SceneMesh_cacheToVertexBuffer(lua_State *L) {
  7390. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  7391. SceneMesh *inst = (SceneMesh*)lua_topointer(L, 1);
  7392. luaL_checktype(L, 2, LUA_TBOOLEAN);
  7393. bool cache = lua_toboolean(L, 2);
  7394. inst->cacheToVertexBuffer(cache);
  7395. return 0;
  7396. }
  7397. static int Polycore_delete_SceneMesh(lua_State *L) {
  7398. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  7399. SceneMesh *inst = (SceneMesh*)lua_topointer(L, 1);
  7400. delete inst;
  7401. return 0;
  7402. }
  7403. static int Polycore_ScenePrimitive(lua_State *L) {
  7404. luaL_checktype(L, 1, LUA_TNUMBER);
  7405. int type = lua_tointeger(L, 1);
  7406. Number v1;
  7407. if(lua_isnumber(L, 2)) {
  7408. v1 = lua_tonumber(L, 2);
  7409. } else {
  7410. v1 = 1.0f;
  7411. }
  7412. Number v2;
  7413. if(lua_isnumber(L, 3)) {
  7414. v2 = lua_tonumber(L, 3);
  7415. } else {
  7416. v2 = 1.0f;
  7417. }
  7418. Number v3;
  7419. if(lua_isnumber(L, 4)) {
  7420. v3 = lua_tonumber(L, 4);
  7421. } else {
  7422. v3 = 1.0f;
  7423. }
  7424. Number v4;
  7425. if(lua_isnumber(L, 5)) {
  7426. v4 = lua_tonumber(L, 5);
  7427. } else {
  7428. v4 = 0.0f;
  7429. }
  7430. Number v5;
  7431. if(lua_isnumber(L, 6)) {
  7432. v5 = lua_tonumber(L, 6);
  7433. } else {
  7434. v5 = 0.0f;
  7435. }
  7436. ScenePrimitive *inst = new ScenePrimitive(type, v1, v2, v3, v4, v5);
  7437. lua_pushlightuserdata(L, (void*)inst);
  7438. return 1;
  7439. }
  7440. static int Polycore_delete_ScenePrimitive(lua_State *L) {
  7441. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  7442. ScenePrimitive *inst = (ScenePrimitive*)lua_topointer(L, 1);
  7443. delete inst;
  7444. return 0;
  7445. }
  7446. static int Polycore_SceneRenderTexture(lua_State *L) {
  7447. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  7448. Scene* targetScene = (Scene*)lua_topointer(L, 1);
  7449. luaL_checktype(L, 2, LUA_TLIGHTUSERDATA);
  7450. Camera* targetCamera = (Camera*)lua_topointer(L, 2);
  7451. luaL_checktype(L, 3, LUA_TNUMBER);
  7452. int r_enderWidth = lua_tointeger(L, 3);
  7453. luaL_checktype(L, 4, LUA_TNUMBER);
  7454. int r_enderHeight = lua_tointeger(L, 4);
  7455. SceneRenderTexture *inst = new SceneRenderTexture(targetScene, targetCamera, r_enderWidth, r_enderHeight);
  7456. lua_pushlightuserdata(L, (void*)inst);
  7457. return 1;
  7458. }
  7459. static int Polycore_SceneRenderTexture_drawScreen(lua_State *L) {
  7460. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  7461. SceneRenderTexture *inst = (SceneRenderTexture*)lua_topointer(L, 1);
  7462. inst->drawScreen();
  7463. return 0;
  7464. }
  7465. static int Polycore_SceneRenderTexture_getTargetTexture(lua_State *L) {
  7466. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  7467. SceneRenderTexture *inst = (SceneRenderTexture*)lua_topointer(L, 1);
  7468. void *ptrRetVal = (void*)inst->getTargetTexture();
  7469. if(ptrRetVal == NULL) {
  7470. lua_pushnil(L);
  7471. } else {
  7472. lua_pushlightuserdata(L, ptrRetVal);
  7473. }
  7474. return 1;
  7475. }
  7476. static int Polycore_SceneRenderTexture_getTargetScene(lua_State *L) {
  7477. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  7478. SceneRenderTexture *inst = (SceneRenderTexture*)lua_topointer(L, 1);
  7479. void *ptrRetVal = (void*)inst->getTargetScene();
  7480. if(ptrRetVal == NULL) {
  7481. lua_pushnil(L);
  7482. } else {
  7483. lua_pushlightuserdata(L, ptrRetVal);
  7484. }
  7485. return 1;
  7486. }
  7487. static int Polycore_SceneRenderTexture_getTargetCamera(lua_State *L) {
  7488. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  7489. SceneRenderTexture *inst = (SceneRenderTexture*)lua_topointer(L, 1);
  7490. void *ptrRetVal = (void*)inst->getTargetCamera();
  7491. if(ptrRetVal == NULL) {
  7492. lua_pushnil(L);
  7493. } else {
  7494. lua_pushlightuserdata(L, ptrRetVal);
  7495. }
  7496. return 1;
  7497. }
  7498. static int Polycore_delete_SceneRenderTexture(lua_State *L) {
  7499. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  7500. SceneRenderTexture *inst = (SceneRenderTexture*)lua_topointer(L, 1);
  7501. delete inst;
  7502. return 0;
  7503. }
  7504. static int Polycore_SceneSound(lua_State *L) {
  7505. luaL_checktype(L, 1, LUA_TSTRING);
  7506. String fileName = String(lua_tostring(L, 1));
  7507. luaL_checktype(L, 2, LUA_TNUMBER);
  7508. Number referenceDistance = lua_tonumber(L, 2);
  7509. luaL_checktype(L, 3, LUA_TNUMBER);
  7510. Number maxDistance = lua_tonumber(L, 3);
  7511. SceneSound *inst = new SceneSound(fileName, referenceDistance, maxDistance);
  7512. lua_pushlightuserdata(L, (void*)inst);
  7513. return 1;
  7514. }
  7515. static int Polycore_SceneSound_Update(lua_State *L) {
  7516. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  7517. SceneSound *inst = (SceneSound*)lua_topointer(L, 1);
  7518. inst->Update();
  7519. return 0;
  7520. }
  7521. static int Polycore_SceneSound_getSound(lua_State *L) {
  7522. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  7523. SceneSound *inst = (SceneSound*)lua_topointer(L, 1);
  7524. void *ptrRetVal = (void*)inst->getSound();
  7525. if(ptrRetVal == NULL) {
  7526. lua_pushnil(L);
  7527. } else {
  7528. lua_pushlightuserdata(L, ptrRetVal);
  7529. }
  7530. return 1;
  7531. }
  7532. static int Polycore_delete_SceneSound(lua_State *L) {
  7533. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  7534. SceneSound *inst = (SceneSound*)lua_topointer(L, 1);
  7535. delete inst;
  7536. return 0;
  7537. }
  7538. static int Polycore_SceneSoundListener(lua_State *L) {
  7539. SceneSoundListener *inst = new SceneSoundListener();
  7540. lua_pushlightuserdata(L, (void*)inst);
  7541. return 1;
  7542. }
  7543. static int Polycore_SceneSoundListener_Update(lua_State *L) {
  7544. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  7545. SceneSoundListener *inst = (SceneSoundListener*)lua_topointer(L, 1);
  7546. inst->Update();
  7547. return 0;
  7548. }
  7549. static int Polycore_delete_SceneSoundListener(lua_State *L) {
  7550. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  7551. SceneSoundListener *inst = (SceneSoundListener*)lua_topointer(L, 1);
  7552. delete inst;
  7553. return 0;
  7554. }
  7555. static int Polycore_Screen_get_enabled(lua_State *L) {
  7556. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  7557. Screen *inst = (Screen*)lua_topointer(L, 1);
  7558. lua_pushboolean(L, inst->enabled);
  7559. return 1;
  7560. }
  7561. static int Polycore_Screen_set_enabled(lua_State *L) {
  7562. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  7563. Screen *inst = (Screen*)lua_topointer(L, 1);
  7564. bool param = lua_toboolean(L, 2);
  7565. inst->enabled = param;
  7566. return 0;
  7567. }
  7568. static int Polycore_Screen(lua_State *L) {
  7569. Screen *inst = new Screen();
  7570. lua_pushlightuserdata(L, (void*)inst);
  7571. return 1;
  7572. }
  7573. static int Polycore_Screen_addChild(lua_State *L) {
  7574. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  7575. Screen *inst = (Screen*)lua_topointer(L, 1);
  7576. luaL_checktype(L, 2, LUA_TLIGHTUSERDATA);
  7577. ScreenEntity* newEntity = (ScreenEntity*)lua_topointer(L, 2);
  7578. void *ptrRetVal = (void*)inst->addChild(newEntity);
  7579. if(ptrRetVal == NULL) {
  7580. lua_pushnil(L);
  7581. } else {
  7582. lua_pushlightuserdata(L, ptrRetVal);
  7583. }
  7584. return 1;
  7585. }
  7586. static int Polycore_Screen_removeChild(lua_State *L) {
  7587. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  7588. Screen *inst = (Screen*)lua_topointer(L, 1);
  7589. luaL_checktype(L, 2, LUA_TLIGHTUSERDATA);
  7590. ScreenEntity* entityToRemove = (ScreenEntity*)lua_topointer(L, 2);
  7591. void *ptrRetVal = (void*)inst->removeChild(entityToRemove);
  7592. if(ptrRetVal == NULL) {
  7593. lua_pushnil(L);
  7594. } else {
  7595. lua_pushlightuserdata(L, ptrRetVal);
  7596. }
  7597. return 1;
  7598. }
  7599. static int Polycore_Screen_setScreenOffset(lua_State *L) {
  7600. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  7601. Screen *inst = (Screen*)lua_topointer(L, 1);
  7602. luaL_checktype(L, 2, LUA_TNUMBER);
  7603. Number x = lua_tonumber(L, 2);
  7604. luaL_checktype(L, 3, LUA_TNUMBER);
  7605. Number y = lua_tonumber(L, 3);
  7606. inst->setScreenOffset(x, y);
  7607. return 0;
  7608. }
  7609. static int Polycore_Screen_getScreenOffset(lua_State *L) {
  7610. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  7611. Screen *inst = (Screen*)lua_topointer(L, 1);
  7612. Vector2 *retInst = new Vector2();
  7613. *retInst = inst->getScreenOffset();
  7614. lua_pushlightuserdata(L, retInst);
  7615. return 1;
  7616. }
  7617. static int Polycore_Screen_Shutdown(lua_State *L) {
  7618. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  7619. Screen *inst = (Screen*)lua_topointer(L, 1);
  7620. inst->Shutdown();
  7621. return 0;
  7622. }
  7623. static int Polycore_Screen_Update(lua_State *L) {
  7624. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  7625. Screen *inst = (Screen*)lua_topointer(L, 1);
  7626. inst->Update();
  7627. return 0;
  7628. }
  7629. static int Polycore_Screen_getEntityAt(lua_State *L) {
  7630. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  7631. Screen *inst = (Screen*)lua_topointer(L, 1);
  7632. luaL_checktype(L, 2, LUA_TNUMBER);
  7633. Number x = lua_tonumber(L, 2);
  7634. luaL_checktype(L, 3, LUA_TNUMBER);
  7635. Number y = lua_tonumber(L, 3);
  7636. void *ptrRetVal = (void*)inst->getEntityAt(x, y);
  7637. if(ptrRetVal == NULL) {
  7638. lua_pushnil(L);
  7639. } else {
  7640. lua_pushlightuserdata(L, ptrRetVal);
  7641. }
  7642. return 1;
  7643. }
  7644. static int Polycore_Screen_Render(lua_State *L) {
  7645. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  7646. Screen *inst = (Screen*)lua_topointer(L, 1);
  7647. inst->Render();
  7648. return 0;
  7649. }
  7650. static int Polycore_Screen_setRenderer(lua_State *L) {
  7651. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  7652. Screen *inst = (Screen*)lua_topointer(L, 1);
  7653. luaL_checktype(L, 2, LUA_TLIGHTUSERDATA);
  7654. Renderer* r_enderer = (Renderer*)lua_topointer(L, 2);
  7655. inst->setRenderer(r_enderer);
  7656. return 0;
  7657. }
  7658. static int Polycore_Screen_setNormalizedCoordinates(lua_State *L) {
  7659. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  7660. Screen *inst = (Screen*)lua_topointer(L, 1);
  7661. luaL_checktype(L, 2, LUA_TBOOLEAN);
  7662. bool newVal = lua_toboolean(L, 2);
  7663. Number yCoordinateSize;
  7664. if(lua_isnumber(L, 3)) {
  7665. yCoordinateSize = lua_tonumber(L, 3);
  7666. } else {
  7667. yCoordinateSize = 1.0f;
  7668. }
  7669. inst->setNormalizedCoordinates(newVal, yCoordinateSize);
  7670. return 0;
  7671. }
  7672. static int Polycore_Screen_setScreenShader(lua_State *L) {
  7673. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  7674. Screen *inst = (Screen*)lua_topointer(L, 1);
  7675. luaL_checktype(L, 2, LUA_TSTRING);
  7676. String shaderName = String(lua_tostring(L, 2));
  7677. inst->setScreenShader(shaderName);
  7678. return 0;
  7679. }
  7680. static int Polycore_Screen_clearScreenShader(lua_State *L) {
  7681. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  7682. Screen *inst = (Screen*)lua_topointer(L, 1);
  7683. inst->clearScreenShader();
  7684. return 0;
  7685. }
  7686. static int Polycore_Screen_getHighestZIndex(lua_State *L) {
  7687. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  7688. Screen *inst = (Screen*)lua_topointer(L, 1);
  7689. lua_pushinteger(L, inst->getHighestZIndex());
  7690. return 1;
  7691. }
  7692. static int Polycore_Screen_sortChildren(lua_State *L) {
  7693. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  7694. Screen *inst = (Screen*)lua_topointer(L, 1);
  7695. inst->sortChildren();
  7696. return 0;
  7697. }
  7698. static int Polycore_Screen_cmpZindex(lua_State *L) {
  7699. luaL_checktype(L, 2, LUA_TLIGHTUSERDATA);
  7700. ScreenEntity* left = (ScreenEntity*)lua_topointer(L, 2);
  7701. luaL_checktype(L, 3, LUA_TLIGHTUSERDATA);
  7702. ScreenEntity* right = (ScreenEntity*)lua_topointer(L, 3);
  7703. lua_pushboolean(L, Screen::cmpZindex(left, right));
  7704. return 1;
  7705. }
  7706. static int Polycore_Screen_handleInputEvent(lua_State *L) {
  7707. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  7708. Screen *inst = (Screen*)lua_topointer(L, 1);
  7709. luaL_checktype(L, 2, LUA_TLIGHTUSERDATA);
  7710. InputEvent* inputEvent = (InputEvent*)lua_topointer(L, 2);
  7711. inst->handleInputEvent(inputEvent);
  7712. return 0;
  7713. }
  7714. static int Polycore_Screen_hasFilterShader(lua_State *L) {
  7715. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  7716. Screen *inst = (Screen*)lua_topointer(L, 1);
  7717. lua_pushboolean(L, inst->hasFilterShader());
  7718. return 1;
  7719. }
  7720. static int Polycore_Screen_drawFilter(lua_State *L) {
  7721. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  7722. Screen *inst = (Screen*)lua_topointer(L, 1);
  7723. inst->drawFilter();
  7724. return 0;
  7725. }
  7726. static int Polycore_Screen_usesNormalizedCoordinates(lua_State *L) {
  7727. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  7728. Screen *inst = (Screen*)lua_topointer(L, 1);
  7729. lua_pushboolean(L, inst->usesNormalizedCoordinates());
  7730. return 1;
  7731. }
  7732. static int Polycore_Screen_getYCoordinateSize(lua_State *L) {
  7733. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  7734. Screen *inst = (Screen*)lua_topointer(L, 1);
  7735. lua_pushnumber(L, inst->getYCoordinateSize());
  7736. return 1;
  7737. }
  7738. static int Polycore_Screen_getRootEntity(lua_State *L) {
  7739. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  7740. Screen *inst = (Screen*)lua_topointer(L, 1);
  7741. void *ptrRetVal = (void*)inst->getRootEntity();
  7742. if(ptrRetVal == NULL) {
  7743. lua_pushnil(L);
  7744. } else {
  7745. lua_pushlightuserdata(L, ptrRetVal);
  7746. }
  7747. return 1;
  7748. }
  7749. static int Polycore_Screen_getScreenShaderMaterial(lua_State *L) {
  7750. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  7751. Screen *inst = (Screen*)lua_topointer(L, 1);
  7752. void *ptrRetVal = (void*)inst->getScreenShaderMaterial();
  7753. if(ptrRetVal == NULL) {
  7754. lua_pushnil(L);
  7755. } else {
  7756. lua_pushlightuserdata(L, ptrRetVal);
  7757. }
  7758. return 1;
  7759. }
  7760. static int Polycore_delete_Screen(lua_State *L) {
  7761. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  7762. Screen *inst = (Screen*)lua_topointer(L, 1);
  7763. delete inst;
  7764. return 0;
  7765. }
  7766. static int Polycore_ScreenCurve(lua_State *L) {
  7767. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  7768. BezierCurve* curve = (BezierCurve*)lua_topointer(L, 1);
  7769. luaL_checktype(L, 2, LUA_TNUMBER);
  7770. int numVertices = lua_tointeger(L, 2);
  7771. ScreenCurve *inst = new ScreenCurve(curve, numVertices);
  7772. lua_pushlightuserdata(L, (void*)inst);
  7773. return 1;
  7774. }
  7775. static int Polycore_delete_ScreenCurve(lua_State *L) {
  7776. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  7777. ScreenCurve *inst = (ScreenCurve*)lua_topointer(L, 1);
  7778. delete inst;
  7779. return 0;
  7780. }
  7781. static int Polycore_ScreenEntity_get_hasFocus(lua_State *L) {
  7782. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  7783. ScreenEntity *inst = (ScreenEntity*)lua_topointer(L, 1);
  7784. lua_pushboolean(L, inst->hasFocus);
  7785. return 1;
  7786. }
  7787. static int Polycore_ScreenEntity_get_blockMouseInput(lua_State *L) {
  7788. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  7789. ScreenEntity *inst = (ScreenEntity*)lua_topointer(L, 1);
  7790. lua_pushboolean(L, inst->blockMouseInput);
  7791. return 1;
  7792. }
  7793. static int Polycore_ScreenEntity_get_zindex(lua_State *L) {
  7794. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  7795. ScreenEntity *inst = (ScreenEntity*)lua_topointer(L, 1);
  7796. lua_pushinteger(L, inst->zindex);
  7797. return 1;
  7798. }
  7799. static int Polycore_ScreenEntity_get_snapToPixels(lua_State *L) {
  7800. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  7801. ScreenEntity *inst = (ScreenEntity*)lua_topointer(L, 1);
  7802. lua_pushboolean(L, inst->snapToPixels);
  7803. return 1;
  7804. }
  7805. static int Polycore_ScreenEntity_set_hasFocus(lua_State *L) {
  7806. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  7807. ScreenEntity *inst = (ScreenEntity*)lua_topointer(L, 1);
  7808. bool param = lua_toboolean(L, 2);
  7809. inst->hasFocus = param;
  7810. return 0;
  7811. }
  7812. static int Polycore_ScreenEntity_set_blockMouseInput(lua_State *L) {
  7813. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  7814. ScreenEntity *inst = (ScreenEntity*)lua_topointer(L, 1);
  7815. bool param = lua_toboolean(L, 2);
  7816. inst->blockMouseInput = param;
  7817. return 0;
  7818. }
  7819. static int Polycore_ScreenEntity_set_zindex(lua_State *L) {
  7820. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  7821. ScreenEntity *inst = (ScreenEntity*)lua_topointer(L, 1);
  7822. int param = lua_tointeger(L, 2);
  7823. inst->zindex = param;
  7824. return 0;
  7825. }
  7826. static int Polycore_ScreenEntity_set_snapToPixels(lua_State *L) {
  7827. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  7828. ScreenEntity *inst = (ScreenEntity*)lua_topointer(L, 1);
  7829. bool param = lua_toboolean(L, 2);
  7830. inst->snapToPixels = param;
  7831. return 0;
  7832. }
  7833. static int Polycore_ScreenEntity(lua_State *L) {
  7834. ScreenEntity *inst = new ScreenEntity();
  7835. lua_pushlightuserdata(L, (void*)inst);
  7836. return 1;
  7837. }
  7838. static int Polycore_ScreenEntity_setPosition(lua_State *L) {
  7839. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  7840. ScreenEntity *inst = (ScreenEntity*)lua_topointer(L, 1);
  7841. luaL_checktype(L, 2, LUA_TNUMBER);
  7842. Number x = lua_tonumber(L, 2);
  7843. luaL_checktype(L, 3, LUA_TNUMBER);
  7844. Number y = lua_tonumber(L, 3);
  7845. inst->setPosition(x, y);
  7846. return 0;
  7847. }
  7848. static int Polycore_ScreenEntity_setScale(lua_State *L) {
  7849. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  7850. ScreenEntity *inst = (ScreenEntity*)lua_topointer(L, 1);
  7851. luaL_checktype(L, 2, LUA_TNUMBER);
  7852. Number x = lua_tonumber(L, 2);
  7853. luaL_checktype(L, 3, LUA_TNUMBER);
  7854. Number y = lua_tonumber(L, 3);
  7855. inst->setScale(x, y);
  7856. return 0;
  7857. }
  7858. static int Polycore_ScreenEntity_setRotation(lua_State *L) {
  7859. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  7860. ScreenEntity *inst = (ScreenEntity*)lua_topointer(L, 1);
  7861. luaL_checktype(L, 2, LUA_TNUMBER);
  7862. Number roatation = lua_tonumber(L, 2);
  7863. inst->setRotation(roatation);
  7864. return 0;
  7865. }
  7866. static int Polycore_ScreenEntity_getRotation(lua_State *L) {
  7867. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  7868. ScreenEntity *inst = (ScreenEntity*)lua_topointer(L, 1);
  7869. lua_pushnumber(L, inst->getRotation());
  7870. return 1;
  7871. }
  7872. static int Polycore_ScreenEntity__onMouseDown(lua_State *L) {
  7873. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  7874. ScreenEntity *inst = (ScreenEntity*)lua_topointer(L, 1);
  7875. luaL_checktype(L, 2, LUA_TNUMBER);
  7876. Number x = lua_tonumber(L, 2);
  7877. luaL_checktype(L, 3, LUA_TNUMBER);
  7878. Number y = lua_tonumber(L, 3);
  7879. luaL_checktype(L, 4, LUA_TNUMBER);
  7880. int mouseButton = lua_tointeger(L, 4);
  7881. luaL_checktype(L, 5, LUA_TNUMBER);
  7882. int timestamp = lua_tointeger(L, 5);
  7883. lua_pushboolean(L, inst->_onMouseDown(x, y, mouseButton, timestamp));
  7884. return 1;
  7885. }
  7886. static int Polycore_ScreenEntity__onMouseUp(lua_State *L) {
  7887. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  7888. ScreenEntity *inst = (ScreenEntity*)lua_topointer(L, 1);
  7889. luaL_checktype(L, 2, LUA_TNUMBER);
  7890. Number x = lua_tonumber(L, 2);
  7891. luaL_checktype(L, 3, LUA_TNUMBER);
  7892. Number y = lua_tonumber(L, 3);
  7893. luaL_checktype(L, 4, LUA_TNUMBER);
  7894. int mouseButton = lua_tointeger(L, 4);
  7895. luaL_checktype(L, 5, LUA_TNUMBER);
  7896. int timestamp = lua_tointeger(L, 5);
  7897. lua_pushboolean(L, inst->_onMouseUp(x, y, mouseButton, timestamp));
  7898. return 1;
  7899. }
  7900. static int Polycore_ScreenEntity__onMouseMove(lua_State *L) {
  7901. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  7902. ScreenEntity *inst = (ScreenEntity*)lua_topointer(L, 1);
  7903. luaL_checktype(L, 2, LUA_TNUMBER);
  7904. Number x = lua_tonumber(L, 2);
  7905. luaL_checktype(L, 3, LUA_TNUMBER);
  7906. Number y = lua_tonumber(L, 3);
  7907. luaL_checktype(L, 4, LUA_TNUMBER);
  7908. int timestamp = lua_tointeger(L, 4);
  7909. inst->_onMouseMove(x, y, timestamp);
  7910. return 0;
  7911. }
  7912. static int Polycore_ScreenEntity__onMouseWheelUp(lua_State *L) {
  7913. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  7914. ScreenEntity *inst = (ScreenEntity*)lua_topointer(L, 1);
  7915. luaL_checktype(L, 2, LUA_TNUMBER);
  7916. Number x = lua_tonumber(L, 2);
  7917. luaL_checktype(L, 3, LUA_TNUMBER);
  7918. Number y = lua_tonumber(L, 3);
  7919. luaL_checktype(L, 4, LUA_TNUMBER);
  7920. int timestamp = lua_tointeger(L, 4);
  7921. inst->_onMouseWheelUp(x, y, timestamp);
  7922. return 0;
  7923. }
  7924. static int Polycore_ScreenEntity__onMouseWheelDown(lua_State *L) {
  7925. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  7926. ScreenEntity *inst = (ScreenEntity*)lua_topointer(L, 1);
  7927. luaL_checktype(L, 2, LUA_TNUMBER);
  7928. Number x = lua_tonumber(L, 2);
  7929. luaL_checktype(L, 3, LUA_TNUMBER);
  7930. Number y = lua_tonumber(L, 3);
  7931. luaL_checktype(L, 4, LUA_TNUMBER);
  7932. int timestamp = lua_tointeger(L, 4);
  7933. inst->_onMouseWheelDown(x, y, timestamp);
  7934. return 0;
  7935. }
  7936. static int Polycore_ScreenEntity_onMouseDown(lua_State *L) {
  7937. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  7938. ScreenEntity *inst = (ScreenEntity*)lua_topointer(L, 1);
  7939. luaL_checktype(L, 2, LUA_TNUMBER);
  7940. Number x = lua_tonumber(L, 2);
  7941. luaL_checktype(L, 3, LUA_TNUMBER);
  7942. Number y = lua_tonumber(L, 3);
  7943. inst->onMouseDown(x, y);
  7944. return 0;
  7945. }
  7946. static int Polycore_ScreenEntity_onMouseUp(lua_State *L) {
  7947. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  7948. ScreenEntity *inst = (ScreenEntity*)lua_topointer(L, 1);
  7949. luaL_checktype(L, 2, LUA_TNUMBER);
  7950. Number x = lua_tonumber(L, 2);
  7951. luaL_checktype(L, 3, LUA_TNUMBER);
  7952. Number y = lua_tonumber(L, 3);
  7953. inst->onMouseUp(x, y);
  7954. return 0;
  7955. }
  7956. static int Polycore_ScreenEntity_onMouseMove(lua_State *L) {
  7957. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  7958. ScreenEntity *inst = (ScreenEntity*)lua_topointer(L, 1);
  7959. luaL_checktype(L, 2, LUA_TNUMBER);
  7960. Number x = lua_tonumber(L, 2);
  7961. luaL_checktype(L, 3, LUA_TNUMBER);
  7962. Number y = lua_tonumber(L, 3);
  7963. inst->onMouseMove(x, y);
  7964. return 0;
  7965. }
  7966. static int Polycore_ScreenEntity_onMouseWheelUp(lua_State *L) {
  7967. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  7968. ScreenEntity *inst = (ScreenEntity*)lua_topointer(L, 1);
  7969. luaL_checktype(L, 2, LUA_TNUMBER);
  7970. Number x = lua_tonumber(L, 2);
  7971. luaL_checktype(L, 3, LUA_TNUMBER);
  7972. Number y = lua_tonumber(L, 3);
  7973. inst->onMouseWheelUp(x, y);
  7974. return 0;
  7975. }
  7976. static int Polycore_ScreenEntity_onMouseWheelDown(lua_State *L) {
  7977. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  7978. ScreenEntity *inst = (ScreenEntity*)lua_topointer(L, 1);
  7979. luaL_checktype(L, 2, LUA_TNUMBER);
  7980. Number x = lua_tonumber(L, 2);
  7981. luaL_checktype(L, 3, LUA_TNUMBER);
  7982. Number y = lua_tonumber(L, 3);
  7983. inst->onMouseWheelDown(x, y);
  7984. return 0;
  7985. }
  7986. static int Polycore_ScreenEntity__onKeyDown(lua_State *L) {
  7987. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  7988. ScreenEntity *inst = (ScreenEntity*)lua_topointer(L, 1);
  7989. luaL_checktype(L, 2, LUA_TLIGHTUSERDATA);
  7990. PolyKEY key = *(PolyKEY*)lua_topointer(L, 2);
  7991. luaL_checktype(L, 3, LUA_TLIGHTUSERDATA);
  7992. wchar_t charCode = *(wchar_t*)lua_topointer(L, 3);
  7993. inst->_onKeyDown(key, charCode);
  7994. return 0;
  7995. }
  7996. static int Polycore_ScreenEntity__onKeyUp(lua_State *L) {
  7997. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  7998. ScreenEntity *inst = (ScreenEntity*)lua_topointer(L, 1);
  7999. luaL_checktype(L, 2, LUA_TLIGHTUSERDATA);
  8000. PolyKEY key = *(PolyKEY*)lua_topointer(L, 2);
  8001. luaL_checktype(L, 3, LUA_TLIGHTUSERDATA);
  8002. wchar_t charCode = *(wchar_t*)lua_topointer(L, 3);
  8003. inst->_onKeyUp(key, charCode);
  8004. return 0;
  8005. }
  8006. static int Polycore_ScreenEntity_onKeyDown(lua_State *L) {
  8007. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  8008. ScreenEntity *inst = (ScreenEntity*)lua_topointer(L, 1);
  8009. luaL_checktype(L, 2, LUA_TLIGHTUSERDATA);
  8010. PolyKEY key = *(PolyKEY*)lua_topointer(L, 2);
  8011. luaL_checktype(L, 3, LUA_TLIGHTUSERDATA);
  8012. wchar_t charCode = *(wchar_t*)lua_topointer(L, 3);
  8013. inst->onKeyDown(key, charCode);
  8014. return 0;
  8015. }
  8016. static int Polycore_ScreenEntity_onKeyUp(lua_State *L) {
  8017. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  8018. ScreenEntity *inst = (ScreenEntity*)lua_topointer(L, 1);
  8019. luaL_checktype(L, 2, LUA_TLIGHTUSERDATA);
  8020. PolyKEY key = *(PolyKEY*)lua_topointer(L, 2);
  8021. luaL_checktype(L, 3, LUA_TLIGHTUSERDATA);
  8022. wchar_t charCode = *(wchar_t*)lua_topointer(L, 3);
  8023. inst->onKeyUp(key, charCode);
  8024. return 0;
  8025. }
  8026. static int Polycore_ScreenEntity_hitTest(lua_State *L) {
  8027. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  8028. ScreenEntity *inst = (ScreenEntity*)lua_topointer(L, 1);
  8029. luaL_checktype(L, 2, LUA_TNUMBER);
  8030. Number x = lua_tonumber(L, 2);
  8031. luaL_checktype(L, 3, LUA_TNUMBER);
  8032. Number y = lua_tonumber(L, 3);
  8033. lua_pushboolean(L, inst->hitTest(x, y));
  8034. return 1;
  8035. }
  8036. static int Polycore_ScreenEntity_buildPositionMatrix(lua_State *L) {
  8037. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  8038. ScreenEntity *inst = (ScreenEntity*)lua_topointer(L, 1);
  8039. Matrix4 *retInst = new Matrix4();
  8040. *retInst = inst->buildPositionMatrix();
  8041. lua_pushlightuserdata(L, retInst);
  8042. return 1;
  8043. }
  8044. static int Polycore_ScreenEntity_adjustMatrixForChildren(lua_State *L) {
  8045. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  8046. ScreenEntity *inst = (ScreenEntity*)lua_topointer(L, 1);
  8047. inst->adjustMatrixForChildren();
  8048. return 0;
  8049. }
  8050. static int Polycore_ScreenEntity_getWidth(lua_State *L) {
  8051. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  8052. ScreenEntity *inst = (ScreenEntity*)lua_topointer(L, 1);
  8053. lua_pushnumber(L, inst->getWidth());
  8054. return 1;
  8055. }
  8056. static int Polycore_ScreenEntity_getHeight(lua_State *L) {
  8057. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  8058. ScreenEntity *inst = (ScreenEntity*)lua_topointer(L, 1);
  8059. lua_pushnumber(L, inst->getHeight());
  8060. return 1;
  8061. }
  8062. static int Polycore_ScreenEntity_setWidth(lua_State *L) {
  8063. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  8064. ScreenEntity *inst = (ScreenEntity*)lua_topointer(L, 1);
  8065. luaL_checktype(L, 2, LUA_TNUMBER);
  8066. Number w = lua_tonumber(L, 2);
  8067. inst->setWidth(w);
  8068. return 0;
  8069. }
  8070. static int Polycore_ScreenEntity_setHeight(lua_State *L) {
  8071. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  8072. ScreenEntity *inst = (ScreenEntity*)lua_topointer(L, 1);
  8073. luaL_checktype(L, 2, LUA_TNUMBER);
  8074. Number h = lua_tonumber(L, 2);
  8075. inst->setHeight(h);
  8076. return 0;
  8077. }
  8078. static int Polycore_ScreenEntity_onGainFocus(lua_State *L) {
  8079. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  8080. ScreenEntity *inst = (ScreenEntity*)lua_topointer(L, 1);
  8081. inst->onGainFocus();
  8082. return 0;
  8083. }
  8084. static int Polycore_ScreenEntity_onLoseFocus(lua_State *L) {
  8085. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  8086. ScreenEntity *inst = (ScreenEntity*)lua_topointer(L, 1);
  8087. inst->onLoseFocus();
  8088. return 0;
  8089. }
  8090. static int Polycore_ScreenEntity_startDrag(lua_State *L) {
  8091. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  8092. ScreenEntity *inst = (ScreenEntity*)lua_topointer(L, 1);
  8093. luaL_checktype(L, 2, LUA_TNUMBER);
  8094. Number xOffset = lua_tonumber(L, 2);
  8095. luaL_checktype(L, 3, LUA_TNUMBER);
  8096. Number yOffset = lua_tonumber(L, 3);
  8097. inst->startDrag(xOffset, yOffset);
  8098. return 0;
  8099. }
  8100. static int Polycore_ScreenEntity_stopDrag(lua_State *L) {
  8101. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  8102. ScreenEntity *inst = (ScreenEntity*)lua_topointer(L, 1);
  8103. inst->stopDrag();
  8104. return 0;
  8105. }
  8106. static int Polycore_ScreenEntity_setBlendingMode(lua_State *L) {
  8107. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  8108. ScreenEntity *inst = (ScreenEntity*)lua_topointer(L, 1);
  8109. luaL_checktype(L, 2, LUA_TNUMBER);
  8110. int newBl_endingMode = lua_tointeger(L, 2);
  8111. inst->setBlendingMode(newBl_endingMode);
  8112. return 0;
  8113. }
  8114. static int Polycore_ScreenEntity_setPositionMode(lua_State *L) {
  8115. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  8116. ScreenEntity *inst = (ScreenEntity*)lua_topointer(L, 1);
  8117. luaL_checktype(L, 2, LUA_TNUMBER);
  8118. int newPositionMode = lua_tointeger(L, 2);
  8119. inst->setPositionMode(newPositionMode);
  8120. return 0;
  8121. }
  8122. static int Polycore_ScreenEntity_setDragLimits(lua_State *L) {
  8123. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  8124. ScreenEntity *inst = (ScreenEntity*)lua_topointer(L, 1);
  8125. luaL_checktype(L, 2, LUA_TLIGHTUSERDATA);
  8126. Polycode::Rectangle rect = *(Polycode::Rectangle*)lua_topointer(L, 2);
  8127. inst->setDragLimits(rect);
  8128. return 0;
  8129. }
  8130. static int Polycore_ScreenEntity_clearDragLimits(lua_State *L) {
  8131. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  8132. ScreenEntity *inst = (ScreenEntity*)lua_topointer(L, 1);
  8133. inst->clearDragLimits();
  8134. return 0;
  8135. }
  8136. static int Polycore_ScreenEntity_focusChild(lua_State *L) {
  8137. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  8138. ScreenEntity *inst = (ScreenEntity*)lua_topointer(L, 1);
  8139. luaL_checktype(L, 2, LUA_TLIGHTUSERDATA);
  8140. ScreenEntity* child = (ScreenEntity*)lua_topointer(L, 2);
  8141. inst->focusChild(child);
  8142. return 0;
  8143. }
  8144. static int Polycore_ScreenEntity_focusNextChild(lua_State *L) {
  8145. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  8146. ScreenEntity *inst = (ScreenEntity*)lua_topointer(L, 1);
  8147. inst->focusNextChild();
  8148. return 0;
  8149. }
  8150. static int Polycore_ScreenEntity_getPosition2D(lua_State *L) {
  8151. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  8152. ScreenEntity *inst = (ScreenEntity*)lua_topointer(L, 1);
  8153. Vector2 *retInst = new Vector2();
  8154. *retInst = inst->getPosition2D();
  8155. lua_pushlightuserdata(L, retInst);
  8156. return 1;
  8157. }
  8158. static int Polycore_ScreenEntity_isFocusable(lua_State *L) {
  8159. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  8160. ScreenEntity *inst = (ScreenEntity*)lua_topointer(L, 1);
  8161. lua_pushboolean(L, inst->isFocusable());
  8162. return 1;
  8163. }
  8164. static int Polycore_delete_ScreenEntity(lua_State *L) {
  8165. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  8166. ScreenEntity *inst = (ScreenEntity*)lua_topointer(L, 1);
  8167. delete inst;
  8168. return 0;
  8169. }
  8170. static int Polycore_ScreenEvent(lua_State *L) {
  8171. ScreenEvent *inst = new ScreenEvent();
  8172. lua_pushlightuserdata(L, (void*)inst);
  8173. return 1;
  8174. }
  8175. static int Polycore_delete_ScreenEvent(lua_State *L) {
  8176. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  8177. ScreenEvent *inst = (ScreenEvent*)lua_topointer(L, 1);
  8178. delete inst;
  8179. return 0;
  8180. }
  8181. static int Polycore_ScreenImage(lua_State *L) {
  8182. luaL_checktype(L, 1, LUA_TSTRING);
  8183. String fileName = String(lua_tostring(L, 1));
  8184. ScreenImage *inst = new ScreenImage(fileName);
  8185. lua_pushlightuserdata(L, (void*)inst);
  8186. return 1;
  8187. }
  8188. static int Polycore_ScreenImage_setImageCoordinates(lua_State *L) {
  8189. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  8190. ScreenImage *inst = (ScreenImage*)lua_topointer(L, 1);
  8191. luaL_checktype(L, 2, LUA_TNUMBER);
  8192. Number x = lua_tonumber(L, 2);
  8193. luaL_checktype(L, 3, LUA_TNUMBER);
  8194. Number y = lua_tonumber(L, 3);
  8195. luaL_checktype(L, 4, LUA_TNUMBER);
  8196. Number width = lua_tonumber(L, 4);
  8197. luaL_checktype(L, 5, LUA_TNUMBER);
  8198. Number height = lua_tonumber(L, 5);
  8199. inst->setImageCoordinates(x, y, width, height);
  8200. return 0;
  8201. }
  8202. static int Polycore_ScreenImage_getImageWidth(lua_State *L) {
  8203. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  8204. ScreenImage *inst = (ScreenImage*)lua_topointer(L, 1);
  8205. lua_pushnumber(L, inst->getImageWidth());
  8206. return 1;
  8207. }
  8208. static int Polycore_ScreenImage_getImageHeight(lua_State *L) {
  8209. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  8210. ScreenImage *inst = (ScreenImage*)lua_topointer(L, 1);
  8211. lua_pushnumber(L, inst->getImageHeight());
  8212. return 1;
  8213. }
  8214. static int Polycore_delete_ScreenImage(lua_State *L) {
  8215. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  8216. ScreenImage *inst = (ScreenImage*)lua_topointer(L, 1);
  8217. delete inst;
  8218. return 0;
  8219. }
  8220. static int Polycore_ScreenLabel(lua_State *L) {
  8221. luaL_checktype(L, 1, LUA_TSTRING);
  8222. String text = String(lua_tostring(L, 1));
  8223. luaL_checktype(L, 2, LUA_TNUMBER);
  8224. int size = lua_tointeger(L, 2);
  8225. String fontName;
  8226. if(lua_isstring(L, 3)) {
  8227. fontName = lua_tostring(L, 3);
  8228. } else {
  8229. fontName = "sans";
  8230. }
  8231. int amode;
  8232. if(lua_isnumber(L, 4)) {
  8233. amode = lua_tointeger(L, 4);
  8234. } else {
  8235. amode = 0;
  8236. }
  8237. ScreenLabel *inst = new ScreenLabel(text, size, fontName, amode);
  8238. lua_pushlightuserdata(L, (void*)inst);
  8239. return 1;
  8240. }
  8241. static int Polycore_ScreenLabel_addDropShadow(lua_State *L) {
  8242. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  8243. ScreenLabel *inst = (ScreenLabel*)lua_topointer(L, 1);
  8244. luaL_checktype(L, 2, LUA_TLIGHTUSERDATA);
  8245. Color color = *(Color*)lua_topointer(L, 2);
  8246. luaL_checktype(L, 3, LUA_TNUMBER);
  8247. Number size = lua_tonumber(L, 3);
  8248. luaL_checktype(L, 4, LUA_TNUMBER);
  8249. Number offsetX = lua_tonumber(L, 4);
  8250. luaL_checktype(L, 5, LUA_TNUMBER);
  8251. Number offsetY = lua_tonumber(L, 5);
  8252. inst->addDropShadow(color, size, offsetX, offsetY);
  8253. return 0;
  8254. }
  8255. static int Polycore_ScreenLabel_setText(lua_State *L) {
  8256. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  8257. ScreenLabel *inst = (ScreenLabel*)lua_topointer(L, 1);
  8258. luaL_checktype(L, 2, LUA_TSTRING);
  8259. String newText = String(lua_tostring(L, 2));
  8260. inst->setText(newText);
  8261. return 0;
  8262. }
  8263. static int Polycore_ScreenLabel_getText(lua_State *L) {
  8264. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  8265. ScreenLabel *inst = (ScreenLabel*)lua_topointer(L, 1);
  8266. String *retInst = new String ();
  8267. *retInst = inst->getText();
  8268. lua_pushlightuserdata(L, retInst);
  8269. return 1;
  8270. }
  8271. static int Polycore_ScreenLabel_getLabel(lua_State *L) {
  8272. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  8273. ScreenLabel *inst = (ScreenLabel*)lua_topointer(L, 1);
  8274. void *ptrRetVal = (void*)inst->getLabel();
  8275. if(ptrRetVal == NULL) {
  8276. lua_pushnil(L);
  8277. } else {
  8278. lua_pushlightuserdata(L, ptrRetVal);
  8279. }
  8280. return 1;
  8281. }
  8282. static int Polycore_delete_ScreenLabel(lua_State *L) {
  8283. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  8284. ScreenLabel *inst = (ScreenLabel*)lua_topointer(L, 1);
  8285. delete inst;
  8286. return 0;
  8287. }
  8288. static int Polycore_ScreenLine(lua_State *L) {
  8289. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  8290. Vector2* start = (Vector2*)lua_topointer(L, 1);
  8291. luaL_checktype(L, 2, LUA_TLIGHTUSERDATA);
  8292. Vector2* _end = (Vector2*)lua_topointer(L, 2);
  8293. ScreenLine *inst = new ScreenLine(start, _end);
  8294. lua_pushlightuserdata(L, (void*)inst);
  8295. return 1;
  8296. }
  8297. static int Polycore_ScreenLine_Update(lua_State *L) {
  8298. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  8299. ScreenLine *inst = (ScreenLine*)lua_topointer(L, 1);
  8300. inst->Update();
  8301. return 0;
  8302. }
  8303. static int Polycore_ScreenLine_Render(lua_State *L) {
  8304. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  8305. ScreenLine *inst = (ScreenLine*)lua_topointer(L, 1);
  8306. inst->Render();
  8307. return 0;
  8308. }
  8309. static int Polycore_ScreenLine_setLineWidth(lua_State *L) {
  8310. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  8311. ScreenLine *inst = (ScreenLine*)lua_topointer(L, 1);
  8312. luaL_checktype(L, 2, LUA_TNUMBER);
  8313. Number width = lua_tonumber(L, 2);
  8314. inst->setLineWidth(width);
  8315. return 0;
  8316. }
  8317. static int Polycore_delete_ScreenLine(lua_State *L) {
  8318. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  8319. ScreenLine *inst = (ScreenLine*)lua_topointer(L, 1);
  8320. delete inst;
  8321. return 0;
  8322. }
  8323. static int Polycore_ScreenManager(lua_State *L) {
  8324. ScreenManager *inst = new ScreenManager();
  8325. lua_pushlightuserdata(L, (void*)inst);
  8326. return 1;
  8327. }
  8328. static int Polycore_ScreenManager_removeScreen(lua_State *L) {
  8329. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  8330. ScreenManager *inst = (ScreenManager*)lua_topointer(L, 1);
  8331. luaL_checktype(L, 2, LUA_TLIGHTUSERDATA);
  8332. Screen* screen = (Screen*)lua_topointer(L, 2);
  8333. inst->removeScreen(screen);
  8334. return 0;
  8335. }
  8336. static int Polycore_ScreenManager_addScreen(lua_State *L) {
  8337. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  8338. ScreenManager *inst = (ScreenManager*)lua_topointer(L, 1);
  8339. luaL_checktype(L, 2, LUA_TLIGHTUSERDATA);
  8340. Screen* screen = (Screen*)lua_topointer(L, 2);
  8341. inst->addScreen(screen);
  8342. return 0;
  8343. }
  8344. static int Polycore_ScreenManager_Update(lua_State *L) {
  8345. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  8346. ScreenManager *inst = (ScreenManager*)lua_topointer(L, 1);
  8347. inst->Update();
  8348. return 0;
  8349. }
  8350. static int Polycore_delete_ScreenManager(lua_State *L) {
  8351. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  8352. ScreenManager *inst = (ScreenManager*)lua_topointer(L, 1);
  8353. delete inst;
  8354. return 0;
  8355. }
  8356. static int Polycore_ScreenMesh(lua_State *L) {
  8357. luaL_checktype(L, 1, LUA_TSTRING);
  8358. String fileName = String(lua_tostring(L, 1));
  8359. ScreenMesh *inst = new ScreenMesh(fileName);
  8360. lua_pushlightuserdata(L, (void*)inst);
  8361. return 1;
  8362. }
  8363. static int Polycore_ScreenMesh_Render(lua_State *L) {
  8364. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  8365. ScreenMesh *inst = (ScreenMesh*)lua_topointer(L, 1);
  8366. inst->Render();
  8367. return 0;
  8368. }
  8369. static int Polycore_ScreenMesh_getMesh(lua_State *L) {
  8370. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  8371. ScreenMesh *inst = (ScreenMesh*)lua_topointer(L, 1);
  8372. void *ptrRetVal = (void*)inst->getMesh();
  8373. if(ptrRetVal == NULL) {
  8374. lua_pushnil(L);
  8375. } else {
  8376. lua_pushlightuserdata(L, ptrRetVal);
  8377. }
  8378. return 1;
  8379. }
  8380. static int Polycore_ScreenMesh_getTexture(lua_State *L) {
  8381. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  8382. ScreenMesh *inst = (ScreenMesh*)lua_topointer(L, 1);
  8383. void *ptrRetVal = (void*)inst->getTexture();
  8384. if(ptrRetVal == NULL) {
  8385. lua_pushnil(L);
  8386. } else {
  8387. lua_pushlightuserdata(L, ptrRetVal);
  8388. }
  8389. return 1;
  8390. }
  8391. static int Polycore_ScreenMesh_loadTexture(lua_State *L) {
  8392. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  8393. ScreenMesh *inst = (ScreenMesh*)lua_topointer(L, 1);
  8394. luaL_checktype(L, 2, LUA_TSTRING);
  8395. String fileName = String(lua_tostring(L, 2));
  8396. inst->loadTexture(fileName);
  8397. return 0;
  8398. }
  8399. static int Polycore_ScreenMesh_setTexture(lua_State *L) {
  8400. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  8401. ScreenMesh *inst = (ScreenMesh*)lua_topointer(L, 1);
  8402. luaL_checktype(L, 2, LUA_TLIGHTUSERDATA);
  8403. Texture* texture = (Texture*)lua_topointer(L, 2);
  8404. inst->setTexture(texture);
  8405. return 0;
  8406. }
  8407. static int Polycore_delete_ScreenMesh(lua_State *L) {
  8408. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  8409. ScreenMesh *inst = (ScreenMesh*)lua_topointer(L, 1);
  8410. delete inst;
  8411. return 0;
  8412. }
  8413. static int Polycore_ScreenShape_get_strokeEnabled(lua_State *L) {
  8414. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  8415. ScreenShape *inst = (ScreenShape*)lua_topointer(L, 1);
  8416. lua_pushboolean(L, inst->strokeEnabled);
  8417. return 1;
  8418. }
  8419. static int Polycore_ScreenShape_get_strokeColor(lua_State *L) {
  8420. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  8421. ScreenShape *inst = (ScreenShape*)lua_topointer(L, 1);
  8422. lua_pushlightuserdata(L, &inst->strokeColor);
  8423. return 1;
  8424. }
  8425. static int Polycore_ScreenShape_get_lineSmooth(lua_State *L) {
  8426. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  8427. ScreenShape *inst = (ScreenShape*)lua_topointer(L, 1);
  8428. lua_pushboolean(L, inst->lineSmooth);
  8429. return 1;
  8430. }
  8431. static int Polycore_ScreenShape_set_strokeEnabled(lua_State *L) {
  8432. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  8433. ScreenShape *inst = (ScreenShape*)lua_topointer(L, 1);
  8434. bool param = lua_toboolean(L, 2);
  8435. inst->strokeEnabled = param;
  8436. return 0;
  8437. }
  8438. static int Polycore_ScreenShape_set_lineSmooth(lua_State *L) {
  8439. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  8440. ScreenShape *inst = (ScreenShape*)lua_topointer(L, 1);
  8441. bool param = lua_toboolean(L, 2);
  8442. inst->lineSmooth = param;
  8443. return 0;
  8444. }
  8445. static int Polycore_ScreenShape(lua_State *L) {
  8446. luaL_checktype(L, 1, LUA_TNUMBER);
  8447. int shapeType = lua_tointeger(L, 1);
  8448. Number option1;
  8449. if(lua_isnumber(L, 2)) {
  8450. option1 = lua_tonumber(L, 2);
  8451. } else {
  8452. option1 = 0;
  8453. }
  8454. Number option2;
  8455. if(lua_isnumber(L, 3)) {
  8456. option2 = lua_tonumber(L, 3);
  8457. } else {
  8458. option2 = 0;
  8459. }
  8460. Number option3;
  8461. if(lua_isnumber(L, 4)) {
  8462. option3 = lua_tonumber(L, 4);
  8463. } else {
  8464. option3 = 0;
  8465. }
  8466. Number option4;
  8467. if(lua_isnumber(L, 5)) {
  8468. option4 = lua_tonumber(L, 5);
  8469. } else {
  8470. option4 = 0;
  8471. }
  8472. ScreenShape *inst = new ScreenShape(shapeType, option1, option2, option3, option4);
  8473. lua_pushlightuserdata(L, (void*)inst);
  8474. return 1;
  8475. }
  8476. static int Polycore_ScreenShape_Render(lua_State *L) {
  8477. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  8478. ScreenShape *inst = (ScreenShape*)lua_topointer(L, 1);
  8479. inst->Render();
  8480. return 0;
  8481. }
  8482. static int Polycore_ScreenShape_setStrokeColor(lua_State *L) {
  8483. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  8484. ScreenShape *inst = (ScreenShape*)lua_topointer(L, 1);
  8485. luaL_checktype(L, 2, LUA_TNUMBER);
  8486. Number r = lua_tonumber(L, 2);
  8487. luaL_checktype(L, 3, LUA_TNUMBER);
  8488. Number g = lua_tonumber(L, 3);
  8489. luaL_checktype(L, 4, LUA_TNUMBER);
  8490. Number b = lua_tonumber(L, 4);
  8491. luaL_checktype(L, 5, LUA_TNUMBER);
  8492. Number a = lua_tonumber(L, 5);
  8493. inst->setStrokeColor(r, g, b, a);
  8494. return 0;
  8495. }
  8496. static int Polycore_ScreenShape_setStrokeWidth(lua_State *L) {
  8497. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  8498. ScreenShape *inst = (ScreenShape*)lua_topointer(L, 1);
  8499. luaL_checktype(L, 2, LUA_TNUMBER);
  8500. Number width = lua_tonumber(L, 2);
  8501. inst->setStrokeWidth(width);
  8502. return 0;
  8503. }
  8504. static int Polycore_ScreenShape_setGradient(lua_State *L) {
  8505. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  8506. ScreenShape *inst = (ScreenShape*)lua_topointer(L, 1);
  8507. luaL_checktype(L, 2, LUA_TNUMBER);
  8508. Number r1 = lua_tonumber(L, 2);
  8509. luaL_checktype(L, 3, LUA_TNUMBER);
  8510. Number g1 = lua_tonumber(L, 3);
  8511. luaL_checktype(L, 4, LUA_TNUMBER);
  8512. Number b1 = lua_tonumber(L, 4);
  8513. luaL_checktype(L, 5, LUA_TNUMBER);
  8514. Number a1 = lua_tonumber(L, 5);
  8515. luaL_checktype(L, 6, LUA_TNUMBER);
  8516. Number r2 = lua_tonumber(L, 6);
  8517. luaL_checktype(L, 7, LUA_TNUMBER);
  8518. Number g2 = lua_tonumber(L, 7);
  8519. luaL_checktype(L, 8, LUA_TNUMBER);
  8520. Number b2 = lua_tonumber(L, 8);
  8521. luaL_checktype(L, 9, LUA_TNUMBER);
  8522. Number a2 = lua_tonumber(L, 9);
  8523. inst->setGradient(r1, g1, b1, a1, r2, g2, b2, a2);
  8524. return 0;
  8525. }
  8526. static int Polycore_ScreenShape_clearGradient(lua_State *L) {
  8527. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  8528. ScreenShape *inst = (ScreenShape*)lua_topointer(L, 1);
  8529. inst->clearGradient();
  8530. return 0;
  8531. }
  8532. static int Polycore_ScreenShape_setShapeSize(lua_State *L) {
  8533. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  8534. ScreenShape *inst = (ScreenShape*)lua_topointer(L, 1);
  8535. luaL_checktype(L, 2, LUA_TNUMBER);
  8536. Number newWidth = lua_tonumber(L, 2);
  8537. luaL_checktype(L, 3, LUA_TNUMBER);
  8538. Number newHeight = lua_tonumber(L, 3);
  8539. inst->setShapeSize(newWidth, newHeight);
  8540. return 0;
  8541. }
  8542. static int Polycore_ScreenShape_addShapePoint(lua_State *L) {
  8543. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  8544. ScreenShape *inst = (ScreenShape*)lua_topointer(L, 1);
  8545. luaL_checktype(L, 2, LUA_TNUMBER);
  8546. Number x = lua_tonumber(L, 2);
  8547. luaL_checktype(L, 3, LUA_TNUMBER);
  8548. Number y = lua_tonumber(L, 3);
  8549. inst->addShapePoint(x, y);
  8550. return 0;
  8551. }
  8552. static int Polycore_delete_ScreenShape(lua_State *L) {
  8553. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  8554. ScreenShape *inst = (ScreenShape*)lua_topointer(L, 1);
  8555. delete inst;
  8556. return 0;
  8557. }
  8558. static int Polycore_ScreenSoundListener(lua_State *L) {
  8559. ScreenSoundListener *inst = new ScreenSoundListener();
  8560. lua_pushlightuserdata(L, (void*)inst);
  8561. return 1;
  8562. }
  8563. static int Polycore_ScreenSoundListener_Update(lua_State *L) {
  8564. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  8565. ScreenSoundListener *inst = (ScreenSoundListener*)lua_topointer(L, 1);
  8566. inst->Update();
  8567. return 0;
  8568. }
  8569. static int Polycore_delete_ScreenSoundListener(lua_State *L) {
  8570. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  8571. ScreenSoundListener *inst = (ScreenSoundListener*)lua_topointer(L, 1);
  8572. delete inst;
  8573. return 0;
  8574. }
  8575. static int Polycore_ScreenSound(lua_State *L) {
  8576. luaL_checktype(L, 1, LUA_TSTRING);
  8577. String fileName = String(lua_tostring(L, 1));
  8578. luaL_checktype(L, 2, LUA_TNUMBER);
  8579. Number referenceDistance = lua_tonumber(L, 2);
  8580. luaL_checktype(L, 3, LUA_TNUMBER);
  8581. Number maxDistance = lua_tonumber(L, 3);
  8582. ScreenSound *inst = new ScreenSound(fileName, referenceDistance, maxDistance);
  8583. lua_pushlightuserdata(L, (void*)inst);
  8584. return 1;
  8585. }
  8586. static int Polycore_ScreenSound_Update(lua_State *L) {
  8587. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  8588. ScreenSound *inst = (ScreenSound*)lua_topointer(L, 1);
  8589. inst->Update();
  8590. return 0;
  8591. }
  8592. static int Polycore_ScreenSound_getSound(lua_State *L) {
  8593. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  8594. ScreenSound *inst = (ScreenSound*)lua_topointer(L, 1);
  8595. void *ptrRetVal = (void*)inst->getSound();
  8596. if(ptrRetVal == NULL) {
  8597. lua_pushnil(L);
  8598. } else {
  8599. lua_pushlightuserdata(L, ptrRetVal);
  8600. }
  8601. return 1;
  8602. }
  8603. static int Polycore_delete_ScreenSound(lua_State *L) {
  8604. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  8605. ScreenSound *inst = (ScreenSound*)lua_topointer(L, 1);
  8606. delete inst;
  8607. return 0;
  8608. }
  8609. static int Polycore_ScreenSprite(lua_State *L) {
  8610. luaL_checktype(L, 1, LUA_TSTRING);
  8611. String fileName = String(lua_tostring(L, 1));
  8612. luaL_checktype(L, 2, LUA_TNUMBER);
  8613. Number spriteWidth = lua_tonumber(L, 2);
  8614. luaL_checktype(L, 3, LUA_TNUMBER);
  8615. Number spriteHeight = lua_tonumber(L, 3);
  8616. ScreenSprite *inst = new ScreenSprite(fileName, spriteWidth, spriteHeight);
  8617. lua_pushlightuserdata(L, (void*)inst);
  8618. return 1;
  8619. }
  8620. static int Polycore_ScreenSprite_addAnimation(lua_State *L) {
  8621. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  8622. ScreenSprite *inst = (ScreenSprite*)lua_topointer(L, 1);
  8623. luaL_checktype(L, 2, LUA_TSTRING);
  8624. String name = String(lua_tostring(L, 2));
  8625. luaL_checktype(L, 3, LUA_TSTRING);
  8626. String frames = String(lua_tostring(L, 3));
  8627. luaL_checktype(L, 4, LUA_TNUMBER);
  8628. Number speed = lua_tonumber(L, 4);
  8629. inst->addAnimation(name, frames, speed);
  8630. return 0;
  8631. }
  8632. static int Polycore_ScreenSprite_playAnimation(lua_State *L) {
  8633. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  8634. ScreenSprite *inst = (ScreenSprite*)lua_topointer(L, 1);
  8635. luaL_checktype(L, 2, LUA_TSTRING);
  8636. String name = String(lua_tostring(L, 2));
  8637. luaL_checktype(L, 3, LUA_TNUMBER);
  8638. int startFrame = lua_tointeger(L, 3);
  8639. luaL_checktype(L, 4, LUA_TBOOLEAN);
  8640. bool once = lua_toboolean(L, 4);
  8641. inst->playAnimation(name, startFrame, once);
  8642. return 0;
  8643. }
  8644. static int Polycore_ScreenSprite_Update(lua_State *L) {
  8645. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  8646. ScreenSprite *inst = (ScreenSprite*)lua_topointer(L, 1);
  8647. inst->Update();
  8648. return 0;
  8649. }
  8650. static int Polycore_ScreenSprite_Pause(lua_State *L) {
  8651. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  8652. ScreenSprite *inst = (ScreenSprite*)lua_topointer(L, 1);
  8653. luaL_checktype(L, 2, LUA_TBOOLEAN);
  8654. bool val = lua_toboolean(L, 2);
  8655. inst->Pause(val);
  8656. return 0;
  8657. }
  8658. static int Polycore_delete_ScreenSprite(lua_State *L) {
  8659. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  8660. ScreenSprite *inst = (ScreenSprite*)lua_topointer(L, 1);
  8661. delete inst;
  8662. return 0;
  8663. }
  8664. static int Polycore_Shader_get_numSpotLights(lua_State *L) {
  8665. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  8666. Shader *inst = (Shader*)lua_topointer(L, 1);
  8667. lua_pushinteger(L, inst->numSpotLights);
  8668. return 1;
  8669. }
  8670. static int Polycore_Shader_get_numAreaLights(lua_State *L) {
  8671. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  8672. Shader *inst = (Shader*)lua_topointer(L, 1);
  8673. lua_pushinteger(L, inst->numAreaLights);
  8674. return 1;
  8675. }
  8676. static int Polycore_Shader_set_numSpotLights(lua_State *L) {
  8677. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  8678. Shader *inst = (Shader*)lua_topointer(L, 1);
  8679. int param = lua_tointeger(L, 2);
  8680. inst->numSpotLights = param;
  8681. return 0;
  8682. }
  8683. static int Polycore_Shader_set_numAreaLights(lua_State *L) {
  8684. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  8685. Shader *inst = (Shader*)lua_topointer(L, 1);
  8686. int param = lua_tointeger(L, 2);
  8687. inst->numAreaLights = param;
  8688. return 0;
  8689. }
  8690. static int Polycore_Shader_getType(lua_State *L) {
  8691. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  8692. Shader *inst = (Shader*)lua_topointer(L, 1);
  8693. lua_pushinteger(L, inst->getType());
  8694. return 1;
  8695. }
  8696. static int Polycore_Shader_setName(lua_State *L) {
  8697. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  8698. Shader *inst = (Shader*)lua_topointer(L, 1);
  8699. luaL_checktype(L, 2, LUA_TSTRING);
  8700. String name = String(lua_tostring(L, 2));
  8701. inst->setName(name);
  8702. return 0;
  8703. }
  8704. static int Polycore_Shader_getName(lua_State *L) {
  8705. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  8706. Shader *inst = (Shader*)lua_topointer(L, 1);
  8707. String *retInst = new String ();
  8708. *retInst = inst->getName();
  8709. lua_pushlightuserdata(L, retInst);
  8710. return 1;
  8711. }
  8712. static int Polycore_Shader_createBinding(lua_State *L) {
  8713. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  8714. Shader *inst = (Shader*)lua_topointer(L, 1);
  8715. void *ptrRetVal = (void*)inst->createBinding();
  8716. if(ptrRetVal == NULL) {
  8717. lua_pushnil(L);
  8718. } else {
  8719. lua_pushlightuserdata(L, ptrRetVal);
  8720. }
  8721. return 1;
  8722. }
  8723. static int Polycore_delete_Shader(lua_State *L) {
  8724. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  8725. Shader *inst = (Shader*)lua_topointer(L, 1);
  8726. delete inst;
  8727. return 0;
  8728. }
  8729. static int Polycore_ShaderBinding(lua_State *L) {
  8730. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  8731. Shader* shader = (Shader*)lua_topointer(L, 1);
  8732. ShaderBinding *inst = new ShaderBinding(shader);
  8733. lua_pushlightuserdata(L, (void*)inst);
  8734. return 1;
  8735. }
  8736. static int Polycore_ShaderBinding_clearTexture(lua_State *L) {
  8737. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  8738. ShaderBinding *inst = (ShaderBinding*)lua_topointer(L, 1);
  8739. luaL_checktype(L, 2, LUA_TSTRING);
  8740. String name = String(lua_tostring(L, 2));
  8741. inst->clearTexture(name);
  8742. return 0;
  8743. }
  8744. static int Polycore_ShaderBinding_addTexture(lua_State *L) {
  8745. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  8746. ShaderBinding *inst = (ShaderBinding*)lua_topointer(L, 1);
  8747. luaL_checktype(L, 2, LUA_TSTRING);
  8748. String name = String(lua_tostring(L, 2));
  8749. luaL_checktype(L, 3, LUA_TLIGHTUSERDATA);
  8750. Texture* texture = (Texture*)lua_topointer(L, 3);
  8751. inst->addTexture(name, texture);
  8752. return 0;
  8753. }
  8754. static int Polycore_ShaderBinding_addParam(lua_State *L) {
  8755. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  8756. ShaderBinding *inst = (ShaderBinding*)lua_topointer(L, 1);
  8757. luaL_checktype(L, 2, LUA_TSTRING);
  8758. String type = String(lua_tostring(L, 2));
  8759. luaL_checktype(L, 3, LUA_TSTRING);
  8760. String name = String(lua_tostring(L, 3));
  8761. luaL_checktype(L, 4, LUA_TSTRING);
  8762. String value = String(lua_tostring(L, 4));
  8763. inst->addParam(type, name, value);
  8764. return 0;
  8765. }
  8766. static int Polycore_ShaderBinding_addCubemap(lua_State *L) {
  8767. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  8768. ShaderBinding *inst = (ShaderBinding*)lua_topointer(L, 1);
  8769. luaL_checktype(L, 2, LUA_TSTRING);
  8770. String name = String(lua_tostring(L, 2));
  8771. luaL_checktype(L, 3, LUA_TLIGHTUSERDATA);
  8772. Cubemap* cubemap = (Cubemap*)lua_topointer(L, 3);
  8773. inst->addCubemap(name, cubemap);
  8774. return 0;
  8775. }
  8776. static int Polycore_ShaderBinding_getNumLocalParams(lua_State *L) {
  8777. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  8778. ShaderBinding *inst = (ShaderBinding*)lua_topointer(L, 1);
  8779. lua_pushinteger(L, inst->getNumLocalParams());
  8780. return 1;
  8781. }
  8782. static int Polycore_ShaderBinding_getLocalParam(lua_State *L) {
  8783. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  8784. ShaderBinding *inst = (ShaderBinding*)lua_topointer(L, 1);
  8785. luaL_checktype(L, 2, LUA_TNUMBER);
  8786. unsigned int index = lua_tointeger(L, 2);
  8787. void *ptrRetVal = (void*)inst->getLocalParam(index);
  8788. if(ptrRetVal == NULL) {
  8789. lua_pushnil(L);
  8790. } else {
  8791. lua_pushlightuserdata(L, ptrRetVal);
  8792. }
  8793. return 1;
  8794. }
  8795. static int Polycore_ShaderBinding_getLocalParamByName(lua_State *L) {
  8796. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  8797. ShaderBinding *inst = (ShaderBinding*)lua_topointer(L, 1);
  8798. luaL_checktype(L, 2, LUA_TSTRING);
  8799. String name = String(lua_tostring(L, 2));
  8800. void *ptrRetVal = (void*)inst->getLocalParamByName(name);
  8801. if(ptrRetVal == NULL) {
  8802. lua_pushnil(L);
  8803. } else {
  8804. lua_pushlightuserdata(L, ptrRetVal);
  8805. }
  8806. return 1;
  8807. }
  8808. static int Polycore_ShaderBinding_addRenderTargetBinding(lua_State *L) {
  8809. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  8810. ShaderBinding *inst = (ShaderBinding*)lua_topointer(L, 1);
  8811. luaL_checktype(L, 2, LUA_TLIGHTUSERDATA);
  8812. RenderTargetBinding* binding = (RenderTargetBinding*)lua_topointer(L, 2);
  8813. inst->addRenderTargetBinding(binding);
  8814. return 0;
  8815. }
  8816. static int Polycore_ShaderBinding_getNumRenderTargetBindings(lua_State *L) {
  8817. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  8818. ShaderBinding *inst = (ShaderBinding*)lua_topointer(L, 1);
  8819. lua_pushinteger(L, inst->getNumRenderTargetBindings());
  8820. return 1;
  8821. }
  8822. static int Polycore_ShaderBinding_getRenderTargetBinding(lua_State *L) {
  8823. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  8824. ShaderBinding *inst = (ShaderBinding*)lua_topointer(L, 1);
  8825. luaL_checktype(L, 2, LUA_TNUMBER);
  8826. unsigned int index = lua_tointeger(L, 2);
  8827. void *ptrRetVal = (void*)inst->getRenderTargetBinding(index);
  8828. if(ptrRetVal == NULL) {
  8829. lua_pushnil(L);
  8830. } else {
  8831. lua_pushlightuserdata(L, ptrRetVal);
  8832. }
  8833. return 1;
  8834. }
  8835. static int Polycore_ShaderBinding_getNumInTargetBindings(lua_State *L) {
  8836. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  8837. ShaderBinding *inst = (ShaderBinding*)lua_topointer(L, 1);
  8838. lua_pushinteger(L, inst->getNumInTargetBindings());
  8839. return 1;
  8840. }
  8841. static int Polycore_ShaderBinding_getInTargetBinding(lua_State *L) {
  8842. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  8843. ShaderBinding *inst = (ShaderBinding*)lua_topointer(L, 1);
  8844. luaL_checktype(L, 2, LUA_TNUMBER);
  8845. unsigned int index = lua_tointeger(L, 2);
  8846. void *ptrRetVal = (void*)inst->getInTargetBinding(index);
  8847. if(ptrRetVal == NULL) {
  8848. lua_pushnil(L);
  8849. } else {
  8850. lua_pushlightuserdata(L, ptrRetVal);
  8851. }
  8852. return 1;
  8853. }
  8854. static int Polycore_ShaderBinding_getNumOutTargetBindings(lua_State *L) {
  8855. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  8856. ShaderBinding *inst = (ShaderBinding*)lua_topointer(L, 1);
  8857. lua_pushinteger(L, inst->getNumOutTargetBindings());
  8858. return 1;
  8859. }
  8860. static int Polycore_ShaderBinding_getOutTargetBinding(lua_State *L) {
  8861. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  8862. ShaderBinding *inst = (ShaderBinding*)lua_topointer(L, 1);
  8863. luaL_checktype(L, 2, LUA_TNUMBER);
  8864. unsigned int index = lua_tointeger(L, 2);
  8865. void *ptrRetVal = (void*)inst->getOutTargetBinding(index);
  8866. if(ptrRetVal == NULL) {
  8867. lua_pushnil(L);
  8868. } else {
  8869. lua_pushlightuserdata(L, ptrRetVal);
  8870. }
  8871. return 1;
  8872. }
  8873. static int Polycore_ShaderBinding_addLocalParam(lua_State *L) {
  8874. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  8875. ShaderBinding *inst = (ShaderBinding*)lua_topointer(L, 1);
  8876. luaL_checktype(L, 2, LUA_TSTRING);
  8877. String name = String(lua_tostring(L, 2));
  8878. luaL_checktype(L, 3, LUA_TLIGHTUSERDATA);
  8879. void* ptr = (void*)lua_topointer(L, 3);
  8880. inst->addLocalParam(name, ptr);
  8881. return 0;
  8882. }
  8883. static int Polycore_delete_ShaderBinding(lua_State *L) {
  8884. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  8885. ShaderBinding *inst = (ShaderBinding*)lua_topointer(L, 1);
  8886. delete inst;
  8887. return 0;
  8888. }
  8889. static int Polycore_SkeletonAnimation(lua_State *L) {
  8890. luaL_checktype(L, 1, LUA_TSTRING);
  8891. String name = String(lua_tostring(L, 1));
  8892. luaL_checktype(L, 2, LUA_TNUMBER);
  8893. Number duration = lua_tonumber(L, 2);
  8894. SkeletonAnimation *inst = new SkeletonAnimation(name, duration);
  8895. lua_pushlightuserdata(L, (void*)inst);
  8896. return 1;
  8897. }
  8898. static int Polycore_SkeletonAnimation_addBoneTrack(lua_State *L) {
  8899. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  8900. SkeletonAnimation *inst = (SkeletonAnimation*)lua_topointer(L, 1);
  8901. luaL_checktype(L, 2, LUA_TLIGHTUSERDATA);
  8902. BoneTrack* boneTrack = (BoneTrack*)lua_topointer(L, 2);
  8903. inst->addBoneTrack(boneTrack);
  8904. return 0;
  8905. }
  8906. static int Polycore_SkeletonAnimation_getName(lua_State *L) {
  8907. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  8908. SkeletonAnimation *inst = (SkeletonAnimation*)lua_topointer(L, 1);
  8909. String *retInst = new String ();
  8910. *retInst = inst->getName();
  8911. lua_pushlightuserdata(L, retInst);
  8912. return 1;
  8913. }
  8914. static int Polycore_SkeletonAnimation_Play(lua_State *L) {
  8915. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  8916. SkeletonAnimation *inst = (SkeletonAnimation*)lua_topointer(L, 1);
  8917. luaL_checktype(L, 2, LUA_TBOOLEAN);
  8918. bool once = lua_toboolean(L, 2);
  8919. inst->Play(once);
  8920. return 0;
  8921. }
  8922. static int Polycore_SkeletonAnimation_Stop(lua_State *L) {
  8923. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  8924. SkeletonAnimation *inst = (SkeletonAnimation*)lua_topointer(L, 1);
  8925. inst->Stop();
  8926. return 0;
  8927. }
  8928. static int Polycore_SkeletonAnimation_Update(lua_State *L) {
  8929. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  8930. SkeletonAnimation *inst = (SkeletonAnimation*)lua_topointer(L, 1);
  8931. inst->Update();
  8932. return 0;
  8933. }
  8934. static int Polycore_SkeletonAnimation_setSpeed(lua_State *L) {
  8935. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  8936. SkeletonAnimation *inst = (SkeletonAnimation*)lua_topointer(L, 1);
  8937. luaL_checktype(L, 2, LUA_TNUMBER);
  8938. Number speed = lua_tonumber(L, 2);
  8939. inst->setSpeed(speed);
  8940. return 0;
  8941. }
  8942. static int Polycore_delete_SkeletonAnimation(lua_State *L) {
  8943. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  8944. SkeletonAnimation *inst = (SkeletonAnimation*)lua_topointer(L, 1);
  8945. delete inst;
  8946. return 0;
  8947. }
  8948. static int Polycore_Skeleton(lua_State *L) {
  8949. luaL_checktype(L, 1, LUA_TSTRING);
  8950. String fileName = String(lua_tostring(L, 1));
  8951. Skeleton *inst = new Skeleton(fileName);
  8952. lua_pushlightuserdata(L, (void*)inst);
  8953. return 1;
  8954. }
  8955. static int Polycore_Skeleton_loadSkeleton(lua_State *L) {
  8956. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  8957. Skeleton *inst = (Skeleton*)lua_topointer(L, 1);
  8958. luaL_checktype(L, 2, LUA_TSTRING);
  8959. String fileName = String(lua_tostring(L, 2));
  8960. inst->loadSkeleton(fileName);
  8961. return 0;
  8962. }
  8963. static int Polycore_Skeleton_playAnimation(lua_State *L) {
  8964. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  8965. Skeleton *inst = (Skeleton*)lua_topointer(L, 1);
  8966. luaL_checktype(L, 2, LUA_TSTRING);
  8967. String animName = String(lua_tostring(L, 2));
  8968. bool once;
  8969. if(lua_isboolean(L, 3)) {
  8970. once = lua_toboolean(L, 3);
  8971. } else {
  8972. once = false;
  8973. }
  8974. inst->playAnimation(animName, once);
  8975. return 0;
  8976. }
  8977. static int Polycore_Skeleton_playAnimationByIndex(lua_State *L) {
  8978. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  8979. Skeleton *inst = (Skeleton*)lua_topointer(L, 1);
  8980. luaL_checktype(L, 2, LUA_TNUMBER);
  8981. int index = lua_tointeger(L, 2);
  8982. bool once;
  8983. if(lua_isboolean(L, 3)) {
  8984. once = lua_toboolean(L, 3);
  8985. } else {
  8986. once = false;
  8987. }
  8988. inst->playAnimationByIndex(index, once);
  8989. return 0;
  8990. }
  8991. static int Polycore_Skeleton_addAnimation(lua_State *L) {
  8992. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  8993. Skeleton *inst = (Skeleton*)lua_topointer(L, 1);
  8994. luaL_checktype(L, 2, LUA_TSTRING);
  8995. String name = String(lua_tostring(L, 2));
  8996. luaL_checktype(L, 3, LUA_TSTRING);
  8997. String fileName = String(lua_tostring(L, 3));
  8998. inst->addAnimation(name, fileName);
  8999. return 0;
  9000. }
  9001. static int Polycore_Skeleton_getAnimation(lua_State *L) {
  9002. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  9003. Skeleton *inst = (Skeleton*)lua_topointer(L, 1);
  9004. luaL_checktype(L, 2, LUA_TSTRING);
  9005. String name = String(lua_tostring(L, 2));
  9006. void *ptrRetVal = (void*)inst->getAnimation(name);
  9007. if(ptrRetVal == NULL) {
  9008. lua_pushnil(L);
  9009. } else {
  9010. lua_pushlightuserdata(L, ptrRetVal);
  9011. }
  9012. return 1;
  9013. }
  9014. static int Polycore_Skeleton_Update(lua_State *L) {
  9015. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  9016. Skeleton *inst = (Skeleton*)lua_topointer(L, 1);
  9017. inst->Update();
  9018. return 0;
  9019. }
  9020. static int Polycore_Skeleton_getBoneByName(lua_State *L) {
  9021. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  9022. Skeleton *inst = (Skeleton*)lua_topointer(L, 1);
  9023. luaL_checktype(L, 2, LUA_TSTRING);
  9024. String name = String(lua_tostring(L, 2));
  9025. void *ptrRetVal = (void*)inst->getBoneByName(name);
  9026. if(ptrRetVal == NULL) {
  9027. lua_pushnil(L);
  9028. } else {
  9029. lua_pushlightuserdata(L, ptrRetVal);
  9030. }
  9031. return 1;
  9032. }
  9033. static int Polycore_Skeleton_bonesVisible(lua_State *L) {
  9034. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  9035. Skeleton *inst = (Skeleton*)lua_topointer(L, 1);
  9036. luaL_checktype(L, 2, LUA_TBOOLEAN);
  9037. bool val = lua_toboolean(L, 2);
  9038. inst->bonesVisible(val);
  9039. return 0;
  9040. }
  9041. static int Polycore_Skeleton_enableBoneLabels(lua_State *L) {
  9042. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  9043. Skeleton *inst = (Skeleton*)lua_topointer(L, 1);
  9044. luaL_checktype(L, 2, LUA_TSTRING);
  9045. String labelFont = String(lua_tostring(L, 2));
  9046. luaL_checktype(L, 3, LUA_TNUMBER);
  9047. Number size = lua_tonumber(L, 3);
  9048. luaL_checktype(L, 4, LUA_TNUMBER);
  9049. Number scale = lua_tonumber(L, 4);
  9050. luaL_checktype(L, 5, LUA_TLIGHTUSERDATA);
  9051. Color labelColor = *(Color*)lua_topointer(L, 5);
  9052. inst->enableBoneLabels(labelFont, size, scale, labelColor);
  9053. return 0;
  9054. }
  9055. static int Polycore_Skeleton_getNumBones(lua_State *L) {
  9056. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  9057. Skeleton *inst = (Skeleton*)lua_topointer(L, 1);
  9058. lua_pushinteger(L, inst->getNumBones());
  9059. return 1;
  9060. }
  9061. static int Polycore_Skeleton_getBone(lua_State *L) {
  9062. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  9063. Skeleton *inst = (Skeleton*)lua_topointer(L, 1);
  9064. luaL_checktype(L, 2, LUA_TNUMBER);
  9065. int index = lua_tointeger(L, 2);
  9066. void *ptrRetVal = (void*)inst->getBone(index);
  9067. if(ptrRetVal == NULL) {
  9068. lua_pushnil(L);
  9069. } else {
  9070. lua_pushlightuserdata(L, ptrRetVal);
  9071. }
  9072. return 1;
  9073. }
  9074. static int Polycore_Skeleton_getCurrentAnimation(lua_State *L) {
  9075. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  9076. Skeleton *inst = (Skeleton*)lua_topointer(L, 1);
  9077. void *ptrRetVal = (void*)inst->getCurrentAnimation();
  9078. if(ptrRetVal == NULL) {
  9079. lua_pushnil(L);
  9080. } else {
  9081. lua_pushlightuserdata(L, ptrRetVal);
  9082. }
  9083. return 1;
  9084. }
  9085. static int Polycore_delete_Skeleton(lua_State *L) {
  9086. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  9087. Skeleton *inst = (Skeleton*)lua_topointer(L, 1);
  9088. delete inst;
  9089. return 0;
  9090. }
  9091. static int Polycore_BoneTrack_get_LocXVec(lua_State *L) {
  9092. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  9093. BoneTrack *inst = (BoneTrack*)lua_topointer(L, 1);
  9094. lua_pushlightuserdata(L, &inst->LocXVec);
  9095. return 1;
  9096. }
  9097. static int Polycore_BoneTrack_get_LocYVec(lua_State *L) {
  9098. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  9099. BoneTrack *inst = (BoneTrack*)lua_topointer(L, 1);
  9100. lua_pushlightuserdata(L, &inst->LocYVec);
  9101. return 1;
  9102. }
  9103. static int Polycore_BoneTrack_get_LocZVec(lua_State *L) {
  9104. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  9105. BoneTrack *inst = (BoneTrack*)lua_topointer(L, 1);
  9106. lua_pushlightuserdata(L, &inst->LocZVec);
  9107. return 1;
  9108. }
  9109. static int Polycore_BoneTrack_get_ScaleXVec(lua_State *L) {
  9110. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  9111. BoneTrack *inst = (BoneTrack*)lua_topointer(L, 1);
  9112. lua_pushlightuserdata(L, &inst->ScaleXVec);
  9113. return 1;
  9114. }
  9115. static int Polycore_BoneTrack_get_ScaleYVec(lua_State *L) {
  9116. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  9117. BoneTrack *inst = (BoneTrack*)lua_topointer(L, 1);
  9118. lua_pushlightuserdata(L, &inst->ScaleYVec);
  9119. return 1;
  9120. }
  9121. static int Polycore_BoneTrack_get_ScaleZVec(lua_State *L) {
  9122. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  9123. BoneTrack *inst = (BoneTrack*)lua_topointer(L, 1);
  9124. lua_pushlightuserdata(L, &inst->ScaleZVec);
  9125. return 1;
  9126. }
  9127. static int Polycore_BoneTrack_get_boneQuat(lua_State *L) {
  9128. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  9129. BoneTrack *inst = (BoneTrack*)lua_topointer(L, 1);
  9130. lua_pushlightuserdata(L, &inst->boneQuat);
  9131. return 1;
  9132. }
  9133. static int Polycore_BoneTrack_get_QuatWVec(lua_State *L) {
  9134. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  9135. BoneTrack *inst = (BoneTrack*)lua_topointer(L, 1);
  9136. lua_pushlightuserdata(L, &inst->QuatWVec);
  9137. return 1;
  9138. }
  9139. static int Polycore_BoneTrack_get_QuatXVec(lua_State *L) {
  9140. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  9141. BoneTrack *inst = (BoneTrack*)lua_topointer(L, 1);
  9142. lua_pushlightuserdata(L, &inst->QuatXVec);
  9143. return 1;
  9144. }
  9145. static int Polycore_BoneTrack_get_QuatYVec(lua_State *L) {
  9146. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  9147. BoneTrack *inst = (BoneTrack*)lua_topointer(L, 1);
  9148. lua_pushlightuserdata(L, &inst->QuatYVec);
  9149. return 1;
  9150. }
  9151. static int Polycore_BoneTrack_get_QuatZVec(lua_State *L) {
  9152. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  9153. BoneTrack *inst = (BoneTrack*)lua_topointer(L, 1);
  9154. lua_pushlightuserdata(L, &inst->QuatZVec);
  9155. return 1;
  9156. }
  9157. static int Polycore_BoneTrack(lua_State *L) {
  9158. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  9159. Bone* bone = (Bone*)lua_topointer(L, 1);
  9160. luaL_checktype(L, 2, LUA_TNUMBER);
  9161. Number length = lua_tonumber(L, 2);
  9162. BoneTrack *inst = new BoneTrack(bone, length);
  9163. lua_pushlightuserdata(L, (void*)inst);
  9164. return 1;
  9165. }
  9166. static int Polycore_BoneTrack_Play(lua_State *L) {
  9167. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  9168. BoneTrack *inst = (BoneTrack*)lua_topointer(L, 1);
  9169. bool once;
  9170. if(lua_isboolean(L, 2)) {
  9171. once = lua_toboolean(L, 2);
  9172. } else {
  9173. once = false;
  9174. }
  9175. inst->Play(once);
  9176. return 0;
  9177. }
  9178. static int Polycore_BoneTrack_Stop(lua_State *L) {
  9179. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  9180. BoneTrack *inst = (BoneTrack*)lua_topointer(L, 1);
  9181. inst->Stop();
  9182. return 0;
  9183. }
  9184. static int Polycore_BoneTrack_Update(lua_State *L) {
  9185. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  9186. BoneTrack *inst = (BoneTrack*)lua_topointer(L, 1);
  9187. inst->Update();
  9188. return 0;
  9189. }
  9190. static int Polycore_BoneTrack_setSpeed(lua_State *L) {
  9191. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  9192. BoneTrack *inst = (BoneTrack*)lua_topointer(L, 1);
  9193. luaL_checktype(L, 2, LUA_TNUMBER);
  9194. Number speed = lua_tonumber(L, 2);
  9195. inst->setSpeed(speed);
  9196. return 0;
  9197. }
  9198. static int Polycore_delete_BoneTrack(lua_State *L) {
  9199. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  9200. BoneTrack *inst = (BoneTrack*)lua_topointer(L, 1);
  9201. delete inst;
  9202. return 0;
  9203. }
  9204. static int Polycore_Sound(lua_State *L) {
  9205. luaL_checktype(L, 1, LUA_TSTRING);
  9206. String fileName = String(lua_tostring(L, 1));
  9207. Sound *inst = new Sound(fileName);
  9208. lua_pushlightuserdata(L, (void*)inst);
  9209. return 1;
  9210. }
  9211. static int Polycore_Sound_Play(lua_State *L) {
  9212. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  9213. Sound *inst = (Sound*)lua_topointer(L, 1);
  9214. bool loop;
  9215. if(lua_isboolean(L, 2)) {
  9216. loop = lua_toboolean(L, 2);
  9217. } else {
  9218. loop = false;
  9219. }
  9220. inst->Play(loop);
  9221. return 0;
  9222. }
  9223. static int Polycore_Sound_Stop(lua_State *L) {
  9224. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  9225. Sound *inst = (Sound*)lua_topointer(L, 1);
  9226. inst->Stop();
  9227. return 0;
  9228. }
  9229. static int Polycore_Sound_setVolume(lua_State *L) {
  9230. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  9231. Sound *inst = (Sound*)lua_topointer(L, 1);
  9232. luaL_checktype(L, 2, LUA_TNUMBER);
  9233. Number newVolume = lua_tonumber(L, 2);
  9234. inst->setVolume(newVolume);
  9235. return 0;
  9236. }
  9237. static int Polycore_Sound_setPitch(lua_State *L) {
  9238. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  9239. Sound *inst = (Sound*)lua_topointer(L, 1);
  9240. luaL_checktype(L, 2, LUA_TNUMBER);
  9241. Number newPitch = lua_tonumber(L, 2);
  9242. inst->setPitch(newPitch);
  9243. return 0;
  9244. }
  9245. static int Polycore_Sound_setIsPositional(lua_State *L) {
  9246. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  9247. Sound *inst = (Sound*)lua_topointer(L, 1);
  9248. luaL_checktype(L, 2, LUA_TBOOLEAN);
  9249. bool isPositional = lua_toboolean(L, 2);
  9250. inst->setIsPositional(isPositional);
  9251. return 0;
  9252. }
  9253. static int Polycore_Sound_setSoundPosition(lua_State *L) {
  9254. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  9255. Sound *inst = (Sound*)lua_topointer(L, 1);
  9256. luaL_checktype(L, 2, LUA_TLIGHTUSERDATA);
  9257. Vector3 position = *(Vector3*)lua_topointer(L, 2);
  9258. inst->setSoundPosition(position);
  9259. return 0;
  9260. }
  9261. static int Polycore_Sound_setSoundVelocity(lua_State *L) {
  9262. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  9263. Sound *inst = (Sound*)lua_topointer(L, 1);
  9264. luaL_checktype(L, 2, LUA_TLIGHTUSERDATA);
  9265. Vector3 velocity = *(Vector3*)lua_topointer(L, 2);
  9266. inst->setSoundVelocity(velocity);
  9267. return 0;
  9268. }
  9269. static int Polycore_Sound_setSoundDirection(lua_State *L) {
  9270. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  9271. Sound *inst = (Sound*)lua_topointer(L, 1);
  9272. luaL_checktype(L, 2, LUA_TLIGHTUSERDATA);
  9273. Vector3 direction = *(Vector3*)lua_topointer(L, 2);
  9274. inst->setSoundDirection(direction);
  9275. return 0;
  9276. }
  9277. static int Polycore_Sound_setPositionalProperties(lua_State *L) {
  9278. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  9279. Sound *inst = (Sound*)lua_topointer(L, 1);
  9280. luaL_checktype(L, 2, LUA_TNUMBER);
  9281. Number referenceDistance = lua_tonumber(L, 2);
  9282. luaL_checktype(L, 3, LUA_TNUMBER);
  9283. Number maxDistance = lua_tonumber(L, 3);
  9284. inst->setPositionalProperties(referenceDistance, maxDistance);
  9285. return 0;
  9286. }
  9287. static int Polycore_Sound_loadWAV(lua_State *L) {
  9288. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  9289. Sound *inst = (Sound*)lua_topointer(L, 1);
  9290. luaL_checktype(L, 2, LUA_TSTRING);
  9291. String fileName = String(lua_tostring(L, 2));
  9292. ALuint *retInst = new ALuint();
  9293. *retInst = inst->loadWAV(fileName);
  9294. lua_pushlightuserdata(L, retInst);
  9295. return 1;
  9296. }
  9297. static int Polycore_Sound_loadOGG(lua_State *L) {
  9298. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  9299. Sound *inst = (Sound*)lua_topointer(L, 1);
  9300. luaL_checktype(L, 2, LUA_TSTRING);
  9301. String fileName = String(lua_tostring(L, 2));
  9302. ALuint *retInst = new ALuint();
  9303. *retInst = inst->loadOGG(fileName);
  9304. lua_pushlightuserdata(L, retInst);
  9305. return 1;
  9306. }
  9307. static int Polycore_Sound_GenSource(lua_State *L) {
  9308. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  9309. Sound *inst = (Sound*)lua_topointer(L, 1);
  9310. luaL_checktype(L, 2, LUA_TLIGHTUSERDATA);
  9311. ALuint buffer = *(ALuint*)lua_topointer(L, 2);
  9312. ALuint *retInst = new ALuint();
  9313. *retInst = inst->GenSource(buffer);
  9314. lua_pushlightuserdata(L, retInst);
  9315. return 1;
  9316. }
  9317. static int Polycore_Sound_checkALError(lua_State *L) {
  9318. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  9319. Sound *inst = (Sound*)lua_topointer(L, 1);
  9320. luaL_checktype(L, 2, LUA_TSTRING);
  9321. String operation = String(lua_tostring(L, 2));
  9322. inst->checkALError(operation);
  9323. return 0;
  9324. }
  9325. static int Polycore_Sound_soundError(lua_State *L) {
  9326. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  9327. Sound *inst = (Sound*)lua_topointer(L, 1);
  9328. luaL_checktype(L, 2, LUA_TSTRING);
  9329. String err = String(lua_tostring(L, 2));
  9330. inst->soundError(err);
  9331. return 0;
  9332. }
  9333. static int Polycore_Sound_soundCheck(lua_State *L) {
  9334. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  9335. Sound *inst = (Sound*)lua_topointer(L, 1);
  9336. luaL_checktype(L, 2, LUA_TBOOLEAN);
  9337. bool result = lua_toboolean(L, 2);
  9338. luaL_checktype(L, 3, LUA_TSTRING);
  9339. String err = String(lua_tostring(L, 3));
  9340. inst->soundCheck(result, err);
  9341. return 0;
  9342. }
  9343. static int Polycore_delete_Sound(lua_State *L) {
  9344. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  9345. Sound *inst = (Sound*)lua_topointer(L, 1);
  9346. delete inst;
  9347. return 0;
  9348. }
  9349. static int Polycore_SoundManager(lua_State *L) {
  9350. SoundManager *inst = new SoundManager();
  9351. lua_pushlightuserdata(L, (void*)inst);
  9352. return 1;
  9353. }
  9354. static int Polycore_SoundManager_setListenerPosition(lua_State *L) {
  9355. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  9356. SoundManager *inst = (SoundManager*)lua_topointer(L, 1);
  9357. luaL_checktype(L, 2, LUA_TLIGHTUSERDATA);
  9358. Vector3 position = *(Vector3*)lua_topointer(L, 2);
  9359. inst->setListenerPosition(position);
  9360. return 0;
  9361. }
  9362. static int Polycore_SoundManager_setListenerOrientation(lua_State *L) {
  9363. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  9364. SoundManager *inst = (SoundManager*)lua_topointer(L, 1);
  9365. luaL_checktype(L, 2, LUA_TLIGHTUSERDATA);
  9366. Vector3 orientation = *(Vector3*)lua_topointer(L, 2);
  9367. inst->setListenerOrientation(orientation);
  9368. return 0;
  9369. }
  9370. static int Polycore_SoundManager_initAL(lua_State *L) {
  9371. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  9372. SoundManager *inst = (SoundManager*)lua_topointer(L, 1);
  9373. inst->initAL();
  9374. return 0;
  9375. }
  9376. static int Polycore_SoundManager_setGlobalVolume(lua_State *L) {
  9377. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  9378. SoundManager *inst = (SoundManager*)lua_topointer(L, 1);
  9379. luaL_checktype(L, 2, LUA_TNUMBER);
  9380. Number globalVolume = lua_tonumber(L, 2);
  9381. inst->setGlobalVolume(globalVolume);
  9382. return 0;
  9383. }
  9384. static int Polycore_delete_SoundManager(lua_State *L) {
  9385. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  9386. SoundManager *inst = (SoundManager*)lua_topointer(L, 1);
  9387. delete inst;
  9388. return 0;
  9389. }
  9390. static int Polycore_String_get_contents(lua_State *L) {
  9391. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  9392. String *inst = (String*)lua_topointer(L, 1);
  9393. lua_pushlightuserdata(L, &inst->contents);
  9394. return 1;
  9395. }
  9396. static int Polycore_String(lua_State *L) {
  9397. String *inst = new String();
  9398. lua_pushlightuserdata(L, (void*)inst);
  9399. return 1;
  9400. }
  9401. static int Polycore_String_size(lua_State *L) {
  9402. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  9403. String *inst = (String*)lua_topointer(L, 1);
  9404. lua_pushinteger(L, inst->size());
  9405. return 1;
  9406. }
  9407. static int Polycore_String_length(lua_State *L) {
  9408. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  9409. String *inst = (String*)lua_topointer(L, 1);
  9410. lua_pushinteger(L, inst->length());
  9411. return 1;
  9412. }
  9413. static int Polycore_String_substr(lua_State *L) {
  9414. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  9415. String *inst = (String*)lua_topointer(L, 1);
  9416. luaL_checktype(L, 2, LUA_TLIGHTUSERDATA);
  9417. size_t pos = *(size_t*)lua_topointer(L, 2);
  9418. luaL_checktype(L, 3, LUA_TLIGHTUSERDATA);
  9419. size_t n = *(size_t*)lua_topointer(L, 3);
  9420. lua_pushstring(L, inst->substr(pos, n).c_str());
  9421. return 1;
  9422. }
  9423. static int Polycore_String_rfind(lua_State *L) {
  9424. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  9425. String *inst = (String*)lua_topointer(L, 1);
  9426. luaL_checktype(L, 2, LUA_TSTRING);
  9427. String str = String(lua_tostring(L, 2));
  9428. luaL_checktype(L, 3, LUA_TLIGHTUSERDATA);
  9429. size_t pos = *(size_t*)lua_topointer(L, 3);
  9430. lua_pushinteger(L, inst->rfind(str, pos));
  9431. return 1;
  9432. }
  9433. static int Polycore_String_find(lua_State *L) {
  9434. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  9435. String *inst = (String*)lua_topointer(L, 1);
  9436. luaL_checktype(L, 2, LUA_TSTRING);
  9437. String str = String(lua_tostring(L, 2));
  9438. luaL_checktype(L, 3, LUA_TLIGHTUSERDATA);
  9439. size_t pos = *(size_t*)lua_topointer(L, 3);
  9440. lua_pushinteger(L, inst->find(str, pos));
  9441. return 1;
  9442. }
  9443. static int Polycore_String_find_last_of(lua_State *L) {
  9444. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  9445. String *inst = (String*)lua_topointer(L, 1);
  9446. luaL_checktype(L, 2, LUA_TSTRING);
  9447. String str = String(lua_tostring(L, 2));
  9448. luaL_checktype(L, 3, LUA_TLIGHTUSERDATA);
  9449. size_t pos = *(size_t*)lua_topointer(L, 3);
  9450. lua_pushinteger(L, inst->find_last_of(str, pos));
  9451. return 1;
  9452. }
  9453. static int Polycore_String_toLowerCase(lua_State *L) {
  9454. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  9455. String *inst = (String*)lua_topointer(L, 1);
  9456. lua_pushstring(L, inst->toLowerCase().c_str());
  9457. return 1;
  9458. }
  9459. static int Polycore_String_toUpperCase(lua_State *L) {
  9460. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  9461. String *inst = (String*)lua_topointer(L, 1);
  9462. lua_pushstring(L, inst->toUpperCase().c_str());
  9463. return 1;
  9464. }
  9465. static int Polycore_String_replace(lua_State *L) {
  9466. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  9467. String *inst = (String*)lua_topointer(L, 1);
  9468. luaL_checktype(L, 2, LUA_TSTRING);
  9469. String what = String(lua_tostring(L, 2));
  9470. luaL_checktype(L, 3, LUA_TSTRING);
  9471. String withWhat = String(lua_tostring(L, 3));
  9472. lua_pushstring(L, inst->replace(what, withWhat).c_str());
  9473. return 1;
  9474. }
  9475. static int Polycore_String_NumberToString(lua_State *L) {
  9476. luaL_checktype(L, 2, LUA_TNUMBER);
  9477. Number value = lua_tonumber(L, 2);
  9478. lua_pushstring(L, String::NumberToString(value).c_str());
  9479. return 1;
  9480. }
  9481. static int Polycore_String_IntToString(lua_State *L) {
  9482. luaL_checktype(L, 2, LUA_TNUMBER);
  9483. int value = lua_tointeger(L, 2);
  9484. lua_pushstring(L, String::IntToString(value).c_str());
  9485. return 1;
  9486. }
  9487. static int Polycore_String_c_str(lua_State *L) {
  9488. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  9489. String *inst = (String*)lua_topointer(L, 1);
  9490. void *ptrRetVal = (void*)inst->c_str();
  9491. if(ptrRetVal == NULL) {
  9492. lua_pushnil(L);
  9493. } else {
  9494. lua_pushlightuserdata(L, ptrRetVal);
  9495. }
  9496. return 1;
  9497. }
  9498. static int Polycore_String_getDataWithEncoding(lua_State *L) {
  9499. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  9500. String *inst = (String*)lua_topointer(L, 1);
  9501. luaL_checktype(L, 2, LUA_TNUMBER);
  9502. int encoding = lua_tointeger(L, 2);
  9503. void *ptrRetVal = (void*)inst->getDataWithEncoding(encoding);
  9504. if(ptrRetVal == NULL) {
  9505. lua_pushnil(L);
  9506. } else {
  9507. lua_pushlightuserdata(L, ptrRetVal);
  9508. }
  9509. return 1;
  9510. }
  9511. static int Polycore_String_getDataSizeWithEncoding(lua_State *L) {
  9512. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  9513. String *inst = (String*)lua_topointer(L, 1);
  9514. luaL_checktype(L, 2, LUA_TNUMBER);
  9515. int encoding = lua_tointeger(L, 2);
  9516. lua_pushinteger(L, inst->getDataSizeWithEncoding(encoding));
  9517. return 1;
  9518. }
  9519. static int Polycore_String_setDataWithEncoding(lua_State *L) {
  9520. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  9521. String *inst = (String*)lua_topointer(L, 1);
  9522. luaL_checktype(L, 2, LUA_TLIGHTUSERDATA);
  9523. char* data = (char*)lua_topointer(L, 2);
  9524. luaL_checktype(L, 3, LUA_TNUMBER);
  9525. int encoding = lua_tointeger(L, 3);
  9526. inst->setDataWithEncoding(data, encoding);
  9527. return 0;
  9528. }
  9529. static int Polycore_delete_String(lua_State *L) {
  9530. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  9531. String *inst = (String*)lua_topointer(L, 1);
  9532. delete inst;
  9533. return 0;
  9534. }
  9535. static int Polycore_Texture_get_scrollSpeedX(lua_State *L) {
  9536. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  9537. Texture *inst = (Texture*)lua_topointer(L, 1);
  9538. lua_pushnumber(L, inst->scrollSpeedX);
  9539. return 1;
  9540. }
  9541. static int Polycore_Texture_get_scrollSpeedY(lua_State *L) {
  9542. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  9543. Texture *inst = (Texture*)lua_topointer(L, 1);
  9544. lua_pushnumber(L, inst->scrollSpeedY);
  9545. return 1;
  9546. }
  9547. static int Polycore_Texture_get_clamp(lua_State *L) {
  9548. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  9549. Texture *inst = (Texture*)lua_topointer(L, 1);
  9550. lua_pushboolean(L, inst->clamp);
  9551. return 1;
  9552. }
  9553. static int Polycore_Texture_set_scrollSpeedX(lua_State *L) {
  9554. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  9555. Texture *inst = (Texture*)lua_topointer(L, 1);
  9556. Number param = lua_tonumber(L, 2);
  9557. inst->scrollSpeedX = param;
  9558. return 0;
  9559. }
  9560. static int Polycore_Texture_set_scrollSpeedY(lua_State *L) {
  9561. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  9562. Texture *inst = (Texture*)lua_topointer(L, 1);
  9563. Number param = lua_tonumber(L, 2);
  9564. inst->scrollSpeedY = param;
  9565. return 0;
  9566. }
  9567. static int Polycore_Texture_set_clamp(lua_State *L) {
  9568. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  9569. Texture *inst = (Texture*)lua_topointer(L, 1);
  9570. bool param = lua_toboolean(L, 2);
  9571. inst->clamp = param;
  9572. return 0;
  9573. }
  9574. static int Polycore_Texture_setTextureData(lua_State *L) {
  9575. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  9576. Texture *inst = (Texture*)lua_topointer(L, 1);
  9577. luaL_checktype(L, 2, LUA_TLIGHTUSERDATA);
  9578. char* data = (char*)lua_topointer(L, 2);
  9579. inst->setTextureData(data);
  9580. return 0;
  9581. }
  9582. static int Polycore_Texture_recreateFromImageData(lua_State *L) {
  9583. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  9584. Texture *inst = (Texture*)lua_topointer(L, 1);
  9585. inst->recreateFromImageData();
  9586. return 0;
  9587. }
  9588. static int Polycore_Texture_getScrollOffsetX(lua_State *L) {
  9589. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  9590. Texture *inst = (Texture*)lua_topointer(L, 1);
  9591. lua_pushnumber(L, inst->getScrollOffsetX());
  9592. return 1;
  9593. }
  9594. static int Polycore_Texture_getScrollOffsetY(lua_State *L) {
  9595. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  9596. Texture *inst = (Texture*)lua_topointer(L, 1);
  9597. lua_pushnumber(L, inst->getScrollOffsetY());
  9598. return 1;
  9599. }
  9600. static int Polycore_Texture_setImageData(lua_State *L) {
  9601. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  9602. Texture *inst = (Texture*)lua_topointer(L, 1);
  9603. luaL_checktype(L, 2, LUA_TLIGHTUSERDATA);
  9604. Image* data = (Image*)lua_topointer(L, 2);
  9605. inst->setImageData(data);
  9606. return 0;
  9607. }
  9608. static int Polycore_Texture_updateScroll(lua_State *L) {
  9609. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  9610. Texture *inst = (Texture*)lua_topointer(L, 1);
  9611. luaL_checktype(L, 2, LUA_TNUMBER);
  9612. int elapsed = lua_tointeger(L, 2);
  9613. inst->updateScroll(elapsed);
  9614. return 0;
  9615. }
  9616. static int Polycore_Texture_setResourcePath(lua_State *L) {
  9617. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  9618. Texture *inst = (Texture*)lua_topointer(L, 1);
  9619. luaL_checktype(L, 2, LUA_TSTRING);
  9620. String newPath = String(lua_tostring(L, 2));
  9621. inst->setResourcePath(newPath);
  9622. return 0;
  9623. }
  9624. static int Polycore_Texture_getResourcePath(lua_State *L) {
  9625. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  9626. Texture *inst = (Texture*)lua_topointer(L, 1);
  9627. String *retInst = new String ();
  9628. *retInst = inst->getResourcePath();
  9629. lua_pushlightuserdata(L, retInst);
  9630. return 1;
  9631. }
  9632. static int Polycore_Texture_getTextureData(lua_State *L) {
  9633. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  9634. Texture *inst = (Texture*)lua_topointer(L, 1);
  9635. void *ptrRetVal = (void*)inst->getTextureData();
  9636. if(ptrRetVal == NULL) {
  9637. lua_pushnil(L);
  9638. } else {
  9639. lua_pushlightuserdata(L, ptrRetVal);
  9640. }
  9641. return 1;
  9642. }
  9643. static int Polycore_Texture_getWidth(lua_State *L) {
  9644. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  9645. Texture *inst = (Texture*)lua_topointer(L, 1);
  9646. lua_pushinteger(L, inst->getWidth());
  9647. return 1;
  9648. }
  9649. static int Polycore_Texture_getHeight(lua_State *L) {
  9650. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  9651. Texture *inst = (Texture*)lua_topointer(L, 1);
  9652. lua_pushinteger(L, inst->getHeight());
  9653. return 1;
  9654. }
  9655. static int Polycore_delete_Texture(lua_State *L) {
  9656. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  9657. Texture *inst = (Texture*)lua_topointer(L, 1);
  9658. delete inst;
  9659. return 0;
  9660. }
  9661. static int Polycore_Timer(lua_State *L) {
  9662. luaL_checktype(L, 1, LUA_TBOOLEAN);
  9663. bool triggerMode = lua_toboolean(L, 1);
  9664. luaL_checktype(L, 2, LUA_TNUMBER);
  9665. int msecs = lua_tointeger(L, 2);
  9666. Timer *inst = new Timer(triggerMode, msecs);
  9667. lua_pushlightuserdata(L, (void*)inst);
  9668. return 1;
  9669. }
  9670. static int Polycore_Timer_Pause(lua_State *L) {
  9671. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  9672. Timer *inst = (Timer*)lua_topointer(L, 1);
  9673. luaL_checktype(L, 2, LUA_TBOOLEAN);
  9674. bool paused = lua_toboolean(L, 2);
  9675. inst->Pause(paused);
  9676. return 0;
  9677. }
  9678. static int Polycore_Timer_isPaused(lua_State *L) {
  9679. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  9680. Timer *inst = (Timer*)lua_topointer(L, 1);
  9681. lua_pushboolean(L, inst->isPaused());
  9682. return 1;
  9683. }
  9684. static int Polycore_Timer_getTicks(lua_State *L) {
  9685. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  9686. Timer *inst = (Timer*)lua_topointer(L, 1);
  9687. lua_pushinteger(L, inst->getTicks());
  9688. return 1;
  9689. }
  9690. static int Polycore_Timer_Update(lua_State *L) {
  9691. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  9692. Timer *inst = (Timer*)lua_topointer(L, 1);
  9693. luaL_checktype(L, 2, LUA_TNUMBER);
  9694. unsigned int ticks = lua_tointeger(L, 2);
  9695. inst->Update(ticks);
  9696. return 0;
  9697. }
  9698. static int Polycore_Timer_Reset(lua_State *L) {
  9699. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  9700. Timer *inst = (Timer*)lua_topointer(L, 1);
  9701. inst->Reset();
  9702. return 0;
  9703. }
  9704. static int Polycore_Timer_hasElapsed(lua_State *L) {
  9705. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  9706. Timer *inst = (Timer*)lua_topointer(L, 1);
  9707. lua_pushboolean(L, inst->hasElapsed());
  9708. return 1;
  9709. }
  9710. static int Polycore_Timer_getElapsedf(lua_State *L) {
  9711. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  9712. Timer *inst = (Timer*)lua_topointer(L, 1);
  9713. lua_pushnumber(L, inst->getElapsedf());
  9714. return 1;
  9715. }
  9716. static int Polycore_delete_Timer(lua_State *L) {
  9717. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  9718. Timer *inst = (Timer*)lua_topointer(L, 1);
  9719. delete inst;
  9720. return 0;
  9721. }
  9722. static int Polycore_TimerManager(lua_State *L) {
  9723. TimerManager *inst = new TimerManager();
  9724. lua_pushlightuserdata(L, (void*)inst);
  9725. return 1;
  9726. }
  9727. static int Polycore_TimerManager_removeTimer(lua_State *L) {
  9728. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  9729. TimerManager *inst = (TimerManager*)lua_topointer(L, 1);
  9730. luaL_checktype(L, 2, LUA_TLIGHTUSERDATA);
  9731. Timer* timer = (Timer*)lua_topointer(L, 2);
  9732. inst->removeTimer(timer);
  9733. return 0;
  9734. }
  9735. static int Polycore_TimerManager_addTimer(lua_State *L) {
  9736. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  9737. TimerManager *inst = (TimerManager*)lua_topointer(L, 1);
  9738. luaL_checktype(L, 2, LUA_TLIGHTUSERDATA);
  9739. Timer* timer = (Timer*)lua_topointer(L, 2);
  9740. inst->addTimer(timer);
  9741. return 0;
  9742. }
  9743. static int Polycore_TimerManager_Update(lua_State *L) {
  9744. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  9745. TimerManager *inst = (TimerManager*)lua_topointer(L, 1);
  9746. inst->Update();
  9747. return 0;
  9748. }
  9749. static int Polycore_delete_TimerManager(lua_State *L) {
  9750. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  9751. TimerManager *inst = (TimerManager*)lua_topointer(L, 1);
  9752. delete inst;
  9753. return 0;
  9754. }
  9755. static int Polycore_QuaternionTween(lua_State *L) {
  9756. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  9757. Quaternion* target = (Quaternion*)lua_topointer(L, 1);
  9758. luaL_checktype(L, 2, LUA_TLIGHTUSERDATA);
  9759. BezierCurve* wCurve = (BezierCurve*)lua_topointer(L, 2);
  9760. luaL_checktype(L, 3, LUA_TLIGHTUSERDATA);
  9761. BezierCurve* xCurve = (BezierCurve*)lua_topointer(L, 3);
  9762. luaL_checktype(L, 4, LUA_TLIGHTUSERDATA);
  9763. BezierCurve* yCurve = (BezierCurve*)lua_topointer(L, 4);
  9764. luaL_checktype(L, 5, LUA_TLIGHTUSERDATA);
  9765. BezierCurve* zCurve = (BezierCurve*)lua_topointer(L, 5);
  9766. luaL_checktype(L, 6, LUA_TNUMBER);
  9767. int easeType = lua_tointeger(L, 6);
  9768. luaL_checktype(L, 7, LUA_TNUMBER);
  9769. Number time = lua_tonumber(L, 7);
  9770. bool _repeat;
  9771. if(lua_isboolean(L, 8)) {
  9772. _repeat = lua_toboolean(L, 8);
  9773. } else {
  9774. _repeat = false;
  9775. }
  9776. QuaternionTween *inst = new QuaternionTween(target, wCurve, xCurve, yCurve, zCurve, easeType, time, _repeat);
  9777. lua_pushlightuserdata(L, (void*)inst);
  9778. return 1;
  9779. }
  9780. static int Polycore_QuaternionTween_updateCustomTween(lua_State *L) {
  9781. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  9782. QuaternionTween *inst = (QuaternionTween*)lua_topointer(L, 1);
  9783. inst->updateCustomTween();
  9784. return 0;
  9785. }
  9786. static int Polycore_delete_QuaternionTween(lua_State *L) {
  9787. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  9788. QuaternionTween *inst = (QuaternionTween*)lua_topointer(L, 1);
  9789. delete inst;
  9790. return 0;
  9791. }
  9792. static int Polycore_Tween_get_repeat(lua_State *L) {
  9793. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  9794. Tween *inst = (Tween*)lua_topointer(L, 1);
  9795. lua_pushboolean(L, inst->repeat);
  9796. return 1;
  9797. }
  9798. static int Polycore_Tween_set_repeat(lua_State *L) {
  9799. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  9800. Tween *inst = (Tween*)lua_topointer(L, 1);
  9801. bool param = lua_toboolean(L, 2);
  9802. inst->repeat = param;
  9803. return 0;
  9804. }
  9805. static int Polycore_Tween(lua_State *L) {
  9806. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  9807. Number* target = (Number*)lua_topointer(L, 1);
  9808. luaL_checktype(L, 2, LUA_TNUMBER);
  9809. int easeType = lua_tointeger(L, 2);
  9810. luaL_checktype(L, 3, LUA_TNUMBER);
  9811. Number startVal = lua_tonumber(L, 3);
  9812. luaL_checktype(L, 4, LUA_TNUMBER);
  9813. Number _endVal = lua_tonumber(L, 4);
  9814. luaL_checktype(L, 5, LUA_TNUMBER);
  9815. Number time = lua_tonumber(L, 5);
  9816. bool _repeat;
  9817. if(lua_isboolean(L, 6)) {
  9818. _repeat = lua_toboolean(L, 6);
  9819. } else {
  9820. _repeat = false;
  9821. }
  9822. Tween *inst = new Tween(target, easeType, startVal, _endVal, time, _repeat);
  9823. lua_pushlightuserdata(L, (void*)inst);
  9824. return 1;
  9825. }
  9826. static int Polycore_Tween_interpolateTween(lua_State *L) {
  9827. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  9828. Tween *inst = (Tween*)lua_topointer(L, 1);
  9829. lua_pushnumber(L, inst->interpolateTween());
  9830. return 1;
  9831. }
  9832. static int Polycore_Tween_updateCustomTween(lua_State *L) {
  9833. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  9834. Tween *inst = (Tween*)lua_topointer(L, 1);
  9835. inst->updateCustomTween();
  9836. return 0;
  9837. }
  9838. static int Polycore_Tween_doOnComplete(lua_State *L) {
  9839. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  9840. Tween *inst = (Tween*)lua_topointer(L, 1);
  9841. inst->doOnComplete();
  9842. return 0;
  9843. }
  9844. static int Polycore_Tween_Pause(lua_State *L) {
  9845. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  9846. Tween *inst = (Tween*)lua_topointer(L, 1);
  9847. luaL_checktype(L, 2, LUA_TBOOLEAN);
  9848. bool pauseVal = lua_toboolean(L, 2);
  9849. inst->Pause(pauseVal);
  9850. return 0;
  9851. }
  9852. static int Polycore_Tween_Reset(lua_State *L) {
  9853. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  9854. Tween *inst = (Tween*)lua_topointer(L, 1);
  9855. inst->Reset();
  9856. return 0;
  9857. }
  9858. static int Polycore_Tween_isComplete(lua_State *L) {
  9859. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  9860. Tween *inst = (Tween*)lua_topointer(L, 1);
  9861. lua_pushboolean(L, inst->isComplete());
  9862. return 1;
  9863. }
  9864. static int Polycore_Tween_setSpeed(lua_State *L) {
  9865. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  9866. Tween *inst = (Tween*)lua_topointer(L, 1);
  9867. luaL_checktype(L, 2, LUA_TNUMBER);
  9868. Number speed = lua_tonumber(L, 2);
  9869. inst->setSpeed(speed);
  9870. return 0;
  9871. }
  9872. static int Polycore_delete_Tween(lua_State *L) {
  9873. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  9874. Tween *inst = (Tween*)lua_topointer(L, 1);
  9875. delete inst;
  9876. return 0;
  9877. }
  9878. static int Polycore_BezierPathTween(lua_State *L) {
  9879. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  9880. Vector3* target = (Vector3*)lua_topointer(L, 1);
  9881. luaL_checktype(L, 2, LUA_TLIGHTUSERDATA);
  9882. BezierCurve* curve = (BezierCurve*)lua_topointer(L, 2);
  9883. luaL_checktype(L, 3, LUA_TNUMBER);
  9884. int easeType = lua_tointeger(L, 3);
  9885. luaL_checktype(L, 4, LUA_TNUMBER);
  9886. Number time = lua_tonumber(L, 4);
  9887. bool _repeat;
  9888. if(lua_isboolean(L, 5)) {
  9889. _repeat = lua_toboolean(L, 5);
  9890. } else {
  9891. _repeat = false;
  9892. }
  9893. BezierPathTween *inst = new BezierPathTween(target, curve, easeType, time, _repeat);
  9894. lua_pushlightuserdata(L, (void*)inst);
  9895. return 1;
  9896. }
  9897. static int Polycore_BezierPathTween_updateCustomTween(lua_State *L) {
  9898. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  9899. BezierPathTween *inst = (BezierPathTween*)lua_topointer(L, 1);
  9900. inst->updateCustomTween();
  9901. return 0;
  9902. }
  9903. static int Polycore_delete_BezierPathTween(lua_State *L) {
  9904. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  9905. BezierPathTween *inst = (BezierPathTween*)lua_topointer(L, 1);
  9906. delete inst;
  9907. return 0;
  9908. }
  9909. static int Polycore_TweenManager(lua_State *L) {
  9910. TweenManager *inst = new TweenManager();
  9911. lua_pushlightuserdata(L, (void*)inst);
  9912. return 1;
  9913. }
  9914. static int Polycore_TweenManager_addTween(lua_State *L) {
  9915. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  9916. TweenManager *inst = (TweenManager*)lua_topointer(L, 1);
  9917. luaL_checktype(L, 2, LUA_TLIGHTUSERDATA);
  9918. Tween* tween = (Tween*)lua_topointer(L, 2);
  9919. inst->addTween(tween);
  9920. return 0;
  9921. }
  9922. static int Polycore_TweenManager_removeTween(lua_State *L) {
  9923. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  9924. TweenManager *inst = (TweenManager*)lua_topointer(L, 1);
  9925. luaL_checktype(L, 2, LUA_TLIGHTUSERDATA);
  9926. Tween* tween = (Tween*)lua_topointer(L, 2);
  9927. inst->removeTween(tween);
  9928. return 0;
  9929. }
  9930. static int Polycore_TweenManager_Update(lua_State *L) {
  9931. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  9932. TweenManager *inst = (TweenManager*)lua_topointer(L, 1);
  9933. inst->Update();
  9934. return 0;
  9935. }
  9936. static int Polycore_delete_TweenManager(lua_State *L) {
  9937. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  9938. TweenManager *inst = (TweenManager*)lua_topointer(L, 1);
  9939. delete inst;
  9940. return 0;
  9941. }
  9942. static int Polycore_Vector2(lua_State *L) {
  9943. Vector2 *inst = new Vector2();
  9944. lua_pushlightuserdata(L, (void*)inst);
  9945. return 1;
  9946. }
  9947. static int Polycore_delete_Vector2(lua_State *L) {
  9948. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  9949. Vector2 *inst = (Vector2*)lua_topointer(L, 1);
  9950. delete inst;
  9951. return 0;
  9952. }
  9953. static int Polycore_Vector3_get_x(lua_State *L) {
  9954. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  9955. Vector3 *inst = (Vector3*)lua_topointer(L, 1);
  9956. lua_pushnumber(L, inst->x);
  9957. return 1;
  9958. }
  9959. static int Polycore_Vector3_get_y(lua_State *L) {
  9960. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  9961. Vector3 *inst = (Vector3*)lua_topointer(L, 1);
  9962. lua_pushnumber(L, inst->y);
  9963. return 1;
  9964. }
  9965. static int Polycore_Vector3_get_z(lua_State *L) {
  9966. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  9967. Vector3 *inst = (Vector3*)lua_topointer(L, 1);
  9968. lua_pushnumber(L, inst->z);
  9969. return 1;
  9970. }
  9971. static int Polycore_Vector3_set_x(lua_State *L) {
  9972. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  9973. Vector3 *inst = (Vector3*)lua_topointer(L, 1);
  9974. Number param = lua_tonumber(L, 2);
  9975. inst->x = param;
  9976. return 0;
  9977. }
  9978. static int Polycore_Vector3_set_y(lua_State *L) {
  9979. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  9980. Vector3 *inst = (Vector3*)lua_topointer(L, 1);
  9981. Number param = lua_tonumber(L, 2);
  9982. inst->y = param;
  9983. return 0;
  9984. }
  9985. static int Polycore_Vector3_set_z(lua_State *L) {
  9986. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  9987. Vector3 *inst = (Vector3*)lua_topointer(L, 1);
  9988. Number param = lua_tonumber(L, 2);
  9989. inst->z = param;
  9990. return 0;
  9991. }
  9992. static int Polycore_Vector3(lua_State *L) {
  9993. luaL_checktype(L, 1, LUA_TNUMBER);
  9994. Number x = lua_tonumber(L, 1);
  9995. luaL_checktype(L, 2, LUA_TNUMBER);
  9996. Number y = lua_tonumber(L, 2);
  9997. luaL_checktype(L, 3, LUA_TNUMBER);
  9998. Number z = lua_tonumber(L, 3);
  9999. Vector3 *inst = new Vector3(x, y, z);
  10000. lua_pushlightuserdata(L, (void*)inst);
  10001. return 1;
  10002. }
  10003. static int Polycore_Vector3_set(lua_State *L) {
  10004. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  10005. Vector3 *inst = (Vector3*)lua_topointer(L, 1);
  10006. luaL_checktype(L, 2, LUA_TNUMBER);
  10007. Number x = lua_tonumber(L, 2);
  10008. luaL_checktype(L, 3, LUA_TNUMBER);
  10009. Number y = lua_tonumber(L, 3);
  10010. luaL_checktype(L, 4, LUA_TNUMBER);
  10011. Number z = lua_tonumber(L, 4);
  10012. inst->set(x, y, z);
  10013. return 0;
  10014. }
  10015. static int Polycore_Vector3_distance(lua_State *L) {
  10016. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  10017. Vector3 *inst = (Vector3*)lua_topointer(L, 1);
  10018. luaL_checktype(L, 2, LUA_TLIGHTUSERDATA);
  10019. Vector3 vec2 = *(Vector3*)lua_topointer(L, 2);
  10020. lua_pushnumber(L, inst->distance(vec2));
  10021. return 1;
  10022. }
  10023. static int Polycore_Vector3_length(lua_State *L) {
  10024. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  10025. Vector3 *inst = (Vector3*)lua_topointer(L, 1);
  10026. lua_pushnumber(L, inst->length());
  10027. return 1;
  10028. }
  10029. static int Polycore_Vector3_dot(lua_State *L) {
  10030. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  10031. Vector3 *inst = (Vector3*)lua_topointer(L, 1);
  10032. luaL_checktype(L, 2, LUA_TLIGHTUSERDATA);
  10033. Vector3 u = *(Vector3*)lua_topointer(L, 2);
  10034. lua_pushnumber(L, inst->dot(u));
  10035. return 1;
  10036. }
  10037. static int Polycore_Vector3_crossProduct(lua_State *L) {
  10038. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  10039. Vector3 *inst = (Vector3*)lua_topointer(L, 1);
  10040. luaL_checktype(L, 2, LUA_TLIGHTUSERDATA);
  10041. Vector3 vec2 = *(Vector3*)lua_topointer(L, 2);
  10042. Vector3 *retInst = new Vector3();
  10043. *retInst = inst->crossProduct(vec2);
  10044. lua_pushlightuserdata(L, retInst);
  10045. return 1;
  10046. }
  10047. static int Polycore_Vector3_Normalize(lua_State *L) {
  10048. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  10049. Vector3 *inst = (Vector3*)lua_topointer(L, 1);
  10050. inst->Normalize();
  10051. return 0;
  10052. }
  10053. static int Polycore_delete_Vector3(lua_State *L) {
  10054. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  10055. Vector3 *inst = (Vector3*)lua_topointer(L, 1);
  10056. delete inst;
  10057. return 0;
  10058. }
  10059. static int Polycore_Vertex_get_restNormal(lua_State *L) {
  10060. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  10061. Vertex *inst = (Vertex*)lua_topointer(L, 1);
  10062. lua_pushlightuserdata(L, &inst->restNormal);
  10063. return 1;
  10064. }
  10065. static int Polycore_Vertex_get_restPosition(lua_State *L) {
  10066. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  10067. Vertex *inst = (Vertex*)lua_topointer(L, 1);
  10068. lua_pushlightuserdata(L, &inst->restPosition);
  10069. return 1;
  10070. }
  10071. static int Polycore_Vertex_get_normal(lua_State *L) {
  10072. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  10073. Vertex *inst = (Vertex*)lua_topointer(L, 1);
  10074. lua_pushlightuserdata(L, &inst->normal);
  10075. return 1;
  10076. }
  10077. static int Polycore_Vertex_get_tangent(lua_State *L) {
  10078. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  10079. Vertex *inst = (Vertex*)lua_topointer(L, 1);
  10080. lua_pushlightuserdata(L, &inst->tangent);
  10081. return 1;
  10082. }
  10083. static int Polycore_Vertex_get_vertexColor(lua_State *L) {
  10084. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  10085. Vertex *inst = (Vertex*)lua_topointer(L, 1);
  10086. lua_pushlightuserdata(L, &inst->vertexColor);
  10087. return 1;
  10088. }
  10089. static int Polycore_Vertex_get_texCoord(lua_State *L) {
  10090. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  10091. Vertex *inst = (Vertex*)lua_topointer(L, 1);
  10092. lua_pushlightuserdata(L, &inst->texCoord);
  10093. return 1;
  10094. }
  10095. static int Polycore_Vertex_get_useVertexColor(lua_State *L) {
  10096. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  10097. Vertex *inst = (Vertex*)lua_topointer(L, 1);
  10098. lua_pushboolean(L, inst->useVertexColor);
  10099. return 1;
  10100. }
  10101. static int Polycore_Vertex_set_useVertexColor(lua_State *L) {
  10102. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  10103. Vertex *inst = (Vertex*)lua_topointer(L, 1);
  10104. bool param = lua_toboolean(L, 2);
  10105. inst->useVertexColor = param;
  10106. return 0;
  10107. }
  10108. static int Polycore_Vertex(lua_State *L) {
  10109. Vertex *inst = new Vertex();
  10110. lua_pushlightuserdata(L, (void*)inst);
  10111. return 1;
  10112. }
  10113. static int Polycore_Vertex_addBoneAssignment(lua_State *L) {
  10114. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  10115. Vertex *inst = (Vertex*)lua_topointer(L, 1);
  10116. luaL_checktype(L, 2, LUA_TNUMBER);
  10117. unsigned int boneID = lua_tointeger(L, 2);
  10118. luaL_checktype(L, 3, LUA_TNUMBER);
  10119. Number boneWeight = lua_tonumber(L, 3);
  10120. inst->addBoneAssignment(boneID, boneWeight);
  10121. return 0;
  10122. }
  10123. static int Polycore_Vertex_getNumBoneAssignments(lua_State *L) {
  10124. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  10125. Vertex *inst = (Vertex*)lua_topointer(L, 1);
  10126. lua_pushinteger(L, inst->getNumBoneAssignments());
  10127. return 1;
  10128. }
  10129. static int Polycore_Vertex_getBoneAssignment(lua_State *L) {
  10130. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  10131. Vertex *inst = (Vertex*)lua_topointer(L, 1);
  10132. luaL_checktype(L, 2, LUA_TNUMBER);
  10133. unsigned int index = lua_tointeger(L, 2);
  10134. void *ptrRetVal = (void*)inst->getBoneAssignment(index);
  10135. if(ptrRetVal == NULL) {
  10136. lua_pushnil(L);
  10137. } else {
  10138. lua_pushlightuserdata(L, ptrRetVal);
  10139. }
  10140. return 1;
  10141. }
  10142. static int Polycore_Vertex_normalizeWeights(lua_State *L) {
  10143. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  10144. Vertex *inst = (Vertex*)lua_topointer(L, 1);
  10145. inst->normalizeWeights();
  10146. return 0;
  10147. }
  10148. static int Polycore_Vertex_getTexCoord(lua_State *L) {
  10149. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  10150. Vertex *inst = (Vertex*)lua_topointer(L, 1);
  10151. Vector2 *retInst = new Vector2();
  10152. *retInst = inst->getTexCoord();
  10153. lua_pushlightuserdata(L, retInst);
  10154. return 1;
  10155. }
  10156. static int Polycore_Vertex_setTexCoord(lua_State *L) {
  10157. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  10158. Vertex *inst = (Vertex*)lua_topointer(L, 1);
  10159. luaL_checktype(L, 2, LUA_TNUMBER);
  10160. Number u = lua_tonumber(L, 2);
  10161. luaL_checktype(L, 3, LUA_TNUMBER);
  10162. Number v = lua_tonumber(L, 3);
  10163. inst->setTexCoord(u, v);
  10164. return 0;
  10165. }
  10166. static int Polycore_Vertex_setNormal(lua_State *L) {
  10167. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  10168. Vertex *inst = (Vertex*)lua_topointer(L, 1);
  10169. luaL_checktype(L, 2, LUA_TNUMBER);
  10170. Number x = lua_tonumber(L, 2);
  10171. luaL_checktype(L, 3, LUA_TNUMBER);
  10172. Number y = lua_tonumber(L, 3);
  10173. luaL_checktype(L, 4, LUA_TNUMBER);
  10174. Number z = lua_tonumber(L, 4);
  10175. inst->setNormal(x, y, z);
  10176. return 0;
  10177. }
  10178. static int Polycore_delete_Vertex(lua_State *L) {
  10179. luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
  10180. Vertex *inst = (Vertex*)lua_topointer(L, 1);
  10181. delete inst;
  10182. return 0;
  10183. }
  10184. } // namespace Polycode