OVRPlugin.cs 138 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358
  1. /************************************************************************************
  2. Copyright : Copyright (c) Facebook Technologies, LLC and its affiliates. All rights reserved.
  3. Licensed under the Oculus Utilities SDK License Version 1.31 (the "License"); you may not use
  4. the Utilities SDK except in compliance with the License, which is provided at the time of installation
  5. or download, or which otherwise accompanies this software in either electronic or hard copy form.
  6. You may obtain a copy of the License at
  7. https://developer.oculus.com/licenses/utilities-1.31
  8. Unless required by applicable law or agreed to in writing, the Utilities SDK distributed
  9. under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
  10. ANY KIND, either express or implied. See the License for the specific language governing
  11. permissions and limitations under the License.
  12. ************************************************************************************/
  13. #if USING_XR_MANAGEMENT && USING_XR_SDK_OCULUS
  14. #define USING_XR_SDK
  15. #endif
  16. #if !(UNITY_EDITOR_WIN || UNITY_STANDALONE_WIN || (UNITY_ANDROID && !UNITY_EDITOR))
  17. #define OVRPLUGIN_UNSUPPORTED_PLATFORM
  18. #endif
  19. #if UNITY_ANDROID && !UNITY_EDITOR
  20. #define OVRPLUGIN_INCLUDE_MRC_ANDROID
  21. #endif
  22. using System;
  23. using System.Runtime.InteropServices;
  24. using UnityEngine;
  25. // Internal C# wrapper for OVRPlugin.
  26. public static class OVRPlugin
  27. {
  28. #if OVRPLUGIN_UNSUPPORTED_PLATFORM
  29. public const bool isSupportedPlatform = false;
  30. #else
  31. public const bool isSupportedPlatform = true;
  32. #endif
  33. #if OVRPLUGIN_UNSUPPORTED_PLATFORM
  34. public static readonly System.Version wrapperVersion = _versionZero;
  35. #else
  36. public static readonly System.Version wrapperVersion = OVRP_1_44_0.version;
  37. #endif
  38. #if !OVRPLUGIN_UNSUPPORTED_PLATFORM
  39. private static System.Version _version;
  40. #endif
  41. public static System.Version version
  42. {
  43. get {
  44. #if OVRPLUGIN_UNSUPPORTED_PLATFORM
  45. Debug.LogWarning("Platform is not currently supported by OVRPlugin");
  46. return _versionZero;
  47. #else
  48. if (_version == null)
  49. {
  50. try
  51. {
  52. string pluginVersion = OVRP_1_1_0.ovrp_GetVersion();
  53. if (pluginVersion != null)
  54. {
  55. // Truncate unsupported trailing version info for System.Version. Original string is returned if not present.
  56. pluginVersion = pluginVersion.Split('-')[0];
  57. _version = new System.Version(pluginVersion);
  58. }
  59. else
  60. {
  61. _version = _versionZero;
  62. }
  63. }
  64. catch
  65. {
  66. _version = _versionZero;
  67. }
  68. // Unity 5.1.1f3-p3 have OVRPlugin version "0.5.0", which isn't accurate.
  69. if (_version == OVRP_0_5_0.version)
  70. _version = OVRP_0_1_0.version;
  71. if (_version > _versionZero && _version < OVRP_1_3_0.version)
  72. throw new PlatformNotSupportedException("Oculus Utilities version " + wrapperVersion + " is too new for OVRPlugin version " + _version.ToString() + ". Update to the latest version of Unity.");
  73. }
  74. return _version;
  75. #endif
  76. }
  77. }
  78. #if !OVRPLUGIN_UNSUPPORTED_PLATFORM
  79. private static System.Version _nativeSDKVersion;
  80. #endif
  81. public static System.Version nativeSDKVersion
  82. {
  83. get {
  84. #if OVRPLUGIN_UNSUPPORTED_PLATFORM
  85. return _versionZero;
  86. #else
  87. if (_nativeSDKVersion == null)
  88. {
  89. try
  90. {
  91. string sdkVersion = string.Empty;
  92. if (version >= OVRP_1_1_0.version)
  93. sdkVersion = OVRP_1_1_0.ovrp_GetNativeSDKVersion();
  94. else
  95. sdkVersion = _versionZero.ToString();
  96. if (sdkVersion != null)
  97. {
  98. // Truncate unsupported trailing version info for System.Version. Original string is returned if not present.
  99. sdkVersion = sdkVersion.Split('-')[0];
  100. _nativeSDKVersion = new System.Version(sdkVersion);
  101. }
  102. else
  103. {
  104. _nativeSDKVersion = _versionZero;
  105. }
  106. }
  107. catch
  108. {
  109. _nativeSDKVersion = _versionZero;
  110. }
  111. }
  112. return _nativeSDKVersion;
  113. #endif
  114. }
  115. }
  116. [StructLayout(LayoutKind.Sequential)]
  117. private class GUID
  118. {
  119. public int a;
  120. public short b;
  121. public short c;
  122. public byte d0;
  123. public byte d1;
  124. public byte d2;
  125. public byte d3;
  126. public byte d4;
  127. public byte d5;
  128. public byte d6;
  129. public byte d7;
  130. }
  131. public enum Bool
  132. {
  133. False = 0,
  134. True
  135. }
  136. public enum Result
  137. {
  138. /// Success
  139. Success = 0,
  140. /// Failure
  141. Failure = -1000,
  142. Failure_InvalidParameter = -1001,
  143. Failure_NotInitialized = -1002,
  144. Failure_InvalidOperation = -1003,
  145. Failure_Unsupported = -1004,
  146. Failure_NotYetImplemented = -1005,
  147. Failure_OperationFailed = -1006,
  148. Failure_InsufficientSize = -1007,
  149. }
  150. public enum CameraStatus
  151. {
  152. CameraStatus_None,
  153. CameraStatus_Connected,
  154. CameraStatus_Calibrating,
  155. CameraStatus_CalibrationFailed,
  156. CameraStatus_Calibrated,
  157. CameraStatus_EnumSize = 0x7fffffff
  158. }
  159. public enum Eye
  160. {
  161. None = -1,
  162. Left = 0,
  163. Right = 1,
  164. Count = 2
  165. }
  166. public enum Tracker
  167. {
  168. None = -1,
  169. Zero = 0,
  170. One = 1,
  171. Two = 2,
  172. Three = 3,
  173. Count,
  174. }
  175. public enum Node
  176. {
  177. None = -1,
  178. EyeLeft = 0,
  179. EyeRight = 1,
  180. EyeCenter = 2,
  181. HandLeft = 3,
  182. HandRight = 4,
  183. TrackerZero = 5,
  184. TrackerOne = 6,
  185. TrackerTwo = 7,
  186. TrackerThree = 8,
  187. Head = 9,
  188. DeviceObjectZero = 10,
  189. Count,
  190. }
  191. public enum Controller
  192. {
  193. None = 0,
  194. LTouch = 0x00000001,
  195. RTouch = 0x00000002,
  196. Touch = LTouch | RTouch,
  197. Remote = 0x00000004,
  198. Gamepad = 0x00000010,
  199. LHand = 0x00000020,
  200. RHand = 0x00000040,
  201. Hands = LHand | RHand,
  202. Touchpad = 0x08000000,
  203. LTrackedRemote = 0x01000000,
  204. RTrackedRemote = 0x02000000,
  205. Active = unchecked((int)0x80000000),
  206. All = ~None,
  207. }
  208. public enum Handedness
  209. {
  210. Unsupported = 0,
  211. LeftHanded = 1,
  212. RightHanded = 2,
  213. }
  214. public enum TrackingOrigin
  215. {
  216. EyeLevel = 0,
  217. FloorLevel = 1,
  218. Stage = 2,
  219. Count,
  220. }
  221. public enum RecenterFlags
  222. {
  223. Default = 0,
  224. Controllers = 0x40000000,
  225. IgnoreAll = unchecked((int)0x80000000),
  226. Count,
  227. }
  228. public enum BatteryStatus
  229. {
  230. Charging = 0,
  231. Discharging,
  232. Full,
  233. NotCharging,
  234. Unknown,
  235. }
  236. public enum EyeTextureFormat
  237. {
  238. Default = 0,
  239. R8G8B8A8_sRGB = 0,
  240. R8G8B8A8 = 1,
  241. R16G16B16A16_FP = 2,
  242. R11G11B10_FP = 3,
  243. B8G8R8A8_sRGB = 4,
  244. B8G8R8A8 = 5,
  245. R5G6B5 = 11,
  246. EnumSize = 0x7fffffff
  247. }
  248. public enum PlatformUI
  249. {
  250. None = -1,
  251. ConfirmQuit = 1,
  252. GlobalMenuTutorial, // Deprecated
  253. }
  254. public enum SystemRegion
  255. {
  256. Unspecified = 0,
  257. Japan,
  258. China,
  259. }
  260. public enum SystemHeadset
  261. {
  262. None = 0,
  263. GearVR_R320, // Note4 Innovator
  264. GearVR_R321, // S6 Innovator
  265. GearVR_R322, // Commercial 1
  266. GearVR_R323, // Commercial 2 (USB Type C)
  267. GearVR_R324, // Commercial 3 (USB Type C)
  268. GearVR_R325, // Commercial 4 (USB Type C)
  269. Oculus_Go,
  270. Oculus_Quest,
  271. Rift_DK1 = 0x1000,
  272. Rift_DK2,
  273. Rift_CV1,
  274. Rift_CB,
  275. Rift_S,
  276. }
  277. public enum OverlayShape
  278. {
  279. Quad = 0,
  280. Cylinder = 1,
  281. Cubemap = 2,
  282. OffcenterCubemap = 4,
  283. Equirect = 5,
  284. }
  285. public enum Step
  286. {
  287. Render = -1,
  288. Physics = 0,
  289. }
  290. public enum CameraDevice
  291. {
  292. None = 0,
  293. WebCamera0 = 100,
  294. WebCamera1 = 101,
  295. ZEDCamera = 300,
  296. }
  297. public enum CameraDeviceDepthSensingMode
  298. {
  299. Standard = 0,
  300. Fill = 1,
  301. }
  302. public enum CameraDeviceDepthQuality
  303. {
  304. Low = 0,
  305. Medium = 1,
  306. High = 2,
  307. }
  308. public enum FixedFoveatedRenderingLevel
  309. {
  310. Off = 0,
  311. Low = 1,
  312. Medium = 2,
  313. High = 3,
  314. // High foveation setting with more detail toward the bottom of the view and more foveation near the top (Same as High on Oculus Go)
  315. HighTop = 4,
  316. EnumSize = 0x7FFFFFFF
  317. }
  318. [Obsolete("Please use FixedFoveatedRenderingLevel instead", false)]
  319. public enum TiledMultiResLevel
  320. {
  321. Off = 0,
  322. LMSLow = FixedFoveatedRenderingLevel.Low,
  323. LMSMedium = FixedFoveatedRenderingLevel.Medium,
  324. LMSHigh = FixedFoveatedRenderingLevel.High,
  325. // High foveation setting with more detail toward the bottom of the view and more foveation near the top (Same as High on Oculus Go)
  326. LMSHighTop = FixedFoveatedRenderingLevel.HighTop,
  327. EnumSize = 0x7FFFFFFF
  328. }
  329. public enum PerfMetrics
  330. {
  331. App_CpuTime_Float = 0,
  332. App_GpuTime_Float = 1,
  333. Compositor_CpuTime_Float = 3,
  334. Compositor_GpuTime_Float = 4,
  335. Compositor_DroppedFrameCount_Int = 5,
  336. System_GpuUtilPercentage_Float = 7,
  337. System_CpuUtilAveragePercentage_Float = 8,
  338. System_CpuUtilWorstPercentage_Float = 9,
  339. // 1.32.0
  340. Device_CpuClockFrequencyInMHz_Float = 10,
  341. Device_GpuClockFrequencyInMHz_Float = 11,
  342. Device_CpuClockLevel_Int = 12,
  343. Device_GpuClockLevel_Int = 13,
  344. Count,
  345. EnumSize = 0x7FFFFFFF
  346. }
  347. [StructLayout(LayoutKind.Sequential)]
  348. public struct CameraDeviceIntrinsicsParameters
  349. {
  350. float fx; /* Focal length in pixels along x axis. */
  351. float fy; /* Focal length in pixels along y axis. */
  352. float cx; /* Optical center along x axis, defined in pixels (usually close to width/2). */
  353. float cy; /* Optical center along y axis, defined in pixels (usually close to height/2). */
  354. double disto0; /* Distortion factor : [ k1, k2, p1, p2, k3 ]. Radial (k1,k2,k3) and Tangential (p1,p2) distortion.*/
  355. double disto1;
  356. double disto2;
  357. double disto3;
  358. double disto4;
  359. float v_fov; /* Vertical field of view after stereo rectification, in degrees. */
  360. float h_fov; /* Horizontal field of view after stereo rectification, in degrees.*/
  361. float d_fov; /* Diagonal field of view after stereo rectification, in degrees.*/
  362. int w; /* Resolution width */
  363. int h; /* Resolution height */
  364. }
  365. private const int OverlayShapeFlagShift = 4;
  366. private enum OverlayFlag
  367. {
  368. None = unchecked((int)0x00000000),
  369. OnTop = unchecked((int)0x00000001),
  370. HeadLocked = unchecked((int)0x00000002),
  371. NoDepth = unchecked((int)0x00000004),
  372. ExpensiveSuperSample = unchecked((int)0x00000008),
  373. // Using the 5-8 bits for shapes, total 16 potential shapes can be supported 0x000000[0]0 -> 0x000000[F]0
  374. ShapeFlag_Quad = unchecked((int)OverlayShape.Quad << OverlayShapeFlagShift),
  375. ShapeFlag_Cylinder = unchecked((int)OverlayShape.Cylinder << OverlayShapeFlagShift),
  376. ShapeFlag_Cubemap = unchecked((int)OverlayShape.Cubemap << OverlayShapeFlagShift),
  377. ShapeFlag_OffcenterCubemap = unchecked((int)OverlayShape.OffcenterCubemap << OverlayShapeFlagShift),
  378. ShapeFlagRangeMask = unchecked((int)0xF << OverlayShapeFlagShift),
  379. Hidden = unchecked((int)0x000000200),
  380. }
  381. [StructLayout(LayoutKind.Sequential)]
  382. public struct Vector2f
  383. {
  384. public float x;
  385. public float y;
  386. }
  387. [StructLayout(LayoutKind.Sequential)]
  388. public struct Vector3f
  389. {
  390. public float x;
  391. public float y;
  392. public float z;
  393. public static readonly Vector3f zero = new Vector3f { x = 0.0f, y = 0.0f, z = 0.0f };
  394. public override string ToString()
  395. {
  396. return string.Format("{0}, {1}, {2}", x, y, z);
  397. }
  398. }
  399. [StructLayout(LayoutKind.Sequential)]
  400. public struct Vector4f
  401. {
  402. public float x;
  403. public float y;
  404. public float z;
  405. public float w;
  406. public static readonly Vector4f zero = new Vector4f { x = 0.0f, y = 0.0f, z = 0.0f, w = 0.0f };
  407. public override string ToString()
  408. {
  409. return string.Format("{0}, {1}, {2}, {3}", x, y, z, w);
  410. }
  411. }
  412. [StructLayout(LayoutKind.Sequential)]
  413. public struct Vector4s
  414. {
  415. public short x;
  416. public short y;
  417. public short z;
  418. public short w;
  419. public static readonly Vector4s zero = new Vector4s { x = 0, y = 0, z = 0, w = 0 };
  420. public override string ToString()
  421. {
  422. return string.Format("{0}, {1}, {2}, {3}", x, y, z, w);
  423. }
  424. }
  425. [StructLayout(LayoutKind.Sequential)]
  426. public struct Quatf
  427. {
  428. public float x;
  429. public float y;
  430. public float z;
  431. public float w;
  432. public static readonly Quatf identity = new Quatf { x = 0.0f, y = 0.0f, z = 0.0f, w = 1.0f };
  433. public override string ToString()
  434. {
  435. return string.Format("{0}, {1}, {2}, {3}", x, y, z, w);
  436. }
  437. }
  438. [StructLayout(LayoutKind.Sequential)]
  439. public struct Posef
  440. {
  441. public Quatf Orientation;
  442. public Vector3f Position;
  443. public static readonly Posef identity = new Posef { Orientation = Quatf.identity, Position = Vector3f.zero };
  444. public override string ToString()
  445. {
  446. return string.Format("Position ({0}), Orientation({1})", Position, Orientation);
  447. }
  448. }
  449. [StructLayout(LayoutKind.Sequential)]
  450. public struct TextureRectMatrixf
  451. {
  452. public Rect leftRect;
  453. public Rect rightRect;
  454. public Vector4 leftScaleBias;
  455. public Vector4 rightScaleBias;
  456. public static readonly TextureRectMatrixf zero = new TextureRectMatrixf { leftRect = new Rect(0, 0, 1, 1), rightRect = new Rect(0, 0, 1, 1), leftScaleBias = new Vector4(1, 1, 0, 0), rightScaleBias = new Vector4(1, 1, 0, 0) };
  457. public override string ToString()
  458. {
  459. return string.Format("Rect Left ({0}), Rect Right({1}), Scale Bias Left ({2}), Scale Bias Right({3})", leftRect, rightRect, leftScaleBias, rightScaleBias);
  460. }
  461. }
  462. [StructLayout(LayoutKind.Sequential)]
  463. public struct PoseStatef
  464. {
  465. public Posef Pose;
  466. public Vector3f Velocity;
  467. public Vector3f Acceleration;
  468. public Vector3f AngularVelocity;
  469. public Vector3f AngularAcceleration;
  470. public double Time;
  471. public static readonly PoseStatef identity = new PoseStatef
  472. {
  473. Pose = Posef.identity,
  474. Velocity = Vector3f.zero,
  475. Acceleration = Vector3f.zero,
  476. AngularVelocity = Vector3f.zero,
  477. AngularAcceleration = Vector3f.zero
  478. };
  479. }
  480. [StructLayout(LayoutKind.Sequential)]
  481. public struct ControllerState4
  482. {
  483. public uint ConnectedControllers;
  484. public uint Buttons;
  485. public uint Touches;
  486. public uint NearTouches;
  487. public float LIndexTrigger;
  488. public float RIndexTrigger;
  489. public float LHandTrigger;
  490. public float RHandTrigger;
  491. public Vector2f LThumbstick;
  492. public Vector2f RThumbstick;
  493. public Vector2f LTouchpad;
  494. public Vector2f RTouchpad;
  495. public byte LBatteryPercentRemaining;
  496. public byte RBatteryPercentRemaining;
  497. public byte LRecenterCount;
  498. public byte RRecenterCount;
  499. public byte Reserved_27;
  500. public byte Reserved_26;
  501. public byte Reserved_25;
  502. public byte Reserved_24;
  503. public byte Reserved_23;
  504. public byte Reserved_22;
  505. public byte Reserved_21;
  506. public byte Reserved_20;
  507. public byte Reserved_19;
  508. public byte Reserved_18;
  509. public byte Reserved_17;
  510. public byte Reserved_16;
  511. public byte Reserved_15;
  512. public byte Reserved_14;
  513. public byte Reserved_13;
  514. public byte Reserved_12;
  515. public byte Reserved_11;
  516. public byte Reserved_10;
  517. public byte Reserved_09;
  518. public byte Reserved_08;
  519. public byte Reserved_07;
  520. public byte Reserved_06;
  521. public byte Reserved_05;
  522. public byte Reserved_04;
  523. public byte Reserved_03;
  524. public byte Reserved_02;
  525. public byte Reserved_01;
  526. public byte Reserved_00;
  527. public ControllerState4(ControllerState2 cs)
  528. {
  529. ConnectedControllers = cs.ConnectedControllers;
  530. Buttons = cs.Buttons;
  531. Touches = cs.Touches;
  532. NearTouches = cs.NearTouches;
  533. LIndexTrigger = cs.LIndexTrigger;
  534. RIndexTrigger = cs.RIndexTrigger;
  535. LHandTrigger = cs.LHandTrigger;
  536. RHandTrigger = cs.RHandTrigger;
  537. LThumbstick = cs.LThumbstick;
  538. RThumbstick = cs.RThumbstick;
  539. LTouchpad = cs.LTouchpad;
  540. RTouchpad = cs.RTouchpad;
  541. LBatteryPercentRemaining = 0;
  542. RBatteryPercentRemaining = 0;
  543. LRecenterCount = 0;
  544. RRecenterCount = 0;
  545. Reserved_27 = 0;
  546. Reserved_26 = 0;
  547. Reserved_25 = 0;
  548. Reserved_24 = 0;
  549. Reserved_23 = 0;
  550. Reserved_22 = 0;
  551. Reserved_21 = 0;
  552. Reserved_20 = 0;
  553. Reserved_19 = 0;
  554. Reserved_18 = 0;
  555. Reserved_17 = 0;
  556. Reserved_16 = 0;
  557. Reserved_15 = 0;
  558. Reserved_14 = 0;
  559. Reserved_13 = 0;
  560. Reserved_12 = 0;
  561. Reserved_11 = 0;
  562. Reserved_10 = 0;
  563. Reserved_09 = 0;
  564. Reserved_08 = 0;
  565. Reserved_07 = 0;
  566. Reserved_06 = 0;
  567. Reserved_05 = 0;
  568. Reserved_04 = 0;
  569. Reserved_03 = 0;
  570. Reserved_02 = 0;
  571. Reserved_01 = 0;
  572. Reserved_00 = 0;
  573. }
  574. }
  575. [StructLayout(LayoutKind.Sequential)]
  576. public struct ControllerState2
  577. {
  578. public uint ConnectedControllers;
  579. public uint Buttons;
  580. public uint Touches;
  581. public uint NearTouches;
  582. public float LIndexTrigger;
  583. public float RIndexTrigger;
  584. public float LHandTrigger;
  585. public float RHandTrigger;
  586. public Vector2f LThumbstick;
  587. public Vector2f RThumbstick;
  588. public Vector2f LTouchpad;
  589. public Vector2f RTouchpad;
  590. public ControllerState2(ControllerState cs)
  591. {
  592. ConnectedControllers = cs.ConnectedControllers;
  593. Buttons = cs.Buttons;
  594. Touches = cs.Touches;
  595. NearTouches = cs.NearTouches;
  596. LIndexTrigger = cs.LIndexTrigger;
  597. RIndexTrigger = cs.RIndexTrigger;
  598. LHandTrigger = cs.LHandTrigger;
  599. RHandTrigger = cs.RHandTrigger;
  600. LThumbstick = cs.LThumbstick;
  601. RThumbstick = cs.RThumbstick;
  602. LTouchpad = new Vector2f() { x = 0.0f, y = 0.0f };
  603. RTouchpad = new Vector2f() { x = 0.0f, y = 0.0f };
  604. }
  605. }
  606. [StructLayout(LayoutKind.Sequential)]
  607. public struct ControllerState
  608. {
  609. public uint ConnectedControllers;
  610. public uint Buttons;
  611. public uint Touches;
  612. public uint NearTouches;
  613. public float LIndexTrigger;
  614. public float RIndexTrigger;
  615. public float LHandTrigger;
  616. public float RHandTrigger;
  617. public Vector2f LThumbstick;
  618. public Vector2f RThumbstick;
  619. }
  620. [StructLayout(LayoutKind.Sequential)]
  621. public struct HapticsBuffer
  622. {
  623. public IntPtr Samples;
  624. public int SamplesCount;
  625. }
  626. [StructLayout(LayoutKind.Sequential)]
  627. public struct HapticsState
  628. {
  629. public int SamplesAvailable;
  630. public int SamplesQueued;
  631. }
  632. [StructLayout(LayoutKind.Sequential)]
  633. public struct HapticsDesc
  634. {
  635. public int SampleRateHz;
  636. public int SampleSizeInBytes;
  637. public int MinimumSafeSamplesQueued;
  638. public int MinimumBufferSamplesCount;
  639. public int OptimalBufferSamplesCount;
  640. public int MaximumBufferSamplesCount;
  641. }
  642. [StructLayout(LayoutKind.Sequential)]
  643. public struct AppPerfFrameStats
  644. {
  645. public int HmdVsyncIndex;
  646. public int AppFrameIndex;
  647. public int AppDroppedFrameCount;
  648. public float AppMotionToPhotonLatency;
  649. public float AppQueueAheadTime;
  650. public float AppCpuElapsedTime;
  651. public float AppGpuElapsedTime;
  652. public int CompositorFrameIndex;
  653. public int CompositorDroppedFrameCount;
  654. public float CompositorLatency;
  655. public float CompositorCpuElapsedTime;
  656. public float CompositorGpuElapsedTime;
  657. public float CompositorCpuStartToGpuEndElapsedTime;
  658. public float CompositorGpuEndToVsyncElapsedTime;
  659. }
  660. public const int AppPerfFrameStatsMaxCount = 5;
  661. [StructLayout(LayoutKind.Sequential)]
  662. public struct AppPerfStats
  663. {
  664. [MarshalAs(UnmanagedType.ByValArray, SizeConst = AppPerfFrameStatsMaxCount)]
  665. public AppPerfFrameStats[] FrameStats;
  666. public int FrameStatsCount;
  667. public Bool AnyFrameStatsDropped;
  668. public float AdaptiveGpuPerformanceScale;
  669. }
  670. [StructLayout(LayoutKind.Sequential)]
  671. public struct Sizei
  672. {
  673. public int w;
  674. public int h;
  675. public static readonly Sizei zero = new Sizei { w = 0, h = 0 };
  676. }
  677. [StructLayout(LayoutKind.Sequential)]
  678. public struct Sizef
  679. {
  680. public float w;
  681. public float h;
  682. public static readonly Sizef zero = new Sizef { w = 0, h = 0 };
  683. }
  684. [StructLayout(LayoutKind.Sequential)]
  685. public struct Vector2i
  686. {
  687. public int x;
  688. public int y;
  689. }
  690. [StructLayout(LayoutKind.Sequential)]
  691. public struct Recti {
  692. Vector2i Pos;
  693. Sizei Size;
  694. }
  695. [StructLayout(LayoutKind.Sequential)]
  696. public struct Rectf {
  697. Vector2f Pos;
  698. Sizef Size;
  699. }
  700. [StructLayout(LayoutKind.Sequential)]
  701. public struct Frustumf
  702. {
  703. public float zNear;
  704. public float zFar;
  705. public float fovX;
  706. public float fovY;
  707. }
  708. [StructLayout(LayoutKind.Sequential)]
  709. public struct Frustumf2
  710. {
  711. public float zNear;
  712. public float zFar;
  713. public Fovf Fov;
  714. }
  715. public enum BoundaryType
  716. {
  717. OuterBoundary = 0x0001,
  718. PlayArea = 0x0100,
  719. }
  720. [StructLayout(LayoutKind.Sequential)]
  721. public struct BoundaryTestResult
  722. {
  723. public Bool IsTriggering;
  724. public float ClosestDistance;
  725. public Vector3f ClosestPoint;
  726. public Vector3f ClosestPointNormal;
  727. }
  728. [StructLayout(LayoutKind.Sequential)]
  729. public struct BoundaryGeometry
  730. {
  731. public BoundaryType BoundaryType;
  732. [MarshalAs(UnmanagedType.ByValArray, SizeConst = 256)]
  733. public Vector3f[] Points;
  734. public int PointsCount;
  735. }
  736. [StructLayout(LayoutKind.Sequential)]
  737. public struct Colorf
  738. {
  739. public float r;
  740. public float g;
  741. public float b;
  742. public float a;
  743. }
  744. [StructLayout(LayoutKind.Sequential)]
  745. public struct Fovf
  746. {
  747. public float UpTan;
  748. public float DownTan;
  749. public float LeftTan;
  750. public float RightTan;
  751. }
  752. [StructLayout(LayoutKind.Sequential)]
  753. public struct CameraIntrinsics
  754. {
  755. public Bool IsValid;
  756. public double LastChangedTimeSeconds;
  757. public Fovf FOVPort;
  758. public float VirtualNearPlaneDistanceMeters;
  759. public float VirtualFarPlaneDistanceMeters;
  760. public Sizei ImageSensorPixelResolution;
  761. }
  762. [StructLayout(LayoutKind.Sequential)]
  763. public struct CameraExtrinsics
  764. {
  765. public Bool IsValid;
  766. public double LastChangedTimeSeconds;
  767. public CameraStatus CameraStatusData;
  768. public Node AttachedToNode;
  769. public Posef RelativePose;
  770. }
  771. public enum LayerLayout
  772. {
  773. Stereo = 0,
  774. Mono = 1,
  775. DoubleWide = 2,
  776. Array = 3,
  777. EnumSize = 0xF
  778. }
  779. public enum LayerFlags
  780. {
  781. Static = (1 << 0),
  782. LoadingScreen = (1 << 1),
  783. SymmetricFov = (1 << 2),
  784. TextureOriginAtBottomLeft = (1 << 3),
  785. ChromaticAberrationCorrection = (1 << 4),
  786. NoAllocation = (1 << 5),
  787. ProtectedContent = (1 << 6),
  788. AndroidSurfaceSwapChain = (1 << 7),
  789. }
  790. [StructLayout(LayoutKind.Sequential)]
  791. public struct LayerDesc
  792. {
  793. public OverlayShape Shape;
  794. public LayerLayout Layout;
  795. public Sizei TextureSize;
  796. public int MipLevels;
  797. public int SampleCount;
  798. public EyeTextureFormat Format;
  799. public int LayerFlags;
  800. //Eye FOV-only members.
  801. [MarshalAs(UnmanagedType.ByValArray, SizeConst = 2)]
  802. public Fovf[] Fov;
  803. [MarshalAs(UnmanagedType.ByValArray, SizeConst = 2)]
  804. public Rectf[] VisibleRect;
  805. public Sizei MaxViewportSize;
  806. EyeTextureFormat DepthFormat;
  807. public override string ToString()
  808. {
  809. string delim = ", ";
  810. return Shape.ToString()
  811. + delim + Layout.ToString()
  812. + delim + TextureSize.w.ToString() + "x" + TextureSize.h.ToString()
  813. + delim + MipLevels.ToString()
  814. + delim + SampleCount.ToString()
  815. + delim + Format.ToString()
  816. + delim + LayerFlags.ToString();
  817. }
  818. }
  819. [StructLayout(LayoutKind.Sequential)]
  820. public struct LayerSubmit
  821. {
  822. int LayerId;
  823. int TextureStage;
  824. [MarshalAs(UnmanagedType.ByValArray, SizeConst = 2)]
  825. Recti[] ViewportRect;
  826. Posef Pose;
  827. int LayerSubmitFlags;
  828. }
  829. public enum TrackingConfidence
  830. {
  831. Low = 0,
  832. High = 0x3f800000,
  833. }
  834. public enum Hand
  835. {
  836. None = -1,
  837. HandLeft = 0,
  838. HandRight = 1,
  839. }
  840. [Flags]
  841. public enum HandStatus
  842. {
  843. HandTracked = (1 << 0), // if this is set the hand pose and bone rotations data is usable
  844. InputStateValid = (1 << 1), // if this is set the pointer pose and pinch data is usable
  845. SystemGestureInProgress = (1 << 6), // if this is set the hand is currently processing a system gesture
  846. }
  847. public enum BoneId
  848. {
  849. Invalid = -1,
  850. Hand_Start = 0,
  851. Hand_WristRoot = Hand_Start + 0, // root frame of the hand, where the wrist is located
  852. Hand_ForearmStub = Hand_Start + 1, // frame for user's forearm
  853. Hand_Thumb0 = Hand_Start + 2, // thumb trapezium bone
  854. Hand_Thumb1 = Hand_Start + 3, // thumb metacarpal bone
  855. Hand_Thumb2 = Hand_Start + 4, // thumb proximal phalange bone
  856. Hand_Thumb3 = Hand_Start + 5, // thumb distal phalange bone
  857. Hand_Index1 = Hand_Start + 6, // index proximal phalange bone
  858. Hand_Index2 = Hand_Start + 7, // index intermediate phalange bone
  859. Hand_Index3 = Hand_Start + 8, // index distal phalange bone
  860. Hand_Middle1 = Hand_Start + 9, // middle proximal phalange bone
  861. Hand_Middle2 = Hand_Start + 10, // middle intermediate phalange bone
  862. Hand_Middle3 = Hand_Start + 11, // middle distal phalange bone
  863. Hand_Ring1 = Hand_Start + 12, // ring proximal phalange bone
  864. Hand_Ring2 = Hand_Start + 13, // ring intermediate phalange bone
  865. Hand_Ring3 = Hand_Start + 14, // ring distal phalange bone
  866. Hand_Pinky0 = Hand_Start + 15, // pinky metacarpal bone
  867. Hand_Pinky1 = Hand_Start + 16, // pinky proximal phalange bone
  868. Hand_Pinky2 = Hand_Start + 17, // pinky intermediate phalange bone
  869. Hand_Pinky3 = Hand_Start + 18, // pinky distal phalange bone
  870. Hand_MaxSkinnable = Hand_Start + 19,
  871. // Bone tips are position only. They are not used for skinning but are useful for hit-testing.
  872. // NOTE: Hand_ThumbTip == Hand_MaxSkinnable since the extended tips need to be contiguous
  873. Hand_ThumbTip = Hand_Start + Hand_MaxSkinnable + 0, // tip of the thumb
  874. Hand_IndexTip = Hand_Start + Hand_MaxSkinnable + 1, // tip of the index finger
  875. Hand_MiddleTip = Hand_Start + Hand_MaxSkinnable + 2, // tip of the middle finger
  876. Hand_RingTip = Hand_Start + Hand_MaxSkinnable + 3, // tip of the ring finger
  877. Hand_PinkyTip = Hand_Start + Hand_MaxSkinnable + 4, // tip of the pinky
  878. Hand_End = Hand_Start + Hand_MaxSkinnable + 5,
  879. // add new bones here
  880. Max = Hand_End + 0,
  881. }
  882. public enum HandFinger
  883. {
  884. Thumb = 0,
  885. Index = 1,
  886. Middle = 2,
  887. Ring = 3,
  888. Pinky = 4,
  889. Max = 5,
  890. }
  891. [Flags]
  892. public enum HandFingerPinch
  893. {
  894. Thumb = (1 << HandFinger.Thumb),
  895. Index = (1 << HandFinger.Index),
  896. Middle = (1 << HandFinger.Middle),
  897. Ring = (1 << HandFinger.Ring),
  898. Pinky = (1 << HandFinger.Pinky),
  899. }
  900. [StructLayout(LayoutKind.Sequential)]
  901. public struct HandState
  902. {
  903. public HandStatus Status;
  904. public Posef RootPose;
  905. public Quatf[] BoneRotations;
  906. public HandFingerPinch Pinches;
  907. public float[] PinchStrength;
  908. public Posef PointerPose;
  909. public float HandScale;
  910. public TrackingConfidence HandConfidence;
  911. public TrackingConfidence[] FingerConfidences;
  912. public double RequestedTimeStamp;
  913. public double SampleTimeStamp;
  914. }
  915. [StructLayout(LayoutKind.Sequential)]
  916. private struct HandStateInternal
  917. {
  918. public HandStatus Status;
  919. public Posef RootPose;
  920. public Quatf BoneRotations_0;
  921. public Quatf BoneRotations_1;
  922. public Quatf BoneRotations_2;
  923. public Quatf BoneRotations_3;
  924. public Quatf BoneRotations_4;
  925. public Quatf BoneRotations_5;
  926. public Quatf BoneRotations_6;
  927. public Quatf BoneRotations_7;
  928. public Quatf BoneRotations_8;
  929. public Quatf BoneRotations_9;
  930. public Quatf BoneRotations_10;
  931. public Quatf BoneRotations_11;
  932. public Quatf BoneRotations_12;
  933. public Quatf BoneRotations_13;
  934. public Quatf BoneRotations_14;
  935. public Quatf BoneRotations_15;
  936. public Quatf BoneRotations_16;
  937. public Quatf BoneRotations_17;
  938. public Quatf BoneRotations_18;
  939. public Quatf BoneRotations_19;
  940. public Quatf BoneRotations_20;
  941. public Quatf BoneRotations_21;
  942. public Quatf BoneRotations_22;
  943. public Quatf BoneRotations_23;
  944. public HandFingerPinch Pinches;
  945. public float PinchStrength_0;
  946. public float PinchStrength_1;
  947. public float PinchStrength_2;
  948. public float PinchStrength_3;
  949. public float PinchStrength_4;
  950. public Posef PointerPose;
  951. public float HandScale;
  952. public TrackingConfidence HandConfidence;
  953. public TrackingConfidence FingerConfidences_0;
  954. public TrackingConfidence FingerConfidences_1;
  955. public TrackingConfidence FingerConfidences_2;
  956. public TrackingConfidence FingerConfidences_3;
  957. public TrackingConfidence FingerConfidences_4;
  958. public double RequestedTimeStamp;
  959. public double SampleTimeStamp;
  960. }
  961. [StructLayout(LayoutKind.Sequential)]
  962. public struct BoneCapsule
  963. {
  964. public short BoneIndex;
  965. [MarshalAs(UnmanagedType.ByValArray, SizeConst = 2)]
  966. public Vector3f[] Points;
  967. public float Radius;
  968. }
  969. [StructLayout(LayoutKind.Sequential)]
  970. public struct Bone
  971. {
  972. public BoneId Id;
  973. public short ParentBoneIndex;
  974. public Posef Pose;
  975. }
  976. public enum SkeletonConstants
  977. {
  978. MaxBones = BoneId.Max,
  979. MaxBoneCapsules = 19,
  980. }
  981. public enum SkeletonType
  982. {
  983. None = -1,
  984. HandLeft = 0,
  985. HandRight = 1,
  986. }
  987. [StructLayout(LayoutKind.Sequential)]
  988. public struct Skeleton
  989. {
  990. public SkeletonType Type;
  991. public uint NumBones;
  992. public uint NumBoneCapsules;
  993. [MarshalAs(UnmanagedType.ByValArray, SizeConst = (int)SkeletonConstants.MaxBones)]
  994. public Bone[] Bones;
  995. [MarshalAs(UnmanagedType.ByValArray, SizeConst = (int)SkeletonConstants.MaxBoneCapsules)]
  996. public BoneCapsule[] BoneCapsules;
  997. }
  998. public enum MeshConstants
  999. {
  1000. MaxVertices = 3000,
  1001. MaxIndices = MaxVertices * 6,
  1002. }
  1003. public enum MeshType
  1004. {
  1005. None = -1,
  1006. HandLeft = 0,
  1007. HandRight = 1,
  1008. }
  1009. [StructLayout(LayoutKind.Sequential)]
  1010. public struct Mesh
  1011. {
  1012. public MeshType Type;
  1013. public uint NumVertices;
  1014. public uint NumIndices;
  1015. [MarshalAs(UnmanagedType.ByValArray, SizeConst = (int)MeshConstants.MaxVertices)]
  1016. public Vector3f[] VertexPositions;
  1017. [MarshalAs(UnmanagedType.ByValArray, SizeConst = (int)MeshConstants.MaxIndices)]
  1018. public short[] Indices;
  1019. [MarshalAs(UnmanagedType.ByValArray, SizeConst = (int)MeshConstants.MaxVertices)]
  1020. public Vector3f[] VertexNormals;
  1021. [MarshalAs(UnmanagedType.ByValArray, SizeConst = (int)MeshConstants.MaxVertices)]
  1022. public Vector2f[] VertexUV0;
  1023. [MarshalAs(UnmanagedType.ByValArray, SizeConst = (int)MeshConstants.MaxVertices)]
  1024. public Vector4s[] BlendIndices;
  1025. [MarshalAs(UnmanagedType.ByValArray, SizeConst = (int)MeshConstants.MaxVertices)]
  1026. public Vector4f[] BlendWeights;
  1027. }
  1028. public static bool initialized
  1029. {
  1030. get {
  1031. #if OVRPLUGIN_UNSUPPORTED_PLATFORM
  1032. return false;
  1033. #else
  1034. return OVRP_1_1_0.ovrp_GetInitialized() == OVRPlugin.Bool.True;
  1035. #endif
  1036. }
  1037. }
  1038. public static bool chromatic
  1039. {
  1040. get {
  1041. #if OVRPLUGIN_UNSUPPORTED_PLATFORM
  1042. return false;
  1043. #else
  1044. if (version >= OVRP_1_7_0.version)
  1045. return initialized && OVRP_1_7_0.ovrp_GetAppChromaticCorrection() == OVRPlugin.Bool.True;
  1046. #if UNITY_ANDROID && !UNITY_EDITOR
  1047. return false;
  1048. #else
  1049. return true;
  1050. #endif
  1051. #endif
  1052. }
  1053. set {
  1054. #if OVRPLUGIN_UNSUPPORTED_PLATFORM
  1055. return;
  1056. #else
  1057. if (initialized && version >= OVRP_1_7_0.version)
  1058. OVRP_1_7_0.ovrp_SetAppChromaticCorrection(ToBool(value));
  1059. #endif
  1060. }
  1061. }
  1062. public static bool monoscopic
  1063. {
  1064. get {
  1065. #if OVRPLUGIN_UNSUPPORTED_PLATFORM
  1066. return false;
  1067. #else
  1068. return initialized && OVRP_1_1_0.ovrp_GetAppMonoscopic() == OVRPlugin.Bool.True;
  1069. #endif
  1070. }
  1071. set {
  1072. #if OVRPLUGIN_UNSUPPORTED_PLATFORM
  1073. return;
  1074. #else
  1075. if (initialized)
  1076. {
  1077. OVRP_1_1_0.ovrp_SetAppMonoscopic(ToBool(value));
  1078. }
  1079. #endif
  1080. }
  1081. }
  1082. public static bool rotation
  1083. {
  1084. get {
  1085. #if OVRPLUGIN_UNSUPPORTED_PLATFORM
  1086. return false;
  1087. #else
  1088. return initialized && OVRP_1_1_0.ovrp_GetTrackingOrientationEnabled() == Bool.True;
  1089. #endif
  1090. }
  1091. set {
  1092. #if OVRPLUGIN_UNSUPPORTED_PLATFORM
  1093. return;
  1094. #else
  1095. if (initialized)
  1096. {
  1097. OVRP_1_1_0.ovrp_SetTrackingOrientationEnabled(ToBool(value));
  1098. }
  1099. #endif
  1100. }
  1101. }
  1102. public static bool position
  1103. {
  1104. get {
  1105. #if OVRPLUGIN_UNSUPPORTED_PLATFORM
  1106. return false;
  1107. #else
  1108. return initialized && OVRP_1_1_0.ovrp_GetTrackingPositionEnabled() == Bool.True;
  1109. #endif
  1110. }
  1111. set {
  1112. #if OVRPLUGIN_UNSUPPORTED_PLATFORM
  1113. return;
  1114. #else
  1115. if (initialized)
  1116. {
  1117. OVRP_1_1_0.ovrp_SetTrackingPositionEnabled(ToBool(value));
  1118. }
  1119. #endif
  1120. }
  1121. }
  1122. public static bool useIPDInPositionTracking
  1123. {
  1124. get {
  1125. #if OVRPLUGIN_UNSUPPORTED_PLATFORM
  1126. return false;
  1127. #else
  1128. if (initialized && version >= OVRP_1_6_0.version)
  1129. return OVRP_1_6_0.ovrp_GetTrackingIPDEnabled() == OVRPlugin.Bool.True;
  1130. return true;
  1131. #endif
  1132. }
  1133. set {
  1134. #if OVRPLUGIN_UNSUPPORTED_PLATFORM
  1135. return;
  1136. #else
  1137. if (initialized && version >= OVRP_1_6_0.version)
  1138. OVRP_1_6_0.ovrp_SetTrackingIPDEnabled(ToBool(value));
  1139. #endif
  1140. }
  1141. }
  1142. public static bool positionSupported
  1143. {
  1144. get {
  1145. #if OVRPLUGIN_UNSUPPORTED_PLATFORM
  1146. return false;
  1147. #else
  1148. return initialized && OVRP_1_1_0.ovrp_GetTrackingPositionSupported() == Bool.True;
  1149. #endif
  1150. }
  1151. }
  1152. public static bool positionTracked
  1153. {
  1154. get {
  1155. #if OVRPLUGIN_UNSUPPORTED_PLATFORM
  1156. return false;
  1157. #else
  1158. return initialized && OVRP_1_1_0.ovrp_GetNodePositionTracked(Node.EyeCenter) == Bool.True;
  1159. #endif
  1160. }
  1161. }
  1162. public static bool powerSaving
  1163. {
  1164. get {
  1165. #if OVRPLUGIN_UNSUPPORTED_PLATFORM
  1166. return false;
  1167. #else
  1168. return initialized && OVRP_1_1_0.ovrp_GetSystemPowerSavingMode() == Bool.True;
  1169. #endif
  1170. }
  1171. }
  1172. public static bool hmdPresent
  1173. {
  1174. get {
  1175. #if OVRPLUGIN_UNSUPPORTED_PLATFORM
  1176. return false;
  1177. #else
  1178. return initialized && OVRP_1_1_0.ovrp_GetNodePresent(Node.EyeCenter) == Bool.True;
  1179. #endif
  1180. }
  1181. }
  1182. public static bool userPresent
  1183. {
  1184. get {
  1185. #if OVRPLUGIN_UNSUPPORTED_PLATFORM
  1186. return false;
  1187. #else
  1188. return initialized && OVRP_1_1_0.ovrp_GetUserPresent() == Bool.True;
  1189. #endif
  1190. }
  1191. }
  1192. public static bool headphonesPresent
  1193. {
  1194. get {
  1195. #if OVRPLUGIN_UNSUPPORTED_PLATFORM
  1196. return false;
  1197. #else
  1198. return initialized && OVRP_1_3_0.ovrp_GetSystemHeadphonesPresent() == OVRPlugin.Bool.True;
  1199. #endif
  1200. }
  1201. }
  1202. public static int recommendedMSAALevel
  1203. {
  1204. get {
  1205. #if OVRPLUGIN_UNSUPPORTED_PLATFORM
  1206. return 2;
  1207. #else
  1208. if (initialized && version >= OVRP_1_6_0.version)
  1209. return OVRP_1_6_0.ovrp_GetSystemRecommendedMSAALevel();
  1210. else
  1211. return 2;
  1212. #endif
  1213. }
  1214. }
  1215. public static SystemRegion systemRegion
  1216. {
  1217. get {
  1218. #if OVRPLUGIN_UNSUPPORTED_PLATFORM
  1219. return SystemRegion.Unspecified;
  1220. #else
  1221. if (initialized && version >= OVRP_1_5_0.version)
  1222. return OVRP_1_5_0.ovrp_GetSystemRegion();
  1223. else
  1224. return SystemRegion.Unspecified;
  1225. #endif
  1226. }
  1227. }
  1228. #if !OVRPLUGIN_UNSUPPORTED_PLATFORM
  1229. private static GUID _nativeAudioOutGuid = new OVRPlugin.GUID();
  1230. private static Guid _cachedAudioOutGuid;
  1231. private static string _cachedAudioOutString;
  1232. #endif
  1233. public static string audioOutId
  1234. {
  1235. get {
  1236. #if OVRPLUGIN_UNSUPPORTED_PLATFORM
  1237. return string.Empty;
  1238. #else
  1239. try
  1240. {
  1241. if (_nativeAudioOutGuid == null)
  1242. _nativeAudioOutGuid = new OVRPlugin.GUID();
  1243. IntPtr ptr = OVRP_1_1_0.ovrp_GetAudioOutId();
  1244. if (ptr != IntPtr.Zero)
  1245. {
  1246. Marshal.PtrToStructure(ptr, _nativeAudioOutGuid);
  1247. Guid managedGuid = new Guid(
  1248. _nativeAudioOutGuid.a,
  1249. _nativeAudioOutGuid.b,
  1250. _nativeAudioOutGuid.c,
  1251. _nativeAudioOutGuid.d0,
  1252. _nativeAudioOutGuid.d1,
  1253. _nativeAudioOutGuid.d2,
  1254. _nativeAudioOutGuid.d3,
  1255. _nativeAudioOutGuid.d4,
  1256. _nativeAudioOutGuid.d5,
  1257. _nativeAudioOutGuid.d6,
  1258. _nativeAudioOutGuid.d7);
  1259. if (managedGuid != _cachedAudioOutGuid)
  1260. {
  1261. _cachedAudioOutGuid = managedGuid;
  1262. _cachedAudioOutString = _cachedAudioOutGuid.ToString();
  1263. }
  1264. return _cachedAudioOutString;
  1265. }
  1266. }
  1267. catch { }
  1268. return string.Empty;
  1269. #endif
  1270. }
  1271. }
  1272. #if !OVRPLUGIN_UNSUPPORTED_PLATFORM
  1273. private static GUID _nativeAudioInGuid = new OVRPlugin.GUID();
  1274. private static Guid _cachedAudioInGuid;
  1275. private static string _cachedAudioInString;
  1276. #endif
  1277. public static string audioInId
  1278. {
  1279. get {
  1280. #if OVRPLUGIN_UNSUPPORTED_PLATFORM
  1281. return string.Empty;
  1282. #else
  1283. try
  1284. {
  1285. if (_nativeAudioInGuid == null)
  1286. _nativeAudioInGuid = new OVRPlugin.GUID();
  1287. IntPtr ptr = OVRP_1_1_0.ovrp_GetAudioInId();
  1288. if (ptr != IntPtr.Zero)
  1289. {
  1290. Marshal.PtrToStructure(ptr, _nativeAudioInGuid);
  1291. Guid managedGuid = new Guid(
  1292. _nativeAudioInGuid.a,
  1293. _nativeAudioInGuid.b,
  1294. _nativeAudioInGuid.c,
  1295. _nativeAudioInGuid.d0,
  1296. _nativeAudioInGuid.d1,
  1297. _nativeAudioInGuid.d2,
  1298. _nativeAudioInGuid.d3,
  1299. _nativeAudioInGuid.d4,
  1300. _nativeAudioInGuid.d5,
  1301. _nativeAudioInGuid.d6,
  1302. _nativeAudioInGuid.d7);
  1303. if (managedGuid != _cachedAudioInGuid)
  1304. {
  1305. _cachedAudioInGuid = managedGuid;
  1306. _cachedAudioInString = _cachedAudioInGuid.ToString();
  1307. }
  1308. return _cachedAudioInString;
  1309. }
  1310. }
  1311. catch { }
  1312. return string.Empty;
  1313. #endif
  1314. }
  1315. }
  1316. public static bool hasVrFocus
  1317. {
  1318. get {
  1319. #if OVRPLUGIN_UNSUPPORTED_PLATFORM
  1320. return false;
  1321. #else
  1322. return OVRP_1_1_0.ovrp_GetAppHasVrFocus() == Bool.True;
  1323. #endif
  1324. }
  1325. }
  1326. public static bool hasInputFocus
  1327. {
  1328. get
  1329. {
  1330. #if OVRPLUGIN_UNSUPPORTED_PLATFORM
  1331. return true;
  1332. #else
  1333. if (version >= OVRP_1_18_0.version)
  1334. {
  1335. Bool inputFocus = Bool.False;
  1336. Result result = OVRP_1_18_0.ovrp_GetAppHasInputFocus(out inputFocus);
  1337. if (Result.Success == result)
  1338. return inputFocus == Bool.True;
  1339. else
  1340. {
  1341. //Debug.LogWarning("ovrp_GetAppHasInputFocus return " + result);
  1342. return false;
  1343. }
  1344. }
  1345. return true;
  1346. #endif
  1347. }
  1348. }
  1349. public static bool shouldQuit
  1350. {
  1351. get {
  1352. #if OVRPLUGIN_UNSUPPORTED_PLATFORM
  1353. return false;
  1354. #else
  1355. return OVRP_1_1_0.ovrp_GetAppShouldQuit() == Bool.True;
  1356. #endif
  1357. }
  1358. }
  1359. public static bool shouldRecenter
  1360. {
  1361. get {
  1362. #if OVRPLUGIN_UNSUPPORTED_PLATFORM
  1363. return false;
  1364. #else
  1365. return OVRP_1_1_0.ovrp_GetAppShouldRecenter() == Bool.True;
  1366. #endif
  1367. }
  1368. }
  1369. public static string productName
  1370. {
  1371. get {
  1372. #if OVRPLUGIN_UNSUPPORTED_PLATFORM
  1373. return string.Empty;
  1374. #else
  1375. return OVRP_1_1_0.ovrp_GetSystemProductName();
  1376. #endif
  1377. }
  1378. }
  1379. public static string latency
  1380. {
  1381. get {
  1382. #if OVRPLUGIN_UNSUPPORTED_PLATFORM
  1383. return string.Empty;
  1384. #else
  1385. if (!initialized)
  1386. return string.Empty;
  1387. return OVRP_1_1_0.ovrp_GetAppLatencyTimings();
  1388. #endif
  1389. }
  1390. }
  1391. public static float eyeDepth
  1392. {
  1393. get {
  1394. #if OVRPLUGIN_UNSUPPORTED_PLATFORM
  1395. return 0.0f;
  1396. #else
  1397. if (!initialized)
  1398. return 0.0f;
  1399. return OVRP_1_1_0.ovrp_GetUserEyeDepth();
  1400. #endif
  1401. }
  1402. set {
  1403. #if OVRPLUGIN_UNSUPPORTED_PLATFORM
  1404. return;
  1405. #else
  1406. OVRP_1_1_0.ovrp_SetUserEyeDepth(value);
  1407. #endif
  1408. }
  1409. }
  1410. public static float eyeHeight
  1411. {
  1412. get {
  1413. #if OVRPLUGIN_UNSUPPORTED_PLATFORM
  1414. return 0.0f;
  1415. #else
  1416. return OVRP_1_1_0.ovrp_GetUserEyeHeight();
  1417. #endif
  1418. }
  1419. set {
  1420. #if OVRPLUGIN_UNSUPPORTED_PLATFORM
  1421. return;
  1422. #else
  1423. OVRP_1_1_0.ovrp_SetUserEyeHeight(value);
  1424. #endif
  1425. }
  1426. }
  1427. public static float batteryLevel
  1428. {
  1429. get {
  1430. #if OVRPLUGIN_UNSUPPORTED_PLATFORM
  1431. return 0.0f;
  1432. #else
  1433. return OVRP_1_1_0.ovrp_GetSystemBatteryLevel();
  1434. #endif
  1435. }
  1436. }
  1437. public static float batteryTemperature
  1438. {
  1439. get {
  1440. #if OVRPLUGIN_UNSUPPORTED_PLATFORM
  1441. return 0.0f;
  1442. #else
  1443. return OVRP_1_1_0.ovrp_GetSystemBatteryTemperature();
  1444. #endif
  1445. }
  1446. }
  1447. public static int cpuLevel
  1448. {
  1449. get {
  1450. #if OVRPLUGIN_UNSUPPORTED_PLATFORM
  1451. return 0;
  1452. #else
  1453. return OVRP_1_1_0.ovrp_GetSystemCpuLevel();
  1454. #endif
  1455. }
  1456. set {
  1457. #if OVRPLUGIN_UNSUPPORTED_PLATFORM
  1458. return;
  1459. #else
  1460. OVRP_1_1_0.ovrp_SetSystemCpuLevel(value);
  1461. #endif
  1462. }
  1463. }
  1464. public static int gpuLevel
  1465. {
  1466. get {
  1467. #if OVRPLUGIN_UNSUPPORTED_PLATFORM
  1468. return 0;
  1469. #else
  1470. return OVRP_1_1_0.ovrp_GetSystemGpuLevel();
  1471. #endif
  1472. }
  1473. set {
  1474. #if OVRPLUGIN_UNSUPPORTED_PLATFORM
  1475. return;
  1476. #else
  1477. OVRP_1_1_0.ovrp_SetSystemGpuLevel(value);
  1478. #endif
  1479. }
  1480. }
  1481. public static int vsyncCount
  1482. {
  1483. get {
  1484. #if OVRPLUGIN_UNSUPPORTED_PLATFORM
  1485. return 0;
  1486. #else
  1487. return OVRP_1_1_0.ovrp_GetSystemVSyncCount();
  1488. #endif
  1489. }
  1490. set {
  1491. #if OVRPLUGIN_UNSUPPORTED_PLATFORM
  1492. return;
  1493. #else
  1494. OVRP_1_2_0.ovrp_SetSystemVSyncCount(value);
  1495. #endif
  1496. }
  1497. }
  1498. public static float systemVolume
  1499. {
  1500. get {
  1501. #if OVRPLUGIN_UNSUPPORTED_PLATFORM
  1502. return 0.0f;
  1503. #else
  1504. return OVRP_1_1_0.ovrp_GetSystemVolume();
  1505. #endif
  1506. }
  1507. }
  1508. public static float ipd
  1509. {
  1510. get {
  1511. #if OVRPLUGIN_UNSUPPORTED_PLATFORM
  1512. return 0.0f;
  1513. #else
  1514. return OVRP_1_1_0.ovrp_GetUserIPD();
  1515. #endif
  1516. }
  1517. set {
  1518. #if OVRPLUGIN_UNSUPPORTED_PLATFORM
  1519. return;
  1520. #else
  1521. OVRP_1_1_0.ovrp_SetUserIPD(value);
  1522. #endif
  1523. }
  1524. }
  1525. public static bool occlusionMesh
  1526. {
  1527. get {
  1528. #if OVRPLUGIN_UNSUPPORTED_PLATFORM
  1529. return false;
  1530. #else
  1531. return initialized && (OVRP_1_3_0.ovrp_GetEyeOcclusionMeshEnabled() == Bool.True);
  1532. #endif
  1533. }
  1534. set {
  1535. #if OVRPLUGIN_UNSUPPORTED_PLATFORM
  1536. return;
  1537. #else
  1538. if (!initialized)
  1539. return;
  1540. OVRP_1_3_0.ovrp_SetEyeOcclusionMeshEnabled(ToBool(value));
  1541. #endif
  1542. }
  1543. }
  1544. public static BatteryStatus batteryStatus
  1545. {
  1546. get {
  1547. #if OVRPLUGIN_UNSUPPORTED_PLATFORM
  1548. return default(BatteryStatus);
  1549. #else
  1550. return OVRP_1_1_0.ovrp_GetSystemBatteryStatus();
  1551. #endif
  1552. }
  1553. }
  1554. public static Frustumf GetEyeFrustum(Eye eyeId)
  1555. {
  1556. #if OVRPLUGIN_UNSUPPORTED_PLATFORM
  1557. return new Frustumf();
  1558. #else
  1559. return OVRP_1_1_0.ovrp_GetNodeFrustum((Node)eyeId);
  1560. #endif
  1561. }
  1562. public static Sizei GetEyeTextureSize(Eye eyeId)
  1563. {
  1564. #if OVRPLUGIN_UNSUPPORTED_PLATFORM
  1565. return new Sizei();
  1566. #else
  1567. return OVRP_0_1_0.ovrp_GetEyeTextureSize(eyeId);
  1568. #endif
  1569. }
  1570. public static Posef GetTrackerPose(Tracker trackerId)
  1571. {
  1572. #if OVRPLUGIN_UNSUPPORTED_PLATFORM
  1573. return Posef.identity;
  1574. #else
  1575. return GetNodePose((Node)((int)trackerId + (int)Node.TrackerZero), Step.Render);
  1576. #endif
  1577. }
  1578. public static Frustumf GetTrackerFrustum(Tracker trackerId)
  1579. {
  1580. #if OVRPLUGIN_UNSUPPORTED_PLATFORM
  1581. return new Frustumf();
  1582. #else
  1583. return OVRP_1_1_0.ovrp_GetNodeFrustum((Node)((int)trackerId + (int)Node.TrackerZero));
  1584. #endif
  1585. }
  1586. public static bool ShowUI(PlatformUI ui)
  1587. {
  1588. #if OVRPLUGIN_UNSUPPORTED_PLATFORM
  1589. return false;
  1590. #else
  1591. return OVRP_1_1_0.ovrp_ShowSystemUI(ui) == Bool.True;
  1592. #endif
  1593. }
  1594. public static bool EnqueueSubmitLayer(bool onTop, bool headLocked, bool noDepthBufferTesting, IntPtr leftTexture, IntPtr rightTexture, int layerId, int frameIndex, Posef pose, Vector3f scale, int layerIndex = 0, OverlayShape shape = OverlayShape.Quad,
  1595. bool overrideTextureRectMatrix = false, TextureRectMatrixf textureRectMatrix = default(TextureRectMatrixf), bool overridePerLayerColorScaleAndOffset = false, Vector4 colorScale = default(Vector4), Vector4 colorOffset = default(Vector4),
  1596. bool expensiveSuperSample = false, bool hidden = false)
  1597. {
  1598. #if OVRPLUGIN_UNSUPPORTED_PLATFORM
  1599. return false;
  1600. #else
  1601. if (!initialized)
  1602. return false;
  1603. if (version >= OVRP_1_6_0.version)
  1604. {
  1605. uint flags = (uint)OverlayFlag.None;
  1606. if (onTop)
  1607. flags |= (uint)OverlayFlag.OnTop;
  1608. if (headLocked)
  1609. flags |= (uint)OverlayFlag.HeadLocked;
  1610. if (noDepthBufferTesting)
  1611. flags |= (uint)OverlayFlag.NoDepth;
  1612. if (expensiveSuperSample)
  1613. flags |= (uint)OverlayFlag.ExpensiveSuperSample;
  1614. if (hidden)
  1615. flags |= (uint)OverlayFlag.Hidden;
  1616. if (shape == OverlayShape.Cylinder || shape == OverlayShape.Cubemap)
  1617. {
  1618. #if UNITY_ANDROID
  1619. if (version >= OVRP_1_7_0.version)
  1620. flags |= (uint)(shape) << OverlayShapeFlagShift;
  1621. else
  1622. #else
  1623. if (shape == OverlayShape.Cubemap && version >= OVRP_1_10_0.version)
  1624. flags |= (uint)(shape) << OverlayShapeFlagShift;
  1625. else if (shape == OverlayShape.Cylinder && version >= OVRP_1_16_0.version)
  1626. flags |= (uint)(shape) << OverlayShapeFlagShift;
  1627. else
  1628. #endif
  1629. return false;
  1630. }
  1631. if (shape == OverlayShape.OffcenterCubemap)
  1632. {
  1633. #if UNITY_ANDROID
  1634. if (version >= OVRP_1_11_0.version)
  1635. flags |= (uint)(shape) << OverlayShapeFlagShift;
  1636. else
  1637. #endif
  1638. return false;
  1639. }
  1640. if (shape == OverlayShape.Equirect)
  1641. {
  1642. #if UNITY_ANDROID
  1643. if (version >= OVRP_1_21_0.version)
  1644. flags |= (uint)(shape) << OverlayShapeFlagShift;
  1645. else
  1646. #endif
  1647. return false;
  1648. }
  1649. if (version >= OVRP_1_34_0.version && layerId != -1)
  1650. return OVRP_1_34_0.ovrp_EnqueueSubmitLayer2(flags, leftTexture, rightTexture, layerId, frameIndex, ref pose, ref scale, layerIndex,
  1651. overrideTextureRectMatrix ? Bool.True : Bool.False, ref textureRectMatrix, overridePerLayerColorScaleAndOffset ? Bool.True : Bool.False, ref colorScale, ref colorOffset) == Result.Success;
  1652. else if (version >= OVRP_1_15_0.version && layerId != -1)
  1653. return OVRP_1_15_0.ovrp_EnqueueSubmitLayer(flags, leftTexture, rightTexture, layerId, frameIndex, ref pose, ref scale, layerIndex) == Result.Success;
  1654. return OVRP_1_6_0.ovrp_SetOverlayQuad3(flags, leftTexture, rightTexture, IntPtr.Zero, pose, scale, layerIndex) == Bool.True;
  1655. }
  1656. if (layerIndex != 0)
  1657. return false;
  1658. return OVRP_0_1_1.ovrp_SetOverlayQuad2(ToBool(onTop), ToBool(headLocked), leftTexture, IntPtr.Zero, pose, scale) == Bool.True;
  1659. #endif
  1660. }
  1661. public static LayerDesc CalculateLayerDesc(OverlayShape shape, LayerLayout layout, Sizei textureSize,
  1662. int mipLevels, int sampleCount, EyeTextureFormat format, int layerFlags)
  1663. {
  1664. #if OVRPLUGIN_UNSUPPORTED_PLATFORM
  1665. return new LayerDesc();
  1666. #else
  1667. LayerDesc layerDesc = new LayerDesc();
  1668. if (!initialized)
  1669. return layerDesc;
  1670. if (version >= OVRP_1_15_0.version)
  1671. {
  1672. OVRP_1_15_0.ovrp_CalculateLayerDesc(shape, layout, ref textureSize,
  1673. mipLevels, sampleCount, format, layerFlags, ref layerDesc);
  1674. }
  1675. return layerDesc;
  1676. #endif
  1677. }
  1678. public static bool EnqueueSetupLayer(LayerDesc desc, int compositionDepth, IntPtr layerID)
  1679. {
  1680. #if OVRPLUGIN_UNSUPPORTED_PLATFORM
  1681. return false;
  1682. #else
  1683. if (!initialized)
  1684. return false;
  1685. if (version >= OVRP_1_28_0.version)
  1686. return OVRP_1_28_0.ovrp_EnqueueSetupLayer2(ref desc, compositionDepth, layerID) == Result.Success;
  1687. else if (version >= OVRP_1_15_0.version)
  1688. {
  1689. if (compositionDepth != 0)
  1690. {
  1691. Debug.LogWarning("Use Oculus Plugin 1.28.0 or above to support non-zero compositionDepth");
  1692. }
  1693. return OVRP_1_15_0.ovrp_EnqueueSetupLayer(ref desc, layerID) == Result.Success;
  1694. }
  1695. return false;
  1696. #endif
  1697. }
  1698. public static bool EnqueueDestroyLayer(IntPtr layerID)
  1699. {
  1700. #if OVRPLUGIN_UNSUPPORTED_PLATFORM
  1701. return false;
  1702. #else
  1703. if (!initialized)
  1704. return false;
  1705. if (version >= OVRP_1_15_0.version)
  1706. return OVRP_1_15_0.ovrp_EnqueueDestroyLayer(layerID) == Result.Success;
  1707. return false;
  1708. #endif
  1709. }
  1710. public static IntPtr GetLayerTexture(int layerId, int stage, Eye eyeId)
  1711. {
  1712. #if OVRPLUGIN_UNSUPPORTED_PLATFORM
  1713. return IntPtr.Zero;
  1714. #else
  1715. IntPtr textureHandle = IntPtr.Zero;
  1716. if (!initialized)
  1717. return textureHandle;
  1718. if (version >= OVRP_1_15_0.version)
  1719. OVRP_1_15_0.ovrp_GetLayerTexturePtr(layerId, stage, eyeId, ref textureHandle);
  1720. return textureHandle;
  1721. #endif
  1722. }
  1723. public static int GetLayerTextureStageCount(int layerId)
  1724. {
  1725. #if OVRPLUGIN_UNSUPPORTED_PLATFORM
  1726. return 1;
  1727. #else
  1728. if (!initialized)
  1729. return 1;
  1730. int stageCount = 1;
  1731. if (version >= OVRP_1_15_0.version)
  1732. OVRP_1_15_0.ovrp_GetLayerTextureStageCount(layerId, ref stageCount);
  1733. return stageCount;
  1734. #endif
  1735. }
  1736. public static IntPtr GetLayerAndroidSurfaceObject(int layerId)
  1737. {
  1738. #if OVRPLUGIN_UNSUPPORTED_PLATFORM
  1739. return IntPtr.Zero;
  1740. #else
  1741. IntPtr surfaceObject = IntPtr.Zero;
  1742. if (!initialized)
  1743. return surfaceObject;
  1744. if (version >= OVRP_1_29_0.version)
  1745. OVRP_1_29_0.ovrp_GetLayerAndroidSurfaceObject(layerId, ref surfaceObject);
  1746. return surfaceObject;
  1747. #endif
  1748. }
  1749. public static bool UpdateNodePhysicsPoses(int frameIndex, double predictionSeconds)
  1750. {
  1751. #if OVRPLUGIN_UNSUPPORTED_PLATFORM
  1752. return false;
  1753. #else
  1754. if (version >= OVRP_1_8_0.version)
  1755. return OVRP_1_8_0.ovrp_Update2((int)Step.Physics, frameIndex, predictionSeconds) == Bool.True;
  1756. return false;
  1757. #endif
  1758. }
  1759. public static Posef GetNodePose(Node nodeId, Step stepId)
  1760. {
  1761. #if OVRPLUGIN_UNSUPPORTED_PLATFORM
  1762. return Posef.identity;
  1763. #else
  1764. if (version >= OVRP_1_12_0.version)
  1765. return OVRP_1_12_0.ovrp_GetNodePoseState(stepId, nodeId).Pose;
  1766. if (version >= OVRP_1_8_0.version && stepId == Step.Physics)
  1767. return OVRP_1_8_0.ovrp_GetNodePose2(0, nodeId);
  1768. return OVRP_0_1_2.ovrp_GetNodePose(nodeId);
  1769. #endif
  1770. }
  1771. public static Vector3f GetNodeVelocity(Node nodeId, Step stepId)
  1772. {
  1773. #if OVRPLUGIN_UNSUPPORTED_PLATFORM
  1774. return new Vector3f();
  1775. #else
  1776. if (version >= OVRP_1_12_0.version)
  1777. return OVRP_1_12_0.ovrp_GetNodePoseState(stepId, nodeId).Velocity;
  1778. if (version >= OVRP_1_8_0.version && stepId == Step.Physics)
  1779. return OVRP_1_8_0.ovrp_GetNodeVelocity2(0, nodeId).Position;
  1780. return OVRP_0_1_3.ovrp_GetNodeVelocity(nodeId).Position;
  1781. #endif
  1782. }
  1783. public static Vector3f GetNodeAngularVelocity(Node nodeId, Step stepId)
  1784. {
  1785. #if OVRPLUGIN_UNSUPPORTED_PLATFORM
  1786. return new Vector3f();
  1787. #else
  1788. if (version >= OVRP_1_12_0.version)
  1789. return OVRP_1_12_0.ovrp_GetNodePoseState(stepId, nodeId).AngularVelocity;
  1790. return new Vector3f(); //TODO: Convert legacy quat to vec3?
  1791. #endif
  1792. }
  1793. public static Vector3f GetNodeAcceleration(Node nodeId, Step stepId)
  1794. {
  1795. #if OVRPLUGIN_UNSUPPORTED_PLATFORM
  1796. return new Vector3f();
  1797. #else
  1798. if (version >= OVRP_1_12_0.version)
  1799. return OVRP_1_12_0.ovrp_GetNodePoseState(stepId, nodeId).Acceleration;
  1800. if (version >= OVRP_1_8_0.version && stepId == Step.Physics)
  1801. return OVRP_1_8_0.ovrp_GetNodeAcceleration2(0, nodeId).Position;
  1802. return OVRP_0_1_3.ovrp_GetNodeAcceleration(nodeId).Position;
  1803. #endif
  1804. }
  1805. public static Vector3f GetNodeAngularAcceleration(Node nodeId, Step stepId)
  1806. {
  1807. #if OVRPLUGIN_UNSUPPORTED_PLATFORM
  1808. return new Vector3f();
  1809. #else
  1810. if (version >= OVRP_1_12_0.version)
  1811. return OVRP_1_12_0.ovrp_GetNodePoseState(stepId, nodeId).AngularAcceleration;
  1812. return new Vector3f(); //TODO: Convert legacy quat to vec3?
  1813. #endif
  1814. }
  1815. public static bool GetNodePresent(Node nodeId)
  1816. {
  1817. #if OVRPLUGIN_UNSUPPORTED_PLATFORM
  1818. return false;
  1819. #else
  1820. return OVRP_1_1_0.ovrp_GetNodePresent(nodeId) == Bool.True;
  1821. #endif
  1822. }
  1823. public static bool GetNodeOrientationTracked(Node nodeId)
  1824. {
  1825. #if OVRPLUGIN_UNSUPPORTED_PLATFORM
  1826. return false;
  1827. #else
  1828. return OVRP_1_1_0.ovrp_GetNodeOrientationTracked(nodeId) == Bool.True;
  1829. #endif
  1830. }
  1831. public static bool GetNodeOrientationValid(Node nodeId)
  1832. {
  1833. #if OVRPLUGIN_UNSUPPORTED_PLATFORM
  1834. return false;
  1835. #else
  1836. if (version >= OVRP_1_38_0.version)
  1837. {
  1838. Bool orientationValid = Bool.False;
  1839. Result result = OVRP_1_38_0.ovrp_GetNodeOrientationValid(nodeId, ref orientationValid);
  1840. return result == Result.Success && orientationValid == Bool.True;
  1841. }
  1842. else
  1843. {
  1844. return GetNodeOrientationTracked(nodeId);
  1845. }
  1846. #endif
  1847. }
  1848. public static bool GetNodePositionTracked(Node nodeId)
  1849. {
  1850. #if OVRPLUGIN_UNSUPPORTED_PLATFORM
  1851. return false;
  1852. #else
  1853. return OVRP_1_1_0.ovrp_GetNodePositionTracked(nodeId) == Bool.True;
  1854. #endif
  1855. }
  1856. public static bool GetNodePositionValid(Node nodeId)
  1857. {
  1858. #if OVRPLUGIN_UNSUPPORTED_PLATFORM
  1859. return false;
  1860. #else
  1861. if (version >= OVRP_1_38_0.version)
  1862. {
  1863. Bool positionValid = Bool.False;
  1864. Result result = OVRP_1_38_0.ovrp_GetNodePositionValid(nodeId, ref positionValid);
  1865. return result == Result.Success && positionValid == Bool.True;
  1866. }
  1867. else
  1868. {
  1869. return GetNodePositionTracked(nodeId);
  1870. }
  1871. #endif
  1872. }
  1873. public static PoseStatef GetNodePoseStateRaw(Node nodeId, Step stepId)
  1874. {
  1875. #if OVRPLUGIN_UNSUPPORTED_PLATFORM
  1876. return PoseStatef.identity;
  1877. #else
  1878. if (version >= OVRP_1_29_0.version)
  1879. {
  1880. PoseStatef nodePoseState;
  1881. Result result = OVRP_1_29_0.ovrp_GetNodePoseStateRaw(stepId, -1, nodeId, out nodePoseState);
  1882. if (result == Result.Success)
  1883. {
  1884. return nodePoseState;
  1885. }
  1886. else
  1887. {
  1888. return PoseStatef.identity;
  1889. }
  1890. }
  1891. if (version >= OVRP_1_12_0.version)
  1892. return OVRP_1_12_0.ovrp_GetNodePoseState(stepId, nodeId);
  1893. else
  1894. return PoseStatef.identity;
  1895. #endif
  1896. }
  1897. public static Posef GetCurrentTrackingTransformPose()
  1898. {
  1899. #if OVRPLUGIN_UNSUPPORTED_PLATFORM
  1900. return Posef.identity;
  1901. #else
  1902. if (version >= OVRP_1_30_0.version)
  1903. {
  1904. Posef trackingTransformPose;
  1905. Result result = OVRP_1_30_0.ovrp_GetCurrentTrackingTransformPose(out trackingTransformPose);
  1906. if (result == Result.Success)
  1907. {
  1908. return trackingTransformPose;
  1909. }
  1910. else
  1911. {
  1912. return Posef.identity;
  1913. }
  1914. }
  1915. else
  1916. {
  1917. return Posef.identity;
  1918. }
  1919. #endif
  1920. }
  1921. public static Posef GetTrackingTransformRawPose()
  1922. {
  1923. #if OVRPLUGIN_UNSUPPORTED_PLATFORM
  1924. return Posef.identity;
  1925. #else
  1926. if (version >= OVRP_1_30_0.version)
  1927. {
  1928. Posef trackingTransforRawPose;
  1929. Result result = OVRP_1_30_0.ovrp_GetTrackingTransformRawPose(out trackingTransforRawPose);
  1930. if (result == Result.Success)
  1931. {
  1932. return trackingTransforRawPose;
  1933. }
  1934. else
  1935. {
  1936. return Posef.identity;
  1937. }
  1938. }
  1939. else
  1940. {
  1941. return Posef.identity;
  1942. }
  1943. #endif
  1944. }
  1945. public static Posef GetTrackingTransformRelativePose(TrackingOrigin trackingOrigin)
  1946. {
  1947. #if OVRPLUGIN_UNSUPPORTED_PLATFORM
  1948. return Posef.identity;
  1949. #else
  1950. if (version >= OVRP_1_38_0.version)
  1951. {
  1952. Posef trackingTransformRelativePose = Posef.identity;
  1953. Result result = OVRP_1_38_0.ovrp_GetTrackingTransformRelativePose(ref trackingTransformRelativePose, trackingOrigin);
  1954. if (result == Result.Success)
  1955. {
  1956. return trackingTransformRelativePose;
  1957. }
  1958. else
  1959. {
  1960. return Posef.identity;
  1961. }
  1962. }
  1963. else
  1964. {
  1965. return Posef.identity;
  1966. }
  1967. #endif
  1968. }
  1969. public static ControllerState GetControllerState(uint controllerMask)
  1970. {
  1971. #if OVRPLUGIN_UNSUPPORTED_PLATFORM
  1972. return new ControllerState();
  1973. #else
  1974. return OVRP_1_1_0.ovrp_GetControllerState(controllerMask);
  1975. #endif
  1976. }
  1977. public static ControllerState2 GetControllerState2(uint controllerMask)
  1978. {
  1979. #if OVRPLUGIN_UNSUPPORTED_PLATFORM
  1980. return new ControllerState2();
  1981. #else
  1982. if (version >= OVRP_1_12_0.version)
  1983. {
  1984. return OVRP_1_12_0.ovrp_GetControllerState2(controllerMask);
  1985. }
  1986. return new ControllerState2(OVRP_1_1_0.ovrp_GetControllerState(controllerMask));
  1987. #endif
  1988. }
  1989. public static ControllerState4 GetControllerState4(uint controllerMask)
  1990. {
  1991. #if OVRPLUGIN_UNSUPPORTED_PLATFORM
  1992. return new ControllerState4();
  1993. #else
  1994. if (version >= OVRP_1_16_0.version)
  1995. {
  1996. ControllerState4 controllerState = new ControllerState4();
  1997. OVRP_1_16_0.ovrp_GetControllerState4(controllerMask, ref controllerState);
  1998. return controllerState;
  1999. }
  2000. return new ControllerState4(GetControllerState2(controllerMask));
  2001. #endif
  2002. }
  2003. public static bool SetControllerVibration(uint controllerMask, float frequency, float amplitude)
  2004. {
  2005. #if OVRPLUGIN_UNSUPPORTED_PLATFORM
  2006. return false;
  2007. #else
  2008. return OVRP_0_1_2.ovrp_SetControllerVibration(controllerMask, frequency, amplitude) == Bool.True;
  2009. #endif
  2010. }
  2011. public static HapticsDesc GetControllerHapticsDesc(uint controllerMask)
  2012. {
  2013. #if OVRPLUGIN_UNSUPPORTED_PLATFORM
  2014. return new HapticsDesc();
  2015. #else
  2016. if (version >= OVRP_1_6_0.version)
  2017. {
  2018. return OVRP_1_6_0.ovrp_GetControllerHapticsDesc(controllerMask);
  2019. }
  2020. else
  2021. {
  2022. return new HapticsDesc();
  2023. }
  2024. #endif
  2025. }
  2026. public static HapticsState GetControllerHapticsState(uint controllerMask)
  2027. {
  2028. #if OVRPLUGIN_UNSUPPORTED_PLATFORM
  2029. return new HapticsState();
  2030. #else
  2031. if (version >= OVRP_1_6_0.version)
  2032. {
  2033. return OVRP_1_6_0.ovrp_GetControllerHapticsState(controllerMask);
  2034. }
  2035. else
  2036. {
  2037. return new HapticsState();
  2038. }
  2039. #endif
  2040. }
  2041. public static bool SetControllerHaptics(uint controllerMask, HapticsBuffer hapticsBuffer)
  2042. {
  2043. #if OVRPLUGIN_UNSUPPORTED_PLATFORM
  2044. return false;
  2045. #else
  2046. if (version >= OVRP_1_6_0.version)
  2047. {
  2048. return OVRP_1_6_0.ovrp_SetControllerHaptics(controllerMask, hapticsBuffer) == Bool.True;
  2049. }
  2050. else
  2051. {
  2052. return false;
  2053. }
  2054. #endif
  2055. }
  2056. public static float GetEyeRecommendedResolutionScale()
  2057. {
  2058. #if OVRPLUGIN_UNSUPPORTED_PLATFORM
  2059. return 1.0f;
  2060. #else
  2061. if (version >= OVRP_1_6_0.version)
  2062. {
  2063. return OVRP_1_6_0.ovrp_GetEyeRecommendedResolutionScale();
  2064. }
  2065. else
  2066. {
  2067. return 1.0f;
  2068. }
  2069. #endif
  2070. }
  2071. public static float GetAppCpuStartToGpuEndTime()
  2072. {
  2073. #if OVRPLUGIN_UNSUPPORTED_PLATFORM
  2074. return 0.0f;
  2075. #else
  2076. if (version >= OVRP_1_6_0.version)
  2077. {
  2078. return OVRP_1_6_0.ovrp_GetAppCpuStartToGpuEndTime();
  2079. }
  2080. else
  2081. {
  2082. return 0.0f;
  2083. }
  2084. #endif
  2085. }
  2086. public static bool GetBoundaryConfigured()
  2087. {
  2088. #if OVRPLUGIN_UNSUPPORTED_PLATFORM
  2089. return false;
  2090. #else
  2091. if (version >= OVRP_1_8_0.version)
  2092. {
  2093. return OVRP_1_8_0.ovrp_GetBoundaryConfigured() == OVRPlugin.Bool.True;
  2094. }
  2095. else
  2096. {
  2097. return false;
  2098. }
  2099. #endif
  2100. }
  2101. public static BoundaryTestResult TestBoundaryNode(Node nodeId, BoundaryType boundaryType)
  2102. {
  2103. #if OVRPLUGIN_UNSUPPORTED_PLATFORM
  2104. return new BoundaryTestResult();
  2105. #else
  2106. if (version >= OVRP_1_8_0.version)
  2107. {
  2108. return OVRP_1_8_0.ovrp_TestBoundaryNode(nodeId, boundaryType);
  2109. }
  2110. else
  2111. {
  2112. return new BoundaryTestResult();
  2113. }
  2114. #endif
  2115. }
  2116. public static BoundaryTestResult TestBoundaryPoint(Vector3f point, BoundaryType boundaryType)
  2117. {
  2118. #if OVRPLUGIN_UNSUPPORTED_PLATFORM
  2119. return new BoundaryTestResult();
  2120. #else
  2121. if (version >= OVRP_1_8_0.version)
  2122. {
  2123. return OVRP_1_8_0.ovrp_TestBoundaryPoint(point, boundaryType);
  2124. }
  2125. else
  2126. {
  2127. return new BoundaryTestResult();
  2128. }
  2129. #endif
  2130. }
  2131. public static BoundaryGeometry GetBoundaryGeometry(BoundaryType boundaryType)
  2132. {
  2133. #if OVRPLUGIN_UNSUPPORTED_PLATFORM
  2134. return new BoundaryGeometry();
  2135. #else
  2136. if (version >= OVRP_1_8_0.version)
  2137. {
  2138. return OVRP_1_8_0.ovrp_GetBoundaryGeometry(boundaryType);
  2139. }
  2140. else
  2141. {
  2142. return new BoundaryGeometry();
  2143. }
  2144. #endif
  2145. }
  2146. public static bool GetBoundaryGeometry2(BoundaryType boundaryType, IntPtr points, ref int pointsCount)
  2147. {
  2148. #if OVRPLUGIN_UNSUPPORTED_PLATFORM
  2149. pointsCount = 0;
  2150. return false;
  2151. #else
  2152. if (version >= OVRP_1_9_0.version)
  2153. {
  2154. return OVRP_1_9_0.ovrp_GetBoundaryGeometry2(boundaryType, points, ref pointsCount) == OVRPlugin.Bool.True;
  2155. }
  2156. else
  2157. {
  2158. pointsCount = 0;
  2159. return false;
  2160. }
  2161. #endif
  2162. }
  2163. public static AppPerfStats GetAppPerfStats()
  2164. {
  2165. #if OVRPLUGIN_UNSUPPORTED_PLATFORM
  2166. return new AppPerfStats();
  2167. #else
  2168. if (version >= OVRP_1_9_0.version)
  2169. {
  2170. return OVRP_1_9_0.ovrp_GetAppPerfStats();
  2171. }
  2172. else
  2173. {
  2174. return new AppPerfStats();
  2175. }
  2176. #endif
  2177. }
  2178. public static bool ResetAppPerfStats()
  2179. {
  2180. #if OVRPLUGIN_UNSUPPORTED_PLATFORM
  2181. return false;
  2182. #else
  2183. if (version >= OVRP_1_9_0.version)
  2184. {
  2185. return OVRP_1_9_0.ovrp_ResetAppPerfStats() == OVRPlugin.Bool.True;
  2186. }
  2187. else
  2188. {
  2189. return false;
  2190. }
  2191. #endif
  2192. }
  2193. public static float GetAppFramerate()
  2194. {
  2195. #if OVRPLUGIN_UNSUPPORTED_PLATFORM
  2196. return 0.0f;
  2197. #else
  2198. if (version >= OVRP_1_12_0.version)
  2199. {
  2200. return OVRP_1_12_0.ovrp_GetAppFramerate();
  2201. }
  2202. else
  2203. {
  2204. return 0.0f;
  2205. }
  2206. #endif
  2207. }
  2208. public static bool SetHandNodePoseStateLatency(double latencyInSeconds)
  2209. {
  2210. #if OVRPLUGIN_UNSUPPORTED_PLATFORM
  2211. return false;
  2212. #else
  2213. if (version >= OVRP_1_18_0.version)
  2214. {
  2215. Result result = OVRP_1_18_0.ovrp_SetHandNodePoseStateLatency(latencyInSeconds);
  2216. if (result == Result.Success)
  2217. {
  2218. return true;
  2219. }
  2220. else
  2221. {
  2222. //Debug.LogWarning("ovrp_SetHandNodePoseStateLatency return " + result);
  2223. return false;
  2224. }
  2225. }
  2226. else
  2227. {
  2228. return false;
  2229. }
  2230. #endif
  2231. }
  2232. public static double GetHandNodePoseStateLatency()
  2233. {
  2234. #if OVRPLUGIN_UNSUPPORTED_PLATFORM
  2235. return 0.0;
  2236. #else
  2237. if (version >= OVRP_1_18_0.version)
  2238. {
  2239. double value = 0.0;
  2240. if (OVRP_1_18_0.ovrp_GetHandNodePoseStateLatency(out value) == OVRPlugin.Result.Success)
  2241. {
  2242. return value;
  2243. }
  2244. else
  2245. {
  2246. return 0.0;
  2247. }
  2248. }
  2249. else
  2250. {
  2251. return 0.0;
  2252. }
  2253. #endif
  2254. }
  2255. public static EyeTextureFormat GetDesiredEyeTextureFormat()
  2256. {
  2257. #if OVRPLUGIN_UNSUPPORTED_PLATFORM
  2258. return EyeTextureFormat.Default;
  2259. #else
  2260. if (version >= OVRP_1_11_0.version)
  2261. {
  2262. uint eyeTextureFormatValue = (uint)OVRP_1_11_0.ovrp_GetDesiredEyeTextureFormat();
  2263. // convert both R8G8B8A8 and R8G8B8A8_SRGB to R8G8B8A8 here for avoid confusing developers
  2264. if (eyeTextureFormatValue == 1)
  2265. eyeTextureFormatValue = 0;
  2266. return (EyeTextureFormat)eyeTextureFormatValue;
  2267. }
  2268. else
  2269. {
  2270. return EyeTextureFormat.Default;
  2271. }
  2272. #endif
  2273. }
  2274. public static bool SetDesiredEyeTextureFormat(EyeTextureFormat value)
  2275. {
  2276. #if OVRPLUGIN_UNSUPPORTED_PLATFORM
  2277. return false;
  2278. #else
  2279. if (version >= OVRP_1_11_0.version)
  2280. {
  2281. return OVRP_1_11_0.ovrp_SetDesiredEyeTextureFormat(value) == OVRPlugin.Bool.True;
  2282. }
  2283. else
  2284. {
  2285. return false;
  2286. }
  2287. #endif
  2288. }
  2289. public static bool InitializeMixedReality()
  2290. {
  2291. #if OVRPLUGIN_UNSUPPORTED_PLATFORM
  2292. return false;
  2293. #else
  2294. #if OVRPLUGIN_INCLUDE_MRC_ANDROID
  2295. if (version >= OVRP_1_38_0.version) // MRC functions are invalid before 1.38.0
  2296. #else
  2297. if (version >= OVRP_1_15_0.version)
  2298. #endif
  2299. {
  2300. Result result = OVRP_1_15_0.ovrp_InitializeMixedReality();
  2301. if (result != Result.Success)
  2302. {
  2303. //Debug.LogWarning("ovrp_InitializeMixedReality return " + result);
  2304. }
  2305. return result == Result.Success;
  2306. }
  2307. else
  2308. {
  2309. return false;
  2310. }
  2311. #endif
  2312. }
  2313. public static bool ShutdownMixedReality()
  2314. {
  2315. #if OVRPLUGIN_UNSUPPORTED_PLATFORM
  2316. return false;
  2317. #else
  2318. #if OVRPLUGIN_INCLUDE_MRC_ANDROID
  2319. if (version >= OVRP_1_38_0.version) // MRC functions are invalid before 1.38.0
  2320. #else
  2321. if (version >= OVRP_1_15_0.version)
  2322. #endif
  2323. {
  2324. Result result = OVRP_1_15_0.ovrp_ShutdownMixedReality();
  2325. if (result != Result.Success)
  2326. {
  2327. //Debug.LogWarning("ovrp_ShutdownMixedReality return " + result);
  2328. }
  2329. return result == Result.Success;
  2330. }
  2331. else
  2332. {
  2333. return false;
  2334. }
  2335. #endif
  2336. }
  2337. public static bool IsMixedRealityInitialized()
  2338. {
  2339. #if OVRPLUGIN_UNSUPPORTED_PLATFORM
  2340. return false;
  2341. #else
  2342. #if OVRPLUGIN_INCLUDE_MRC_ANDROID
  2343. if (version >= OVRP_1_38_0.version) // MRC functions are invalid before 1.38.0
  2344. #else
  2345. if (version >= OVRP_1_15_0.version)
  2346. #endif
  2347. {
  2348. return OVRP_1_15_0.ovrp_GetMixedRealityInitialized() == Bool.True;
  2349. }
  2350. else
  2351. {
  2352. return false;
  2353. }
  2354. #endif
  2355. }
  2356. public static int GetExternalCameraCount()
  2357. {
  2358. #if OVRPLUGIN_UNSUPPORTED_PLATFORM
  2359. return 0;
  2360. #else
  2361. #if OVRPLUGIN_INCLUDE_MRC_ANDROID
  2362. if (version >= OVRP_1_38_0.version) // MRC functions are invalid before 1.38.0
  2363. #else
  2364. if (version >= OVRP_1_15_0.version)
  2365. #endif
  2366. {
  2367. int cameraCount = 0;
  2368. Result result = OVRP_1_15_0.ovrp_GetExternalCameraCount(out cameraCount);
  2369. if (result != OVRPlugin.Result.Success)
  2370. {
  2371. //Debug.LogWarning("ovrp_GetExternalCameraCount return " + result);
  2372. return 0;
  2373. }
  2374. return cameraCount;
  2375. }
  2376. else
  2377. {
  2378. return 0;
  2379. }
  2380. #endif
  2381. }
  2382. public static bool UpdateExternalCamera()
  2383. {
  2384. #if OVRPLUGIN_UNSUPPORTED_PLATFORM
  2385. return false;
  2386. #else
  2387. #if OVRPLUGIN_INCLUDE_MRC_ANDROID
  2388. if (version >= OVRP_1_38_0.version) // MRC functions are invalid before 1.38.0
  2389. #else
  2390. if (version >= OVRP_1_15_0.version)
  2391. #endif
  2392. {
  2393. Result result = OVRP_1_15_0.ovrp_UpdateExternalCamera();
  2394. if (result != Result.Success)
  2395. {
  2396. //Debug.LogWarning("ovrp_UpdateExternalCamera return " + result);
  2397. }
  2398. return result == Result.Success;
  2399. }
  2400. else
  2401. {
  2402. return false;
  2403. }
  2404. #endif
  2405. }
  2406. public static bool GetMixedRealityCameraInfo(int cameraId, out CameraExtrinsics cameraExtrinsics, out CameraIntrinsics cameraIntrinsics, out Posef calibrationRawPose)
  2407. {
  2408. #if OVRPLUGIN_UNSUPPORTED_PLATFORM
  2409. cameraExtrinsics = default(CameraExtrinsics);
  2410. cameraIntrinsics = default(CameraIntrinsics);
  2411. calibrationRawPose = Posef.identity;
  2412. return false;
  2413. #else
  2414. cameraExtrinsics = default(CameraExtrinsics);
  2415. cameraIntrinsics = default(CameraIntrinsics);
  2416. calibrationRawPose = Posef.identity;
  2417. #if OVRPLUGIN_INCLUDE_MRC_ANDROID
  2418. if (version >= OVRP_1_38_0.version) // MRC functions are invalid before 1.38.0
  2419. #else
  2420. if (version >= OVRP_1_15_0.version)
  2421. #endif
  2422. {
  2423. bool retValue = true;
  2424. Result result = OVRP_1_15_0.ovrp_GetExternalCameraExtrinsics(cameraId, out cameraExtrinsics);
  2425. if (result != Result.Success)
  2426. {
  2427. retValue = false;
  2428. //Debug.LogWarning("ovrp_GetExternalCameraExtrinsics return " + result);
  2429. }
  2430. result = OVRP_1_15_0.ovrp_GetExternalCameraIntrinsics(cameraId, out cameraIntrinsics);
  2431. if (result != Result.Success)
  2432. {
  2433. retValue = false;
  2434. //Debug.LogWarning("ovrp_GetExternalCameraIntrinsics return " + result);
  2435. }
  2436. #if OVRPLUGIN_INCLUDE_MRC_ANDROID
  2437. result = OVRP_1_38_0.ovrp_GetExternalCameraCalibrationRawPose(cameraId, out calibrationRawPose);
  2438. if (result != Result.Success)
  2439. {
  2440. retValue = false;
  2441. //Debug.LogWarning("ovrp_GetExternalCameraCalibrationRawPose return " + result);
  2442. }
  2443. #endif
  2444. return retValue;
  2445. }
  2446. else
  2447. {
  2448. return false;
  2449. }
  2450. #endif
  2451. }
  2452. public static bool OverrideExternalCameraFov(int cameraId, bool useOverriddenFov, Fovf fov)
  2453. {
  2454. #if OVRPLUGIN_UNSUPPORTED_PLATFORM
  2455. return false;
  2456. #else
  2457. if (version >= OVRP_1_44_0.version)
  2458. {
  2459. bool retValue = true;
  2460. Result result = OVRP_1_44_0.ovrp_OverrideExternalCameraFov(cameraId, useOverriddenFov ? Bool.True : Bool.False, ref fov);
  2461. if (result != Result.Success)
  2462. {
  2463. retValue = false;
  2464. }
  2465. return retValue;
  2466. }
  2467. else
  2468. {
  2469. return false;
  2470. }
  2471. #endif
  2472. }
  2473. public static bool GetUseOverriddenExternalCameraFov(int cameraId)
  2474. {
  2475. #if OVRPLUGIN_UNSUPPORTED_PLATFORM
  2476. return false;
  2477. #else
  2478. if (version >= OVRP_1_44_0.version)
  2479. {
  2480. bool retValue = true;
  2481. Bool useOverriddenFov = Bool.False;
  2482. Result result = OVRP_1_44_0.ovrp_GetUseOverriddenExternalCameraFov(cameraId, out useOverriddenFov);
  2483. if (result != Result.Success)
  2484. {
  2485. retValue = false;
  2486. }
  2487. if (useOverriddenFov == Bool.False)
  2488. {
  2489. retValue = false;
  2490. }
  2491. return retValue;
  2492. }
  2493. else
  2494. {
  2495. return false;
  2496. }
  2497. #endif
  2498. }
  2499. public static bool OverrideExternalCameraStaticPose(int cameraId, bool useOverriddenPose, Posef pose)
  2500. {
  2501. #if OVRPLUGIN_UNSUPPORTED_PLATFORM
  2502. return false;
  2503. #else
  2504. if (version >= OVRP_1_44_0.version)
  2505. {
  2506. bool retValue = true;
  2507. Result result = OVRP_1_44_0.ovrp_OverrideExternalCameraStaticPose(cameraId, useOverriddenPose ? Bool.True : Bool.False, ref pose);
  2508. if (result != Result.Success)
  2509. {
  2510. retValue = false;
  2511. }
  2512. return retValue;
  2513. }
  2514. else
  2515. {
  2516. return false;
  2517. }
  2518. #endif
  2519. }
  2520. public static bool GetUseOverriddenExternalCameraStaticPose(int cameraId)
  2521. {
  2522. #if OVRPLUGIN_UNSUPPORTED_PLATFORM
  2523. return false;
  2524. #else
  2525. if (version >= OVRP_1_44_0.version)
  2526. {
  2527. bool retValue = true;
  2528. Bool useOverriddenStaticPose = Bool.False;
  2529. Result result = OVRP_1_44_0.ovrp_GetUseOverriddenExternalCameraStaticPose(cameraId, out useOverriddenStaticPose);
  2530. if (result != Result.Success)
  2531. {
  2532. retValue = false;
  2533. }
  2534. if (useOverriddenStaticPose == Bool.False)
  2535. {
  2536. retValue = false;
  2537. }
  2538. return retValue;
  2539. }
  2540. else
  2541. {
  2542. return false;
  2543. }
  2544. #endif
  2545. }
  2546. public static bool ResetDefaultExternalCamera()
  2547. {
  2548. #if OVRPLUGIN_UNSUPPORTED_PLATFORM
  2549. return false;
  2550. #else
  2551. if (version >= OVRP_1_44_0.version)
  2552. {
  2553. Result result = OVRP_1_44_0.ovrp_ResetDefaultExternalCamera();
  2554. if (result != Result.Success)
  2555. {
  2556. return false;
  2557. }
  2558. return true;
  2559. }
  2560. else
  2561. {
  2562. return false;
  2563. }
  2564. #endif
  2565. }
  2566. public static bool SetDefaultExternalCamera(string cameraName, ref CameraIntrinsics cameraIntrinsics, ref CameraExtrinsics cameraExtrinsics)
  2567. {
  2568. #if OVRPLUGIN_UNSUPPORTED_PLATFORM
  2569. return false;
  2570. #else
  2571. if (version >= OVRP_1_44_0.version)
  2572. {
  2573. Result result = OVRP_1_44_0.ovrp_SetDefaultExternalCamera(cameraName, ref cameraIntrinsics, ref cameraExtrinsics);
  2574. if (result != Result.Success)
  2575. {
  2576. return false;
  2577. }
  2578. return true;
  2579. }
  2580. else
  2581. {
  2582. return false;
  2583. }
  2584. #endif
  2585. }
  2586. public static Vector3f GetBoundaryDimensions(BoundaryType boundaryType)
  2587. {
  2588. #if OVRPLUGIN_UNSUPPORTED_PLATFORM
  2589. return new Vector3f();
  2590. #else
  2591. if (version >= OVRP_1_8_0.version)
  2592. {
  2593. return OVRP_1_8_0.ovrp_GetBoundaryDimensions(boundaryType);
  2594. }
  2595. else
  2596. {
  2597. return new Vector3f();
  2598. }
  2599. #endif
  2600. }
  2601. public static bool GetBoundaryVisible()
  2602. {
  2603. #if OVRPLUGIN_UNSUPPORTED_PLATFORM
  2604. return false;
  2605. #else
  2606. if (version >= OVRP_1_8_0.version)
  2607. {
  2608. return OVRP_1_8_0.ovrp_GetBoundaryVisible() == OVRPlugin.Bool.True;
  2609. }
  2610. else
  2611. {
  2612. return false;
  2613. }
  2614. #endif
  2615. }
  2616. public static bool SetBoundaryVisible(bool value)
  2617. {
  2618. #if OVRPLUGIN_UNSUPPORTED_PLATFORM
  2619. return false;
  2620. #else
  2621. if (version >= OVRP_1_8_0.version)
  2622. {
  2623. return OVRP_1_8_0.ovrp_SetBoundaryVisible(ToBool(value)) == OVRPlugin.Bool.True;
  2624. }
  2625. else
  2626. {
  2627. return false;
  2628. }
  2629. #endif
  2630. }
  2631. public static SystemHeadset GetSystemHeadsetType()
  2632. {
  2633. #if OVRPLUGIN_UNSUPPORTED_PLATFORM
  2634. return SystemHeadset.None;
  2635. #else
  2636. if (version >= OVRP_1_9_0.version)
  2637. return OVRP_1_9_0.ovrp_GetSystemHeadsetType();
  2638. return SystemHeadset.None;
  2639. #endif
  2640. }
  2641. public static Controller GetActiveController()
  2642. {
  2643. #if OVRPLUGIN_UNSUPPORTED_PLATFORM
  2644. return Controller.None;
  2645. #else
  2646. if (version >= OVRP_1_9_0.version)
  2647. return OVRP_1_9_0.ovrp_GetActiveController();
  2648. return Controller.None;
  2649. #endif
  2650. }
  2651. public static Controller GetConnectedControllers()
  2652. {
  2653. #if OVRPLUGIN_UNSUPPORTED_PLATFORM
  2654. return Controller.None;
  2655. #else
  2656. if (version >= OVRP_1_9_0.version)
  2657. return OVRP_1_9_0.ovrp_GetConnectedControllers();
  2658. return Controller.None;
  2659. #endif
  2660. }
  2661. private static Bool ToBool(bool b)
  2662. {
  2663. return (b) ? OVRPlugin.Bool.True : OVRPlugin.Bool.False;
  2664. }
  2665. public static TrackingOrigin GetTrackingOriginType()
  2666. {
  2667. #if OVRPLUGIN_UNSUPPORTED_PLATFORM
  2668. return default(TrackingOrigin);
  2669. #else
  2670. return OVRP_1_0_0.ovrp_GetTrackingOriginType();
  2671. #endif
  2672. }
  2673. public static bool SetTrackingOriginType(TrackingOrigin originType)
  2674. {
  2675. #if OVRPLUGIN_UNSUPPORTED_PLATFORM
  2676. return false;
  2677. #else
  2678. return OVRP_1_0_0.ovrp_SetTrackingOriginType(originType) == Bool.True;
  2679. #endif
  2680. }
  2681. public static Posef GetTrackingCalibratedOrigin()
  2682. {
  2683. #if OVRPLUGIN_UNSUPPORTED_PLATFORM
  2684. return Posef.identity;
  2685. #else
  2686. return OVRP_1_0_0.ovrp_GetTrackingCalibratedOrigin();
  2687. #endif
  2688. }
  2689. public static bool SetTrackingCalibratedOrigin()
  2690. {
  2691. #if OVRPLUGIN_UNSUPPORTED_PLATFORM
  2692. return false;
  2693. #else
  2694. return OVRP_1_2_0.ovrpi_SetTrackingCalibratedOrigin() == Bool.True;
  2695. #endif
  2696. }
  2697. public static bool RecenterTrackingOrigin(RecenterFlags flags)
  2698. {
  2699. #if OVRPLUGIN_UNSUPPORTED_PLATFORM
  2700. return false;
  2701. #else
  2702. return OVRP_1_0_0.ovrp_RecenterTrackingOrigin((uint)flags) == Bool.True;
  2703. #endif
  2704. }
  2705. #if UNITY_EDITOR || UNITY_STANDALONE_WIN
  2706. public static bool UpdateCameraDevices()
  2707. {
  2708. #if OVRPLUGIN_UNSUPPORTED_PLATFORM
  2709. return false;
  2710. #else
  2711. if (version >= OVRP_1_16_0.version)
  2712. {
  2713. Result result = OVRP_1_16_0.ovrp_UpdateCameraDevices();
  2714. if (result != Result.Success)
  2715. {
  2716. //Debug.LogWarning("ovrp_UpdateCameraDevices return " + result);
  2717. }
  2718. return result == Result.Success;
  2719. }
  2720. else
  2721. {
  2722. return false;
  2723. }
  2724. #endif
  2725. }
  2726. public static bool IsCameraDeviceAvailable(CameraDevice cameraDevice)
  2727. {
  2728. #if OVRPLUGIN_UNSUPPORTED_PLATFORM
  2729. return false;
  2730. #else
  2731. if (version >= OVRP_1_16_0.version)
  2732. {
  2733. Bool result = OVRP_1_16_0.ovrp_IsCameraDeviceAvailable(cameraDevice);
  2734. return result == Bool.True;
  2735. }
  2736. else
  2737. {
  2738. return false;
  2739. }
  2740. #endif
  2741. }
  2742. public static bool SetCameraDevicePreferredColorFrameSize(CameraDevice cameraDevice, int width, int height)
  2743. {
  2744. #if OVRPLUGIN_UNSUPPORTED_PLATFORM
  2745. return false;
  2746. #else
  2747. if (version >= OVRP_1_16_0.version)
  2748. {
  2749. Sizei size = new Sizei();
  2750. size.w = width;
  2751. size.h = height;
  2752. Result result = OVRP_1_16_0.ovrp_SetCameraDevicePreferredColorFrameSize(cameraDevice, size);
  2753. if (result != Result.Success)
  2754. {
  2755. //Debug.LogWarning("ovrp_SetCameraDevicePreferredColorFrameSize return " + result);
  2756. }
  2757. return result == Result.Success;
  2758. }
  2759. else
  2760. {
  2761. return false;
  2762. }
  2763. #endif
  2764. }
  2765. public static bool OpenCameraDevice(CameraDevice cameraDevice)
  2766. {
  2767. #if OVRPLUGIN_UNSUPPORTED_PLATFORM
  2768. return false;
  2769. #else
  2770. if (version >= OVRP_1_16_0.version)
  2771. {
  2772. Result result = OVRP_1_16_0.ovrp_OpenCameraDevice(cameraDevice);
  2773. if (result != Result.Success)
  2774. {
  2775. //Debug.LogWarning("ovrp_OpenCameraDevice return " + result);
  2776. }
  2777. return result == Result.Success;
  2778. }
  2779. else
  2780. {
  2781. return false;
  2782. }
  2783. #endif
  2784. }
  2785. public static bool CloseCameraDevice(CameraDevice cameraDevice)
  2786. {
  2787. #if OVRPLUGIN_UNSUPPORTED_PLATFORM
  2788. return false;
  2789. #else
  2790. if (version >= OVRP_1_16_0.version)
  2791. {
  2792. Result result = OVRP_1_16_0.ovrp_CloseCameraDevice(cameraDevice);
  2793. if (result != Result.Success)
  2794. {
  2795. //Debug.LogWarning("ovrp_OpenCameraDevice return " + result);
  2796. }
  2797. return result == Result.Success;
  2798. }
  2799. else
  2800. {
  2801. return false;
  2802. }
  2803. #endif
  2804. }
  2805. public static bool HasCameraDeviceOpened(CameraDevice cameraDevice)
  2806. {
  2807. #if OVRPLUGIN_UNSUPPORTED_PLATFORM
  2808. return false;
  2809. #else
  2810. if (version >= OVRP_1_16_0.version)
  2811. {
  2812. Bool result = OVRP_1_16_0.ovrp_HasCameraDeviceOpened(cameraDevice);
  2813. return result == Bool.True;
  2814. }
  2815. else
  2816. {
  2817. return false;
  2818. }
  2819. #endif
  2820. }
  2821. public static bool IsCameraDeviceColorFrameAvailable(CameraDevice cameraDevice)
  2822. {
  2823. #if OVRPLUGIN_UNSUPPORTED_PLATFORM
  2824. return false;
  2825. #else
  2826. if (version >= OVRP_1_16_0.version)
  2827. {
  2828. Bool result = OVRP_1_16_0.ovrp_IsCameraDeviceColorFrameAvailable(cameraDevice);
  2829. return result == Bool.True;
  2830. }
  2831. else
  2832. {
  2833. return false;
  2834. }
  2835. #endif
  2836. }
  2837. #if !OVRPLUGIN_UNSUPPORTED_PLATFORM
  2838. private static Texture2D cachedCameraFrameTexture = null;
  2839. #endif
  2840. public static Texture2D GetCameraDeviceColorFrameTexture(CameraDevice cameraDevice)
  2841. {
  2842. #if OVRPLUGIN_UNSUPPORTED_PLATFORM
  2843. return null;
  2844. #else
  2845. if (version >= OVRP_1_16_0.version)
  2846. {
  2847. Sizei size = new Sizei();
  2848. Result result = OVRP_1_16_0.ovrp_GetCameraDeviceColorFrameSize(cameraDevice, out size);
  2849. if (result != Result.Success)
  2850. {
  2851. //Debug.LogWarning("ovrp_GetCameraDeviceColorFrameSize return " + result);
  2852. return null;
  2853. }
  2854. IntPtr pixels;
  2855. int rowPitch;
  2856. result = OVRP_1_16_0.ovrp_GetCameraDeviceColorFrameBgraPixels(cameraDevice, out pixels, out rowPitch);
  2857. if (result != Result.Success)
  2858. {
  2859. //Debug.LogWarning("ovrp_GetCameraDeviceColorFrameBgraPixels return " + result);
  2860. return null;
  2861. }
  2862. if (rowPitch != size.w * 4)
  2863. {
  2864. //Debug.LogWarning(string.Format("RowPitch mismatch, expected {0}, get {1}", size.w * 4, rowPitch));
  2865. return null;
  2866. }
  2867. if (!cachedCameraFrameTexture || cachedCameraFrameTexture.width != size.w || cachedCameraFrameTexture.height != size.h)
  2868. {
  2869. cachedCameraFrameTexture = new Texture2D(size.w, size.h, TextureFormat.BGRA32, false);
  2870. }
  2871. cachedCameraFrameTexture.LoadRawTextureData(pixels, rowPitch * size.h);
  2872. cachedCameraFrameTexture.Apply();
  2873. return cachedCameraFrameTexture;
  2874. }
  2875. else
  2876. {
  2877. return null;
  2878. }
  2879. #endif
  2880. }
  2881. public static bool DoesCameraDeviceSupportDepth(CameraDevice cameraDevice)
  2882. {
  2883. #if OVRPLUGIN_UNSUPPORTED_PLATFORM
  2884. return false;
  2885. #else
  2886. if (version >= OVRP_1_17_0.version)
  2887. {
  2888. Bool supportDepth;
  2889. Result result = OVRP_1_17_0.ovrp_DoesCameraDeviceSupportDepth(cameraDevice, out supportDepth);
  2890. return result == Result.Success && supportDepth == Bool.True;
  2891. }
  2892. else
  2893. {
  2894. return false;
  2895. }
  2896. #endif
  2897. }
  2898. public static bool SetCameraDeviceDepthSensingMode(CameraDevice camera, CameraDeviceDepthSensingMode depthSensoringMode)
  2899. {
  2900. #if OVRPLUGIN_UNSUPPORTED_PLATFORM
  2901. return false;
  2902. #else
  2903. if (version >= OVRP_1_17_0.version)
  2904. {
  2905. Result result = OVRP_1_17_0.ovrp_SetCameraDeviceDepthSensingMode(camera, depthSensoringMode);
  2906. return result == Result.Success;
  2907. }
  2908. else
  2909. {
  2910. return false;
  2911. }
  2912. #endif
  2913. }
  2914. public static bool SetCameraDevicePreferredDepthQuality(CameraDevice camera, CameraDeviceDepthQuality depthQuality)
  2915. {
  2916. #if OVRPLUGIN_UNSUPPORTED_PLATFORM
  2917. return false;
  2918. #else
  2919. if (version >= OVRP_1_17_0.version)
  2920. {
  2921. Result result = OVRP_1_17_0.ovrp_SetCameraDevicePreferredDepthQuality(camera, depthQuality);
  2922. return result == Result.Success;
  2923. }
  2924. else
  2925. {
  2926. return false;
  2927. }
  2928. #endif
  2929. }
  2930. public static bool IsCameraDeviceDepthFrameAvailable(CameraDevice cameraDevice)
  2931. {
  2932. #if OVRPLUGIN_UNSUPPORTED_PLATFORM
  2933. return false;
  2934. #else
  2935. if (version >= OVRP_1_17_0.version)
  2936. {
  2937. Bool available;
  2938. Result result = OVRP_1_17_0.ovrp_IsCameraDeviceDepthFrameAvailable(cameraDevice, out available);
  2939. return result == Result.Success && available == Bool.True;
  2940. }
  2941. else
  2942. {
  2943. return false;
  2944. }
  2945. #endif
  2946. }
  2947. #if !OVRPLUGIN_UNSUPPORTED_PLATFORM
  2948. private static Texture2D cachedCameraDepthTexture = null;
  2949. #endif
  2950. public static Texture2D GetCameraDeviceDepthFrameTexture(CameraDevice cameraDevice)
  2951. {
  2952. #if OVRPLUGIN_UNSUPPORTED_PLATFORM
  2953. return null;
  2954. #else
  2955. if (version >= OVRP_1_17_0.version)
  2956. {
  2957. Sizei size = new Sizei();
  2958. Result result = OVRP_1_17_0.ovrp_GetCameraDeviceDepthFrameSize(cameraDevice, out size);
  2959. if (result != Result.Success)
  2960. {
  2961. //Debug.LogWarning("ovrp_GetCameraDeviceDepthFrameSize return " + result);
  2962. return null;
  2963. }
  2964. IntPtr depthData;
  2965. int rowPitch;
  2966. result = OVRP_1_17_0.ovrp_GetCameraDeviceDepthFramePixels(cameraDevice, out depthData, out rowPitch);
  2967. if (result != Result.Success)
  2968. {
  2969. //Debug.LogWarning("ovrp_GetCameraDeviceDepthFramePixels return " + result);
  2970. return null;
  2971. }
  2972. if (rowPitch != size.w * 4)
  2973. {
  2974. //Debug.LogWarning(string.Format("RowPitch mismatch, expected {0}, get {1}", size.w * 4, rowPitch));
  2975. return null;
  2976. }
  2977. if (!cachedCameraDepthTexture || cachedCameraDepthTexture.width != size.w || cachedCameraDepthTexture.height != size.h)
  2978. {
  2979. cachedCameraDepthTexture = new Texture2D(size.w, size.h, TextureFormat.RFloat, false);
  2980. cachedCameraDepthTexture.filterMode = FilterMode.Point;
  2981. }
  2982. cachedCameraDepthTexture.LoadRawTextureData(depthData, rowPitch * size.h);
  2983. cachedCameraDepthTexture.Apply();
  2984. return cachedCameraDepthTexture;
  2985. }
  2986. else
  2987. {
  2988. return null;
  2989. }
  2990. #endif
  2991. }
  2992. #if !OVRPLUGIN_UNSUPPORTED_PLATFORM
  2993. private static Texture2D cachedCameraDepthConfidenceTexture = null;
  2994. #endif
  2995. public static Texture2D GetCameraDeviceDepthConfidenceTexture(CameraDevice cameraDevice)
  2996. {
  2997. #if OVRPLUGIN_UNSUPPORTED_PLATFORM
  2998. return null;
  2999. #else
  3000. if (version >= OVRP_1_17_0.version)
  3001. {
  3002. Sizei size = new Sizei();
  3003. Result result = OVRP_1_17_0.ovrp_GetCameraDeviceDepthFrameSize(cameraDevice, out size);
  3004. if (result != Result.Success)
  3005. {
  3006. //Debug.LogWarning("ovrp_GetCameraDeviceDepthFrameSize return " + result);
  3007. return null;
  3008. }
  3009. IntPtr confidenceData;
  3010. int rowPitch;
  3011. result = OVRP_1_17_0.ovrp_GetCameraDeviceDepthConfidencePixels(cameraDevice, out confidenceData, out rowPitch);
  3012. if (result != Result.Success)
  3013. {
  3014. //Debug.LogWarning("ovrp_GetCameraDeviceDepthConfidencePixels return " + result);
  3015. return null;
  3016. }
  3017. if (rowPitch != size.w * 4)
  3018. {
  3019. //Debug.LogWarning(string.Format("RowPitch mismatch, expected {0}, get {1}", size.w * 4, rowPitch));
  3020. return null;
  3021. }
  3022. if (!cachedCameraDepthConfidenceTexture || cachedCameraDepthConfidenceTexture.width != size.w || cachedCameraDepthConfidenceTexture.height != size.h)
  3023. {
  3024. cachedCameraDepthConfidenceTexture = new Texture2D(size.w, size.h, TextureFormat.RFloat, false);
  3025. }
  3026. cachedCameraDepthConfidenceTexture.LoadRawTextureData(confidenceData, rowPitch * size.h);
  3027. cachedCameraDepthConfidenceTexture.Apply();
  3028. return cachedCameraDepthConfidenceTexture;
  3029. }
  3030. else
  3031. {
  3032. return null;
  3033. }
  3034. #endif
  3035. }
  3036. #endif
  3037. public static bool fixedFoveatedRenderingSupported
  3038. {
  3039. get
  3040. {
  3041. #if OVRPLUGIN_UNSUPPORTED_PLATFORM
  3042. return false;
  3043. #else
  3044. if (version >= OVRP_1_21_0.version)
  3045. {
  3046. Bool supported;
  3047. Result result = OVRP_1_21_0.ovrp_GetTiledMultiResSupported(out supported);
  3048. if (result == Result.Success)
  3049. {
  3050. return supported == Bool.True;
  3051. }
  3052. else
  3053. {
  3054. //Debug.LogWarning("ovrp_GetTiledMultiResSupported return " + result);
  3055. return false;
  3056. }
  3057. }
  3058. else
  3059. {
  3060. return false;
  3061. }
  3062. #endif
  3063. }
  3064. }
  3065. public static FixedFoveatedRenderingLevel fixedFoveatedRenderingLevel
  3066. {
  3067. get
  3068. {
  3069. #if OVRPLUGIN_UNSUPPORTED_PLATFORM
  3070. return FixedFoveatedRenderingLevel.Off;
  3071. #else
  3072. if (version >= OVRP_1_21_0.version && fixedFoveatedRenderingSupported)
  3073. {
  3074. FixedFoveatedRenderingLevel level;
  3075. Result result = OVRP_1_21_0.ovrp_GetTiledMultiResLevel(out level);
  3076. if (result != Result.Success)
  3077. {
  3078. //Debug.LogWarning("ovrp_GetTiledMultiResLevel return " + result);
  3079. }
  3080. return level;
  3081. }
  3082. else
  3083. {
  3084. return FixedFoveatedRenderingLevel.Off;
  3085. }
  3086. #endif
  3087. }
  3088. set
  3089. {
  3090. #if OVRPLUGIN_UNSUPPORTED_PLATFORM
  3091. return;
  3092. #else
  3093. if (version >= OVRP_1_21_0.version && fixedFoveatedRenderingSupported)
  3094. {
  3095. Result result = OVRP_1_21_0.ovrp_SetTiledMultiResLevel(value);
  3096. if (result != Result.Success)
  3097. {
  3098. //Debug.LogWarning("ovrp_SetTiledMultiResLevel return " + result);
  3099. }
  3100. }
  3101. #endif
  3102. }
  3103. }
  3104. [Obsolete("Please use fixedFoveatedRenderingSupported instead", false)]
  3105. public static bool tiledMultiResSupported
  3106. {
  3107. get
  3108. {
  3109. return fixedFoveatedRenderingSupported;
  3110. }
  3111. }
  3112. [Obsolete("Please use fixedFoveatedRenderingLevel instead", false)]
  3113. public static TiledMultiResLevel tiledMultiResLevel
  3114. {
  3115. get
  3116. {
  3117. return (TiledMultiResLevel)fixedFoveatedRenderingLevel;
  3118. }
  3119. set
  3120. {
  3121. fixedFoveatedRenderingLevel = (FixedFoveatedRenderingLevel)value;
  3122. }
  3123. }
  3124. public static bool gpuUtilSupported
  3125. {
  3126. get
  3127. {
  3128. #if OVRPLUGIN_UNSUPPORTED_PLATFORM
  3129. return false;
  3130. #else
  3131. if (version >= OVRP_1_21_0.version)
  3132. {
  3133. Bool supported;
  3134. Result result = OVRP_1_21_0.ovrp_GetGPUUtilSupported(out supported);
  3135. if (result == Result.Success)
  3136. {
  3137. return supported == Bool.True;
  3138. }
  3139. else
  3140. {
  3141. //Debug.LogWarning("ovrp_GetGPUUtilSupported return " + result);
  3142. return false;
  3143. }
  3144. }
  3145. else
  3146. {
  3147. return false;
  3148. }
  3149. #endif
  3150. }
  3151. }
  3152. public static float gpuUtilLevel
  3153. {
  3154. get
  3155. {
  3156. #if OVRPLUGIN_UNSUPPORTED_PLATFORM
  3157. return 0.0f;
  3158. #else
  3159. if (version >= OVRP_1_21_0.version && gpuUtilSupported)
  3160. {
  3161. float level;
  3162. Result result = OVRP_1_21_0.ovrp_GetGPUUtilLevel(out level);
  3163. if (result == Result.Success)
  3164. {
  3165. return level;
  3166. }
  3167. else
  3168. {
  3169. //Debug.LogWarning("ovrp_GetGPUUtilLevel return " + result);
  3170. return 0.0f;
  3171. }
  3172. }
  3173. else
  3174. {
  3175. return 0.0f;
  3176. }
  3177. #endif
  3178. }
  3179. }
  3180. #if !OVRPLUGIN_UNSUPPORTED_PLATFORM
  3181. private static OVRNativeBuffer _nativeSystemDisplayFrequenciesAvailable = null;
  3182. private static float[] _cachedSystemDisplayFrequenciesAvailable = null;
  3183. #endif
  3184. public static float[] systemDisplayFrequenciesAvailable
  3185. {
  3186. get
  3187. {
  3188. #if OVRPLUGIN_UNSUPPORTED_PLATFORM
  3189. return new float[0];
  3190. #else
  3191. if (_cachedSystemDisplayFrequenciesAvailable == null)
  3192. {
  3193. _cachedSystemDisplayFrequenciesAvailable = new float[0];
  3194. if (version >= OVRP_1_21_0.version)
  3195. {
  3196. int numFrequencies = 0;
  3197. Result result = OVRP_1_21_0.ovrp_GetSystemDisplayAvailableFrequencies(IntPtr.Zero, ref numFrequencies);
  3198. if (result == Result.Success)
  3199. {
  3200. if (numFrequencies > 0)
  3201. {
  3202. int maxNumElements = numFrequencies;
  3203. _nativeSystemDisplayFrequenciesAvailable = new OVRNativeBuffer(sizeof(float) * maxNumElements);
  3204. result = OVRP_1_21_0.ovrp_GetSystemDisplayAvailableFrequencies(_nativeSystemDisplayFrequenciesAvailable.GetPointer(), ref numFrequencies);
  3205. if (result == Result.Success)
  3206. {
  3207. int numElementsToCopy = (numFrequencies <= maxNumElements) ? numFrequencies : maxNumElements;
  3208. if (numElementsToCopy > 0)
  3209. {
  3210. _cachedSystemDisplayFrequenciesAvailable = new float[numElementsToCopy];
  3211. Marshal.Copy(_nativeSystemDisplayFrequenciesAvailable.GetPointer(), _cachedSystemDisplayFrequenciesAvailable, 0, numElementsToCopy);
  3212. }
  3213. }
  3214. }
  3215. }
  3216. }
  3217. }
  3218. return _cachedSystemDisplayFrequenciesAvailable;
  3219. #endif
  3220. }
  3221. }
  3222. public static float systemDisplayFrequency
  3223. {
  3224. get
  3225. {
  3226. #if OVRPLUGIN_UNSUPPORTED_PLATFORM
  3227. return 0.0f;
  3228. #else
  3229. if (version >= OVRP_1_21_0.version)
  3230. {
  3231. float displayFrequency;
  3232. Result result = OVRP_1_21_0.ovrp_GetSystemDisplayFrequency2(out displayFrequency);
  3233. if (result == Result.Success)
  3234. {
  3235. return displayFrequency;
  3236. }
  3237. return 0.0f;
  3238. }
  3239. else if (version >= OVRP_1_1_0.version)
  3240. {
  3241. return OVRP_1_1_0.ovrp_GetSystemDisplayFrequency();
  3242. }
  3243. else
  3244. {
  3245. return 0.0f;
  3246. }
  3247. #endif
  3248. }
  3249. set
  3250. {
  3251. #if OVRPLUGIN_UNSUPPORTED_PLATFORM
  3252. return;
  3253. #else
  3254. if (version >= OVRP_1_21_0.version)
  3255. {
  3256. OVRP_1_21_0.ovrp_SetSystemDisplayFrequency(value);
  3257. }
  3258. #endif
  3259. }
  3260. }
  3261. public static bool GetNodeFrustum2(Node nodeId, out Frustumf2 frustum)
  3262. {
  3263. frustum = default(Frustumf2);
  3264. #if OVRPLUGIN_UNSUPPORTED_PLATFORM
  3265. return false;
  3266. #else
  3267. if (version >= OVRP_1_15_0.version)
  3268. {
  3269. Result result = OVRP_1_15_0.ovrp_GetNodeFrustum2(nodeId, out frustum);
  3270. if (result != Result.Success)
  3271. {
  3272. return false;
  3273. }
  3274. else
  3275. {
  3276. return true;
  3277. }
  3278. }
  3279. else
  3280. {
  3281. return false;
  3282. }
  3283. #endif
  3284. }
  3285. public static bool AsymmetricFovEnabled
  3286. {
  3287. get
  3288. {
  3289. #if OVRPLUGIN_UNSUPPORTED_PLATFORM
  3290. return false;
  3291. #else
  3292. if (version >= OVRP_1_21_0.version)
  3293. {
  3294. Bool asymmetricFovEnabled = Bool.False;
  3295. Result result = OVRP_1_21_0.ovrp_GetAppAsymmetricFov(out asymmetricFovEnabled);
  3296. if (result != Result.Success)
  3297. {
  3298. return false;
  3299. }
  3300. else
  3301. {
  3302. return asymmetricFovEnabled == Bool.True;
  3303. }
  3304. }
  3305. else
  3306. {
  3307. return false;
  3308. }
  3309. #endif
  3310. }
  3311. }
  3312. public static bool EyeTextureArrayEnabled
  3313. {
  3314. get
  3315. {
  3316. #if OVRPLUGIN_UNSUPPORTED_PLATFORM
  3317. return false;
  3318. #else
  3319. if (version >= OVRP_1_15_0.version)
  3320. {
  3321. Bool enabled = Bool.False;
  3322. enabled = OVRP_1_15_0.ovrp_GetEyeTextureArrayEnabled();
  3323. return enabled == Bool.True;
  3324. }
  3325. else
  3326. {
  3327. return false;
  3328. }
  3329. #endif
  3330. }
  3331. }
  3332. public static Handedness GetDominantHand()
  3333. {
  3334. #if OVRPLUGIN_UNSUPPORTED_PLATFORM
  3335. return Handedness.Unsupported;
  3336. #else
  3337. Handedness dominantHand;
  3338. if (version >= OVRP_1_28_0.version && OVRP_1_28_0.ovrp_GetDominantHand(out dominantHand) == Result.Success)
  3339. {
  3340. return dominantHand;
  3341. }
  3342. return Handedness.Unsupported;
  3343. #endif
  3344. }
  3345. public static bool GetReorientHMDOnControllerRecenter()
  3346. {
  3347. #if OVRPLUGIN_UNSUPPORTED_PLATFORM
  3348. return false;
  3349. #else
  3350. Bool recenterMode;
  3351. if (version < OVRP_1_28_0.version || OVRP_1_28_0.ovrp_GetReorientHMDOnControllerRecenter(out recenterMode) != Result.Success)
  3352. return false;
  3353. return (recenterMode == Bool.True);
  3354. #endif
  3355. }
  3356. public static bool SetReorientHMDOnControllerRecenter(bool recenterSetting)
  3357. {
  3358. #if OVRPLUGIN_UNSUPPORTED_PLATFORM
  3359. return false;
  3360. #else
  3361. Bool ovrpBoolRecenterSetting = recenterSetting ? Bool.True : Bool.False;
  3362. if (version < OVRP_1_28_0.version || OVRP_1_28_0.ovrp_SetReorientHMDOnControllerRecenter(ovrpBoolRecenterSetting) != Result.Success)
  3363. return false;
  3364. return true;
  3365. #endif
  3366. }
  3367. public static bool SendEvent(string name, string param = "", string source = "")
  3368. {
  3369. #if OVRPLUGIN_UNSUPPORTED_PLATFORM
  3370. return false;
  3371. #else
  3372. if (version >= OVRP_1_30_0.version)
  3373. {
  3374. return OVRP_1_30_0.ovrp_SendEvent2(name, param, source.Length == 0 ? "integration": source) == Result.Success;
  3375. }
  3376. else if (version >= OVRP_1_28_0.version)
  3377. {
  3378. return OVRP_1_28_0.ovrp_SendEvent(name, param) == Result.Success;
  3379. }
  3380. else
  3381. {
  3382. return false;
  3383. }
  3384. #endif
  3385. }
  3386. public static bool SetHeadPoseModifier(ref Quatf relativeRotation, ref Vector3f relativeTranslation)
  3387. {
  3388. #if OVRPLUGIN_UNSUPPORTED_PLATFORM
  3389. return false;
  3390. #else
  3391. if (version >= OVRP_1_29_0.version)
  3392. {
  3393. return OVRP_1_29_0.ovrp_SetHeadPoseModifier(ref relativeRotation, ref relativeTranslation) == Result.Success;
  3394. }
  3395. else
  3396. {
  3397. return false;
  3398. }
  3399. #endif
  3400. }
  3401. public static bool GetHeadPoseModifier(out Quatf relativeRotation, out Vector3f relativeTranslation)
  3402. {
  3403. #if OVRPLUGIN_UNSUPPORTED_PLATFORM
  3404. relativeRotation = Quatf.identity;
  3405. relativeTranslation = Vector3f.zero;
  3406. return false;
  3407. #else
  3408. if (version >= OVRP_1_29_0.version)
  3409. {
  3410. return OVRP_1_29_0.ovrp_GetHeadPoseModifier(out relativeRotation, out relativeTranslation) == Result.Success;
  3411. }
  3412. else
  3413. {
  3414. relativeRotation = Quatf.identity;
  3415. relativeTranslation = Vector3f.zero;
  3416. return false;
  3417. }
  3418. #endif
  3419. }
  3420. public static bool IsPerfMetricsSupported(PerfMetrics perfMetrics)
  3421. {
  3422. #if OVRPLUGIN_UNSUPPORTED_PLATFORM
  3423. return false;
  3424. #else
  3425. if (version >= OVRP_1_30_0.version)
  3426. {
  3427. Bool isSupported;
  3428. Result result = OVRP_1_30_0.ovrp_IsPerfMetricsSupported(perfMetrics, out isSupported);
  3429. if (result == Result.Success)
  3430. {
  3431. return isSupported == Bool.True;
  3432. }
  3433. else
  3434. {
  3435. return false;
  3436. }
  3437. }
  3438. else
  3439. {
  3440. return false;
  3441. }
  3442. #endif
  3443. }
  3444. public static float? GetPerfMetricsFloat(PerfMetrics perfMetrics)
  3445. {
  3446. #if OVRPLUGIN_UNSUPPORTED_PLATFORM
  3447. return null;
  3448. #else
  3449. if (version >= OVRP_1_30_0.version)
  3450. {
  3451. float value;
  3452. Result result = OVRP_1_30_0.ovrp_GetPerfMetricsFloat(perfMetrics, out value);
  3453. if (result == Result.Success)
  3454. {
  3455. return value;
  3456. }
  3457. else
  3458. {
  3459. return null;
  3460. }
  3461. }
  3462. else
  3463. {
  3464. return null;
  3465. }
  3466. #endif
  3467. }
  3468. public static int? GetPerfMetricsInt(PerfMetrics perfMetrics)
  3469. {
  3470. #if OVRPLUGIN_UNSUPPORTED_PLATFORM
  3471. return null;
  3472. #else
  3473. if (version >= OVRP_1_30_0.version)
  3474. {
  3475. int value;
  3476. Result result = OVRP_1_30_0.ovrp_GetPerfMetricsInt(perfMetrics, out value);
  3477. if (result == Result.Success)
  3478. {
  3479. return value;
  3480. }
  3481. else
  3482. {
  3483. return null;
  3484. }
  3485. }
  3486. else
  3487. {
  3488. return null;
  3489. }
  3490. #endif
  3491. }
  3492. public static double GetTimeInSeconds()
  3493. {
  3494. #if OVRPLUGIN_UNSUPPORTED_PLATFORM
  3495. return 0.0;
  3496. #else
  3497. if (version >= OVRP_1_31_0.version)
  3498. {
  3499. double value;
  3500. Result result = OVRP_1_31_0.ovrp_GetTimeInSeconds(out value);
  3501. if (result == Result.Success)
  3502. {
  3503. return value;
  3504. }
  3505. else
  3506. {
  3507. return 0.0;
  3508. }
  3509. }
  3510. else
  3511. {
  3512. return 0.0;
  3513. }
  3514. #endif
  3515. }
  3516. public static bool SetColorScaleAndOffset(Vector4 colorScale, Vector4 colorOffset, bool applyToAllLayers)
  3517. {
  3518. #if OVRPLUGIN_UNSUPPORTED_PLATFORM
  3519. return false;
  3520. #else
  3521. #if USING_XR_SDK
  3522. OculusXRPlugin.SetColorScale(colorScale.x, colorScale.y, colorScale.z, colorScale.w);
  3523. OculusXRPlugin.SetColorOffset(colorOffset.x, colorOffset.y, colorOffset.z, colorOffset.w);
  3524. return true;
  3525. #else
  3526. if (version >= OVRP_1_31_0.version)
  3527. {
  3528. Bool ovrpApplyToAllLayers = applyToAllLayers ? Bool.True : Bool.False;
  3529. return OVRP_1_31_0.ovrp_SetColorScaleAndOffset(colorScale, colorOffset, ovrpApplyToAllLayers) == Result.Success;
  3530. }
  3531. else
  3532. {
  3533. return false;
  3534. }
  3535. #endif
  3536. #endif
  3537. }
  3538. public static bool AddCustomMetadata(string name, string param = "")
  3539. {
  3540. #if OVRPLUGIN_UNSUPPORTED_PLATFORM
  3541. return false;
  3542. #else
  3543. if (version >= OVRP_1_32_0.version)
  3544. {
  3545. return OVRP_1_32_0.ovrp_AddCustomMetadata(name, param) == Result.Success;
  3546. }
  3547. else
  3548. {
  3549. return false;
  3550. }
  3551. #endif
  3552. }
  3553. public class Media
  3554. {
  3555. public enum MrcActivationMode
  3556. {
  3557. Automatic = 0,
  3558. Disabled = 1,
  3559. EnumSize = 0x7fffffff
  3560. }
  3561. public enum InputVideoBufferType
  3562. {
  3563. Memory = 0,
  3564. TextureHandle = 1,
  3565. EnumSize = 0x7fffffff
  3566. }
  3567. public static bool Initialize()
  3568. {
  3569. #if OVRPLUGIN_UNSUPPORTED_PLATFORM
  3570. return false;
  3571. #else
  3572. if (version >= OVRP_1_38_0.version)
  3573. {
  3574. return OVRP_1_38_0.ovrp_Media_Initialize() == Result.Success;
  3575. }
  3576. else
  3577. {
  3578. return false;
  3579. }
  3580. #endif
  3581. }
  3582. public static bool Shutdown()
  3583. {
  3584. #if OVRPLUGIN_UNSUPPORTED_PLATFORM
  3585. return false;
  3586. #else
  3587. if (version >= OVRP_1_38_0.version)
  3588. {
  3589. return OVRP_1_38_0.ovrp_Media_Shutdown() == Result.Success;
  3590. }
  3591. else
  3592. {
  3593. return false;
  3594. }
  3595. #endif
  3596. }
  3597. public static bool GetInitialized()
  3598. {
  3599. #if OVRPLUGIN_UNSUPPORTED_PLATFORM
  3600. return false;
  3601. #else
  3602. if (version >= OVRP_1_38_0.version)
  3603. {
  3604. Bool initialized = Bool.False;
  3605. Result result = OVRP_1_38_0.ovrp_Media_GetInitialized(out initialized);
  3606. if (result == Result.Success)
  3607. {
  3608. return initialized == Bool.True ? true : false;
  3609. }
  3610. else
  3611. {
  3612. return false;
  3613. }
  3614. }
  3615. else
  3616. {
  3617. return false;
  3618. }
  3619. #endif
  3620. }
  3621. public static bool Update()
  3622. {
  3623. #if OVRPLUGIN_UNSUPPORTED_PLATFORM
  3624. return false;
  3625. #else
  3626. if (version >= OVRP_1_38_0.version)
  3627. {
  3628. return OVRP_1_38_0.ovrp_Media_Update() == Result.Success;
  3629. }
  3630. else
  3631. {
  3632. return false;
  3633. }
  3634. #endif
  3635. }
  3636. public static MrcActivationMode GetMrcActivationMode()
  3637. {
  3638. #if OVRPLUGIN_UNSUPPORTED_PLATFORM
  3639. return MrcActivationMode.Disabled;
  3640. #else
  3641. if (version >= OVRP_1_38_0.version)
  3642. {
  3643. MrcActivationMode mode;
  3644. if (OVRP_1_38_0.ovrp_Media_GetMrcActivationMode(out mode) == Result.Success)
  3645. {
  3646. return mode;
  3647. }
  3648. else
  3649. {
  3650. return default(MrcActivationMode);
  3651. }
  3652. }
  3653. else
  3654. {
  3655. return default(MrcActivationMode);
  3656. }
  3657. #endif
  3658. }
  3659. public static bool SetMrcActivationMode(MrcActivationMode mode)
  3660. {
  3661. #if OVRPLUGIN_UNSUPPORTED_PLATFORM
  3662. return false;
  3663. #else
  3664. if (version >= OVRP_1_38_0.version)
  3665. {
  3666. return OVRP_1_38_0.ovrp_Media_SetMrcActivationMode(mode) == Result.Success;
  3667. }
  3668. else
  3669. {
  3670. return false;
  3671. }
  3672. #endif
  3673. }
  3674. public static bool IsMrcEnabled()
  3675. {
  3676. #if OVRPLUGIN_UNSUPPORTED_PLATFORM
  3677. return false;
  3678. #else
  3679. if (version >= OVRP_1_38_0.version)
  3680. {
  3681. Bool b;
  3682. if (OVRP_1_38_0.ovrp_Media_IsMrcEnabled(out b) == Result.Success)
  3683. {
  3684. return b == Bool.True ? true : false;
  3685. }
  3686. else
  3687. {
  3688. return false;
  3689. }
  3690. }
  3691. else
  3692. {
  3693. return false;
  3694. }
  3695. #endif
  3696. }
  3697. public static bool IsMrcActivated()
  3698. {
  3699. #if OVRPLUGIN_UNSUPPORTED_PLATFORM
  3700. return false;
  3701. #else
  3702. if (version >= OVRP_1_38_0.version)
  3703. {
  3704. Bool b;
  3705. if (OVRP_1_38_0.ovrp_Media_IsMrcActivated(out b) == Result.Success)
  3706. {
  3707. return b == Bool.True ? true : false;
  3708. }
  3709. else
  3710. {
  3711. return false;
  3712. }
  3713. }
  3714. else
  3715. {
  3716. return false;
  3717. }
  3718. #endif
  3719. }
  3720. public static bool UseMrcDebugCamera()
  3721. {
  3722. #if OVRPLUGIN_UNSUPPORTED_PLATFORM
  3723. return false;
  3724. #else
  3725. if (version >= OVRP_1_38_0.version)
  3726. {
  3727. Bool b;
  3728. if (OVRP_1_38_0.ovrp_Media_UseMrcDebugCamera(out b) == Result.Success)
  3729. {
  3730. return b == Bool.True ? true : false;
  3731. }
  3732. else
  3733. {
  3734. return false;
  3735. }
  3736. }
  3737. else
  3738. {
  3739. return false;
  3740. }
  3741. #endif
  3742. }
  3743. public static bool SetMrcInputVideoBufferType(InputVideoBufferType videoBufferType)
  3744. {
  3745. #if OVRPLUGIN_UNSUPPORTED_PLATFORM
  3746. return false;
  3747. #else
  3748. if (version >= OVRP_1_38_0.version)
  3749. {
  3750. if (OVRP_1_38_0.ovrp_Media_SetMrcInputVideoBufferType(videoBufferType) == Result.Success)
  3751. {
  3752. return true;
  3753. }
  3754. else
  3755. {
  3756. return false;
  3757. }
  3758. }
  3759. else
  3760. {
  3761. return false;
  3762. }
  3763. #endif
  3764. }
  3765. public static InputVideoBufferType GetMrcInputVideoBufferType()
  3766. {
  3767. #if OVRPLUGIN_UNSUPPORTED_PLATFORM
  3768. return InputVideoBufferType.Memory;
  3769. #else
  3770. if (version >= OVRP_1_38_0.version)
  3771. {
  3772. InputVideoBufferType videoBufferType = InputVideoBufferType.Memory;
  3773. OVRP_1_38_0.ovrp_Media_GetMrcInputVideoBufferType(ref videoBufferType);
  3774. return videoBufferType;
  3775. }
  3776. else
  3777. {
  3778. return InputVideoBufferType.Memory;
  3779. }
  3780. #endif
  3781. }
  3782. public static bool SetMrcFrameSize(int frameWidth, int frameHeight)
  3783. {
  3784. #if OVRPLUGIN_UNSUPPORTED_PLATFORM
  3785. return false;
  3786. #else
  3787. if (version >= OVRP_1_38_0.version)
  3788. {
  3789. if (OVRP_1_38_0.ovrp_Media_SetMrcFrameSize(frameWidth, frameHeight) == Result.Success)
  3790. {
  3791. return true;
  3792. }
  3793. else
  3794. {
  3795. return false;
  3796. }
  3797. }
  3798. else
  3799. {
  3800. return false;
  3801. }
  3802. #endif
  3803. }
  3804. public static void GetMrcFrameSize(out int frameWidth, out int frameHeight)
  3805. {
  3806. frameWidth = -1;
  3807. frameHeight = -1;
  3808. #if !OVRPLUGIN_UNSUPPORTED_PLATFORM
  3809. if (version >= OVRP_1_38_0.version)
  3810. {
  3811. OVRP_1_38_0.ovrp_Media_GetMrcFrameSize(ref frameWidth, ref frameHeight);
  3812. }
  3813. #endif
  3814. }
  3815. public static bool SetMrcAudioSampleRate(int sampleRate)
  3816. {
  3817. #if OVRPLUGIN_UNSUPPORTED_PLATFORM
  3818. return false;
  3819. #else
  3820. if (version >= OVRP_1_38_0.version)
  3821. {
  3822. if (OVRP_1_38_0.ovrp_Media_SetMrcAudioSampleRate(sampleRate) == Result.Success)
  3823. {
  3824. return true;
  3825. }
  3826. else
  3827. {
  3828. return false;
  3829. }
  3830. }
  3831. else
  3832. {
  3833. return false;
  3834. }
  3835. #endif
  3836. }
  3837. public static int GetMrcAudioSampleRate()
  3838. {
  3839. #if OVRPLUGIN_UNSUPPORTED_PLATFORM
  3840. return 0;
  3841. #else
  3842. int sampleRate = 0;
  3843. if (version >= OVRP_1_38_0.version)
  3844. {
  3845. OVRP_1_38_0.ovrp_Media_GetMrcAudioSampleRate(ref sampleRate);
  3846. }
  3847. return sampleRate;
  3848. #endif
  3849. }
  3850. public static bool SetMrcFrameImageFlipped(bool imageFlipped)
  3851. {
  3852. #if OVRPLUGIN_UNSUPPORTED_PLATFORM
  3853. return false;
  3854. #else
  3855. if (version >= OVRP_1_38_0.version)
  3856. {
  3857. Bool flipped = imageFlipped ? Bool.True : Bool.False;
  3858. if (OVRP_1_38_0.ovrp_Media_SetMrcFrameImageFlipped(flipped) == Result.Success)
  3859. {
  3860. return true;
  3861. }
  3862. else
  3863. {
  3864. return false;
  3865. }
  3866. }
  3867. else
  3868. {
  3869. return false;
  3870. }
  3871. #endif
  3872. }
  3873. public static bool GetMrcFrameImageFlipped()
  3874. {
  3875. #if OVRPLUGIN_UNSUPPORTED_PLATFORM
  3876. return false;
  3877. #else
  3878. Bool flipped = 0;
  3879. if (version >= OVRP_1_38_0.version)
  3880. {
  3881. OVRP_1_38_0.ovrp_Media_GetMrcFrameImageFlipped(ref flipped);
  3882. }
  3883. return flipped == Bool.True ? true : false;
  3884. #endif
  3885. }
  3886. public static bool EncodeMrcFrame(System.IntPtr textureHandle, float[] audioData, int audioFrames, int audioChannels, double timestamp, ref int outSyncId)
  3887. {
  3888. #if OVRPLUGIN_UNSUPPORTED_PLATFORM
  3889. return false;
  3890. #else
  3891. if (version >= OVRP_1_38_0.version)
  3892. {
  3893. if (textureHandle == System.IntPtr.Zero)
  3894. {
  3895. Debug.LogError("EncodeMrcFrame: textureHandle is null");
  3896. return false;
  3897. }
  3898. InputVideoBufferType videoBufferType = GetMrcInputVideoBufferType();
  3899. if (videoBufferType != InputVideoBufferType.TextureHandle)
  3900. {
  3901. Debug.LogError("EncodeMrcFrame: videoBufferType mismatch");
  3902. return false;
  3903. }
  3904. GCHandle pinnedAudioData = new GCHandle();
  3905. IntPtr audioDataPtr = IntPtr.Zero;
  3906. int audioDataLen = 0;
  3907. if (audioData != null)
  3908. {
  3909. pinnedAudioData = GCHandle.Alloc(audioData, GCHandleType.Pinned);
  3910. audioDataPtr = pinnedAudioData.AddrOfPinnedObject();
  3911. audioDataLen = audioFrames * 4;
  3912. }
  3913. Result result = OVRP_1_38_0.ovrp_Media_EncodeMrcFrame(textureHandle, audioDataPtr, audioDataLen, audioChannels, timestamp, ref outSyncId);
  3914. if (audioData != null)
  3915. {
  3916. pinnedAudioData.Free();
  3917. }
  3918. return result == Result.Success;
  3919. }
  3920. else
  3921. {
  3922. return false;
  3923. }
  3924. #endif
  3925. }
  3926. #if !OVRPLUGIN_UNSUPPORTED_PLATFORM
  3927. static Texture2D cachedTexture = null;
  3928. #endif
  3929. public static bool EncodeMrcFrame(RenderTexture frame, float[] audioData, int audioFrames, int audioChannels, double timestamp, ref int outSyncId)
  3930. {
  3931. #if OVRPLUGIN_UNSUPPORTED_PLATFORM
  3932. return false;
  3933. #else
  3934. if (version >= OVRP_1_38_0.version)
  3935. {
  3936. if (frame == null)
  3937. {
  3938. Debug.LogError("EncodeMrcFrame: frame is null");
  3939. return false;
  3940. }
  3941. InputVideoBufferType videoBufferType = GetMrcInputVideoBufferType();
  3942. if (videoBufferType != InputVideoBufferType.Memory)
  3943. {
  3944. Debug.LogError("EncodeMrcFrame: videoBufferType mismatch");
  3945. return false;
  3946. }
  3947. GCHandle pinnedArray = new GCHandle();
  3948. IntPtr pointer = IntPtr.Zero;
  3949. if (cachedTexture == null || cachedTexture.width != frame.width || cachedTexture.height != frame.height)
  3950. {
  3951. cachedTexture = new Texture2D(frame.width, frame.height, TextureFormat.ARGB32, false);
  3952. }
  3953. RenderTexture lastActive = RenderTexture.active;
  3954. RenderTexture.active = frame;
  3955. cachedTexture.ReadPixels(new Rect(0, 0, frame.width, frame.height), 0, 0);
  3956. RenderTexture.active = lastActive;
  3957. Color32[] bytes = cachedTexture.GetPixels32(0);
  3958. pinnedArray = GCHandle.Alloc(bytes, GCHandleType.Pinned);
  3959. pointer = pinnedArray.AddrOfPinnedObject();
  3960. GCHandle pinnedAudioData = new GCHandle();
  3961. IntPtr audioDataPtr = IntPtr.Zero;
  3962. int audioDataLen = 0;
  3963. if (audioData != null)
  3964. {
  3965. pinnedAudioData = GCHandle.Alloc(audioData, GCHandleType.Pinned);
  3966. audioDataPtr = pinnedAudioData.AddrOfPinnedObject();
  3967. audioDataLen = audioFrames * 4;
  3968. }
  3969. Result result = OVRP_1_38_0.ovrp_Media_EncodeMrcFrame(pointer, audioDataPtr, audioDataLen, audioChannels, timestamp, ref outSyncId);
  3970. pinnedArray.Free();
  3971. if (audioData != null)
  3972. {
  3973. pinnedAudioData.Free();
  3974. }
  3975. return result == Result.Success;
  3976. }
  3977. else
  3978. {
  3979. return false;
  3980. }
  3981. #endif
  3982. }
  3983. public static bool SyncMrcFrame(int syncId)
  3984. {
  3985. #if OVRPLUGIN_UNSUPPORTED_PLATFORM
  3986. return false;
  3987. #else
  3988. if (version >= OVRP_1_38_0.version)
  3989. {
  3990. return OVRP_1_38_0.ovrp_Media_SyncMrcFrame(syncId) == Result.Success;
  3991. }
  3992. else
  3993. {
  3994. return false;
  3995. }
  3996. #endif
  3997. }
  3998. }
  3999. public static bool SetDeveloperMode(Bool active)
  4000. {
  4001. #if OVRPLUGIN_UNSUPPORTED_PLATFORM
  4002. return false;
  4003. #else
  4004. if(version >= OVRP_1_38_0.version)
  4005. {
  4006. return OVRP_1_38_0.ovrp_SetDeveloperMode(active) == Result.Success;
  4007. }
  4008. else
  4009. {
  4010. return false;
  4011. }
  4012. #endif
  4013. }
  4014. public static float GetAdaptiveGPUPerformanceScale()
  4015. {
  4016. #if OVRPLUGIN_UNSUPPORTED_PLATFORM
  4017. return 1.0f;
  4018. #else
  4019. if (version >= OVRP_1_42_0.version)
  4020. {
  4021. float adaptiveScale = 1.0f;
  4022. if (OVRP_1_42_0.ovrp_GetAdaptiveGpuPerformanceScale2(ref adaptiveScale) == Result.Success)
  4023. {
  4024. return adaptiveScale;
  4025. }
  4026. return 1.0f;
  4027. }
  4028. else
  4029. {
  4030. return 1.0f;
  4031. }
  4032. #endif
  4033. }
  4034. public static bool GetHandTrackingEnabled()
  4035. {
  4036. #if OVRPLUGIN_UNSUPPORTED_PLATFORM
  4037. return false;
  4038. #else
  4039. if (version >= OVRP_1_44_0.version)
  4040. {
  4041. Bool val = OVRPlugin.Bool.False;
  4042. Result res = OVRP_1_44_0.ovrp_GetHandTrackingEnabled(ref val);
  4043. if (res == Result.Success)
  4044. {
  4045. return val == OVRPlugin.Bool.True;
  4046. }
  4047. return false;
  4048. }
  4049. else
  4050. {
  4051. return false;
  4052. }
  4053. #endif
  4054. }
  4055. private static HandStateInternal cachedHandState = new HandStateInternal();
  4056. public static bool GetHandState(Step stepId, Hand hand, ref HandState handState)
  4057. {
  4058. #if OVRPLUGIN_UNSUPPORTED_PLATFORM
  4059. return false;
  4060. #else
  4061. if (version >= OVRP_1_44_0.version)
  4062. {
  4063. Result res = OVRP_1_44_0.ovrp_GetHandState(stepId, hand, out cachedHandState);
  4064. if (res == Result.Success)
  4065. {
  4066. // attempt to avoid allocations if client provides appropriately pre-initialized HandState
  4067. if (handState.BoneRotations == null || handState.BoneRotations.Length != ((int)BoneId.Hand_End - (int)BoneId.Hand_Start))
  4068. {
  4069. handState.BoneRotations = new Quatf[(int)BoneId.Hand_End - (int)BoneId.Hand_Start];
  4070. }
  4071. if (handState.PinchStrength == null || handState.PinchStrength.Length != (int)HandFinger.Max)
  4072. {
  4073. handState.PinchStrength = new float[(int)HandFinger.Max];
  4074. }
  4075. if (handState.FingerConfidences == null || handState.FingerConfidences.Length != (int)HandFinger.Max)
  4076. {
  4077. handState.FingerConfidences = new TrackingConfidence[(int)HandFinger.Max];
  4078. }
  4079. // unrolling the arrays is necessary to avoid per-frame allocations during marshaling
  4080. handState.Status = cachedHandState.Status;
  4081. handState.RootPose = cachedHandState.RootPose;
  4082. handState.BoneRotations[0] = cachedHandState.BoneRotations_0;
  4083. handState.BoneRotations[1] = cachedHandState.BoneRotations_1;
  4084. handState.BoneRotations[2] = cachedHandState.BoneRotations_2;
  4085. handState.BoneRotations[3] = cachedHandState.BoneRotations_3;
  4086. handState.BoneRotations[4] = cachedHandState.BoneRotations_4;
  4087. handState.BoneRotations[5] = cachedHandState.BoneRotations_5;
  4088. handState.BoneRotations[6] = cachedHandState.BoneRotations_6;
  4089. handState.BoneRotations[7] = cachedHandState.BoneRotations_7;
  4090. handState.BoneRotations[8] = cachedHandState.BoneRotations_8;
  4091. handState.BoneRotations[9] = cachedHandState.BoneRotations_9;
  4092. handState.BoneRotations[10] = cachedHandState.BoneRotations_10;
  4093. handState.BoneRotations[11] = cachedHandState.BoneRotations_11;
  4094. handState.BoneRotations[12] = cachedHandState.BoneRotations_12;
  4095. handState.BoneRotations[13] = cachedHandState.BoneRotations_13;
  4096. handState.BoneRotations[14] = cachedHandState.BoneRotations_14;
  4097. handState.BoneRotations[15] = cachedHandState.BoneRotations_15;
  4098. handState.BoneRotations[16] = cachedHandState.BoneRotations_16;
  4099. handState.BoneRotations[17] = cachedHandState.BoneRotations_17;
  4100. handState.BoneRotations[18] = cachedHandState.BoneRotations_18;
  4101. handState.BoneRotations[19] = cachedHandState.BoneRotations_19;
  4102. handState.BoneRotations[20] = cachedHandState.BoneRotations_20;
  4103. handState.BoneRotations[21] = cachedHandState.BoneRotations_21;
  4104. handState.BoneRotations[22] = cachedHandState.BoneRotations_22;
  4105. handState.BoneRotations[23] = cachedHandState.BoneRotations_23;
  4106. handState.Pinches = cachedHandState.Pinches;
  4107. handState.PinchStrength[0] = cachedHandState.PinchStrength_0;
  4108. handState.PinchStrength[1] = cachedHandState.PinchStrength_1;
  4109. handState.PinchStrength[2] = cachedHandState.PinchStrength_2;
  4110. handState.PinchStrength[3] = cachedHandState.PinchStrength_3;
  4111. handState.PinchStrength[4] = cachedHandState.PinchStrength_4;
  4112. handState.PointerPose = cachedHandState.PointerPose;
  4113. handState.HandScale = cachedHandState.HandScale;
  4114. handState.HandConfidence = cachedHandState.HandConfidence;
  4115. handState.FingerConfidences[0] = cachedHandState.FingerConfidences_0;
  4116. handState.FingerConfidences[1] = cachedHandState.FingerConfidences_1;
  4117. handState.FingerConfidences[2] = cachedHandState.FingerConfidences_2;
  4118. handState.FingerConfidences[3] = cachedHandState.FingerConfidences_3;
  4119. handState.FingerConfidences[4] = cachedHandState.FingerConfidences_4;
  4120. handState.RequestedTimeStamp = cachedHandState.RequestedTimeStamp;
  4121. handState.SampleTimeStamp = cachedHandState.SampleTimeStamp;
  4122. return true;
  4123. }
  4124. else
  4125. {
  4126. return false;
  4127. }
  4128. }
  4129. else
  4130. {
  4131. return false;
  4132. }
  4133. #endif
  4134. }
  4135. public static bool GetSkeleton(SkeletonType skeletonType, out Skeleton skeleton)
  4136. {
  4137. #if OVRPLUGIN_UNSUPPORTED_PLATFORM
  4138. skeleton = default(Skeleton);
  4139. return false;
  4140. #else
  4141. if (version >= OVRP_1_44_0.version)
  4142. {
  4143. return OVRP_1_44_0.ovrp_GetSkeleton(skeletonType, out skeleton) == Result.Success;
  4144. }
  4145. else
  4146. {
  4147. skeleton = default(Skeleton);
  4148. return false;
  4149. }
  4150. #endif
  4151. }
  4152. public static bool GetMesh(MeshType meshType, out Mesh mesh)
  4153. {
  4154. #if OVRPLUGIN_UNSUPPORTED_PLATFORM
  4155. mesh = default(Mesh);
  4156. return false;
  4157. #else
  4158. if (version >= OVRP_1_44_0.version)
  4159. {
  4160. return OVRP_1_44_0.ovrp_GetMesh(meshType, out mesh) == Result.Success;
  4161. }
  4162. else
  4163. {
  4164. mesh = default(Mesh);
  4165. return false;
  4166. }
  4167. #endif
  4168. }
  4169. private const string pluginName = "OVRPlugin";
  4170. private static System.Version _versionZero = new System.Version(0, 0, 0);
  4171. // Disable all the DllImports when the platform is not supported
  4172. #if !OVRPLUGIN_UNSUPPORTED_PLATFORM
  4173. private static class OVRP_0_1_0
  4174. {
  4175. public static readonly System.Version version = new System.Version(0, 1, 0);
  4176. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl)]
  4177. public static extern Sizei ovrp_GetEyeTextureSize(Eye eyeId);
  4178. }
  4179. private static class OVRP_0_1_1
  4180. {
  4181. public static readonly System.Version version = new System.Version(0, 1, 1);
  4182. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl)]
  4183. public static extern Bool ovrp_SetOverlayQuad2(Bool onTop, Bool headLocked, IntPtr texture, IntPtr device, Posef pose, Vector3f scale);
  4184. }
  4185. private static class OVRP_0_1_2
  4186. {
  4187. public static readonly System.Version version = new System.Version(0, 1, 2);
  4188. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl)]
  4189. public static extern Posef ovrp_GetNodePose(Node nodeId);
  4190. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl)]
  4191. public static extern Bool ovrp_SetControllerVibration(uint controllerMask, float frequency, float amplitude);
  4192. }
  4193. private static class OVRP_0_1_3
  4194. {
  4195. public static readonly System.Version version = new System.Version(0, 1, 3);
  4196. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl)]
  4197. public static extern Posef ovrp_GetNodeVelocity(Node nodeId);
  4198. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl)]
  4199. public static extern Posef ovrp_GetNodeAcceleration(Node nodeId);
  4200. }
  4201. private static class OVRP_0_5_0
  4202. {
  4203. public static readonly System.Version version = new System.Version(0, 5, 0);
  4204. }
  4205. private static class OVRP_1_0_0
  4206. {
  4207. public static readonly System.Version version = new System.Version(1, 0, 0);
  4208. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl)]
  4209. public static extern TrackingOrigin ovrp_GetTrackingOriginType();
  4210. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl)]
  4211. public static extern Bool ovrp_SetTrackingOriginType(TrackingOrigin originType);
  4212. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl)]
  4213. public static extern Posef ovrp_GetTrackingCalibratedOrigin();
  4214. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl)]
  4215. public static extern Bool ovrp_RecenterTrackingOrigin(uint flags);
  4216. }
  4217. private static class OVRP_1_1_0
  4218. {
  4219. public static readonly System.Version version = new System.Version(1, 1, 0);
  4220. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl)]
  4221. public static extern Bool ovrp_GetInitialized();
  4222. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl, EntryPoint = "ovrp_GetVersion")]
  4223. private static extern IntPtr _ovrp_GetVersion();
  4224. public static string ovrp_GetVersion() { return Marshal.PtrToStringAnsi(_ovrp_GetVersion()); }
  4225. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl, EntryPoint = "ovrp_GetNativeSDKVersion")]
  4226. private static extern IntPtr _ovrp_GetNativeSDKVersion();
  4227. public static string ovrp_GetNativeSDKVersion() { return Marshal.PtrToStringAnsi(_ovrp_GetNativeSDKVersion()); }
  4228. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl)]
  4229. public static extern IntPtr ovrp_GetAudioOutId();
  4230. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl)]
  4231. public static extern IntPtr ovrp_GetAudioInId();
  4232. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl)]
  4233. public static extern float ovrp_GetEyeTextureScale();
  4234. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl)]
  4235. public static extern Bool ovrp_SetEyeTextureScale(float value);
  4236. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl)]
  4237. public static extern Bool ovrp_GetTrackingOrientationSupported();
  4238. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl)]
  4239. public static extern Bool ovrp_GetTrackingOrientationEnabled();
  4240. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl)]
  4241. public static extern Bool ovrp_SetTrackingOrientationEnabled(Bool value);
  4242. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl)]
  4243. public static extern Bool ovrp_GetTrackingPositionSupported();
  4244. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl)]
  4245. public static extern Bool ovrp_GetTrackingPositionEnabled();
  4246. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl)]
  4247. public static extern Bool ovrp_SetTrackingPositionEnabled(Bool value);
  4248. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl)]
  4249. public static extern Bool ovrp_GetNodePresent(Node nodeId);
  4250. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl)]
  4251. public static extern Bool ovrp_GetNodeOrientationTracked(Node nodeId);
  4252. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl)]
  4253. public static extern Bool ovrp_GetNodePositionTracked(Node nodeId);
  4254. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl)]
  4255. public static extern Frustumf ovrp_GetNodeFrustum(Node nodeId);
  4256. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl)]
  4257. public static extern ControllerState ovrp_GetControllerState(uint controllerMask);
  4258. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl)]
  4259. public static extern int ovrp_GetSystemCpuLevel();
  4260. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl)]
  4261. public static extern Bool ovrp_SetSystemCpuLevel(int value);
  4262. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl)]
  4263. public static extern int ovrp_GetSystemGpuLevel();
  4264. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl)]
  4265. public static extern Bool ovrp_SetSystemGpuLevel(int value);
  4266. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl)]
  4267. public static extern Bool ovrp_GetSystemPowerSavingMode();
  4268. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl)]
  4269. public static extern float ovrp_GetSystemDisplayFrequency();
  4270. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl)]
  4271. public static extern int ovrp_GetSystemVSyncCount();
  4272. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl)]
  4273. public static extern float ovrp_GetSystemVolume();
  4274. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl)]
  4275. public static extern BatteryStatus ovrp_GetSystemBatteryStatus();
  4276. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl)]
  4277. public static extern float ovrp_GetSystemBatteryLevel();
  4278. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl)]
  4279. public static extern float ovrp_GetSystemBatteryTemperature();
  4280. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl, EntryPoint = "ovrp_GetSystemProductName")]
  4281. private static extern IntPtr _ovrp_GetSystemProductName();
  4282. public static string ovrp_GetSystemProductName() { return Marshal.PtrToStringAnsi(_ovrp_GetSystemProductName()); }
  4283. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl)]
  4284. public static extern Bool ovrp_ShowSystemUI(PlatformUI ui);
  4285. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl)]
  4286. public static extern Bool ovrp_GetAppMonoscopic();
  4287. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl)]
  4288. public static extern Bool ovrp_SetAppMonoscopic(Bool value);
  4289. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl)]
  4290. public static extern Bool ovrp_GetAppHasVrFocus();
  4291. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl)]
  4292. public static extern Bool ovrp_GetAppShouldQuit();
  4293. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl)]
  4294. public static extern Bool ovrp_GetAppShouldRecenter();
  4295. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl, EntryPoint = "ovrp_GetAppLatencyTimings")]
  4296. private static extern IntPtr _ovrp_GetAppLatencyTimings();
  4297. public static string ovrp_GetAppLatencyTimings() { return Marshal.PtrToStringAnsi(_ovrp_GetAppLatencyTimings()); }
  4298. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl)]
  4299. public static extern Bool ovrp_GetUserPresent();
  4300. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl)]
  4301. public static extern float ovrp_GetUserIPD();
  4302. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl)]
  4303. public static extern Bool ovrp_SetUserIPD(float value);
  4304. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl)]
  4305. public static extern float ovrp_GetUserEyeDepth();
  4306. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl)]
  4307. public static extern Bool ovrp_SetUserEyeDepth(float value);
  4308. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl)]
  4309. public static extern float ovrp_GetUserEyeHeight();
  4310. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl)]
  4311. public static extern Bool ovrp_SetUserEyeHeight(float value);
  4312. }
  4313. private static class OVRP_1_2_0
  4314. {
  4315. public static readonly System.Version version = new System.Version(1, 2, 0);
  4316. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl)]
  4317. public static extern Bool ovrp_SetSystemVSyncCount(int vsyncCount);
  4318. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl)]
  4319. public static extern Bool ovrpi_SetTrackingCalibratedOrigin();
  4320. }
  4321. private static class OVRP_1_3_0
  4322. {
  4323. public static readonly System.Version version = new System.Version(1, 3, 0);
  4324. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl)]
  4325. public static extern Bool ovrp_GetEyeOcclusionMeshEnabled();
  4326. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl)]
  4327. public static extern Bool ovrp_SetEyeOcclusionMeshEnabled(Bool value);
  4328. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl)]
  4329. public static extern Bool ovrp_GetSystemHeadphonesPresent();
  4330. }
  4331. private static class OVRP_1_5_0
  4332. {
  4333. public static readonly System.Version version = new System.Version(1, 5, 0);
  4334. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl)]
  4335. public static extern SystemRegion ovrp_GetSystemRegion();
  4336. }
  4337. private static class OVRP_1_6_0
  4338. {
  4339. public static readonly System.Version version = new System.Version(1, 6, 0);
  4340. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl)]
  4341. public static extern Bool ovrp_GetTrackingIPDEnabled();
  4342. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl)]
  4343. public static extern Bool ovrp_SetTrackingIPDEnabled(Bool value);
  4344. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl)]
  4345. public static extern HapticsDesc ovrp_GetControllerHapticsDesc(uint controllerMask);
  4346. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl)]
  4347. public static extern HapticsState ovrp_GetControllerHapticsState(uint controllerMask);
  4348. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl)]
  4349. public static extern Bool ovrp_SetControllerHaptics(uint controllerMask, HapticsBuffer hapticsBuffer);
  4350. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl)]
  4351. public static extern Bool ovrp_SetOverlayQuad3(uint flags, IntPtr textureLeft, IntPtr textureRight, IntPtr device, Posef pose, Vector3f scale, int layerIndex);
  4352. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl)]
  4353. public static extern float ovrp_GetEyeRecommendedResolutionScale();
  4354. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl)]
  4355. public static extern float ovrp_GetAppCpuStartToGpuEndTime();
  4356. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl)]
  4357. public static extern int ovrp_GetSystemRecommendedMSAALevel();
  4358. }
  4359. private static class OVRP_1_7_0
  4360. {
  4361. public static readonly System.Version version = new System.Version(1, 7, 0);
  4362. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl)]
  4363. public static extern Bool ovrp_GetAppChromaticCorrection();
  4364. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl)]
  4365. public static extern Bool ovrp_SetAppChromaticCorrection(Bool value);
  4366. }
  4367. private static class OVRP_1_8_0
  4368. {
  4369. public static readonly System.Version version = new System.Version(1, 8, 0);
  4370. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl)]
  4371. public static extern Bool ovrp_GetBoundaryConfigured();
  4372. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl)]
  4373. public static extern BoundaryTestResult ovrp_TestBoundaryNode(Node nodeId, BoundaryType boundaryType);
  4374. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl)]
  4375. public static extern BoundaryTestResult ovrp_TestBoundaryPoint(Vector3f point, BoundaryType boundaryType);
  4376. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl)]
  4377. public static extern BoundaryGeometry ovrp_GetBoundaryGeometry(BoundaryType boundaryType);
  4378. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl)]
  4379. public static extern Vector3f ovrp_GetBoundaryDimensions(BoundaryType boundaryType);
  4380. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl)]
  4381. public static extern Bool ovrp_GetBoundaryVisible();
  4382. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl)]
  4383. public static extern Bool ovrp_SetBoundaryVisible(Bool value);
  4384. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl)]
  4385. public static extern Bool ovrp_Update2(int stateId, int frameIndex, double predictionSeconds);
  4386. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl)]
  4387. public static extern Posef ovrp_GetNodePose2(int stateId, Node nodeId);
  4388. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl)]
  4389. public static extern Posef ovrp_GetNodeVelocity2(int stateId, Node nodeId);
  4390. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl)]
  4391. public static extern Posef ovrp_GetNodeAcceleration2(int stateId, Node nodeId);
  4392. }
  4393. private static class OVRP_1_9_0
  4394. {
  4395. public static readonly System.Version version = new System.Version(1, 9, 0);
  4396. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl)]
  4397. public static extern SystemHeadset ovrp_GetSystemHeadsetType();
  4398. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl)]
  4399. public static extern Controller ovrp_GetActiveController();
  4400. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl)]
  4401. public static extern Controller ovrp_GetConnectedControllers();
  4402. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl)]
  4403. public static extern Bool ovrp_GetBoundaryGeometry2(BoundaryType boundaryType, IntPtr points, ref int pointsCount);
  4404. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl)]
  4405. public static extern AppPerfStats ovrp_GetAppPerfStats();
  4406. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl)]
  4407. public static extern Bool ovrp_ResetAppPerfStats();
  4408. }
  4409. private static class OVRP_1_10_0
  4410. {
  4411. public static readonly System.Version version = new System.Version(1, 10, 0);
  4412. }
  4413. private static class OVRP_1_11_0
  4414. {
  4415. public static readonly System.Version version = new System.Version(1, 11, 0);
  4416. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl)]
  4417. public static extern Bool ovrp_SetDesiredEyeTextureFormat(EyeTextureFormat value);
  4418. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl)]
  4419. public static extern EyeTextureFormat ovrp_GetDesiredEyeTextureFormat();
  4420. }
  4421. private static class OVRP_1_12_0
  4422. {
  4423. public static readonly System.Version version = new System.Version(1, 12, 0);
  4424. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl)]
  4425. public static extern float ovrp_GetAppFramerate();
  4426. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl)]
  4427. public static extern PoseStatef ovrp_GetNodePoseState(Step stepId, Node nodeId);
  4428. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl)]
  4429. public static extern ControllerState2 ovrp_GetControllerState2(uint controllerMask);
  4430. }
  4431. private static class OVRP_1_15_0
  4432. {
  4433. public static readonly System.Version version = new System.Version(1, 15, 0);
  4434. public const int OVRP_EXTERNAL_CAMERA_NAME_SIZE = 32;
  4435. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl)]
  4436. public static extern Result ovrp_InitializeMixedReality();
  4437. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl)]
  4438. public static extern Result ovrp_ShutdownMixedReality();
  4439. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl)]
  4440. public static extern Bool ovrp_GetMixedRealityInitialized();
  4441. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl)]
  4442. public static extern Result ovrp_UpdateExternalCamera();
  4443. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl)]
  4444. public static extern Result ovrp_GetExternalCameraCount(out int cameraCount);
  4445. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl)]
  4446. public static extern Result ovrp_GetExternalCameraName(int cameraId, [MarshalAs(UnmanagedType.LPArray, SizeConst = OVRP_EXTERNAL_CAMERA_NAME_SIZE)] char[] cameraName);
  4447. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl)]
  4448. public static extern Result ovrp_GetExternalCameraIntrinsics(int cameraId, out CameraIntrinsics cameraIntrinsics);
  4449. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl)]
  4450. public static extern Result ovrp_GetExternalCameraExtrinsics(int cameraId, out CameraExtrinsics cameraExtrinsics);
  4451. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl)]
  4452. public static extern Result ovrp_CalculateLayerDesc(OverlayShape shape, LayerLayout layout, ref Sizei textureSize,
  4453. int mipLevels, int sampleCount, EyeTextureFormat format, int layerFlags, ref LayerDesc layerDesc);
  4454. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl)]
  4455. public static extern Result ovrp_EnqueueSetupLayer(ref LayerDesc desc, IntPtr layerId);
  4456. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl)]
  4457. public static extern Result ovrp_EnqueueDestroyLayer(IntPtr layerId);
  4458. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl)]
  4459. public static extern Result ovrp_GetLayerTextureStageCount(int layerId, ref int layerTextureStageCount);
  4460. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl)]
  4461. public static extern Result ovrp_GetLayerTexturePtr(int layerId, int stage, Eye eyeId, ref IntPtr textureHandle);
  4462. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl)]
  4463. public static extern Result ovrp_EnqueueSubmitLayer(uint flags, IntPtr textureLeft, IntPtr textureRight, int layerId, int frameIndex, ref Posef pose, ref Vector3f scale, int layerIndex);
  4464. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl)]
  4465. public static extern Result ovrp_GetNodeFrustum2(Node nodeId, out Frustumf2 nodeFrustum);
  4466. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl)]
  4467. public static extern Bool ovrp_GetEyeTextureArrayEnabled();
  4468. }
  4469. private static class OVRP_1_16_0
  4470. {
  4471. public static readonly System.Version version = new System.Version(1, 16, 0);
  4472. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl)]
  4473. public static extern Result ovrp_UpdateCameraDevices();
  4474. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl)]
  4475. public static extern Bool ovrp_IsCameraDeviceAvailable(CameraDevice cameraDevice);
  4476. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl)]
  4477. public static extern Result ovrp_SetCameraDevicePreferredColorFrameSize(CameraDevice cameraDevice, Sizei preferredColorFrameSize);
  4478. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl)]
  4479. public static extern Result ovrp_OpenCameraDevice(CameraDevice cameraDevice);
  4480. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl)]
  4481. public static extern Result ovrp_CloseCameraDevice(CameraDevice cameraDevice);
  4482. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl)]
  4483. public static extern Bool ovrp_HasCameraDeviceOpened(CameraDevice cameraDevice);
  4484. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl)]
  4485. public static extern Bool ovrp_IsCameraDeviceColorFrameAvailable(CameraDevice cameraDevice);
  4486. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl)]
  4487. public static extern Result ovrp_GetCameraDeviceColorFrameSize(CameraDevice cameraDevice, out Sizei colorFrameSize);
  4488. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl)]
  4489. public static extern Result ovrp_GetCameraDeviceColorFrameBgraPixels(CameraDevice cameraDevice, out IntPtr colorFrameBgraPixels, out int colorFrameRowPitch);
  4490. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl)]
  4491. public static extern Result ovrp_GetControllerState4(uint controllerMask, ref ControllerState4 controllerState);
  4492. }
  4493. private static class OVRP_1_17_0
  4494. {
  4495. public static readonly System.Version version = new System.Version(1, 17, 0);
  4496. #if UNITY_EDITOR_WIN || UNITY_STANDALONE_WIN
  4497. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl)]
  4498. public static extern Result ovrp_GetExternalCameraPose(CameraDevice camera, out Posef cameraPose);
  4499. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl)]
  4500. public static extern Result ovrp_ConvertPoseToCameraSpace(CameraDevice camera, ref Posef trackingSpacePose, out Posef cameraSpacePose);
  4501. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl)]
  4502. public static extern Result ovrp_GetCameraDeviceIntrinsicsParameters(CameraDevice camera, out Bool supportIntrinsics, out CameraDeviceIntrinsicsParameters intrinsicsParameters);
  4503. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl)]
  4504. public static extern Result ovrp_DoesCameraDeviceSupportDepth(CameraDevice camera, out Bool supportDepth);
  4505. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl)]
  4506. public static extern Result ovrp_GetCameraDeviceDepthSensingMode(CameraDevice camera, out CameraDeviceDepthSensingMode depthSensoringMode);
  4507. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl)]
  4508. public static extern Result ovrp_SetCameraDeviceDepthSensingMode(CameraDevice camera, CameraDeviceDepthSensingMode depthSensoringMode);
  4509. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl)]
  4510. public static extern Result ovrp_GetCameraDevicePreferredDepthQuality(CameraDevice camera, out CameraDeviceDepthQuality depthQuality);
  4511. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl)]
  4512. public static extern Result ovrp_SetCameraDevicePreferredDepthQuality(CameraDevice camera, CameraDeviceDepthQuality depthQuality);
  4513. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl)]
  4514. public static extern Result ovrp_IsCameraDeviceDepthFrameAvailable(CameraDevice camera, out Bool available);
  4515. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl)]
  4516. public static extern Result ovrp_GetCameraDeviceDepthFrameSize(CameraDevice camera, out Sizei depthFrameSize);
  4517. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl)]
  4518. public static extern Result ovrp_GetCameraDeviceDepthFramePixels(CameraDevice cameraDevice, out IntPtr depthFramePixels, out int depthFrameRowPitch);
  4519. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl)]
  4520. public static extern Result ovrp_GetCameraDeviceDepthConfidencePixels(CameraDevice cameraDevice, out IntPtr depthConfidencePixels, out int depthConfidenceRowPitch);
  4521. #endif
  4522. }
  4523. private static class OVRP_1_18_0
  4524. {
  4525. public static readonly System.Version version = new System.Version(1, 18, 0);
  4526. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl)]
  4527. public static extern Result ovrp_SetHandNodePoseStateLatency(double latencyInSeconds);
  4528. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl)]
  4529. public static extern Result ovrp_GetHandNodePoseStateLatency(out double latencyInSeconds);
  4530. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl)]
  4531. public static extern Result ovrp_GetAppHasInputFocus(out Bool appHasInputFocus);
  4532. }
  4533. private static class OVRP_1_19_0
  4534. {
  4535. public static readonly System.Version version = new System.Version(1, 19, 0);
  4536. }
  4537. private static class OVRP_1_21_0
  4538. {
  4539. public static readonly System.Version version = new System.Version(1, 21, 0);
  4540. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl)]
  4541. public static extern Result ovrp_GetTiledMultiResSupported(out Bool foveationSupported);
  4542. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl)]
  4543. public static extern Result ovrp_GetTiledMultiResLevel(out FixedFoveatedRenderingLevel level);
  4544. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl)]
  4545. public static extern Result ovrp_SetTiledMultiResLevel(FixedFoveatedRenderingLevel level);
  4546. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl)]
  4547. public static extern Result ovrp_GetGPUUtilSupported(out Bool gpuUtilSupported);
  4548. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl)]
  4549. public static extern Result ovrp_GetGPUUtilLevel(out float gpuUtil);
  4550. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl)]
  4551. public static extern Result ovrp_GetSystemDisplayFrequency2(out float systemDisplayFrequency);
  4552. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl)]
  4553. public static extern Result ovrp_GetSystemDisplayAvailableFrequencies(IntPtr systemDisplayAvailableFrequencies, ref int numFrequencies);
  4554. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl)]
  4555. public static extern Result ovrp_SetSystemDisplayFrequency(float requestedFrequency);
  4556. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl)]
  4557. public static extern Result ovrp_GetAppAsymmetricFov(out Bool useAsymmetricFov);
  4558. }
  4559. private static class OVRP_1_28_0
  4560. {
  4561. public static readonly System.Version version = new System.Version(1, 28, 0);
  4562. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl)]
  4563. public static extern Result ovrp_GetDominantHand(out Handedness dominantHand);
  4564. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl)]
  4565. public static extern Result ovrp_GetReorientHMDOnControllerRecenter(out Bool recenter);
  4566. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl)]
  4567. public static extern Result ovrp_SetReorientHMDOnControllerRecenter(Bool recenter);
  4568. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl)]
  4569. public static extern Result ovrp_SendEvent(string name, string param);
  4570. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl)]
  4571. public static extern Result ovrp_EnqueueSetupLayer2(ref LayerDesc desc, int compositionDepth, IntPtr layerId);
  4572. }
  4573. private static class OVRP_1_29_0
  4574. {
  4575. public static readonly System.Version version = new System.Version(1, 29, 0);
  4576. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl)]
  4577. public static extern Result ovrp_GetLayerAndroidSurfaceObject(int layerId, ref IntPtr surfaceObject);
  4578. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl)]
  4579. public static extern Result ovrp_SetHeadPoseModifier(ref Quatf relativeRotation, ref Vector3f relativeTranslation);
  4580. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl)]
  4581. public static extern Result ovrp_GetHeadPoseModifier(out Quatf relativeRotation, out Vector3f relativeTranslation);
  4582. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl)]
  4583. public static extern Result ovrp_GetNodePoseStateRaw(Step stepId, int frameIndex, Node nodeId, out PoseStatef nodePoseState);
  4584. }
  4585. private static class OVRP_1_30_0
  4586. {
  4587. public static readonly System.Version version = new System.Version(1, 30, 0);
  4588. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl)]
  4589. public static extern Result ovrp_GetCurrentTrackingTransformPose(out Posef trackingTransformPose);
  4590. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl)]
  4591. public static extern Result ovrp_GetTrackingTransformRawPose(out Posef trackingTransformRawPose);
  4592. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl)]
  4593. public static extern Result ovrp_SendEvent2(string name, string param, string source);
  4594. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl)]
  4595. public static extern Result ovrp_IsPerfMetricsSupported(PerfMetrics perfMetrics, out Bool isSupported);
  4596. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl)]
  4597. public static extern Result ovrp_GetPerfMetricsFloat(PerfMetrics perfMetrics, out float value);
  4598. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl)]
  4599. public static extern Result ovrp_GetPerfMetricsInt(PerfMetrics perfMetrics, out int value);
  4600. }
  4601. private static class OVRP_1_31_0
  4602. {
  4603. public static readonly System.Version version = new System.Version(1, 31, 0);
  4604. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl)]
  4605. public static extern Result ovrp_GetTimeInSeconds(out double value);
  4606. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl)]
  4607. public static extern Result ovrp_SetColorScaleAndOffset(Vector4 colorScale, Vector4 colorOffset, Bool applyToAllLayers);
  4608. }
  4609. private static class OVRP_1_32_0
  4610. {
  4611. public static readonly System.Version version = new System.Version(1, 32, 0);
  4612. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl)]
  4613. public static extern Result ovrp_AddCustomMetadata(string name, string param);
  4614. }
  4615. private static class OVRP_1_34_0
  4616. {
  4617. public static readonly System.Version version = new System.Version(1, 34, 0);
  4618. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl)]
  4619. public static extern Result ovrp_EnqueueSubmitLayer2(uint flags, IntPtr textureLeft, IntPtr textureRight, int layerId, int frameIndex, ref Posef pose, ref Vector3f scale, int layerIndex,
  4620. Bool overrideTextureRectMatrix, ref TextureRectMatrixf textureRectMatrix, Bool overridePerLayerColorScaleAndOffset, ref Vector4 colorScale, ref Vector4 colorOffset);
  4621. }
  4622. private static class OVRP_1_35_0
  4623. {
  4624. public static readonly System.Version version = new System.Version(1, 35, 0);
  4625. }
  4626. private static class OVRP_1_36_0
  4627. {
  4628. public static readonly System.Version version = new System.Version(1, 36, 0);
  4629. }
  4630. private static class OVRP_1_37_0
  4631. {
  4632. public static readonly System.Version version = new System.Version(1, 37, 0);
  4633. }
  4634. private static class OVRP_1_38_0
  4635. {
  4636. public static readonly System.Version version = new System.Version(1, 38, 0);
  4637. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl)]
  4638. public static extern Result ovrp_GetTrackingTransformRelativePose(ref Posef trackingTransformRelativePose, TrackingOrigin trackingOrigin);
  4639. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl)]
  4640. public static extern Result ovrp_Media_Initialize();
  4641. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl)]
  4642. public static extern Result ovrp_Media_Shutdown();
  4643. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl)]
  4644. public static extern Result ovrp_Media_GetInitialized(out Bool initialized);
  4645. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl)]
  4646. public static extern Result ovrp_Media_Update();
  4647. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl)]
  4648. public static extern Result ovrp_Media_GetMrcActivationMode(out Media.MrcActivationMode activationMode);
  4649. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl)]
  4650. public static extern Result ovrp_Media_SetMrcActivationMode(Media.MrcActivationMode activationMode);
  4651. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl)]
  4652. public static extern Result ovrp_Media_IsMrcEnabled(out Bool mrcEnabled);
  4653. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl)]
  4654. public static extern Result ovrp_Media_IsMrcActivated(out Bool mrcActivated);
  4655. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl)]
  4656. public static extern Result ovrp_Media_UseMrcDebugCamera(out Bool useMrcDebugCamera);
  4657. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl)]
  4658. public static extern Result ovrp_Media_SetMrcInputVideoBufferType(Media.InputVideoBufferType inputVideoBufferType);
  4659. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl)]
  4660. public static extern Result ovrp_Media_GetMrcInputVideoBufferType(ref Media.InputVideoBufferType inputVideoBufferType);
  4661. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl)]
  4662. public static extern Result ovrp_Media_SetMrcFrameSize(int frameWidth, int frameHeight);
  4663. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl)]
  4664. public static extern Result ovrp_Media_GetMrcFrameSize(ref int frameWidth, ref int frameHeight);
  4665. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl)]
  4666. public static extern Result ovrp_Media_SetMrcAudioSampleRate(int sampleRate);
  4667. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl)]
  4668. public static extern Result ovrp_Media_GetMrcAudioSampleRate(ref int sampleRate);
  4669. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl)]
  4670. public static extern Result ovrp_Media_SetMrcFrameImageFlipped(Bool flipped);
  4671. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl)]
  4672. public static extern Result ovrp_Media_GetMrcFrameImageFlipped(ref Bool flipped);
  4673. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl)]
  4674. public static extern Result ovrp_Media_EncodeMrcFrame(System.IntPtr rawBuffer, System.IntPtr audioDataPtr, int audioDataLen, int audioChannels, double timestamp, ref int outSyncId);
  4675. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl)]
  4676. public static extern Result ovrp_Media_EncodeMrcFrameWithDualTextures(System.IntPtr backgroundTextureHandle, System.IntPtr foregroundTextureHandle, System.IntPtr audioData, int audioDataLen, int audioChannels, double timestamp, ref int outSyncId);
  4677. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl)]
  4678. public static extern Result ovrp_Media_SyncMrcFrame(int syncId);
  4679. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl)]
  4680. public static extern Result ovrp_GetExternalCameraCalibrationRawPose(int cameraId, out Posef rawPose);
  4681. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl)]
  4682. public static extern Result ovrp_SetDeveloperMode(Bool active);
  4683. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl)]
  4684. public static extern Result ovrp_GetNodeOrientationValid(Node nodeId, ref Bool nodeOrientationValid);
  4685. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl)]
  4686. public static extern Result ovrp_GetNodePositionValid(Node nodeId, ref Bool nodePositionValid);
  4687. }
  4688. private static class OVRP_1_39_0
  4689. {
  4690. public static readonly System.Version version = new System.Version(1, 39, 0);
  4691. }
  4692. private static class OVRP_1_40_0
  4693. {
  4694. public static readonly System.Version version = new System.Version(1, 40, 0);
  4695. }
  4696. private static class OVRP_1_41_0
  4697. {
  4698. public static readonly System.Version version = new System.Version(1, 41, 0);
  4699. }
  4700. private static class OVRP_1_42_0
  4701. {
  4702. public static readonly System.Version version = new System.Version(1, 42, 0);
  4703. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl)]
  4704. public static extern Result ovrp_GetAdaptiveGpuPerformanceScale2(ref float adaptiveGpuPerformanceScale);
  4705. }
  4706. private static class OVRP_1_43_0
  4707. {
  4708. public static readonly System.Version version = new System.Version(1, 43, 0);
  4709. }
  4710. private static class OVRP_1_44_0
  4711. {
  4712. public static readonly System.Version version = new System.Version(1, 44, 0);
  4713. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl)]
  4714. public static extern Result ovrp_GetHandTrackingEnabled(ref Bool handTrackingEnabled);
  4715. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl)]
  4716. public static extern Result ovrp_GetHandState(Step stepId, Hand hand, out HandStateInternal handState);
  4717. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl)]
  4718. public static extern Result ovrp_GetSkeleton(SkeletonType skeletonType, out Skeleton skeleton);
  4719. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl)]
  4720. public static extern Result ovrp_GetMesh(MeshType meshType, out Mesh mesh);
  4721. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl)]
  4722. public static extern Result ovrp_OverrideExternalCameraFov(int cameraId, Bool useOverriddenFov, ref Fovf fov);
  4723. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl)]
  4724. public static extern Result ovrp_GetUseOverriddenExternalCameraFov(int cameraId, out Bool useOverriddenFov);
  4725. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl)]
  4726. public static extern Result ovrp_OverrideExternalCameraStaticPose(int cameraId, Bool useOverriddenPose, ref Posef pose);
  4727. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl)]
  4728. public static extern Result ovrp_GetUseOverriddenExternalCameraStaticPose(int cameraId, out Bool useOverriddenStaticPose);
  4729. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl)]
  4730. public static extern Result ovrp_ResetDefaultExternalCamera();
  4731. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl)]
  4732. public static extern Result ovrp_SetDefaultExternalCamera(string cameraName, ref CameraIntrinsics cameraIntrinsics, ref CameraExtrinsics cameraExtrinsics);
  4733. }
  4734. #endif // !OVRPLUGIN_UNSUPPORTED_PLATFORM
  4735. }