PXR_Plugin.cs 176 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955
  1. /*******************************************************************************
  2. Copyright © 2015-2022 PICO Technology Co., Ltd.All rights reserved.
  3. NOTICE:All information contained herein is, and remains the property of
  4. PICO Technology Co., Ltd. The intellectual and technical concepts
  5. contained herein are proprietary to PICO Technology Co., Ltd. and may be
  6. covered by patents, patents in process, and are protected by trade secret or
  7. copyright law. Dissemination of this information or reproduction of this
  8. material is strictly forbidden unless prior written permission is obtained from
  9. PICO Technology Co., Ltd.
  10. *******************************************************************************/
  11. using System.ComponentModel;
  12. using System.Drawing;
  13. using System;
  14. using System.Collections.Generic;
  15. using System.Runtime.InteropServices;
  16. using UnityEngine;
  17. namespace Unity.XR.PXR
  18. {
  19. //MR
  20. #region MR
  21. #region new mr
  22. public struct PxrAnchorEntityCreateInfo
  23. {
  24. public PxrTrackingOrigin origin;
  25. public PxrPosef pose;
  26. public double time;
  27. }
  28. public struct PxrAnchorEntityDestroyInfo
  29. {
  30. public ulong anchorHandle;
  31. }
  32. public struct PxrUuid
  33. {
  34. public ulong value0;
  35. public ulong value1;
  36. }
  37. public struct PxrAnchorComponentSceneLabelInfo
  38. {
  39. public PxrStructureType type;
  40. public PxrSceneLabel label;
  41. }
  42. public struct PxrAnchorComponentPlaneInfo
  43. {
  44. public PxrStructureType type;
  45. public PxrVector3f center;
  46. public PxrExtent2Df extent;
  47. public uint polygonSize;
  48. public IntPtr polygonVertices; //=>PxrVector3f[]
  49. }
  50. public struct PxrAnchorComponentVolumeInfo
  51. {
  52. public PxrStructureType type;
  53. public PxrVector3f center;
  54. public PxrVector3f extent;
  55. }
  56. public struct PxrExtent2Df
  57. {
  58. public float width;
  59. public float height;
  60. }
  61. public struct PxrAnchorPlaneBoundaryInfo
  62. {
  63. public PxrVector3f center;
  64. public PxrExtent2Df extent;
  65. }
  66. public struct PxrAnchorPlanePolygonInfo
  67. {
  68. public uint inputCount;
  69. public uint outputCount;
  70. public IntPtr vertices;
  71. }
  72. public struct PxrAnchorVolumeInfo
  73. {
  74. public PxrVector3f center;
  75. public PxrVector3f extent;
  76. }
  77. public struct PxrAnchorEntityList
  78. {
  79. public uint count;
  80. public IntPtr anchorHandles;//=>ulong[]
  81. }
  82. public struct PxrAnchorEntityPersistInfo
  83. {
  84. public PxrAnchorEntityList anchorList;
  85. public PxrPersistLocation location;
  86. }
  87. /// <summary>
  88. /// Information about the event of creating an anchor entity.
  89. /// </summary>
  90. public struct PxrEventAnchorEntityCreated
  91. {
  92. /// <summary>
  93. /// Task ID.
  94. /// </summary>
  95. public ulong taskId;
  96. /// <summary>
  97. /// Task result, which indicates whether the anchor entity is successfully created.
  98. /// </summary>
  99. public PxrResult result;
  100. /// <summary>
  101. /// The handle of the anchor entity.
  102. /// </summary>
  103. public ulong anchorHandle;
  104. /// <summary>
  105. /// The UUID of the anchor entity.
  106. /// </summary>
  107. public Guid uuid;
  108. }
  109. /// <summary>
  110. /// Information about the event of persisting an anchor entity.
  111. /// </summary>
  112. public struct PxrEventAnchorEntityPersisted
  113. {
  114. /// <summary>
  115. /// Task ID.
  116. /// </summary>
  117. public ulong taskId;
  118. /// <summary>
  119. /// Task result, which indicates whether the anchor entity is successfully persisted.
  120. /// </summary>
  121. public PxrResult result;
  122. /// <summary>
  123. /// The location where the anchor entity is saved. Currently, the anchor entity can only be saved to the device's local storage.
  124. /// </summary>
  125. public PxrPersistLocation location;
  126. }
  127. public struct PxrAnchorEntityUnPersistInfo
  128. {
  129. public PxrAnchorEntityList anchorList;
  130. public PxrPersistLocation location;
  131. }
  132. /// <summary>
  133. /// Information about the event of unpersisting an anchor entity.
  134. /// </summary>
  135. public struct PxrEventAnchorEntityUnPersisted
  136. {
  137. /// <summary>
  138. /// Task ID.
  139. /// </summary>
  140. public ulong taskId;
  141. /// <summary>
  142. /// Task result, which indicates whether the anchor entity is successfully unpersisted.
  143. /// </summary>
  144. public PxrResult result;
  145. /// <summary>
  146. /// The location from which the anchor entity is unpersisted. Currently, the anchor entity can only be unpersisted from the device's local storage.
  147. /// </summary>
  148. public PxrPersistLocation location;
  149. }
  150. public struct PxrAnchorEntityClearInfo
  151. {
  152. public PxrPersistLocation location;
  153. }
  154. /// <summary>
  155. /// Information about the event of clearing all anchor entities.
  156. /// </summary>
  157. public struct PxrEventAnchorEntityCleared
  158. {
  159. /// <summary>
  160. /// Task ID.
  161. /// </summary>
  162. public ulong taskId;
  163. /// <summary>
  164. /// Task result, which indicates whether the anchor entities are successfully cleared.
  165. /// </summary>
  166. public PxrResult result;
  167. /// <summary>
  168. /// The location of the anchor entities cleared.
  169. /// </summary>
  170. public PxrPersistLocation location;
  171. }
  172. public struct PxrAnchorEntityLoadInfo
  173. {
  174. public uint maxResult;
  175. public ulong timeout;
  176. public PxrPersistLocation location;
  177. public IntPtr include; //=>PxrAnchorEntityLoadFilterBaseHeader
  178. public IntPtr exclude; //=>PxrAnchorEntityLoadFilterBaseHeader
  179. }
  180. public struct PxrAnchorEntityLoadUuidFilter
  181. {
  182. public PxrStructureType type;
  183. public uint uuidCount;
  184. public IntPtr uuidList; //=>PxrUuid[]
  185. }
  186. public struct PxrAnchorEntityLoadComponentFilter
  187. {
  188. public PxrStructureType type;
  189. public ulong typeFlags;
  190. }
  191. public struct PxrAnchorEntityLoadSpatialSceneFilter
  192. {
  193. public PxrStructureType type;
  194. public ulong typeFlags;
  195. }
  196. public struct PxrAnchorEntityLoadResult
  197. {
  198. public ulong anchor;
  199. public PxrUuid uuid;
  200. }
  201. public struct PxrAnchorEntityLoadResults
  202. {
  203. public uint inputCount;
  204. public uint outputCount;
  205. public IntPtr loadResults; //=>PxrAnchorEntityLoadResult[]
  206. }
  207. /// <summary>
  208. /// Information about the event of loading anchor entities.
  209. /// </summary>
  210. public struct PxrEventAnchorEntityLoaded
  211. {
  212. /// <summary>
  213. /// Task ID.
  214. /// </summary>
  215. public ulong taskId;
  216. /// <summary>
  217. /// Task result, which indicates whether the anchor entities are successfully loaded.
  218. /// </summary>
  219. public PxrResult result;
  220. /// <summary>
  221. /// The number of anchor entities loaded.
  222. /// </summary>
  223. public uint count;
  224. /// <summary>
  225. /// The location from which the anchor entities are loaded.
  226. /// </summary>
  227. public PxrPersistLocation location;
  228. }
  229. /// <summary>
  230. /// Information about the event of room calibration.
  231. /// </summary>
  232. public struct PxrEventSpatialSceneCaptured
  233. {
  234. /// <summary>
  235. /// Task ID.
  236. /// </summary>
  237. public ulong taskId;
  238. /// <summary>
  239. /// Task result, which indicate whether the room is successfully calibrated.
  240. /// </summary>
  241. public PxrResult result;
  242. /// <summary>
  243. /// (not defined)
  244. /// </summary>
  245. public PxrSpatialSceneCaptureStatus status;
  246. }
  247. public struct PxrEventSpatialTrackingStateUpdate
  248. {
  249. public PxrSpatialTrackingState state;
  250. public PxrSpatialTrackingStateMessage message;
  251. }
  252. public enum PxrSpatialSceneCaptureStatus
  253. {
  254. NotDefined = 0,
  255. }
  256. /// <summary>
  257. /// The flags of components.
  258. /// </summary>
  259. public enum PxrAnchorComponentTypeFlags
  260. {
  261. Pose = 0x00000001,
  262. Persistence = 0x00000002,
  263. SceneLabel = 0x00000004,
  264. Plane = 0x00000008,
  265. Volume = 0x00000010
  266. }
  267. public enum PxrSpatialSceneDataTypeFlags
  268. {
  269. Unknown = 0x00000001,
  270. Floor = 0x00000002,
  271. Ceiling = 0x00000004,
  272. Wall = 0x00000008,
  273. Door = 0x00000010,
  274. Window = 0x00000020,
  275. Opening = 0x00000040,
  276. Object = 0x00000080
  277. }
  278. public enum PxrTrackingOrigin
  279. {
  280. Eye = 0,
  281. Floor = 1,
  282. Stage = 2
  283. }
  284. public enum PxrAnchorComponentType
  285. {
  286. Pose = 0,
  287. Persistence = 1,
  288. SceneLabel = 2,
  289. Plane = 3,
  290. Volume = 4,
  291. }
  292. public enum PxrSceneLabel
  293. {
  294. UnKnown = 0,
  295. Floor,
  296. Ceiling,
  297. Wall,
  298. Door,
  299. Window,
  300. Opening,
  301. Table,
  302. Sofa,
  303. }
  304. /// <summary>
  305. /// The location that an anchor entity is saved to.
  306. /// </summary>
  307. public enum PxrPersistLocation
  308. {
  309. /// <summary>
  310. /// The device's local storage.
  311. /// </summary>
  312. Local = 1,
  313. /// <summary>
  314. /// (Not supported yet)
  315. /// </summary>
  316. Remote = 2,
  317. }
  318. /// <summary>
  319. /// Video seethrough effect-related parameters.
  320. /// </summary>
  321. public enum PxrLayerEffect
  322. {
  323. Contrast = 0,
  324. Saturation = 1,
  325. Brightness = 2,
  326. /// <summary>
  327. /// Color temperature.
  328. /// </summary>
  329. Colortemp = 3,
  330. }
  331. #endregion
  332. //deprecate
  333. // Spatial Instance uuid 128 bit
  334. public struct PxrSpatialInstanceUuid
  335. {
  336. public UInt64 value0;
  337. public UInt64 value1;
  338. }
  339. // Create info struct used when creating a spatial anchor
  340. public struct PxrSpatialAnchorCreateInfo
  341. {
  342. public PxrReferenceType referenceType; // Global or Local
  343. public PxrPosef pose; // Position and Rotation
  344. public double time; // timestamp in milliseconds
  345. }
  346. // Save info struct used when saving a spatial anchor
  347. public struct PxrSpatialAnchorSaveInfo
  348. {
  349. public UInt64 anchorHandle;
  350. public PxrSpatialPersistenceLocation location;
  351. public PxrSpatialPersistenceMode persistenceMode;
  352. }
  353. // Delete info struct used when deleting a spatial anchor
  354. public struct PxrSpatialAnchorDeleteInfo
  355. {
  356. public UInt64 anchorHandle;
  357. public PxrSpatialPersistenceLocation persistenceLocation;
  358. }
  359. // Used to load all spatial instances that match the uuids provided
  360. // in the filter info. If numIds is set to 0, all Ids will be loaded.
  361. [StructLayout(LayoutKind.Sequential)]
  362. public struct PxrSpatialInstanceIdFilter
  363. {
  364. public UInt32 numIds;
  365. [MarshalAs(UnmanagedType.ByValArray, SizeConst = 1024)]
  366. public PxrSpatialInstanceUuid[] uuids;
  367. }
  368. // Load info strut used when loading spatial instances
  369. [StructLayout(LayoutKind.Sequential)]
  370. public struct PxrSpatialInstanceLoadByIdInfo
  371. {
  372. public UInt32 maxNum; // Max num of handles can be returned by this query
  373. public double timeout; // milliseconds
  374. public PxrSpatialPersistenceLocation persistenceLocation; // Where to load
  375. public PxrSpatialInstanceIdFilter idFilter; // What to load
  376. }
  377. public enum PxrSpatialTrackingState
  378. {
  379. Invalid = 0,
  380. Valid = 1,
  381. Limited = 2,
  382. }
  383. public enum PxrSpatialTrackingStateMessage
  384. {
  385. Unknown = 0,
  386. Error = 1,
  387. Locating = 100,
  388. Located = 101,
  389. LocatingFailed = 102,
  390. LocatingFailedInvalidMap = 103,
  391. LocatingFailedNoMap = 104,
  392. LocateStopping = 105,
  393. LocateStopFailed = 106,
  394. LocateStopped = 107,
  395. MapCreating = 108,
  396. MapCreateFailed = 109,
  397. MapCreated = 110,
  398. MapSaving = 111,
  399. MapSaveFailed = 112,
  400. MapSaveFailedLowQuality = 113,
  401. MapSaveFailedInsufficentDiskSpace = 114,
  402. MapSaved = 115,
  403. MrEngineStarted = 116,
  404. MrEngineStopped = 117,
  405. MrEngineDestroyed = 118,
  406. MrMapLoss = 119,
  407. }
  408. public struct PxrSpatialTrackingStateInfo
  409. {
  410. public PxrSpatialTrackingState state;
  411. public PxrSpatialTrackingStateMessage message;
  412. }
  413. public struct PxrEventSpatialTrackingStateInfo
  414. {
  415. public PxrStructureType type;
  416. public PxrEventLevel eventLevel;
  417. public PxrSpatialTrackingStateInfo stateInfo;
  418. }
  419. public struct PxrEventSpatialAnchorSaveResult
  420. {
  421. public PxrStructureType type;
  422. public PxrEventLevel eventLevel;
  423. public PxrSpatialPersistenceResult result;
  424. public UInt64 asyncRequestId;
  425. public PxrSpatialInstanceUuid uuid;
  426. public UInt64 handle;
  427. public PxrSpatialPersistenceLocation location;
  428. }
  429. public struct PxrEventSpatialAnchorDeleteResult
  430. {
  431. public PxrStructureType type;
  432. public PxrEventLevel eventLevel;
  433. public PxrSpatialPersistenceResult result;
  434. public UInt64 asyncRequestId;
  435. public PxrSpatialInstanceUuid uuid;
  436. public PxrSpatialPersistenceLocation location;
  437. }
  438. public struct PxrSpatialAnchorLoadResult
  439. {
  440. public UInt64 anchorHandle;
  441. public PxrSpatialInstanceUuid uuid;
  442. }
  443. public struct PxrEventSpatialAnchorLoadResults
  444. {
  445. public PxrStructureType type;
  446. public PxrEventLevel eventLevel;
  447. public PxrSpatialPersistenceResult result;
  448. public bool hasNext;
  449. public UInt64 asyncRequestId;
  450. public UInt32 numResults;
  451. [MarshalAs(UnmanagedType.ByValArray, SizeConst = 128)]
  452. public PxrSpatialAnchorLoadResult[] loadResults;
  453. }
  454. public struct PxrSpatialAnchorLoadResults
  455. {
  456. public Int32 resultCapacityInput;
  457. public Int32 resultCountOutput;
  458. public IntPtr results; //PxrSpatialAnchorLoadResult
  459. }
  460. public struct PxrEventSpatialAnchorLoadResultsAvailable
  461. {
  462. public PxrStructureType type;
  463. public PxrEventLevel eventLevel;
  464. public UInt64 asyncRequestId;
  465. }
  466. public struct PxrEventSpatialAnchorLoadResultsComplete
  467. {
  468. public PxrStructureType type;
  469. public PxrEventLevel eventLevel;
  470. public UInt64 asyncRequestId;
  471. public PxrSpatialPersistenceResult result;
  472. }
  473. [StructLayout(LayoutKind.Sequential)]
  474. public struct PxrEventDataBuffer
  475. {
  476. public PxrStructureType type;
  477. public PxrEventLevel eventLevel;
  478. [MarshalAs(UnmanagedType.ByValArray, SizeConst = 500)]
  479. public byte[] data;
  480. };
  481. public struct PxrRoomSceneDataSaveInfo
  482. {
  483. public ulong roomSceneDataHandle;
  484. public PxrSpatialPersistenceLocation location;
  485. }
  486. public struct PxrRoomSceneDataDeleteInfo
  487. {
  488. public ulong roomSceneDataHandle;
  489. public PxrSpatialPersistenceLocation location;
  490. }
  491. public struct PxrEventRoomSceneDataSaveResult
  492. {
  493. public PxrStructureType type;
  494. public PxrEventLevel eventLevel;
  495. public PxrSpatialPersistenceResult result;
  496. public ulong asyncRequestId;
  497. public ulong handle;
  498. public PxrSpatialPersistenceLocation location;
  499. }
  500. public struct PxrEventRoomSceneDataDeleteResult
  501. {
  502. public PxrStructureType type;
  503. public PxrEventLevel eventLevel;
  504. public PxrSpatialPersistenceResult result;
  505. public ulong asyncRequestId;
  506. public ulong handle;
  507. public PxrSpatialPersistenceLocation location;
  508. }
  509. public struct PxrRoomSceneLoadInfo
  510. {
  511. public double timeoutMs; // time in milliseconds
  512. public PxrSpatialPersistenceLocation location;
  513. }
  514. public struct PxrRoomSceneLoadResult
  515. {
  516. public ulong anchorHandle;
  517. public PxrSpatialInstanceUuid anchorUuid;
  518. public ulong roomSceneDataHandle;
  519. public int dataLen;
  520. [MarshalAs(UnmanagedType.ByValArray, SizeConst = 1024)]
  521. public byte[] data;
  522. }
  523. public struct PxrEventRoomSceneLoadResultsComplete
  524. {
  525. public PxrStructureType type;
  526. public PxrEventLevel eventLevel;
  527. public ulong asyncRequestId;
  528. public PxrSpatialPersistenceResult result;
  529. }
  530. public struct PxrRoomSceneLoadResults
  531. {
  532. public int resultCapacityInput;
  533. public int resultCountOutput;
  534. public IntPtr results; //PxrRoomSceneLoadResult
  535. }
  536. public struct PxrEventRoomSceneDataUpdateResult
  537. {
  538. public PxrStructureType type;
  539. public PxrEventLevel level;
  540. public PxrSpatialInstanceUuid anchorUuid;
  541. public ulong roomSceneDataHandle;
  542. public uint result;
  543. public uint dataLength;
  544. [MarshalAs(UnmanagedType.ByValArray, SizeConst = 128)]
  545. public byte[] roomSceneData;
  546. }
  547. public struct PxrEventSemiAutoCandidatesUpdate
  548. {
  549. public uint state;
  550. public uint count;
  551. }
  552. public struct PxrSemiAutoRoomCaptureCandidatesUpdate
  553. {
  554. public PxrStructureType type;
  555. public PxrEventLevel eventLevel;
  556. public PxrSpatialPersistenceResult result;
  557. }
  558. public struct PxrPoint3D
  559. {
  560. public float x;
  561. public float y;
  562. public float z;
  563. }
  564. public struct PxrEventDataSeethroughStateChanged
  565. {
  566. public PxrStructureType type;
  567. public PxrEventLevel eventLevel;
  568. public int state;
  569. };
  570. public enum PxrStructureType
  571. {
  572. Unknown = 0,
  573. PXR_TYPE_EVENT_DATA_SEETHROUGH_STATE_CHANGED = 9,
  574. SpatialAnchorSaveResult = 20,
  575. SpatialAnchorDeleteResult = 21,
  576. SpatialAnchorLoadResults = 22,
  577. NewSpaceReady = 28,
  578. SpatialAnchorLoadResultsAvailable = 29,
  579. SpatialAnchorLoadResultsComplete = 30,
  580. RoomSceneDataSaveResult = 31,
  581. RoomSceneDataDeleteResult = 32,
  582. RoomSceneLoadResultsComplete = 33,
  583. SemiAutoRoomCaptureCandidatesUpdate = 36,
  584. RoomSceneDataUpdateResult = 37,
  585. TrackingStateChanged = 40,
  586. //mrsdk2.0
  587. MRMin = 100,
  588. SpatialTrackingStateUpdate = 101,
  589. AnchorEntityProperties = 102,
  590. AnchorEntityCreateInfo = 103,
  591. AnchorEntityDestroyInfo = 104,
  592. AnchorSpaceCreateInfo = 105,
  593. AnchorComponentSceneLabelInfo = 106,
  594. AnchorComponentPlaneInfo = 107,
  595. AnchorComponentVolumeInfo = 108,
  596. AnchorComponentAddInfo = 109,
  597. AnchorComponentRemoveInfo = 110,
  598. AnchorPlaneBoundaryInfo = 111,
  599. AnchorPlanePolygonInfo = 112,
  600. AnchorVolumeInfo = 113,
  601. AnchorEntityPersistInfo = 114,
  602. AnchorEntityUnPersistInfo = 115,
  603. AnchorEntityList = 116,
  604. AnchorEntityClearInfo = 117,
  605. AnchorEntityPersisted = 118,
  606. AnchorEntityUnPersisted = 119,
  607. AnchorEntityCleared = 120,
  608. AnchorEntityLoadInfo = 121,
  609. AnchorEntityLoadUuidFilter = 122,
  610. AnchorEntityLoadComponentFilter = 123,
  611. AnchorEntityLoaded = 124,
  612. AnchorEntityLoadResult = 125,
  613. SpatialSceneCaptureStartInfo = 126,
  614. SpatialSceneCaptured = 127,
  615. AnchorEntityLoadSpatialSceneFilter = 128,
  616. SemiAutoCandidatesUpdate = 129,
  617. AnchorEntityCreated = 130,
  618. MRMax = 200
  619. }
  620. /// <summary>
  621. /// The result of mixed reality-realted events.
  622. /// </summary>
  623. public enum PxrResult
  624. {
  625. SUCCESS = 0,
  626. TIMEOUT_EXPIRED = 1,
  627. SESSION_LOSS_PENDING = 3,
  628. EVENT_UNAVAILABLE = 4,
  629. SPACE_BOUNDS_UNAVAILABLE = 7,
  630. SESSION_NOT_FOCUSED = 8,
  631. FRAME_DISCARDED = 9,
  632. ERROR_VALIDATION_FAILURE = -1,
  633. ERROR_RUNTIME_FAILURE = -2,
  634. ERROR_OUT_OF_MEMORY = -3,
  635. ERROR_API_VERSION_UNSUPPORTED = -4,
  636. ERROR_INITIALIZATION_FAILED = -6,
  637. ERROR_FUNCTION_UNSUPPORTED = -7,
  638. ERROR_FEATURE_UNSUPPORTED = -8,
  639. ERROR_EXTENSION_NOT_PRESENT = -9,
  640. ERROR_LIMIT_REACHED = -10,
  641. ERROR_SIZE_INSUFFICIENT = -11,
  642. ERROR_HANDLE_INVALID = -12,
  643. ERROR_SPATIAL_LOCALIZATION_RUNNING = -1000,
  644. ERROR_SPATIAL_LOCALIZATION_NOT_RUNNING = -1001,
  645. ERROR_SPATIAL_MAP_CREATED = -1002,
  646. ERROR_SPATIAL_MAP_NOT_CREATED = -1003,
  647. ERROR_COMPONENT_NOT_SUPPORTED = -501,
  648. ERROR_COMPONENT_CONFLICT = -502,
  649. ERROR_COMPONENT_NOT_ADDED = -503,
  650. ERROR_COMPONENT_ADDED = -504,
  651. ERROR_ANCHOR_ENTITY_NOT_FOUND = -505
  652. }
  653. public enum PxrEventLevel
  654. {
  655. Low = 0,
  656. Mid,
  657. High
  658. }
  659. // The reference frame in which the pose is calculated,
  660. // Currently Local and Global are supported.
  661. public enum PxrReferenceType
  662. {
  663. NotDefined = 0,
  664. Local = 1,
  665. Global = 2
  666. }
  667. // Storage location to be used to store, load, erase, and query spatial instances from
  668. public enum PxrSpatialPersistenceLocation
  669. {
  670. NotDefined = 0,
  671. Local = 1, // local device storage
  672. Remote = 2, // remote storage
  673. }
  674. // Persistence mode, only one mode is supported and may be more mode in future.
  675. public enum PxrSpatialPersistenceMode
  676. {
  677. NotDefined = 0,
  678. Default = 1, // only this mode is supported now.
  679. }
  680. public enum PxrSpatialPersistenceResult
  681. {
  682. ErrorRuntimeFailure = -2,
  683. ErrorValidationFailure = -1,
  684. Success = 0,
  685. TimeoutExpired = 1,
  686. }
  687. #endregion
  688. [StructLayout(LayoutKind.Sequential)]
  689. public struct UserDefinedSettings
  690. {
  691. public ushort stereoRenderingMode;
  692. public ushort colorSpace;
  693. public ushort systemDisplayFrequency;
  694. public ushort useContentProtect;
  695. public ushort optimizeBufferDiscards;
  696. public ushort enableAppSpaceWarp;
  697. public ushort enableSubsampled;
  698. public ushort lateLatchingDebug;
  699. public ushort enableStageMode;
  700. public ushort enableSuperResolution;
  701. public ushort normalSharpening;
  702. public ushort qualitySharpening;
  703. public ushort fixedFoveatedSharpening;
  704. public ushort selfAdaptiveSharpening;
  705. }
  706. public enum RenderEvent
  707. {
  708. CreateTexture,
  709. DeleteTexture,
  710. UpdateTexture
  711. }
  712. public enum ResUtilsType
  713. {
  714. TypeTextSize,
  715. TypeColor,
  716. TypeText,
  717. TypeFont,
  718. TypeValue,
  719. TypeDrawable,
  720. TypeObject,
  721. TypeObjectArray,
  722. }
  723. public enum GraphicsAPI
  724. {
  725. OpenGLES,
  726. Vulkan
  727. };
  728. public enum EyeType
  729. {
  730. EyeLeft,
  731. EyeRight,
  732. EyeBoth
  733. };
  734. public enum ConfigType
  735. {
  736. RenderTextureWidth,
  737. RenderTextureHeight,
  738. ShowFps,
  739. RuntimeLogLevel,
  740. PluginLogLevel,
  741. UnityLogLevel,
  742. UnrealLogLevel,
  743. NativeLogLevel,
  744. TargetFrameRate,
  745. NeckModelX,
  746. NeckModelY,
  747. NeckModelZ,
  748. DisplayRefreshRate,
  749. Ability6Dof,
  750. DeviceModel,
  751. PhysicalIPD,
  752. ToDelaSensorY,
  753. SystemDisplayRate,
  754. FoveationSubsampledEnabled,
  755. TrackingOriginHeight,
  756. EngineVersion,
  757. UnrealOpenglNoError,
  758. EnableCPT,
  759. MRCTextureID,
  760. RenderFPS,
  761. AntiAliasingLevelRecommended,
  762. MRCTextureID2,
  763. PxrSetSurfaceView,
  764. PxrAPIVersion,
  765. PxrMrcPosiyionYOffset,
  766. PxrMrcTextureWidth,
  767. PxrMrcTextureHeight,
  768. PxrAndroidLayerDimensions = 34,
  769. PxrANDROID_SN,
  770. PxrSetDesiredFPS,
  771. PxrGetSeethroughState,
  772. PxrSetLayerBlend,
  773. PxrLeftEyeFOV,
  774. PxrRightEyeFOV,
  775. PxrBothEyeFOV,
  776. SupportQuickSeethrough,
  777. SetFilterType,
  778. SetSubmitLayerEXTItemColorMatrix,
  779. };
  780. public enum FoveatedRenderingMode
  781. {
  782. FixedFoveatedRendering = 0,
  783. EyeTrackedFoveatedRendering = 1
  784. }
  785. public enum FoveationLevel
  786. {
  787. None = -1,
  788. Low,
  789. Med,
  790. High,
  791. TopHigh
  792. }
  793. public enum BoundaryType
  794. {
  795. OuterBoundary,
  796. PlayArea
  797. }
  798. public enum BoundaryTrackingNode
  799. {
  800. HandLeft,
  801. HandRight,
  802. Head
  803. }
  804. public enum PxrTrackingState
  805. {
  806. LostNoReason,
  807. LostCamera,
  808. LostHighLight,
  809. LostLowLight,
  810. LostLowFeatureCount,
  811. LostReLocation,
  812. LostInitialization,
  813. LostNoCamera,
  814. LostNoIMU,
  815. LostIMUJitter,
  816. LostUnknown,
  817. }
  818. public enum ResetSensorOption
  819. {
  820. ResetPosition,
  821. ResetRotation,
  822. ResetRotationYOnly,
  823. ResetAll
  824. };
  825. public enum PxrLayerCreateFlags
  826. {
  827. PxrLayerFlagAndroidSurface = 1 << 0,
  828. PxrLayerFlagProtectedContent = 1 << 1,
  829. PxrLayerFlagStaticImage = 1 << 2,
  830. PxrLayerFlagUseExternalImages = 1 << 4,
  831. PxrLayerFlag3DLeftRightSurface = 1 << 5,
  832. PxrLayerFlag3DTopBottomSurface = 1 << 6,
  833. PxrLayerFlagEnableFrameExtrapolation = 1 << 7,
  834. PxrLayerFlagEnableSubsampled = 1 << 8,
  835. PxrLayerFlagEnableFrameExtrapolationPTW = 1 << 9,
  836. PxrLayerFlagSharedImagesBetweenLayers = 1 << 10,
  837. }
  838. public enum PxrLayerSubmitFlagsEXT
  839. {
  840. PxrLayerFlagMRCComposition = 1 << 30,
  841. }
  842. public enum PxrLayerSubmitFlags
  843. {
  844. PxrLayerFlagNoCompositionDepthTesting = 1 << 3,
  845. PxrLayerFlagUseExternalHeadPose = 1 << 5,
  846. PxrLayerFlagLayerPoseNotInTrackingSpace = 1 << 6,
  847. PxrLayerFlagHeadLocked = 1 << 7,
  848. PxrLayerFlagUseExternalImageIndex = 1 << 8,
  849. PxrLayerFlagPresentationProtection = 1 << 9,
  850. PxrLayerFlagSourceAlpha_1_0 = 1 << 10,
  851. PxrLayerFlagUseFrameExtrapolation = 1 << 11,
  852. PxrLayerFlagQuickSeethrough = 1 << 12,
  853. PxrLayerFlagEnableNormalSuperSampling = 1 << 13,
  854. PxrLayerFlagEnableQualitySuperSampling = 1 << 14,
  855. PxrLayerFlagEnableNormalSharpening = 1 << 15,
  856. PxrLayerFlagEnableQualitySharpening = 1 << 16,
  857. PxrLayerFlagEnableFixedFoveatedSuperSampling = 1 << 17,
  858. PxrLayerFlagEnableFixedFoveatedSharpening = 1 << 18,
  859. PxrLayerFlagEnableSelfAdaptiveSharpening = 1 << 19,
  860. PxrLayerFlagPremultipliedAlpha = 1 << 20,
  861. }
  862. public enum PxrControllerKeyMap
  863. {
  864. PXR_CONTROLLER_KEY_HOME = 0,
  865. PXR_CONTROLLER_KEY_AX = 1,
  866. PXR_CONTROLLER_KEY_BY = 2,
  867. PXR_CONTROLLER_KEY_BACK = 3,
  868. PXR_CONTROLLER_KEY_TRIGGER = 4,
  869. PXR_CONTROLLER_KEY_VOL_UP = 5,
  870. PXR_CONTROLLER_KEY_VOL_DOWN = 6,
  871. PXR_CONTROLLER_KEY_ROCKER = 7,
  872. PXR_CONTROLLER_KEY_GRIP = 8,
  873. PXR_CONTROLLER_KEY_TOUCHPAD = 9,
  874. PXR_CONTROLLER_KEY_LASTONE = 127,
  875. PXR_CONTROLLER_TOUCH_AX = 128,
  876. PXR_CONTROLLER_TOUCH_BY = 129,
  877. PXR_CONTROLLER_TOUCH_ROCKER = 130,
  878. PXR_CONTROLLER_TOUCH_TRIGGER = 131,
  879. PXR_CONTROLLER_TOUCH_THUMB = 132,
  880. PXR_CONTROLLER_TOUCH_LASTONE = 255
  881. }
  882. public enum GetDataType
  883. {
  884. PXR_GET_FACE_DATA_DEFAULT = 0,
  885. PXR_GET_FACE_DATA = 3,
  886. PXR_GET_LIP_DATA = 4,
  887. PXR_GET_FACELIP_DATA = 5,
  888. }
  889. /// <summary>
  890. /// Body joint enumerations.
  891. /// * For leg tracking mode, joints numbered from 0 to 15 return data.
  892. /// * For full body tracking mode, all joints return data.
  893. /// </summary>
  894. public enum BodyTrackerRole
  895. {
  896. Pelvis = 0,
  897. LEFT_HIP = 1,
  898. RIGHT_HIP = 2,
  899. SPINE1 = 3,
  900. LEFT_KNEE = 4,
  901. RIGHT_KNEE = 5,
  902. SPINE2 = 6,
  903. LEFT_ANKLE = 7,
  904. RIGHT_ANKLE = 8,
  905. SPINE3 = 9,
  906. LEFT_FOOT = 10,
  907. RIGHT_FOOT = 11,
  908. NECK = 12,
  909. LEFT_COLLAR = 13,
  910. RIGHT_COLLAR = 14,
  911. HEAD = 15,
  912. LEFT_SHOULDER = 16,
  913. RIGHT_SHOULDER = 17,
  914. LEFT_ELBOW = 18,
  915. RIGHT_ELBOW = 19,
  916. LEFT_WRIST = 20,
  917. RIGHT_WRIST = 21,
  918. LEFT_HAND = 22,
  919. RIGHT_HAND = 23,
  920. NONE_ROLE = 24, // unvalid
  921. MIN_ROLE = 0, // min value
  922. MAX_ROLE = 23, // max value
  923. ROLE_NUM = 24,
  924. }
  925. public enum BodyActionList
  926. {
  927. PxrNoneAction = 0x00000000,
  928. PxrTouchGround = 0x00000001,
  929. PxrKeepStatic = 0x00000002,
  930. }
  931. /// <summary>
  932. /// Contains data about the position and rotation of a body joint.
  933. /// </summary>
  934. public struct BodyTrackerTransPose
  935. {
  936. /// <summary>
  937. /// IMU timestamp.
  938. /// </summary>
  939. public Int64 TimeStamp;
  940. /// <summary>
  941. /// The joint's position on the X axis.
  942. /// </summary>
  943. public double PosX;
  944. /// <summary>
  945. /// The joint's position on the Y axis.
  946. /// </summary>
  947. public double PosY;
  948. /// <summary>
  949. /// The joint's position on the Z axis.
  950. /// </summary>
  951. public double PosZ;
  952. /// <summary>
  953. /// The joint's rotation on the X component of the Quaternion.
  954. /// </summary>
  955. public double RotQx;
  956. /// <summary>
  957. /// The joint's rotation on the Y component of the Quaternion.
  958. /// </summary>
  959. public double RotQy;
  960. /// <summary>
  961. /// The joint's rotation on the Z component of the Quaternion.
  962. /// </summary>
  963. public double RotQz;
  964. /// <summary>
  965. /// The joint's rotation on the W component of the Quaternion.
  966. /// </summary>
  967. public double RotQw;
  968. }
  969. /// <summary>
  970. /// Contains data about the position, velocity, acceleration, and action of a body joint.
  971. /// </summary>
  972. [StructLayout(LayoutKind.Sequential)]
  973. public struct BodyTrackerTransform
  974. {
  975. /// <summary>
  976. /// Body joint name. If the value is `NONE_ROLE`, the joint's data will not be calculated.
  977. /// </summary>
  978. public BodyTrackerRole bone;
  979. /// <summary>
  980. /// The joint's position in the scene. Use `localpose` for your app.
  981. /// </summary>
  982. public BodyTrackerTransPose localpose;
  983. /// <summary>
  984. /// (do not use `globalpose`)
  985. /// </summary>
  986. public BodyTrackerTransPose globalpose;
  987. /// <summary>
  988. /// The joint's velocity on the X, Y, and Z axes.
  989. /// </summary>
  990. [MarshalAs(UnmanagedType.ByValArray, SizeConst = 3)]
  991. public double[] velo;
  992. /// <summary>
  993. /// The joint's acceleration on the X, Y, and Z axes.
  994. /// </summary>
  995. [MarshalAs(UnmanagedType.ByValArray, SizeConst = 3)]
  996. public double[] acce;
  997. /// <summary>
  998. /// The joint's angular velocity on the X, Y, and Z axes.
  999. /// </summary>
  1000. [MarshalAs(UnmanagedType.ByValArray, SizeConst = 3)]
  1001. public double[] wvelo;
  1002. /// <summary>
  1003. /// The joint's angular acceleration on the X, Y, and Z axes.
  1004. /// </summary>
  1005. [MarshalAs(UnmanagedType.ByValArray, SizeConst = 3)]
  1006. public double[] wacce;
  1007. /// <summary>
  1008. /// Multiple actions can be supported at the same time by means of OR
  1009. /// </summary>
  1010. public UInt32 Action;
  1011. }
  1012. /// <summary>
  1013. /// Contains data about the position, velocity, acceleration, and action of each body joint.
  1014. /// </summary>
  1015. public struct BodyTrackerResult
  1016. {
  1017. /// <summary>
  1018. /// A fixed-length array, each position transmits the data of one body joint.
  1019. /// </summary>
  1020. [MarshalAs(UnmanagedType.ByValArray, SizeConst = 24)]
  1021. public BodyTrackerTransform[] trackingdata;
  1022. }
  1023. /// <summary>
  1024. /// Information about PICO Motion Tracker's connection state.
  1025. /// </summary>
  1026. [StructLayout(LayoutKind.Sequential)]
  1027. public unsafe struct PxrFitnessBandConnectState
  1028. {
  1029. /// <summary>
  1030. ///
  1031. /// </summary>
  1032. public Byte num;
  1033. /// <summary>
  1034. ///
  1035. /// </summary>
  1036. public fixed Byte trackerID[12];
  1037. }
  1038. public enum BodyTrackingAlgParamType
  1039. {
  1040. HUMAN_HEIGHT = 0,
  1041. SWIFT_MODE = 1,
  1042. BONE_PARAM = 2
  1043. }
  1044. public struct BodyTrackingAlgParam
  1045. {
  1046. public int BodyJointSet;
  1047. public BodyTrackingBoneLength BoneLength;
  1048. }
  1049. /// <summary>
  1050. /// The struct that defines the lengths (in centimeters) of different body parts of the avatar.
  1051. /// </summary>
  1052. public struct BodyTrackingBoneLength
  1053. {
  1054. /// <summary>
  1055. /// The length of the head, which is from the top of the head to the upper area of the neck.
  1056. /// </summary>
  1057. public float headLen;
  1058. /// <summary>
  1059. /// The length of the neck, which is from the upper area of the neck to the lower area of the neck.
  1060. /// </summary>
  1061. public float neckLen;
  1062. /// <summary>
  1063. /// The length of the torso, which is from the lower area of the neck to the navel.
  1064. /// </summary>
  1065. public float torsoLen;
  1066. /// <summary>
  1067. /// The length of the hip, which is from the navel to the center of the upper area of the upper leg.
  1068. /// </summary>
  1069. public float hipLen;
  1070. /// <summary>
  1071. /// The length of the upper leg, which from the hip to the knee-joint.
  1072. /// </summary>
  1073. public float upperLegLen;
  1074. /// <summary>
  1075. /// The length of the lower leg, which is from the knee-joint to the ankle.
  1076. /// </summary>
  1077. public float lowerLegLen;
  1078. /// <summary>
  1079. /// The length of the foot, which is from the ankle to the tiptoe.
  1080. /// </summary>
  1081. public float footLen;
  1082. /// <summary>
  1083. /// The length of the shoulder, which is between the left and right shoulder joints.
  1084. /// </summary>
  1085. public float shoulderLen;
  1086. /// <summary>
  1087. /// The length of the upper arm, which is from the sholder joint to the elbow joint.
  1088. /// </summary>
  1089. public float upperArmLen;
  1090. /// <summary>
  1091. /// The length of the lower arm, which is from the elbow joint to the wrist.
  1092. /// </summary>
  1093. public float lowerArmLen;
  1094. /// <summary>
  1095. /// The length of the hand, which is from the wrist to the finger tip.
  1096. /// </summary>
  1097. public float handLen;
  1098. }
  1099. public enum AdaptiveResolutionPowerSetting
  1100. {
  1101. HIGH_QUALITY, // performance factor = 0.9
  1102. BALANCED, // performance factor = 0.8
  1103. BATTERY_SAVING // performance factor = 0.7
  1104. }
  1105. public struct FoveationParams
  1106. {
  1107. public float foveationGainX;
  1108. public float foveationGainY;
  1109. public float foveationArea;
  1110. public float foveationMinimum;
  1111. }
  1112. [StructLayout(LayoutKind.Sequential)]
  1113. public struct EyeTrackingGazeRay
  1114. {
  1115. public Vector3 direction;
  1116. public bool isValid;
  1117. public Vector3 origin;
  1118. }
  1119. [StructLayout(LayoutKind.Sequential)]
  1120. public struct PxrSensorState
  1121. {
  1122. public int status;
  1123. public PxrPosef pose;
  1124. public PxrVector3f angularVelocity;
  1125. public PxrVector3f linearVelocity;
  1126. public PxrVector3f angularAcceleration;
  1127. public PxrVector3f linearAcceleration;
  1128. public UInt64 poseTimeStampNs;
  1129. }
  1130. [StructLayout(LayoutKind.Sequential)]
  1131. public struct PxrSensorState2
  1132. {
  1133. public int status;
  1134. public PxrPosef pose;
  1135. public PxrPosef globalPose;
  1136. public PxrVector3f angularVelocity;
  1137. public PxrVector3f linearVelocity;
  1138. public PxrVector3f angularAcceleration;
  1139. public PxrVector3f linearAcceleration;
  1140. public UInt64 poseTimeStampNs;
  1141. }
  1142. [StructLayout(LayoutKind.Sequential)]
  1143. public struct PxrControllerTracking
  1144. {
  1145. public PxrSensorState localControllerPose;
  1146. public PxrSensorState globalControllerPose;
  1147. }
  1148. public enum PxrControllerType
  1149. {
  1150. PxrInputG2 = 3,
  1151. PxrInputNeo2 = 4,
  1152. PxrInputNeo3 = 5,
  1153. PxrInputPICO_4 = 6
  1154. }
  1155. public enum PxrControllerDof
  1156. {
  1157. PxrController3Dof,
  1158. PxrController6Dof
  1159. }
  1160. public enum PxrControllerBond
  1161. {
  1162. PxrControllerIsBond,
  1163. PxrControllerUnBond
  1164. }
  1165. public enum PxrBlendFactor
  1166. {
  1167. PxrBlendFactorZero = 0,
  1168. PxrBlendFactorOne = 1,
  1169. PxrBlendFactorSrcAlpha = 2,
  1170. PxrBlendFactorOneMinusSrcAlpha = 3,
  1171. PxrBlendFactorDstAlpha = 4,
  1172. PxrBlendFactorOneMinusDstAlpha = 5
  1173. };
  1174. public enum PxrDeviceAbilities
  1175. {
  1176. PxrTrackingModeRotationBit,
  1177. PxrTrackingModePositionBit,
  1178. PxrTrackingModeEyeBit,
  1179. PxrTrackingModeFaceBit,
  1180. PxrTrackingModeBroadBandMontorBit,
  1181. PxrTrackingModeHandBit
  1182. }
  1183. public enum FaceTrackingMode {
  1184. None,
  1185. Hybrid,
  1186. FaceOnly,
  1187. LipsyncOnly
  1188. }
  1189. public enum SkipInitSettingFlag {
  1190. SkipHandleConnectionTeaching = 1,
  1191. SkipTriggerKeyTeaching = 1 << 1,
  1192. SkipLanguage = 1 << 2,
  1193. SkipCountry = 1 << 3,
  1194. SkipWIFI = 1 << 4,
  1195. SkipQuickSetting = 1 << 5
  1196. }
  1197. public enum PxrPerfSettings {
  1198. CPU = 1,
  1199. GPU = 2,
  1200. }
  1201. public enum PxrSettingsLevel {
  1202. POWER_SAVINGS = 0,
  1203. SUSTAINED_LOW = 1,
  1204. SUSTAINED_HIGH = 3,
  1205. BOOST = 5,
  1206. }
  1207. public enum PxrFtLipsyncValue
  1208. {
  1209. STOP_FT,
  1210. STOP_LIPSYNC,
  1211. START_FT,
  1212. START_LIPSYNC,
  1213. }
  1214. public enum PxrGazeType
  1215. {
  1216. Never,
  1217. DuringMotion,
  1218. Always
  1219. }
  1220. public enum PxrArmModelType
  1221. {
  1222. Controller,
  1223. Wrist,
  1224. Elbow,
  1225. Shoulder
  1226. }
  1227. public enum SharpeningMode
  1228. {
  1229. None,
  1230. Normal,
  1231. Quality
  1232. }
  1233. public enum SharpeningEnhance
  1234. {
  1235. None,
  1236. FixedFoveated,
  1237. SelfAdaptive,
  1238. Both
  1239. }
  1240. [StructLayout(LayoutKind.Sequential)]
  1241. public struct PxrControllerCapability
  1242. {
  1243. public PxrControllerType type;
  1244. public PxrControllerDof inputDof;
  1245. public PxrControllerBond inputBond;
  1246. public UInt64 Abilities;
  1247. }
  1248. [StructLayout(LayoutKind.Sequential)]
  1249. public struct PxrLayerParam
  1250. {
  1251. public int layerId;
  1252. public PXR_OverLay.OverlayShape layerShape;
  1253. public PXR_OverLay.OverlayType layerType;
  1254. public PXR_OverLay.LayerLayout layerLayout;
  1255. public UInt64 format;
  1256. public UInt32 width;
  1257. public UInt32 height;
  1258. public UInt32 sampleCount;
  1259. public UInt32 faceCount;
  1260. public UInt32 arraySize;
  1261. public UInt32 mipmapCount;
  1262. public UInt32 layerFlags;
  1263. public UInt32 externalImageCount;
  1264. public IntPtr leftExternalImages;
  1265. public IntPtr rightExternalImages;
  1266. };
  1267. [StructLayout(LayoutKind.Sequential)]
  1268. public struct PxrVector4f
  1269. {
  1270. public float x;
  1271. public float y;
  1272. public float z;
  1273. public float w;
  1274. };
  1275. [StructLayout(LayoutKind.Sequential)]
  1276. public struct PxrVector3f
  1277. {
  1278. public float x;
  1279. public float y;
  1280. public float z;
  1281. };
  1282. [StructLayout(LayoutKind.Sequential)]
  1283. public struct PxrVector2f
  1284. {
  1285. public float x;
  1286. public float y;
  1287. };
  1288. [StructLayout(LayoutKind.Sequential)]
  1289. public struct PxrBoundaryTriggerInfo
  1290. {
  1291. public bool isTriggering;
  1292. public float closestDistance;
  1293. public PxrVector3f closestPoint;
  1294. public PxrVector3f closestPointNormal;
  1295. public bool valid;
  1296. };
  1297. [StructLayout(LayoutKind.Sequential)]
  1298. public struct PxrPosef
  1299. {
  1300. public PxrVector4f orientation;
  1301. public PxrVector3f position;
  1302. };
  1303. [StructLayout(LayoutKind.Sequential)]
  1304. public struct PxrRecti
  1305. {
  1306. public int x;
  1307. public int y;
  1308. public int width;
  1309. public int height;
  1310. };
  1311. [StructLayout(LayoutKind.Sequential)]
  1312. public struct PxrLayerBlend
  1313. {
  1314. public PxrBlendFactor srcColor;
  1315. public PxrBlendFactor dstColor;
  1316. public PxrBlendFactor srcAlpha;
  1317. public PxrBlendFactor dstAlpha;
  1318. };
  1319. [StructLayout(LayoutKind.Sequential)]
  1320. public struct PxrLayerHeader
  1321. {
  1322. public int layerId;
  1323. public UInt32 layerFlags;
  1324. public float colorScaleX;
  1325. public float colorScaleY;
  1326. public float colorScaleZ;
  1327. public float colorScaleW;
  1328. public float colorBiasX;
  1329. public float colorBiasY;
  1330. public float colorBiasZ;
  1331. public float colorBiasW;
  1332. public int compositionDepth;
  1333. public int sensorFrameIndex;
  1334. public int imageIndex;
  1335. public PxrPosef headPose;
  1336. };
  1337. [StructLayout(LayoutKind.Sequential)]
  1338. public struct PxrLayerHeader2
  1339. {
  1340. public int layerId;
  1341. public UInt32 layerFlags;
  1342. public float colorScaleX;
  1343. public float colorScaleY;
  1344. public float colorScaleZ;
  1345. public float colorScaleW;
  1346. public float colorBiasX;
  1347. public float colorBiasY;
  1348. public float colorBiasZ;
  1349. public float colorBiasW;
  1350. public int compositionDepth;
  1351. public int sensorFrameIndex;
  1352. public int imageIndex;
  1353. public PxrPosef headPose;
  1354. public PXR_OverLay.OverlayShape layerShape;
  1355. public UInt32 useLayerBlend;
  1356. public PxrLayerBlend layerBlend;
  1357. public UInt32 useImageRect;
  1358. public PxrRecti imageRectLeft;
  1359. public PxrRecti imageRectRight;
  1360. public UInt64 reserved0;
  1361. public UInt64 reserved1;
  1362. public UInt64 reserved2;
  1363. public UInt64 reserved3;
  1364. };
  1365. [StructLayout(LayoutKind.Sequential)]
  1366. public struct PxrLayerQuad
  1367. {
  1368. public PxrLayerHeader header;
  1369. public PxrPosef pose;
  1370. public float width;
  1371. public float height;
  1372. };
  1373. [StructLayout(LayoutKind.Sequential)]
  1374. public struct PxrLayerQuad2
  1375. {
  1376. public PxrLayerHeader2 header;
  1377. public PxrPosef poseLeft;
  1378. public PxrPosef poseRight;
  1379. public PxrVector2f sizeLeft;
  1380. public PxrVector2f sizeRight;
  1381. };
  1382. [StructLayout(LayoutKind.Sequential)]
  1383. public struct PxrLayerCylinder
  1384. {
  1385. public PxrLayerHeader header;
  1386. public PxrPosef pose;
  1387. public float radius;
  1388. public float centralAngle;
  1389. public float height;
  1390. };
  1391. [StructLayout(LayoutKind.Sequential)]
  1392. public struct PxrLayerCylinder2
  1393. {
  1394. public PxrLayerHeader2 header;
  1395. public PxrPosef poseLeft;
  1396. public PxrPosef poseRight;
  1397. public float radiusLeft;
  1398. public float radiusRight;
  1399. public float centralAngleLeft;
  1400. public float centralAngleRight;
  1401. public float heightLeft;
  1402. public float heightRight;
  1403. };
  1404. [StructLayout(LayoutKind.Sequential)]
  1405. public struct PxrLayerEquirect
  1406. {
  1407. public PxrLayerHeader2 header;
  1408. public PxrPosef poseLeft;
  1409. public PxrPosef poseRight;
  1410. public float radiusLeft;
  1411. public float radiusRight;
  1412. public float scaleXLeft;
  1413. public float scaleXRight;
  1414. public float scaleYLeft;
  1415. public float scaleYRight;
  1416. public float biasXLeft;
  1417. public float biasXRight;
  1418. public float biasYLeft;
  1419. public float biasYRight;
  1420. };
  1421. [StructLayout(LayoutKind.Sequential)]
  1422. public struct PxrLayerEquirect2
  1423. {
  1424. public PxrLayerHeader2 header;
  1425. public PxrPosef poseLeft;
  1426. public PxrPosef poseRight;
  1427. public float radiusLeft;
  1428. public float radiusRight;
  1429. public float centralHorizontalAngleLeft;
  1430. public float centralHorizontalAngleRight;
  1431. public float upperVerticalAngleLeft;
  1432. public float upperVerticalAngleRight;
  1433. public float lowerVerticalAngleLeft;
  1434. public float lowerVerticalAngleRight;
  1435. };
  1436. [StructLayout(LayoutKind.Sequential)]
  1437. public struct PxrLayerCube2
  1438. {
  1439. public PxrLayerHeader2 header;
  1440. public PxrPosef poseLeft;
  1441. public PxrPosef poseRight;
  1442. };
  1443. [StructLayout(LayoutKind.Sequential)]
  1444. public struct PxrLayerEac2
  1445. {
  1446. public PxrLayerHeader2 header;
  1447. public PxrPosef poseLeft;
  1448. public PxrPosef poseRight;
  1449. public PxrVector3f offsetPosLeft;
  1450. public PxrVector3f offsetPosRight;
  1451. public PxrVector4f offsetRotLeft;
  1452. public PxrVector4f offsetRotRight;
  1453. public UInt32 degreeType;
  1454. public float overlapFactor;
  1455. public UInt64 timestamp;
  1456. };
  1457. [StructLayout(LayoutKind.Sequential)]
  1458. public struct AudioClipData
  1459. {
  1460. public int slot;//手柄
  1461. public UInt64 buffersize;//数据大小
  1462. public int sampleRate;// 采样率
  1463. public int channelCounts;//通道数
  1464. public int bitrate;//bit率
  1465. public int reversal;//反转
  1466. public int isCache;//是否缓存
  1467. };
  1468. [StructLayout(LayoutKind.Sequential)]
  1469. public struct VibrateInfo {
  1470. public uint slot;
  1471. public uint reversal;
  1472. public float amp;
  1473. };
  1474. [StructLayout(LayoutKind.Sequential)]
  1475. public struct PxrPhfParams {
  1476. public UInt64 frameseq;
  1477. public UInt16 play;
  1478. public UInt16 frequency;
  1479. public UInt16 loop;
  1480. public float gain;
  1481. };
  1482. [StructLayout(LayoutKind.Sequential)]
  1483. public struct PxrPhfFile
  1484. {
  1485. public string phfVersion;
  1486. public int frameDuration;
  1487. public PxrPhfParams[] patternData_L;
  1488. public PxrPhfParams[] patternData_R;
  1489. }
  1490. [StructLayout(LayoutKind.Sequential)]
  1491. public struct PxrPhfParamsNum {
  1492. [MarshalAs(UnmanagedType.ByValArray, SizeConst = 50)]
  1493. public PxrPhfParams[] phfParams;
  1494. }
  1495. [StructLayout(LayoutKind.Sequential)]
  1496. public unsafe struct PxrFaceTrackingInfo
  1497. {
  1498. public Int64 timestamp; // us
  1499. public fixed float blendShapeWeight[72]; //72(52+20)Expression component weight
  1500. public fixed float videoInputValid[10]; // Input validity of upper and lower face
  1501. public float laughingProb; // Coefficient of laughter
  1502. public fixed float emotionProb[10]; // Emotional factor
  1503. public fixed float reserved[128];
  1504. };
  1505. [StructLayout(LayoutKind.Sequential)]
  1506. public struct PxrExtent2Di
  1507. {
  1508. public int width;
  1509. public int height;
  1510. };
  1511. public static class PXR_Plugin
  1512. {
  1513. private const string PXR_SDK_Version = "2.4.3";
  1514. private const string PXR_PLATFORM_DLL = "PxrPlatform";
  1515. public const string PXR_API_DLL = "pxr_api";
  1516. private static int PXR_API_Version = 0;
  1517. #region DLLImports
  1518. //MR
  1519. //new
  1520. [DllImport(PXR_API_DLL, CallingConvention = CallingConvention.Cdecl)]
  1521. public static extern int Pxr_EnablePassthroughStyle(bool value);
  1522. [DllImport(PXR_API_DLL, CallingConvention = CallingConvention.Cdecl)]
  1523. public static extern int Pxr_SetPassthroughStyle(PxrLayerEffect type, float value, float duration);
  1524. [DllImport(PXR_API_DLL, CallingConvention = CallingConvention.Cdecl)]
  1525. public static extern int Pxr_SetPassthroughLUT(ref byte[] data, int width, int height, int row, int col);
  1526. [DllImport(PXR_API_DLL, CallingConvention = CallingConvention.Cdecl)]
  1527. private static extern PxrResult Pxr_CreateAnchorEntity(ref PxrAnchorEntityCreateInfo info, out ulong anchorHandle);
  1528. [DllImport(PXR_API_DLL, CallingConvention = CallingConvention.Cdecl)]
  1529. private static extern PxrResult Pxr_DestroyAnchorEntity(ref PxrAnchorEntityDestroyInfo info);
  1530. [DllImport(PXR_API_DLL, CallingConvention = CallingConvention.Cdecl)]
  1531. private static extern PxrResult Pxr_GetAnchorPose(ulong anchorHandle, PxrTrackingOrigin origin, out PxrPosef pose);
  1532. [DllImport(PXR_API_DLL, CallingConvention = CallingConvention.Cdecl)]
  1533. private static extern PxrResult Pxr_GetAnchorEntityUuid(ulong anchorHandle, out PxrUuid uuid);
  1534. [DllImport(PXR_API_DLL, CallingConvention = CallingConvention.Cdecl)]
  1535. private static extern PxrResult Pxr_GetAnchorComponentFlags(ulong anchorHandle,
  1536. out ulong flag);
  1537. [DllImport(PXR_API_DLL, CallingConvention = CallingConvention.Cdecl)]
  1538. private static extern PxrResult Pxr_GetAnchorSceneLabel(ulong anchorHandle, out PxrSceneLabel label);
  1539. [DllImport(PXR_API_DLL, CallingConvention = CallingConvention.Cdecl)]
  1540. private static extern PxrResult Pxr_GetAnchorPlaneBoundaryInfo(ulong anchorHandle,
  1541. ref PxrAnchorPlaneBoundaryInfo info);
  1542. [DllImport(PXR_API_DLL, CallingConvention = CallingConvention.Cdecl)]
  1543. private static extern PxrResult Pxr_GetAnchorPlanePolygonInfo(ulong anchorHandle,
  1544. ref PxrAnchorPlanePolygonInfo info);
  1545. [DllImport(PXR_API_DLL, CallingConvention = CallingConvention.Cdecl)]
  1546. private static extern PxrResult Pxr_GetAnchorBoxInfo(ulong anchorHandle, ref PxrAnchorVolumeInfo info);
  1547. [DllImport(PXR_API_DLL, CallingConvention = CallingConvention.Cdecl)]
  1548. private static extern PxrResult Pxr_PersistAnchorEntity(ref PxrAnchorEntityPersistInfo info,
  1549. out ulong taskId);
  1550. [DllImport(PXR_API_DLL, CallingConvention = CallingConvention.Cdecl)]
  1551. private static extern PxrResult Pxr_UnpersistAnchorEntity(ref PxrAnchorEntityUnPersistInfo info,
  1552. out ulong taskId);
  1553. [DllImport(PXR_API_DLL, CallingConvention = CallingConvention.Cdecl)]
  1554. private static extern PxrResult Pxr_ClearPersistedAnchorEntity(ref PxrAnchorEntityClearInfo info,
  1555. out ulong taskId);
  1556. [DllImport(PXR_API_DLL, CallingConvention = CallingConvention.Cdecl)]
  1557. private static extern PxrResult Pxr_LoadAnchorEntity(ref PxrAnchorEntityLoadInfo info, out ulong taskId);
  1558. [DllImport(PXR_API_DLL, CallingConvention = CallingConvention.Cdecl)]
  1559. private static extern PxrResult Pxr_GetAnchorEntityLoadResults(ulong taskId, ref PxrAnchorEntityLoadResults results);
  1560. [DllImport(PXR_API_DLL, CallingConvention = CallingConvention.Cdecl)]
  1561. private static extern PxrResult Pxr_StartSpatialSceneCapture(out ulong taskId);
  1562. //old
  1563. [DllImport(PXR_API_DLL, CallingConvention = CallingConvention.Cdecl)]
  1564. private static extern int Pxr_StartHumanOcclusion();
  1565. [DllImport(PXR_API_DLL, CallingConvention = CallingConvention.Cdecl)]
  1566. private static extern int Pxr_AcquireMeshingInfo(IntPtr maskBuffer,IntPtr verticesBuffer, out uint verticesSize, IntPtr facetsBuffer, out uint facetSize, out bool haveRead);
  1567. [DllImport(PXR_API_DLL, CallingConvention = CallingConvention.Cdecl)]
  1568. private static extern int Pxr_StopHumanOcclusion();
  1569. [DllImport(PXR_API_DLL, CallingConvention = CallingConvention.Cdecl)]
  1570. private static extern int Pxr_CreateSpatialAnchor(ref PxrSpatialAnchorCreateInfo info, ref UInt64 handle);
  1571. [DllImport(PXR_API_DLL, CallingConvention = CallingConvention.Cdecl)]
  1572. private static extern int Pxr_DestroySpatialAnchor(UInt64 handle);
  1573. [DllImport(PXR_API_DLL, CallingConvention = CallingConvention.Cdecl)]
  1574. private static extern int Pxr_SaveSpatialAnchor(ref PxrSpatialAnchorSaveInfo info, ref UInt64 requestId);
  1575. [DllImport(PXR_API_DLL, CallingConvention = CallingConvention.Cdecl)]
  1576. private static extern int Pxr_DeleteSpatialAnchor(ref PxrSpatialAnchorDeleteInfo info, ref UInt64 requestId);
  1577. [DllImport(PXR_API_DLL, CallingConvention = CallingConvention.Cdecl)]
  1578. private static extern int Pxr_LoadSpatialAnchorById(ref PxrSpatialInstanceLoadByIdInfo info, ref UInt64 requestId);
  1579. [DllImport(PXR_API_DLL, CallingConvention = CallingConvention.Cdecl)]
  1580. private static extern int Pxr_GetSpatialAnchorLoadResults(UInt64 requestId,ref PxrSpatialAnchorLoadResults loadResults);
  1581. [DllImport(PXR_API_DLL, CallingConvention = CallingConvention.Cdecl)]
  1582. private static extern int Pxr_GetSpatialAnchorPose(UInt64 handle, double predictDisplayTime, PxrReferenceType type, ref PxrPosef pose);
  1583. [DllImport(PXR_PLATFORM_DLL, CallingConvention = CallingConvention.Cdecl)]
  1584. private static extern int Pxr_GetSpatialAnchorUuid(UInt64 handle, ref PxrSpatialInstanceUuid uuid);
  1585. [DllImport(PXR_PLATFORM_DLL, CallingConvention = CallingConvention.Cdecl)]
  1586. private static extern bool Pxr_PollEventFromXRPlugin(ref int eventNum, IntPtr[] eventData);
  1587. [DllImport(PXR_API_DLL, CallingConvention = CallingConvention.Cdecl)]
  1588. private static extern int Pxr_CreateRoomSceneData(PxrSpatialInstanceUuid anchorUuid, IntPtr roomSceneData, int dataLen, ref ulong roomSceneDataHandle);
  1589. [DllImport(PXR_API_DLL, CallingConvention = CallingConvention.Cdecl)]
  1590. private static extern int Pxr_DestroyRoomSceneData(ulong roomSceneDataHandle);
  1591. [DllImport(PXR_API_DLL, CallingConvention = CallingConvention.Cdecl)]
  1592. private static extern int Pxr_SaveRoomSceneData(ref PxrRoomSceneDataSaveInfo saveInfo, ref ulong requestId);
  1593. [DllImport(PXR_API_DLL, CallingConvention = CallingConvention.Cdecl)]
  1594. private static extern int Pxr_DeleteRoomSceneData(ref PxrRoomSceneDataDeleteInfo deleteInfo, ref ulong requestId);
  1595. [DllImport(PXR_API_DLL, CallingConvention = CallingConvention.Cdecl)]
  1596. private static extern int Pxr_LoadRoomScene(ref PxrRoomSceneLoadInfo loadInfo, ref ulong requestId);
  1597. [DllImport(PXR_API_DLL, CallingConvention = CallingConvention.Cdecl)]
  1598. private static extern int Pxr_GetRoomSceneLoadResults(ulong requestId, ref PxrRoomSceneLoadResults results);
  1599. [DllImport(PXR_API_DLL, CallingConvention = CallingConvention.Cdecl)]
  1600. private static extern int Pxr_StartRoomCapture();
  1601. //PassThrough
  1602. [DllImport(PXR_PLATFORM_DLL, CallingConvention = CallingConvention.Cdecl)]
  1603. public static extern int Pxr_CameraStart();
  1604. [DllImport(PXR_PLATFORM_DLL, CallingConvention = CallingConvention.Cdecl)]
  1605. public static extern int Pxr_CameraStop();
  1606. [DllImport(PXR_PLATFORM_DLL, CallingConvention = CallingConvention.Cdecl)]
  1607. public static extern int Pxr_CameraDestroy();
  1608. [DllImport(PXR_PLATFORM_DLL, CallingConvention = CallingConvention.Cdecl)]
  1609. public static extern IntPtr Pxr_CameraGetRenderEventFunc();
  1610. [DllImport(PXR_PLATFORM_DLL, CallingConvention = CallingConvention.Cdecl)]
  1611. public static extern void Pxr_CameraSetRenderEventPending();
  1612. [DllImport(PXR_PLATFORM_DLL, CallingConvention = CallingConvention.Cdecl)]
  1613. public static extern void Pxr_CameraWaitForRenderEvent();
  1614. [DllImport(PXR_PLATFORM_DLL, CallingConvention = CallingConvention.Cdecl)]
  1615. public static extern int Pxr_CameraUpdateFrame(int eye);
  1616. [DllImport(PXR_PLATFORM_DLL, CallingConvention = CallingConvention.Cdecl)]
  1617. public static extern int Pxr_CameraCreateTexturesMainThread();
  1618. [DllImport(PXR_PLATFORM_DLL, CallingConvention = CallingConvention.Cdecl)]
  1619. public static extern int Pxr_CameraDeleteTexturesMainThread();
  1620. [DllImport(PXR_PLATFORM_DLL, CallingConvention = CallingConvention.Cdecl)]
  1621. public static extern int Pxr_CameraUpdateTexturesMainThread();
  1622. [DllImport(PXR_PLATFORM_DLL, CallingConvention = CallingConvention.Cdecl)]
  1623. public static extern bool Pxr_SetFoveationLevelEnable(int enable);
  1624. [DllImport(PXR_PLATFORM_DLL, CallingConvention = CallingConvention.Cdecl)]
  1625. public static extern bool Pxr_SetEyeFoveationLevelEnable(int enable);
  1626. [DllImport(PXR_PLATFORM_DLL, CallingConvention = CallingConvention.Cdecl)]
  1627. public static extern void Pxr_SetFFRSubsampled(bool enable);
  1628. //System
  1629. [DllImport(PXR_PLATFORM_DLL, CallingConvention = CallingConvention.Cdecl)]
  1630. public static extern bool Pxr_LoadPlugin();
  1631. [DllImport(PXR_PLATFORM_DLL, CallingConvention = CallingConvention.Cdecl)]
  1632. public static extern void Pxr_UnloadPlugin();
  1633. [DllImport(PXR_PLATFORM_DLL, CallingConvention = CallingConvention.Cdecl)]
  1634. public static extern bool Pxr_GetHomeKey();
  1635. [DllImport(PXR_PLATFORM_DLL, CallingConvention = CallingConvention.Cdecl)]
  1636. public static extern void Pxr_InitHomeKey();
  1637. [DllImport(PXR_PLATFORM_DLL, CallingConvention = CallingConvention.Cdecl)]
  1638. public static extern bool Pxr_GetMRCEnable();
  1639. [DllImport(PXR_PLATFORM_DLL, CallingConvention = CallingConvention.Cdecl)]
  1640. public static extern void Pxr_SetUserDefinedSettings(UserDefinedSettings settings);
  1641. [DllImport(PXR_PLATFORM_DLL, CallingConvention = CallingConvention.Cdecl)]
  1642. public static extern void Pxr_Construct(PXR_Loader.ConvertRotationWith2VectorDelegate fromToRotation);
  1643. [DllImport(PXR_PLATFORM_DLL, CallingConvention = CallingConvention.Cdecl)]
  1644. public static extern float Pxr_RefreshRateChanged();
  1645. [DllImport(PXR_PLATFORM_DLL, CallingConvention = CallingConvention.Cdecl)]
  1646. public static extern bool Pxr_GetFocusState();
  1647. [DllImport(PXR_PLATFORM_DLL, CallingConvention = CallingConvention.Cdecl)]
  1648. public static extern bool Pxr_IsSensorReady();
  1649. [DllImport(PXR_PLATFORM_DLL, CallingConvention = CallingConvention.Cdecl)]
  1650. public static extern int Pxr_GetSensorStatus();
  1651. [DllImport(PXR_PLATFORM_DLL, CallingConvention = CallingConvention.Cdecl)]
  1652. public static extern void Pxr_GetLayerImagePtr(int layerId, EyeType eye, int imageIndex, ref IntPtr image);
  1653. [DllImport(PXR_PLATFORM_DLL, CallingConvention = CallingConvention.Cdecl)]
  1654. private static extern void Pxr_CreateLayerParam(PxrLayerParam layerParam);
  1655. [DllImport(PXR_PLATFORM_DLL, CallingConvention = CallingConvention.Cdecl)]
  1656. private static extern void Pxr_DestroyLayerByRender(int layerId);
  1657. [DllImport(PXR_PLATFORM_DLL, CallingConvention = CallingConvention.Cdecl)]
  1658. private static extern void Pxr_EnableEyeTracking(bool enable);
  1659. [DllImport(PXR_PLATFORM_DLL, CallingConvention = CallingConvention.Cdecl)]
  1660. private static extern void Pxr_EnableFaceTracking(bool enable);
  1661. [DllImport(PXR_PLATFORM_DLL, CallingConvention = CallingConvention.Cdecl)]
  1662. private static extern void Pxr_EnableLipsync(bool enable);
  1663. [DllImport(PXR_PLATFORM_DLL, CallingConvention = CallingConvention.Cdecl)]
  1664. private static extern void Pxr_SetInputDeviceChangedCallBack(InputDeviceChangedCallBack callback);
  1665. [DllImport(PXR_PLATFORM_DLL, CallingConvention = CallingConvention.Cdecl)]
  1666. private static extern void Pxr_SetSeethroughStateChangedCallBack(SeethroughStateChangedCallBack callback);
  1667. [DllImport(PXR_PLATFORM_DLL, CallingConvention = CallingConvention.Cdecl)]
  1668. private static extern void Pxr_SetFitnessBandNumberOfConnectionsCallBack(FitnessBandNumberOfConnectionsCallBack callback);
  1669. [DllImport(PXR_PLATFORM_DLL, CallingConvention = CallingConvention.Cdecl)]
  1670. private static extern void Pxr_SetFitnessBandElectricQuantityCallBack(FitnessBandElectricQuantityCallBack callback);
  1671. [DllImport(PXR_PLATFORM_DLL, CallingConvention = CallingConvention.Cdecl)]
  1672. private static extern void Pxr_SetFitnessBandAbnormalCalibrationDataCallBack(FitnessBandAbnormalCalibrationDataCallBack callback);
  1673. [DllImport(PXR_PLATFORM_DLL, CallingConvention = CallingConvention.Cdecl)]
  1674. private static extern void Pxr_SetLoglevelChangedCallBack(LoglevelChangedCallBack callback);
  1675. [DllImport(PXR_PLATFORM_DLL, CallingConvention = CallingConvention.Cdecl)]
  1676. private static extern void Pxr_EnablePremultipliedAlpha(bool enable);
  1677. [DllImport(PXR_API_DLL, CallingConvention = CallingConvention.Cdecl)]
  1678. private static extern void Pxr_SetGraphicOption(GraphicsAPI option);
  1679. [DllImport(PXR_API_DLL, CallingConvention = CallingConvention.Cdecl)]
  1680. private static extern int Pxr_CreateLayer(IntPtr layerParam);
  1681. [DllImport(PXR_API_DLL, CallingConvention = CallingConvention.Cdecl)]
  1682. private static extern int Pxr_GetLayerNextImageIndex(int layerId, ref int imageIndex);
  1683. [DllImport(PXR_API_DLL, CallingConvention = CallingConvention.Cdecl)]
  1684. private static extern int Pxr_GetLayerImageCount(int layerId, EyeType eye, ref UInt32 imageCount);
  1685. [DllImport(PXR_API_DLL, CallingConvention = CallingConvention.Cdecl)]
  1686. private static extern int Pxr_GetLayerImage(int layerId, EyeType eye, int imageIndex, ref UInt64 image);
  1687. [DllImport(PXR_API_DLL, CallingConvention = CallingConvention.Cdecl)]
  1688. public static extern int Pxr_SetConfigIntArray(ConfigType configIndex, int[] configSetData, int dataCount);
  1689. [DllImport(PXR_API_DLL, CallingConvention = CallingConvention.Cdecl)]
  1690. public static extern int Pxr_SetConfigFloatArray(ConfigType configIndex, float[] configSetData, int dataCount);
  1691. [DllImport(PXR_API_DLL, CallingConvention = CallingConvention.Cdecl)]
  1692. private static extern int Pxr_GetLayerAndroidSurface(int layerId, EyeType eye, ref IntPtr androidSurface);
  1693. [DllImport(PXR_API_DLL, CallingConvention = CallingConvention.Cdecl)]
  1694. private static extern int Pxr_DestroyLayer(int layerId);
  1695. [DllImport(PXR_API_DLL, CallingConvention = CallingConvention.Cdecl)]
  1696. private static extern int Pxr_SubmitLayer(IntPtr layer);
  1697. [DllImport(PXR_API_DLL, CallingConvention = CallingConvention.Cdecl)]
  1698. private static extern int Pxr_SubmitLayerQuad(PxrLayerQuad layer);
  1699. [DllImport(PXR_API_DLL, CallingConvention = CallingConvention.Cdecl)]
  1700. private static extern int Pxr_SubmitLayerQuad2(PxrLayerQuad2 layer);
  1701. [DllImport(PXR_API_DLL, CallingConvention = CallingConvention.Cdecl)]
  1702. private static extern int Pxr_SubmitLayerCylinder(PxrLayerCylinder layer);
  1703. [DllImport(PXR_API_DLL, CallingConvention = CallingConvention.Cdecl)]
  1704. private static extern int Pxr_SubmitLayerCylinder2(PxrLayerCylinder2 layer);
  1705. [DllImport(PXR_API_DLL, CallingConvention = CallingConvention.Cdecl)]
  1706. private static extern int Pxr_SubmitLayerEquirect(PxrLayerEquirect layer);
  1707. [DllImport(PXR_API_DLL, CallingConvention = CallingConvention.Cdecl)]
  1708. private static extern int Pxr_SubmitLayerEquirect2(PxrLayerEquirect2 layer);
  1709. [DllImport(PXR_API_DLL, CallingConvention = CallingConvention.Cdecl)]
  1710. private static extern int Pxr_SubmitLayerCube2(PxrLayerCube2 layer);
  1711. [DllImport(PXR_API_DLL, CallingConvention = CallingConvention.Cdecl)]
  1712. private static extern int Pxr_SubmitLayerEac2(PxrLayerEac2 layer);
  1713. [DllImport(PXR_PLATFORM_DLL, CallingConvention = CallingConvention.Cdecl)]
  1714. private static extern void Pxr_SetLayerBlend(bool enable, PxrLayerBlend layerBlend);
  1715. [DllImport(PXR_API_DLL, CallingConvention = CallingConvention.Cdecl)]
  1716. private static extern FoveationLevel Pxr_GetFoveationLevel();
  1717. [DllImport(PXR_API_DLL, CallingConvention = CallingConvention.Cdecl)]
  1718. private static extern int Pxr_SetFoveationParams(FoveationParams foveationParams);
  1719. [DllImport(PXR_API_DLL, CallingConvention = CallingConvention.Cdecl)]
  1720. public static extern int Pxr_SetFrustum(EyeType eye, float fovLeft, float fovRight, float fovUp, float fovDown, float near, float far);
  1721. [DllImport(PXR_API_DLL, CallingConvention = CallingConvention.Cdecl)]
  1722. public static extern int Pxr_GetFrustum(EyeType eye, ref float fovLeft, ref float fovRight, ref float fovUp, ref float fovDown, ref float near, ref float far);
  1723. [DllImport(PXR_API_DLL, CallingConvention = CallingConvention.Cdecl)]
  1724. public static extern int Pxr_GetConfigFloat(ConfigType configIndex, ref float value);
  1725. [DllImport(PXR_API_DLL, CallingConvention = CallingConvention.Cdecl)]
  1726. public static extern int Pxr_GetConfigInt(ConfigType configIndex, ref int value);
  1727. [DllImport(PXR_API_DLL, CallingConvention = CallingConvention.Cdecl)]
  1728. public static extern int Pxr_SetConfigInt(ConfigType configSetIndex, int configSetData);
  1729. [DllImport(PXR_API_DLL, CallingConvention = CallingConvention.Cdecl)]
  1730. public static extern int Pxr_SetConfigString(ConfigType configSetIndex, string configSetData);
  1731. [DllImport(PXR_API_DLL, CallingConvention = CallingConvention.Cdecl)]
  1732. public static extern int Pxr_SetConfigUint64(ConfigType configSetIndex, UInt64 configSetData);
  1733. [DllImport(PXR_API_DLL, CallingConvention = CallingConvention.Cdecl)]
  1734. public static extern int Pxr_ResetSensor(ResetSensorOption option);
  1735. [DllImport(PXR_API_DLL, CallingConvention = CallingConvention.Cdecl)]
  1736. public static extern int Pxr_SetSensorLostCustomMode(bool value);
  1737. [DllImport(PXR_API_DLL, CallingConvention = CallingConvention.Cdecl)]
  1738. public static extern int Pxr_SetSensorLostCMST(bool value);
  1739. [DllImport(PXR_API_DLL, CallingConvention = CallingConvention.Cdecl)]
  1740. public static extern bool Pxr_GetDisplayRefreshRatesAvailable(ref int configCount, ref IntPtr configArray);
  1741. [DllImport(PXR_API_DLL, CallingConvention = CallingConvention.Cdecl)]
  1742. public static extern int Pxr_SetDisplayRefreshRate(float refreshRate);
  1743. [DllImport(PXR_API_DLL, CallingConvention = CallingConvention.Cdecl)]
  1744. public static extern int Pxr_GetPredictedDisplayTime(ref double predictedDisplayTime);
  1745. [DllImport(PXR_API_DLL, CallingConvention = CallingConvention.Cdecl)]
  1746. public static extern bool Pxr_SetExtraLatencyMode(int mode);
  1747. [DllImport(PXR_API_DLL, CallingConvention = CallingConvention.Cdecl)]
  1748. public static extern int Pxr_GetTrackingMode(ref UInt64 trackingModeFlags);
  1749. [DllImport(PXR_API_DLL, CallingConvention = CallingConvention.Cdecl)]
  1750. public static extern int Pxr_SetTrackingOrigin(PxrTrackingOrigin mode);
  1751. [DllImport(PXR_API_DLL, CallingConvention = CallingConvention.Cdecl)]
  1752. public static extern int Pxr_GetTrackingOrigin(ref PxrTrackingOrigin mode);
  1753. [DllImport(PXR_PLATFORM_DLL, CallingConvention = CallingConvention.Cdecl)]
  1754. public static extern void Pxr_UpdateContentProtectState(int state);
  1755. //Tracking Sensor
  1756. [DllImport(PXR_API_DLL, CallingConvention = CallingConvention.Cdecl)]
  1757. public static extern int Pxr_GetPredictedMainSensorState2(double predictTimeMs, ref PxrSensorState2 sensorState, ref int sensorFrameIndex);
  1758. //Controller
  1759. [DllImport(PXR_PLATFORM_DLL, CallingConvention = CallingConvention.Cdecl)]
  1760. private static extern void Pxr_SetControllerOriginOffset(int controllerID, Vector3 offset);
  1761. [DllImport(PXR_API_DLL, CallingConvention = CallingConvention.Cdecl)]
  1762. private static extern int Pxr_GetControllerTrackingState(UInt32 deviceID, double predictTime, float[] headSensorData, ref PxrControllerTracking tracking);
  1763. [DllImport(PXR_API_DLL, CallingConvention = CallingConvention.Cdecl)]
  1764. private static extern int Pxr_SetControllerMainInputHandle(UInt32 deviceID);
  1765. [DllImport(PXR_API_DLL, CallingConvention = CallingConvention.Cdecl)]
  1766. private static extern int Pxr_GetControllerMainInputHandle(ref int deviceID);
  1767. [DllImport(PXR_API_DLL, CallingConvention = CallingConvention.Cdecl)]
  1768. private static extern int Pxr_SetControllerVibration(UInt32 deviceID, float strength, int time);
  1769. [DllImport(PXR_API_DLL, CallingConvention = CallingConvention.Cdecl)]
  1770. private static extern int Pxr_SetControllerEnableKey(bool isEnable, PxrControllerKeyMap Key);
  1771. [DllImport(PXR_API_DLL, CallingConvention = CallingConvention.Cdecl)]
  1772. private static extern int Pxr_ResetController(UInt32 deviceID);
  1773. [DllImport(PXR_API_DLL, CallingConvention = CallingConvention.Cdecl)]
  1774. private static extern int Pxr_SetArmModelParameters(PxrGazeType gazetype, PxrArmModelType armmodeltype, float elbowHeight, float elbowDepth, float pointerTiltAngle);
  1775. [DllImport(PXR_API_DLL, CallingConvention = CallingConvention.Cdecl)]
  1776. private static extern int Pxr_GetControllerHandness(ref int handness);
  1777. //Vibration
  1778. [DllImport(PXR_API_DLL, CallingConvention = CallingConvention.Cdecl)]
  1779. private static extern int Pxr_SetControllerVibrationEvent(UInt32 deviceID, int frequency, float strength, int time);
  1780. [DllImport(PXR_API_DLL, CallingConvention = CallingConvention.Cdecl)]
  1781. private static extern int Pxr_GetControllerCapabilities(UInt32 deviceID, ref PxrControllerCapability capability);
  1782. [DllImport(PXR_API_DLL, CallingConvention = CallingConvention.Cdecl)]
  1783. private static extern int Pxr_StopControllerVCMotor(int clientId);
  1784. [DllImport(PXR_API_DLL, CallingConvention = CallingConvention.Cdecl)]
  1785. private static extern int Pxr_StartControllerVCMotor(string file, int slot);
  1786. [DllImport(PXR_API_DLL, CallingConvention = CallingConvention.Cdecl)]
  1787. private static extern int Pxr_SetControllerAmp(float mode);
  1788. [DllImport(PXR_API_DLL, CallingConvention = CallingConvention.Cdecl)]
  1789. private static extern int Pxr_SetControllerDelay(int delay);
  1790. [DllImport(PXR_API_DLL, CallingConvention = CallingConvention.Cdecl)]
  1791. private static extern string Pxr_GetVibrateDelayTime(ref int length);
  1792. [DllImport(PXR_API_DLL, CallingConvention = CallingConvention.Cdecl)]
  1793. private static extern int Pxr_StartVibrateBySharemF(float[] data, ref AudioClipData parameter, ref int source_id);
  1794. [DllImport(PXR_API_DLL, CallingConvention = CallingConvention.Cdecl)]
  1795. private static extern int Pxr_StartVibrateByCache(int clicpid);
  1796. [DllImport(PXR_API_DLL, CallingConvention = CallingConvention.Cdecl)]
  1797. private static extern int Pxr_ClearVibrateByCache(int clicpid);
  1798. [DllImport(PXR_API_DLL, CallingConvention = CallingConvention.Cdecl)]
  1799. private static extern int Pxr_StartVibrateByPHF(string data, int buffersize, ref int sourceID, ref VibrateInfo vibrateInfo);
  1800. [DllImport(PXR_API_DLL, CallingConvention = CallingConvention.Cdecl)]
  1801. private static extern int Pxr_PauseVibrate(int sourceID);
  1802. [DllImport(PXR_API_DLL, CallingConvention = CallingConvention.Cdecl)]
  1803. private static extern int Pxr_ResumeVibrate(int sourceID);
  1804. [DllImport(PXR_API_DLL, CallingConvention = CallingConvention.Cdecl)]
  1805. private static extern int Pxr_UpdateVibrateParams(int clicp_id, ref VibrateInfo vibrateInfo);
  1806. [DllImport(PXR_API_DLL, CallingConvention = CallingConvention.Cdecl)]
  1807. private static extern int Pxr_CreateHapticStream(string phfVersion, UInt32 frameDurationMs, ref VibrateInfo hapticInfo, float speed, ref int id);
  1808. [DllImport(PXR_API_DLL, CallingConvention = CallingConvention.Cdecl)]
  1809. private static extern int Pxr_WriteHapticStream(int id, ref PxrPhfParamsNum frames, UInt32 numFrames);
  1810. [DllImport(PXR_API_DLL, CallingConvention = CallingConvention.Cdecl)]
  1811. private static extern int Pxr_SetPHFHapticSpeed(int id, float speed);
  1812. [DllImport(PXR_API_DLL, CallingConvention = CallingConvention.Cdecl)]
  1813. private static extern int Pxr_GetPHFHapticSpeed(int id, ref float speed);
  1814. [DllImport(PXR_API_DLL, CallingConvention = CallingConvention.Cdecl)]
  1815. private static extern int Pxr_GetCurrentFrameSequence(int id, ref UInt64 frameSequence);
  1816. [DllImport(PXR_API_DLL, CallingConvention = CallingConvention.Cdecl)]
  1817. private static extern int Pxr_StartPHFHaptic(int source_id);
  1818. [DllImport(PXR_API_DLL, CallingConvention = CallingConvention.Cdecl)]
  1819. private static extern int Pxr_StopPHFHaptic(int source_id);
  1820. [DllImport(PXR_API_DLL, CallingConvention = CallingConvention.Cdecl)]
  1821. private static extern int Pxr_RemovePHFHaptic(int source_id);
  1822. [DllImport(PXR_PLATFORM_DLL, CallingConvention = CallingConvention.Cdecl)]
  1823. private static extern void Pxr_SetLogInfoActive(bool value);
  1824. //Boundary
  1825. [DllImport(PXR_PLATFORM_DLL, CallingConvention = CallingConvention.Cdecl)]
  1826. public static extern int Pxr_GetSeeThroughState();
  1827. [DllImport(PXR_PLATFORM_DLL, CallingConvention = CallingConvention.Cdecl)]
  1828. public static extern void Pxr_SetVideoSeethroughState(bool value);
  1829. [DllImport(PXR_API_DLL, CallingConvention = CallingConvention.Cdecl)]
  1830. public static extern int Pxr_TestNodeIsInBoundary(BoundaryTrackingNode node, bool isPlayArea, ref PxrBoundaryTriggerInfo info);
  1831. [DllImport(PXR_API_DLL, CallingConvention = CallingConvention.Cdecl)]
  1832. public static extern int Pxr_TestPointIsInBoundary(ref PxrVector3f point, bool isPlayArea, ref PxrBoundaryTriggerInfo info);
  1833. [DllImport(PXR_API_DLL, CallingConvention = CallingConvention.Cdecl)]
  1834. public static extern int Pxr_GetBoundaryGeometry(bool isPlayArea, UInt32 pointsCountInput, ref UInt32 pointsCountOutput, PxrVector3f[] outPoints);
  1835. [DllImport(PXR_API_DLL, CallingConvention = CallingConvention.Cdecl)]
  1836. public static extern int Pxr_GetBoundaryDimensions(bool isPlayArea, out PxrVector3f dimension);
  1837. [DllImport(PXR_API_DLL, CallingConvention = CallingConvention.Cdecl)]
  1838. public static extern bool Pxr_GetBoundaryConfigured();
  1839. [DllImport(PXR_API_DLL, CallingConvention = CallingConvention.Cdecl)]
  1840. public static extern bool Pxr_GetBoundaryEnabled();
  1841. [DllImport(PXR_API_DLL, CallingConvention = CallingConvention.Cdecl)]
  1842. public static extern int Pxr_SetBoundaryVisible(bool value);
  1843. [DllImport(PXR_API_DLL, CallingConvention = CallingConvention.Cdecl)]
  1844. public static extern int Pxr_SetSeeThroughBackground(bool value);
  1845. [DllImport(PXR_API_DLL, CallingConvention = CallingConvention.Cdecl)]
  1846. public static extern bool Pxr_GetBoundaryVisible();
  1847. [DllImport(PXR_API_DLL, CallingConvention = CallingConvention.Cdecl)]
  1848. public static extern void Pxr_ResetSensorHard();
  1849. [DllImport(PXR_API_DLL, CallingConvention = CallingConvention.Cdecl)]
  1850. public static extern int Pxr_GetTrackingState();
  1851. [DllImport(PXR_API_DLL, CallingConvention = CallingConvention.Cdecl)]
  1852. public static extern int Pxr_SetGuardianSystemDisable(bool disable);
  1853. [DllImport(PXR_API_DLL, CallingConvention = CallingConvention.Cdecl)]
  1854. public static extern int Pxr_ResumeGuardianSystemForSTS();
  1855. [DllImport(PXR_API_DLL, CallingConvention = CallingConvention.Cdecl)]
  1856. public static extern int Pxr_PauseGuardianSystemForSTS();
  1857. [DllImport(PXR_API_DLL, CallingConvention = CallingConvention.Cdecl)]
  1858. public static extern int Pxr_ShutdownSdkGuardianSystem();
  1859. [DllImport(PXR_API_DLL, CallingConvention = CallingConvention.Cdecl)]
  1860. public static extern int Pxr_GetRoomModeState();
  1861. [DllImport(PXR_API_DLL, CallingConvention = CallingConvention.Cdecl)]
  1862. public static extern int Pxr_DisableBoundary();
  1863. //MRC
  1864. [DllImport(PXR_API_DLL, CallingConvention = CallingConvention.Cdecl)]
  1865. public static extern bool Pxr_GetMrcStatus();
  1866. [DllImport(PXR_API_DLL, CallingConvention = CallingConvention.Cdecl)]
  1867. public static extern int Pxr_GetMrcPose(ref PxrPosef pose);
  1868. [DllImport(PXR_API_DLL, CallingConvention = CallingConvention.Cdecl)]
  1869. public static extern int Pxr_SetMrcPose(ref PxrPosef pose);
  1870. [DllImport(PXR_API_DLL, CallingConvention = CallingConvention.Cdecl)]
  1871. public static extern int Pxr_SetIsSupportMovingMrc(bool support);
  1872. //Face tracking
  1873. [DllImport(PXR_API_DLL, CallingConvention = CallingConvention.Cdecl)]
  1874. public static extern int Pxr_SetTrackingMode(double trackingMode);
  1875. [DllImport(PXR_API_DLL, CallingConvention = CallingConvention.Cdecl)]
  1876. public static extern int Pxr_GetFaceTrackingData(Int64 ts, int flags, ref PxrFaceTrackingInfo faceTrackingInfo);
  1877. //Application SpaceWarp
  1878. [DllImport(PXR_PLATFORM_DLL, CallingConvention = CallingConvention.Cdecl)]
  1879. public static extern void Pxr_SetSpaceWarp(int value);
  1880. [DllImport(PXR_PLATFORM_DLL, CallingConvention = CallingConvention.Cdecl)]
  1881. public static extern void Pxr_SetAppSpacePosition(float x, float y, float z);
  1882. [DllImport(PXR_PLATFORM_DLL, CallingConvention = CallingConvention.Cdecl)]
  1883. public static extern void Pxr_SetAppSpaceRotation(float x, float y, float z, float w);
  1884. [DllImport(PXR_API_DLL, CallingConvention = CallingConvention.Cdecl)]
  1885. public static extern int Pxr_SetTrackingStatus(String key, String value);
  1886. [DllImport(PXR_API_DLL, CallingConvention = CallingConvention.Cdecl)]
  1887. public static extern int Pxr_SetPerformanceLevels(PxrPerfSettings which, PxrSettingsLevel level);
  1888. [DllImport(PXR_API_DLL, CallingConvention = CallingConvention.Cdecl)]
  1889. public static extern int Pxr_GetPerformanceLevels(PxrPerfSettings which, ref PxrSettingsLevel level);
  1890. //Body tracking
  1891. [DllImport(PXR_API_DLL, CallingConvention = CallingConvention.Cdecl)]
  1892. public static extern int Pxr_GetBodyTrackingPose(double predictTime, ref BodyTrackerResult bodyTrackerResult);
  1893. [DllImport(PXR_API_DLL, CallingConvention = CallingConvention.Cdecl)]
  1894. public static extern int Pxr_SetBodyTrackingMode(int mode);
  1895. [DllImport(PXR_API_DLL, CallingConvention = CallingConvention.Cdecl)]
  1896. public static extern int Pxr_GetFitnessBandConnectState(ref PxrFitnessBandConnectState state);
  1897. [DllImport(PXR_API_DLL, CallingConvention = CallingConvention.Cdecl)]
  1898. public static extern int Pxr_GetFitnessBandBattery(int trackerId, ref int battery);
  1899. [DllImport(PXR_API_DLL, CallingConvention = CallingConvention.Cdecl)]
  1900. public static extern int Pxr_GetFitnessBandCalibState(ref int calibrated);
  1901. [DllImport(PXR_API_DLL, CallingConvention = CallingConvention.Cdecl)]
  1902. public static extern int Pxr_LogSdkApi(string sdkInfo);
  1903. [DllImport(PXR_API_DLL, CallingConvention = CallingConvention.Cdecl)]
  1904. private static extern int Pxr_SetBodyTrackingAlgParam(BodyTrackingAlgParamType AlgParamType, ref BodyTrackingAlgParam Param);
  1905. [DllImport(PXR_API_DLL, CallingConvention = CallingConvention.Cdecl)]
  1906. public static extern int Pxr_UpdateAdaptiveResolution(ref PxrExtent2Di dimensions, AdaptiveResolutionPowerSetting powerSetting);
  1907. #endregion
  1908. public static class System
  1909. {
  1910. public static Action RecenterSuccess;
  1911. public static Action FocusStateAcquired;
  1912. public static Action FocusStateLost;
  1913. public static Action SensorReady;
  1914. public static Action<int> InputDeviceChanged;
  1915. public static Action<int> LoglevelChangedChanged;
  1916. public static Action<int> SeethroughStateChangedChanged;
  1917. public static Action<int, int> FitnessBandNumberOfConnections;
  1918. public static Action<int, int> FitnessBandElectricQuantity;
  1919. public static Action<int, int> FitnessBandAbnormalCalibrationData;
  1920. public static void UPxr_SetTrackingOrigin(PxrTrackingOrigin mode)
  1921. {
  1922. #if UNITY_ANDROID && !UNITY_EDITOR
  1923. Pxr_SetTrackingOrigin(mode);
  1924. #endif
  1925. }
  1926. public static void UPxr_GetTrackingOrigin(ref PxrTrackingOrigin mode)
  1927. {
  1928. #if UNITY_ANDROID && !UNITY_EDITOR
  1929. Pxr_GetTrackingOrigin(ref mode);
  1930. #endif
  1931. }
  1932. public static bool UPxr_LoadPICOPlugin()
  1933. {
  1934. PLog.d(TAG, "UPxr_Load PICO Plugin");
  1935. #if UNITY_ANDROID && !UNITY_EDITOR
  1936. return Pxr_LoadPlugin();
  1937. #else
  1938. return false;
  1939. #endif
  1940. }
  1941. public static void UPxr_UnloadPICOPlugin()
  1942. {
  1943. PLog.d(TAG, "UPxr_Unload PICO Plugin");
  1944. #if UNITY_ANDROID && !UNITY_EDITOR
  1945. Pxr_UnloadPlugin();
  1946. #endif
  1947. }
  1948. public static bool UPxr_QueryDeviceAbilities(PxrDeviceAbilities abilities)
  1949. {
  1950. UInt64 flags = UInt64.MinValue;
  1951. #if UNITY_ANDROID && !UNITY_EDITOR
  1952. if (UPxr_GetAPIVersion() >= 0x2000304)
  1953. {
  1954. Pxr_GetTrackingMode(ref flags);
  1955. }
  1956. #endif
  1957. switch (abilities)
  1958. {
  1959. case PxrDeviceAbilities.PxrTrackingModeRotationBit:
  1960. {
  1961. return Convert.ToBoolean(flags & 0x00000001);
  1962. }
  1963. case PxrDeviceAbilities.PxrTrackingModePositionBit:
  1964. {
  1965. return Convert.ToBoolean(flags & 0x00000002);
  1966. }
  1967. case PxrDeviceAbilities.PxrTrackingModeEyeBit:
  1968. {
  1969. return Convert.ToBoolean(flags & 0x00000004);
  1970. }
  1971. case PxrDeviceAbilities.PxrTrackingModeFaceBit:
  1972. {
  1973. return Convert.ToBoolean(flags & 0x00000008);
  1974. }
  1975. case PxrDeviceAbilities.PxrTrackingModeBroadBandMontorBit:
  1976. {
  1977. return Convert.ToBoolean(flags & 0x00000010);
  1978. }
  1979. case PxrDeviceAbilities.PxrTrackingModeHandBit:
  1980. {
  1981. return Convert.ToBoolean(flags & 0x00000020);
  1982. }
  1983. default:
  1984. throw new ArgumentOutOfRangeException(nameof(abilities), abilities, null);
  1985. }
  1986. }
  1987. public static void UPxr_InitializeFocusCallback()
  1988. {
  1989. Application.onBeforeRender += UPxr_FocusUpdate;
  1990. Application.onBeforeRender += UPxr_SensorReadyStateUpdate;
  1991. }
  1992. public static void UPxr_DeinitializeFocusCallback()
  1993. {
  1994. Application.onBeforeRender -= UPxr_FocusUpdate;
  1995. Application.onBeforeRender -= UPxr_SensorReadyStateUpdate;
  1996. }
  1997. public static void UPxr_SetInputDeviceChangedCallBack(InputDeviceChangedCallBack callback)
  1998. {
  1999. #if !UNITY_EDITOR && UNITY_ANDROID
  2000. Pxr_SetInputDeviceChangedCallBack(callback);
  2001. #endif
  2002. }
  2003. public static void UPxr_SetSeethroughStateChangedCallBack(SeethroughStateChangedCallBack callback)
  2004. {
  2005. #if !UNITY_EDITOR && UNITY_ANDROID
  2006. Pxr_SetSeethroughStateChangedCallBack(callback);
  2007. #endif
  2008. }
  2009. public static void UPxr_SetFitnessBandNumberOfConnectionsCallBack(FitnessBandNumberOfConnectionsCallBack callback) {
  2010. #if !UNITY_EDITOR && UNITY_ANDROID
  2011. Pxr_SetFitnessBandNumberOfConnectionsCallBack(callback);
  2012. #endif
  2013. }
  2014. public static void UPxr_SetFitnessBandAbnormalCalibrationDataCallBack(FitnessBandAbnormalCalibrationDataCallBack callback)
  2015. {
  2016. #if !UNITY_EDITOR && UNITY_ANDROID
  2017. Pxr_SetFitnessBandAbnormalCalibrationDataCallBack(callback);
  2018. #endif
  2019. }
  2020. public static void UPxr_SetFitnessBandElectricQuantityCallBack(FitnessBandElectricQuantityCallBack callback)
  2021. {
  2022. #if !UNITY_EDITOR && UNITY_ANDROID
  2023. Pxr_SetFitnessBandElectricQuantityCallBack(callback);
  2024. #endif
  2025. }
  2026. public static void UPxr_SetLoglevelChangedCallBack(LoglevelChangedCallBack callback)
  2027. {
  2028. #if !UNITY_EDITOR && UNITY_ANDROID
  2029. Pxr_SetLoglevelChangedCallBack(callback);
  2030. #endif
  2031. }
  2032. public static bool UPxr_GetFocusState()
  2033. {
  2034. #if UNITY_ANDROID && !UNITY_EDITOR
  2035. return Pxr_GetFocusState();
  2036. #else
  2037. return false;
  2038. #endif
  2039. }
  2040. public static bool UPxr_IsSensorReady()
  2041. {
  2042. #if UNITY_ANDROID && !UNITY_EDITOR
  2043. return Pxr_IsSensorReady();
  2044. #else
  2045. return false;
  2046. #endif
  2047. }
  2048. private static bool lastAppFocusState = false;
  2049. private static void UPxr_FocusUpdate()
  2050. {
  2051. bool appfocus = UPxr_GetFocusState();
  2052. if (appfocus && !lastAppFocusState)
  2053. {
  2054. if (FocusStateAcquired != null)
  2055. {
  2056. FocusStateAcquired();
  2057. }
  2058. }
  2059. if (!appfocus && lastAppFocusState)
  2060. {
  2061. if (FocusStateLost != null)
  2062. {
  2063. FocusStateLost();
  2064. }
  2065. }
  2066. lastAppFocusState = appfocus;
  2067. }
  2068. private static bool lastSensorReadyState = false;
  2069. private static void UPxr_SensorReadyStateUpdate()
  2070. {
  2071. bool sensorReady = UPxr_IsSensorReady();
  2072. if (sensorReady && !lastSensorReadyState)
  2073. {
  2074. if (SensorReady != null)
  2075. {
  2076. SensorReady();
  2077. }
  2078. }
  2079. lastSensorReadyState = sensorReady;
  2080. }
  2081. public static string UPxr_GetSDKVersion()
  2082. {
  2083. return PXR_SDK_Version;
  2084. }
  2085. public static int UPxr_LogSdkApi(string sdkInfo)
  2086. {
  2087. PLog.d(TAG, "UPxr_LogSdkApi() sdkInfo:" + sdkInfo);
  2088. int result = 0;
  2089. #if UNITY_ANDROID && !UNITY_EDITOR
  2090. result = Pxr_LogSdkApi(sdkInfo);
  2091. #endif
  2092. PLog.d(TAG, "UPxr_LogSdkApi() result:" + result);
  2093. return result;
  2094. }
  2095. public static float UPxr_GetSystemDisplayFrequency()
  2096. {
  2097. return UPxr_GetConfigFloat(ConfigType.SystemDisplayRate);
  2098. }
  2099. public static float UPxr_GetMrcY()
  2100. {
  2101. if (PXR_Plugin.System.UPxr_GetAPIVersion() >= 0x2000300)
  2102. {
  2103. return UPxr_GetConfigFloat(ConfigType.PxrMrcPosiyionYOffset);
  2104. }
  2105. else
  2106. {
  2107. return 0;
  2108. }
  2109. }
  2110. public static double UPxr_GetPredictedDisplayTime()
  2111. {
  2112. PLog.d(TAG, "UPxr_GetPredictedDisplayTime()");
  2113. double predictedDisplayTime = 0;
  2114. #if UNITY_ANDROID && !UNITY_EDITOR
  2115. Pxr_GetPredictedDisplayTime(ref predictedDisplayTime);
  2116. #endif
  2117. PLog.d(TAG, "UPxr_GetPredictedDisplayTime() predictedDisplayTime:" + predictedDisplayTime);
  2118. return predictedDisplayTime;
  2119. }
  2120. public static bool UPxr_SetExtraLatencyMode(int mode)
  2121. {
  2122. PLog.d(TAG, "UPxr_SetExtraLatencyMode() mode:" + mode);
  2123. bool result = false;
  2124. #if UNITY_ANDROID && !UNITY_EDITOR
  2125. result = Pxr_SetExtraLatencyMode(mode);
  2126. #endif
  2127. PLog.d(TAG, "UPxr_SetExtraLatencyMode() result:" + result);
  2128. return result;
  2129. }
  2130. public static int UPxr_UpdateAdaptiveResolution(ref int width, AdaptiveResolutionPowerSetting powerSetting)
  2131. {
  2132. int success = 1;
  2133. PxrExtent2Di dim;
  2134. dim.width = width;
  2135. dim.height = width;
  2136. #if !UNITY_EDITOR && UNITY_ANDROID
  2137. success = Pxr_UpdateAdaptiveResolution(ref dim, powerSetting);
  2138. width = dim.width;
  2139. PLog.i(TAG, "UPxr_UpdateAdaptiveResolution :" + width);
  2140. #endif
  2141. return success;
  2142. }
  2143. public static void UPxr_SetUserDefinedSettings(UserDefinedSettings settings)
  2144. {
  2145. #if UNITY_ANDROID && !UNITY_EDITOR
  2146. Pxr_SetUserDefinedSettings(settings);
  2147. #endif
  2148. }
  2149. public static void UPxr_Construct(PXR_Loader.ConvertRotationWith2VectorDelegate fromToRotation)
  2150. {
  2151. #if UNITY_ANDROID && !UNITY_EDITOR
  2152. Pxr_Construct(fromToRotation);
  2153. #endif
  2154. }
  2155. public static bool UPxr_GetHomeKey()
  2156. {
  2157. #if UNITY_ANDROID && !UNITY_EDITOR
  2158. return Pxr_GetHomeKey();
  2159. #endif
  2160. return false;
  2161. }
  2162. public static void UPxr_InitHomeKey()
  2163. {
  2164. #if UNITY_ANDROID && !UNITY_EDITOR
  2165. Pxr_InitHomeKey();
  2166. #endif
  2167. }
  2168. public static bool UPxr_GetMRCEnable()
  2169. {
  2170. bool result = false;
  2171. if (PXR_Plugin.System.UPxr_GetAPIVersion() >= 0x2000300)
  2172. {
  2173. #if !UNITY_EDITOR && UNITY_ANDROID
  2174. result = Pxr_GetMRCEnable();
  2175. #endif
  2176. }
  2177. PLog.d(TAG, "UPxr_GetMRCEnable() result:" + result);
  2178. return result;
  2179. }
  2180. public static int UPxr_SetMRCTextureID(UInt64 IDData)
  2181. {
  2182. #if UNITY_ANDROID && !UNITY_EDITOR
  2183. Debug.Log("ConfigType.MRCTextureID:"+IDData);
  2184. return Pxr_SetConfigUint64(ConfigType.MRCTextureID, IDData);
  2185. #else
  2186. return 0;
  2187. #endif
  2188. }
  2189. public static int UPxr_SetMRCTextureID2(UInt64 IDData)
  2190. {
  2191. #if UNITY_ANDROID && !UNITY_EDITOR
  2192. Debug.Log("ConfigType.MRCTextureID2:"+IDData);
  2193. return Pxr_SetConfigUint64(ConfigType.MRCTextureID2, IDData);
  2194. #else
  2195. return 0;
  2196. #endif
  2197. }
  2198. public static int UPxr_SetMrcTextutrWidth(UInt64 width)
  2199. {
  2200. if (PXR_Plugin.System.UPxr_GetAPIVersion() >= 0x2000300)
  2201. {
  2202. #if UNITY_ANDROID && !UNITY_EDITOR
  2203. return Pxr_SetConfigUint64(ConfigType.PxrMrcTextureWidth, width);
  2204. #endif
  2205. }
  2206. return 0;
  2207. }
  2208. public static int UPxr_SetMrcTextutrHeight(UInt64 height)
  2209. {
  2210. if (PXR_Plugin.System.UPxr_GetAPIVersion() >= 0x2000300)
  2211. {
  2212. #if UNITY_ANDROID && !UNITY_EDITOR
  2213. return Pxr_SetConfigUint64(ConfigType.PxrMrcTextureHeight, height);
  2214. #endif
  2215. }
  2216. return 0;
  2217. }
  2218. public static bool UPxr_GetMrcPose(ref PxrPosef pose)
  2219. {
  2220. int result = 0;
  2221. if (PXR_Plugin.System.UPxr_GetAPIVersion() >= 0x2000300)
  2222. {
  2223. #if UNITY_ANDROID && !UNITY_EDITOR
  2224. result = Pxr_GetMrcPose(ref pose);
  2225. #endif
  2226. }
  2227. PLog.d(TAG, "UPxr_GetMrcPose() result:" + result + " pos.x:" + pose.position.x + " pos.y:" + pose.position.y + " pos.z:" + pose.position.z
  2228. + " ori.x:" + pose.orientation.x + " ori.y:" + pose.orientation.y + " ori.z:" + pose.orientation.z + " ori.w:" + pose.orientation.w);
  2229. return result == 0;
  2230. }
  2231. public static bool UPxr_SetMrcPose(ref PxrPosef pose)
  2232. {
  2233. int result = 0;
  2234. if (PXR_Plugin.System.UPxr_GetAPIVersion() >= 0x2000300)
  2235. {
  2236. #if UNITY_ANDROID && !UNITY_EDITOR
  2237. result = Pxr_SetMrcPose(ref pose);
  2238. #endif
  2239. }
  2240. PLog.d(TAG, "UPxr_SetMrcPose() result:" + result + " pos.x:" + pose.position.x + " pos.y:" + pose.position.y + " pos.z:" + pose.position.z
  2241. + " ori.x:" + pose.orientation.x + " ori.y:" + pose.orientation.y + " ori.z:" + pose.orientation.z + " ori.w:" + pose.orientation.w);
  2242. return result == 0;
  2243. }
  2244. public static void UPxr_SetIsSupportMovingMrc(bool support)
  2245. {
  2246. if (PXR_Plugin.System.UPxr_GetAPIVersion() >= 0x2000306)
  2247. {
  2248. #if UNITY_ANDROID && !UNITY_EDITOR
  2249. Pxr_SetIsSupportMovingMrc(support);
  2250. #endif
  2251. }
  2252. }
  2253. public static bool UPxr_GetMrcStatus()
  2254. {
  2255. #if UNITY_ANDROID && !UNITY_EDITOR
  2256. if(PXR_Plugin.System.UPxr_GetAPIVersion()>= 0x2000300) {
  2257. return Pxr_GetMrcStatus();
  2258. }else{
  2259. return false;
  2260. }
  2261. #else
  2262. return false;
  2263. #endif
  2264. }
  2265. public static void UPxr_EnableEyeTracking(bool enable)
  2266. {
  2267. Debug.Log(TAG + "UPxr_EnableEyeTracking() enable:" + enable);
  2268. #if UNITY_ANDROID && !UNITY_EDITOR
  2269. Pxr_EnableEyeTracking(enable);
  2270. #endif
  2271. }
  2272. public static void UPxr_EnableFaceTracking(bool enable)
  2273. {
  2274. #if UNITY_ANDROID && !UNITY_EDITOR
  2275. Pxr_EnableFaceTracking(enable);
  2276. #endif
  2277. }
  2278. public static void UPxr_EnableLipSync(bool enable){
  2279. #if UNITY_ANDROID && !UNITY_EDITOR
  2280. Pxr_EnableLipsync(enable);
  2281. #endif
  2282. }
  2283. public static int UPxr_GetFaceTrackingData(Int64 ts, int flags, ref PxrFaceTrackingInfo faceTrackingInfo)
  2284. {
  2285. #if UNITY_ANDROID && !UNITY_EDITOR
  2286. if(PXR_Plugin.System.UPxr_GetAPIVersion()>= 0x2000309) {
  2287. Pxr_GetFaceTrackingData(ts, flags, ref faceTrackingInfo );
  2288. }
  2289. #endif
  2290. return 0;
  2291. }
  2292. public static int UPxr_SetFaceTrackingStatus(PxrFtLipsyncValue value) {
  2293. int num = 0;
  2294. #if UNITY_ANDROID && !UNITY_EDITOR
  2295. if(PXR_Plugin.System.UPxr_GetAPIVersion()>= 0x200030A) {
  2296. num = Pxr_SetTrackingStatus("ft_lipsync_ctl", ((int)value).ToString());
  2297. }
  2298. #endif
  2299. return num;
  2300. }
  2301. private const string TAG = "[PXR_Plugin/System]";
  2302. #if UNITY_ANDROID && !UNITY_EDITOR
  2303. private static AndroidJavaClass unityPlayer = new AndroidJavaClass("com.unity3d.player.UnityPlayer");
  2304. private static AndroidJavaObject currentActivity = unityPlayer.GetStatic<AndroidJavaObject>("currentActivity");
  2305. private static AndroidJavaClass sysActivity = new AndroidJavaClass("com.psmart.aosoperation.SysActivity");
  2306. private static AndroidJavaClass batteryReceiver = new AndroidJavaClass("com.psmart.aosoperation.BatteryReceiver");
  2307. private static AndroidJavaClass audioReceiver = new AndroidJavaClass("com.psmart.aosoperation.AudioReceiver");
  2308. #endif
  2309. public static string UPxr_GetDeviceMode()
  2310. {
  2311. string devicemode = "";
  2312. #if UNITY_ANDROID && !UNITY_EDITOR
  2313. devicemode = SystemInfo.deviceModel;
  2314. #endif
  2315. return devicemode;
  2316. }
  2317. public static float UPxr_GetConfigFloat(ConfigType type)
  2318. {
  2319. PLog.d(TAG, "UPxr_GetConfigFloat() type:" + type);
  2320. float value = 0;
  2321. #if UNITY_ANDROID && !UNITY_EDITOR
  2322. Pxr_GetConfigFloat(type, ref value);
  2323. #endif
  2324. PLog.d(TAG, "UPxr_GetConfigFloat() value:" + value);
  2325. return value;
  2326. }
  2327. public static int UPxr_GetConfigInt(ConfigType type)
  2328. {
  2329. PLog.d(TAG, "UPxr_GetConfigInt() type:" + type);
  2330. int value = 0;
  2331. #if UNITY_ANDROID && !UNITY_EDITOR
  2332. Pxr_GetConfigInt(type, ref value);
  2333. #endif
  2334. PLog.d(TAG, "UPxr_GetConfigInt() value:" + value);
  2335. return value;
  2336. }
  2337. public static int UPxr_SetConfigInt(ConfigType configSetIndex, int configSetData)
  2338. {
  2339. PLog.d(TAG, "UPxr_SetConfigInt() configSetIndex:" + configSetIndex + " configSetData:" + configSetData);
  2340. int result = 0;
  2341. #if UNITY_ANDROID && !UNITY_EDITOR
  2342. result = Pxr_SetConfigInt(configSetIndex, configSetData);
  2343. #endif
  2344. PLog.d(TAG, "UPxr_SetConfigInt() result:" + result);
  2345. return result;
  2346. }
  2347. public static int UPxr_ContentProtect(int data)
  2348. {
  2349. int num = 0;
  2350. #if UNITY_ANDROID && !UNITY_EDITOR
  2351. num = Pxr_SetConfigInt(ConfigType.EnableCPT, data);
  2352. Pxr_UpdateContentProtectState(data);
  2353. #endif
  2354. return num;
  2355. }
  2356. public static int UPxr_SetConfigString(ConfigType configSetIndex, string configSetData)
  2357. {
  2358. PLog.d(TAG, "UPxr_SetConfigString() configSetIndex:" + configSetIndex + " configSetData:" + configSetData);
  2359. int result = 0;
  2360. #if UNITY_ANDROID && !UNITY_EDITOR
  2361. result = Pxr_SetConfigString(configSetIndex, configSetData);
  2362. #endif
  2363. PLog.d(TAG, "UPxr_SetConfigString() result:" + result);
  2364. return result;
  2365. }
  2366. public static int UPxr_SetSystemDisplayFrequency(float rate)
  2367. {
  2368. PLog.d(TAG, "UPxr_SetDisplayRefreshRate() rate:" + rate);
  2369. int result = 0;
  2370. #if UNITY_ANDROID && !UNITY_EDITOR
  2371. result = Pxr_SetDisplayRefreshRate(rate);
  2372. #endif
  2373. PLog.d(TAG, "UPxr_SetDisplayRefreshRate() result:" + result);
  2374. return result;
  2375. }
  2376. public static int UPxr_SetPerformanceLevels(PxrPerfSettings which, PxrSettingsLevel level)
  2377. {
  2378. PLog.d(TAG, "UPxr_SetPerformanceLevels() which:" + which + ", level:" + level);
  2379. int result = 0;
  2380. #if UNITY_ANDROID && !UNITY_EDITOR
  2381. if (PXR_Plugin.System.UPxr_GetAPIVersion() >= 0x200030A)
  2382. {
  2383. result = Pxr_SetPerformanceLevels(which, level);
  2384. }
  2385. #endif
  2386. PLog.d(TAG, "UPxr_SetPerformanceLevels() result:" + result);
  2387. return result;
  2388. }
  2389. public static PxrSettingsLevel UPxr_GetPerformanceLevels(PxrPerfSettings which)
  2390. {
  2391. PLog.d(TAG, "UPxr_GetPerformanceLevels() which:" + which);
  2392. int result = 0;
  2393. PxrSettingsLevel level = PxrSettingsLevel.POWER_SAVINGS;
  2394. #if UNITY_ANDROID && !UNITY_EDITOR
  2395. if (PXR_Plugin.System.UPxr_GetAPIVersion() >= 0x200030A)
  2396. {
  2397. result = Pxr_GetPerformanceLevels(which, ref level);
  2398. }
  2399. #endif
  2400. PLog.d(TAG, "UPxr_GetPerformanceLevels() result:" + result + ", level:" + level);
  2401. return level;
  2402. }
  2403. public static string UPxr_GetDeviceSN()
  2404. {
  2405. string serialNum = "UNKONWN";
  2406. #if UNITY_ANDROID && !UNITY_EDITOR
  2407. serialNum = sysActivity.CallStatic<string>("getDeviceSN");
  2408. #endif
  2409. return serialNum;
  2410. }
  2411. public static void UPxr_Sleep()
  2412. {
  2413. #if UNITY_ANDROID && !UNITY_EDITOR
  2414. sysActivity.CallStatic("pxr_Sleep");
  2415. #endif
  2416. }
  2417. public static void UPxr_SetSecure(bool isOpen)
  2418. {
  2419. #if UNITY_ANDROID && !UNITY_EDITOR
  2420. sysActivity.CallStatic("SetSecure",currentActivity,isOpen);
  2421. #endif
  2422. }
  2423. public static int UPxr_GetColorRes(string name)
  2424. {
  2425. int value = -1;
  2426. #if UNITY_ANDROID && !UNITY_EDITOR
  2427. try
  2428. {
  2429. value = sysActivity.CallStatic<int>("getColorRes", currentActivity, name);
  2430. }
  2431. catch (Exception e)
  2432. {
  2433. PLog.e(TAG, "GetColorResError :" + e.ToString());
  2434. }
  2435. #endif
  2436. return value;
  2437. }
  2438. public static int UPxr_GetConfigInt(string name)
  2439. {
  2440. int value = -1;
  2441. #if UNITY_ANDROID && !UNITY_EDITOR
  2442. try
  2443. {
  2444. value = sysActivity.CallStatic<int>("getConfigInt", currentActivity, name);
  2445. }
  2446. catch (Exception e)
  2447. {
  2448. PLog.e(TAG, "GetConfigIntError :" + e.ToString());
  2449. }
  2450. #endif
  2451. return value;
  2452. }
  2453. public static string UPxr_GetConfigString(string name)
  2454. {
  2455. string value = "";
  2456. #if UNITY_ANDROID && !UNITY_EDITOR
  2457. try
  2458. {
  2459. value = sysActivity.CallStatic<string>("getConfigString", currentActivity, name);
  2460. }
  2461. catch (Exception e)
  2462. {
  2463. PLog.e(TAG, "GetConfigStringError :" + e.ToString());
  2464. }
  2465. #endif
  2466. return value;
  2467. }
  2468. public static string UPxr_GetDrawableLocation(string name)
  2469. {
  2470. string value = "";
  2471. #if UNITY_ANDROID && !UNITY_EDITOR
  2472. try
  2473. {
  2474. value = sysActivity.CallStatic<string>("getDrawableLocation", currentActivity, name);
  2475. }
  2476. catch (Exception e)
  2477. {
  2478. PLog.e(TAG, "GetDrawableLocationError :" + e.ToString());
  2479. }
  2480. #endif
  2481. return value;
  2482. }
  2483. public static int UPxr_GetTextSize(string name)
  2484. {
  2485. int value = -1;
  2486. #if UNITY_ANDROID && !UNITY_EDITOR
  2487. try
  2488. {
  2489. value = sysActivity.CallStatic<int>("getTextSize", currentActivity, name);
  2490. }
  2491. catch (Exception e)
  2492. {
  2493. PLog.e(TAG, "GetTextSizeError :" + e.ToString());
  2494. }
  2495. #endif
  2496. return value;
  2497. }
  2498. public static string UPxr_GetLangString(string name)
  2499. {
  2500. string value = "";
  2501. #if UNITY_ANDROID && !UNITY_EDITOR
  2502. try
  2503. {
  2504. value = sysActivity.CallStatic<string>("getLangString", currentActivity, name);
  2505. }
  2506. catch (Exception e)
  2507. {
  2508. PLog.e(TAG, "GetLangStringError :" + e.ToString());
  2509. }
  2510. #endif
  2511. return value;
  2512. }
  2513. public static string UPxr_GetStringValue(string id, int type)
  2514. {
  2515. string value = "";
  2516. #if UNITY_ANDROID && !UNITY_EDITOR
  2517. try
  2518. {
  2519. value = sysActivity.CallStatic<string>("getStringValue", currentActivity, id, type);
  2520. }
  2521. catch (Exception e)
  2522. {
  2523. PLog.e(TAG, "GetStringValueError :" + e.ToString());
  2524. }
  2525. #endif
  2526. return value;
  2527. }
  2528. public static int UPxr_GetIntValue(string id, int type)
  2529. {
  2530. int value = -1;
  2531. #if UNITY_ANDROID && !UNITY_EDITOR
  2532. try
  2533. {
  2534. value = sysActivity.CallStatic<int>("getIntValue", currentActivity, id, type);
  2535. }
  2536. catch (Exception e)
  2537. {
  2538. PLog.e(TAG, "GetIntValueError :" + e.ToString());
  2539. }
  2540. #endif
  2541. return value;
  2542. }
  2543. public static float UPxr_GetFloatValue(string id)
  2544. {
  2545. float value = -1;
  2546. #if UNITY_ANDROID && !UNITY_EDITOR
  2547. try
  2548. {
  2549. value = sysActivity.CallStatic<float>("getFloatValue", currentActivity, id);
  2550. }
  2551. catch (Exception e)
  2552. {
  2553. PLog.e(TAG, "GetFloatValueError :" + e.ToString());
  2554. }
  2555. #endif
  2556. return value;
  2557. }
  2558. public static string UPxr_GetObjectOrArray(string id, int type)
  2559. {
  2560. string value = "";
  2561. #if UNITY_ANDROID && !UNITY_EDITOR
  2562. try
  2563. {
  2564. value = sysActivity.CallStatic<string>("getObjectOrArray", currentActivity, id, type);
  2565. }
  2566. catch (Exception e)
  2567. {
  2568. PLog.e(TAG, "GetObjectOrArrayError :" + e.ToString());
  2569. }
  2570. #endif
  2571. return value;
  2572. }
  2573. public static int UPxr_GetCharSpace(string id)
  2574. {
  2575. int value = -1;
  2576. #if UNITY_ANDROID && !UNITY_EDITOR
  2577. try
  2578. {
  2579. value = sysActivity.CallStatic<int>("getCharSpace", currentActivity, id);
  2580. }
  2581. catch (Exception e)
  2582. {
  2583. PLog.e(TAG, "GetCharSpaceError :" + e.ToString());
  2584. }
  2585. #endif
  2586. return value;
  2587. }
  2588. public static float UPxr_RefreshRateChanged()
  2589. {
  2590. #if UNITY_ANDROID && !UNITY_EDITOR
  2591. return Pxr_RefreshRateChanged();
  2592. #else
  2593. return -1.0f;
  2594. #endif
  2595. }
  2596. public static float[] UPxr_GetDisplayFrequenciesAvailable()
  2597. {
  2598. float[] configArray = null;
  2599. #if UNITY_ANDROID && !UNITY_EDITOR
  2600. int configCount = 0;
  2601. IntPtr configHandle = IntPtr.Zero;
  2602. Pxr_GetDisplayRefreshRatesAvailable(ref configCount, ref configHandle);
  2603. configArray = new float[configCount];
  2604. Marshal.Copy(configHandle, configArray, 0, configCount);
  2605. for (int i = 0; i < configCount; i++) {
  2606. Debug.Log("LLRR: UPxr_GetDisplayFrequenciesAvailable " + configArray[i]);
  2607. }
  2608. #endif
  2609. return configArray;
  2610. }
  2611. public static int UPxr_GetSensorStatus()
  2612. {
  2613. #if UNITY_ANDROID && !UNITY_EDITOR
  2614. return Pxr_GetSensorStatus();
  2615. #else
  2616. return 0;
  2617. #endif
  2618. }
  2619. public static int UPxr_GetPredictedMainSensorStateNew(ref PxrSensorState2 sensorState, ref int sensorFrameIndex)
  2620. {
  2621. #if UNITY_ANDROID && !UNITY_EDITOR
  2622. if(UPxr_GetAPIVersion() >= 0x2000201){
  2623. double predictTime = UPxr_GetPredictedDisplayTime();
  2624. return Pxr_GetPredictedMainSensorState2(predictTime, ref sensorState, ref sensorFrameIndex);
  2625. }else
  2626. {
  2627. return 0;
  2628. }
  2629. #else
  2630. return 0;
  2631. #endif
  2632. }
  2633. public static int UPxr_GetAPIVersion()
  2634. {
  2635. #if UNITY_ANDROID && !UNITY_EDITOR
  2636. if (PXR_API_Version < 0x0000001)
  2637. {
  2638. PXR_API_Version = UPxr_GetConfigInt(ConfigType.PxrAPIVersion);
  2639. PLog.i(TAG, "API xrVersion :0x" + PXR_API_Version.ToString("X2"));
  2640. }
  2641. return PXR_API_Version;
  2642. #else
  2643. return 0;
  2644. #endif
  2645. }
  2646. public static void UPxr_SetLogInfoActive(bool value)
  2647. {
  2648. #if UNITY_ANDROID && !UNITY_EDITOR
  2649. Pxr_SetLogInfoActive(value);
  2650. #endif
  2651. }
  2652. public static void UPxr_OpenFitnessBandCalibrationAPP()
  2653. {
  2654. UPxr_OpenFitnessBandCalibrationPackage("com.pvr.swift");
  2655. }
  2656. public static void UPxr_OpenPackage(string pkgName)
  2657. {
  2658. AndroidJavaObject activity;
  2659. AndroidJavaClass UnityPlayer = new AndroidJavaClass("com.unity3d.player.UnityPlayer");
  2660. activity = UnityPlayer.GetStatic<AndroidJavaObject>("currentActivity");
  2661. using (AndroidJavaObject joPackageManager = activity.Call<AndroidJavaObject>("getPackageManager"))
  2662. {
  2663. using (AndroidJavaObject joIntent = joPackageManager.Call<AndroidJavaObject>("getLaunchIntentForPackage", pkgName))
  2664. {
  2665. if (null != joIntent)
  2666. {
  2667. activity.Call("startActivity", joIntent);
  2668. }
  2669. else
  2670. {
  2671. Debug.Log("This software is not installed: " + pkgName);
  2672. }
  2673. }
  2674. }
  2675. }
  2676. public static void UPxr_OpenFitnessBandCalibrationPackage(string pkgName)
  2677. {
  2678. using (AndroidJavaClass jcPlayer = new AndroidJavaClass("com.unity3d.player.UnityPlayer"))
  2679. {
  2680. using (AndroidJavaObject joActivity = jcPlayer.GetStatic<AndroidJavaObject>("currentActivity"))
  2681. {
  2682. using (AndroidJavaObject joPackageManager = joActivity.Call<AndroidJavaObject>("getPackageManager"))
  2683. {
  2684. using (AndroidJavaObject joIntent = joPackageManager.Call<AndroidJavaObject>("getLaunchIntentForPackage", pkgName))
  2685. {
  2686. if (null != joIntent)
  2687. {
  2688. //AndroidJavaObject joNIntent = joIntent.Call<AndroidJavaObject>("addFlags", joIntent.GetStatic<int>("FLAG_ACTIVITY_REORDER_TO_FRONT"));
  2689. AndroidJavaObject joNIntent = joIntent.Call<AndroidJavaObject>("putExtra", "enter_flag", Application.identifier);
  2690. joActivity.Call("startActivity", joNIntent);
  2691. joIntent.Dispose();
  2692. }
  2693. else
  2694. {
  2695. string msg = "Package <" + pkgName + "> not exsits on device.";
  2696. Debug.Log(msg);
  2697. using (AndroidJavaClass jT = new AndroidJavaClass("android.widget.Toast"))
  2698. {
  2699. using (AndroidJavaObject jMsg = new AndroidJavaObject("java.lang.String", msg))
  2700. {
  2701. using (AndroidJavaObject jC = joActivity.Call<AndroidJavaObject>("getApplicationContext"))
  2702. {
  2703. int length = jT.GetStatic<int>("LENGTH_SHORT");
  2704. using (AndroidJavaObject toast = jT.CallStatic<AndroidJavaObject>("makeText", jC, jMsg, length))
  2705. {
  2706. toast.Call("show");
  2707. }
  2708. }
  2709. }
  2710. }
  2711. }
  2712. }
  2713. }
  2714. }
  2715. }
  2716. }
  2717. }
  2718. public static class Boundary
  2719. {
  2720. private const string TAG = "[PXR_Plugin/Boundary]";
  2721. public static PxrBoundaryTriggerInfo UPxr_TestNodeIsInBoundary(BoundaryTrackingNode node, BoundaryType boundaryType)
  2722. {
  2723. PxrBoundaryTriggerInfo testResult = new PxrBoundaryTriggerInfo();
  2724. #if UNITY_ANDROID && !UNITY_EDITOR
  2725. Pxr_TestNodeIsInBoundary(node, boundaryType == BoundaryType.PlayArea, ref testResult);
  2726. testResult.closestPoint.z = -testResult.closestPoint.z;
  2727. testResult.closestPointNormal.z = -testResult.closestPointNormal.z;
  2728. if (!testResult.valid)
  2729. {
  2730. PLog.d(TAG, string.Format("Pxr_TestBoundaryNode({0}, {1}) API call failed!", node, boundaryType));
  2731. }
  2732. #endif
  2733. return testResult;
  2734. }
  2735. public static PxrBoundaryTriggerInfo UPxr_TestPointIsInBoundary(PxrVector3f point, BoundaryType boundaryType)
  2736. {
  2737. PxrBoundaryTriggerInfo testResult = new PxrBoundaryTriggerInfo();
  2738. #if UNITY_ANDROID && !UNITY_EDITOR
  2739. Pxr_TestPointIsInBoundary(ref point, boundaryType == BoundaryType.PlayArea, ref testResult);
  2740. if (!testResult.valid)
  2741. {
  2742. PLog.d(TAG, string.Format("Pxr_TestBoundaryPoint({0}, {1}) API call failed!", point, boundaryType));
  2743. }
  2744. #endif
  2745. return testResult;
  2746. }
  2747. public static Vector3[] UPxr_GetBoundaryGeometry(BoundaryType boundaryType)
  2748. {
  2749. Vector3[] points = new Vector3[1];
  2750. #if UNITY_ANDROID && !UNITY_EDITOR
  2751. UInt32 pointsCountOutput = 0;
  2752. PxrVector3f[] outPointsFirst = null;
  2753. Pxr_GetBoundaryGeometry(boundaryType == BoundaryType.PlayArea, 0, ref pointsCountOutput, outPointsFirst);
  2754. if (pointsCountOutput <= 0)
  2755. {
  2756. PLog.d(TAG, "Boundary geometry point count = " + pointsCountOutput);
  2757. return null;
  2758. }
  2759. PxrVector3f[] outPoints = new PxrVector3f[pointsCountOutput];
  2760. Pxr_GetBoundaryGeometry(boundaryType == BoundaryType.PlayArea, pointsCountOutput, ref pointsCountOutput, outPoints);
  2761. points = new Vector3[pointsCountOutput];
  2762. for (int i = 0; i < pointsCountOutput; i++)
  2763. {
  2764. points[i] = new Vector3()
  2765. {
  2766. x = outPoints[i].x,
  2767. y = outPoints[i].y,
  2768. z = -outPoints[i].z,
  2769. };
  2770. }
  2771. #endif
  2772. return points;
  2773. }
  2774. public static Vector3 UPxr_GetBoundaryDimensions(BoundaryType boundaryType)
  2775. {
  2776. // float x = 0, y = 0, z = 0;
  2777. PxrVector3f dimension = new PxrVector3f();
  2778. #if UNITY_ANDROID && !UNITY_EDITOR
  2779. int ret = 0;
  2780. Pxr_GetBoundaryDimensions( boundaryType == BoundaryType.PlayArea, out dimension);
  2781. #endif
  2782. return new Vector3(dimension.x, dimension.y, dimension.z);
  2783. }
  2784. public static void UPxr_SetBoundaryVisiable(bool value)
  2785. {
  2786. #if UNITY_ANDROID && !UNITY_EDITOR
  2787. Pxr_SetBoundaryVisible(value);
  2788. #endif
  2789. }
  2790. public static bool UPxr_GetBoundaryVisiable()
  2791. {
  2792. #if UNITY_ANDROID && !UNITY_EDITOR
  2793. return Pxr_GetBoundaryVisible();
  2794. #else
  2795. return true;
  2796. #endif
  2797. }
  2798. public static bool UPxr_GetBoundaryConfigured()
  2799. {
  2800. #if UNITY_ANDROID && !UNITY_EDITOR
  2801. return Pxr_GetBoundaryConfigured();
  2802. #else
  2803. return true;
  2804. #endif
  2805. }
  2806. public static bool UPxr_GetBoundaryEnabled()
  2807. {
  2808. #if UNITY_ANDROID && !UNITY_EDITOR
  2809. return Pxr_GetBoundaryEnabled();
  2810. #else
  2811. return true;
  2812. #endif
  2813. }
  2814. public static int UPxr_SetSeeThroughBackground(bool value)
  2815. {
  2816. #if UNITY_ANDROID && !UNITY_EDITOR
  2817. return Pxr_SetSeeThroughBackground(value);
  2818. #else
  2819. return 0;
  2820. #endif
  2821. }
  2822. public static int UPxr_GetSeeThroughState()
  2823. {
  2824. var state = 0;
  2825. #if UNITY_ANDROID && !UNITY_EDITOR
  2826. try
  2827. {
  2828. state = Pxr_GetSeeThroughState();
  2829. PLog.d(TAG, "UPxr_GetSeeThroughState() state:" + state);
  2830. }
  2831. catch (Exception e)
  2832. {
  2833. Debug.Log("PXRLog UPxr_GetSeeThroughState :" + e.ToString());
  2834. }
  2835. #endif
  2836. return state;
  2837. }
  2838. public static void UPxr_SetSeeThroughState(bool value)
  2839. {
  2840. #if UNITY_ANDROID && !UNITY_EDITOR
  2841. Pxr_SetVideoSeethroughState(value);
  2842. #endif
  2843. }
  2844. public static void UPxr_ResetSeeThroughSensor()
  2845. {
  2846. #if UNITY_ANDROID && !UNITY_EDITOR
  2847. if (PXR_Plugin.System.UPxr_GetAPIVersion() >= 0x2000301)
  2848. {
  2849. Pxr_ResetSensorHard();
  2850. }
  2851. #endif
  2852. }
  2853. public static PxrTrackingState UPxr_GetSeeThroughTrackingState()
  2854. {
  2855. int state = 0;
  2856. #if UNITY_ANDROID && !UNITY_EDITOR
  2857. if (PXR_Plugin.System.UPxr_GetAPIVersion() >= 0x2000301)
  2858. {
  2859. state = Pxr_GetTrackingState();
  2860. }
  2861. #endif
  2862. return (PxrTrackingState)state;
  2863. }
  2864. public static int UPxr_SetGuardianSystemDisable(bool value)
  2865. {
  2866. #if UNITY_ANDROID && !UNITY_EDITOR
  2867. return Pxr_SetGuardianSystemDisable(value);
  2868. #else
  2869. return 0;
  2870. #endif
  2871. }
  2872. public static int UPxr_ResumeGuardianSystemForSTS()
  2873. {
  2874. #if UNITY_ANDROID && !UNITY_EDITOR
  2875. return Pxr_ResumeGuardianSystemForSTS();
  2876. #else
  2877. return 0;
  2878. #endif
  2879. }
  2880. public static int UPxr_PauseGuardianSystemForSTS()
  2881. {
  2882. #if UNITY_ANDROID && !UNITY_EDITOR
  2883. return Pxr_PauseGuardianSystemForSTS();
  2884. #else
  2885. return 0;
  2886. #endif
  2887. }
  2888. public static int UPxr_ShutdownSdkGuardianSystem()
  2889. {
  2890. #if UNITY_ANDROID && !UNITY_EDITOR
  2891. return Pxr_ShutdownSdkGuardianSystem();
  2892. #else
  2893. return 0;
  2894. #endif
  2895. }
  2896. public static int UPxr_GetRoomModeState()
  2897. {
  2898. #if UNITY_ANDROID && !UNITY_EDITOR
  2899. return Pxr_GetRoomModeState();
  2900. #else
  2901. return 0;
  2902. #endif
  2903. }
  2904. public static int UPxr_DisableBoundary()
  2905. {
  2906. #if UNITY_ANDROID && !UNITY_EDITOR
  2907. return Pxr_DisableBoundary();
  2908. #else
  2909. return 0;
  2910. #endif
  2911. }
  2912. }
  2913. public static class Render
  2914. {
  2915. private const string TAG = "[PXR_Plugin/Render]";
  2916. public static bool UPxr_SetFoveationLevel(FoveationLevel level)
  2917. {
  2918. bool result = true;
  2919. #if UNITY_ANDROID && !UNITY_EDITOR
  2920. result = Pxr_SetFoveationLevelEnable((int)level);
  2921. #endif
  2922. PLog.i(TAG, "UPxr_SetFoveationLevel() level:" + level + " result:" + result);
  2923. return result;
  2924. }
  2925. public static bool UPxr_SetEyeFoveationLevel(FoveationLevel level)
  2926. {
  2927. bool result = true;
  2928. #if UNITY_ANDROID && !UNITY_EDITOR
  2929. result = Pxr_SetEyeFoveationLevelEnable((int)level);
  2930. #endif
  2931. PLog.i(TAG, "UPxr_SetEyeFoveationLevel() level:" + level + " result:" + result);
  2932. return result;
  2933. }
  2934. public static void UPxr_SetFFRSubsampled(bool enable)
  2935. {
  2936. PLog.d(TAG, "UPxr_SetFFRSubsampled() level:" + enable);
  2937. #if UNITY_ANDROID && !UNITY_EDITOR
  2938. Pxr_SetFFRSubsampled(enable);
  2939. #endif
  2940. }
  2941. public static FoveationLevel UPxr_GetFoveationLevel()
  2942. {
  2943. FoveationLevel result = FoveationLevel.None;
  2944. #if UNITY_ANDROID && !UNITY_EDITOR
  2945. result = Pxr_GetFoveationLevel();
  2946. #endif
  2947. PLog.d(TAG, "UPxr_GetFoveationLevel() result:" + result);
  2948. return result;
  2949. }
  2950. public static int UPxr_SetFoveationParameters(float foveationGainX, float foveationGainY, float foveationArea, float foveationMinimum)
  2951. {
  2952. PLog.d(TAG, "UPxr_SetFoveationParameters() foveationGainX:" + foveationGainX + " foveationGainY:" + foveationGainY + " foveationArea:" + foveationArea + " foveationMinimum:" + foveationMinimum);
  2953. int result = 0;
  2954. #if UNITY_ANDROID && !UNITY_EDITOR
  2955. FoveationParams foveationParams = new FoveationParams();
  2956. foveationParams.foveationGainX = foveationGainX;
  2957. foveationParams.foveationGainY = foveationGainY;
  2958. foveationParams.foveationArea = foveationArea;
  2959. foveationParams.foveationMinimum = foveationMinimum;
  2960. result = Pxr_SetFoveationParams(foveationParams);
  2961. #endif
  2962. PLog.d(TAG, "UPxr_SetFoveationParameters() result:" + result);
  2963. return result;
  2964. }
  2965. public static int UPxr_GetFrustum(EyeType eye, ref float fovLeft, ref float fovRight, ref float fovUp, ref float fovDown, ref float near, ref float far)
  2966. {
  2967. int result = 0;
  2968. #if UNITY_ANDROID && !UNITY_EDITOR
  2969. result = Pxr_GetFrustum(eye, ref fovLeft, ref fovRight, ref fovUp, ref fovDown, ref near, ref far);
  2970. #endif
  2971. PLog.d(TAG, "UPxr_GetFrustum() result:" + result + " eye:" + eye + " fovLeft:" + fovLeft + " fovRight:" + fovRight + " fovUp:" + fovUp + " fovDown:" + fovDown + " near:" + near + " far:" + far);
  2972. return result;
  2973. }
  2974. public static int UPxr_SetFrustum(EyeType eye, float fovLeft, float fovRight, float fovUp, float fovDown, float near, float far)
  2975. {
  2976. int result = 1;
  2977. #if UNITY_ANDROID && !UNITY_EDITOR
  2978. result = Pxr_SetFrustum(eye, fovLeft, fovRight, fovUp, fovDown, near, far);
  2979. #endif
  2980. PLog.d(TAG, "UPxr_SetFrustum() result:" + result + " eye:" + eye + " fovLeft:" + fovLeft + " fovRight:" + fovRight + " fovUp:" + fovUp + " fovDown:" + fovDown + " near:" + near + " far:" + far);
  2981. return result;
  2982. }
  2983. public static int UPxr_SetEyeFOV(EyeType eye, float fovLeft, float fovRight, float fovUp, float fovDown)
  2984. {
  2985. int result = 0;
  2986. ConfigType type;
  2987. switch (eye)
  2988. {
  2989. case EyeType.EyeLeft:
  2990. type = ConfigType.PxrLeftEyeFOV;
  2991. break;
  2992. case EyeType.EyeRight:
  2993. type = ConfigType.PxrRightEyeFOV;
  2994. break;
  2995. default:
  2996. type = ConfigType.PxrBothEyeFOV;
  2997. break;
  2998. }
  2999. float[] fovData = new float[4];
  3000. fovData[0] = -Mathf.Deg2Rad * fovLeft;
  3001. fovData[1] = Mathf.Deg2Rad * fovRight;
  3002. fovData[2] = Mathf.Deg2Rad * fovUp;
  3003. fovData[3] = -Mathf.Deg2Rad * fovDown;
  3004. #if UNITY_ANDROID && !UNITY_EDITOR
  3005. if (PXR_Plugin.System.UPxr_GetAPIVersion() >= 0x2000300)
  3006. {
  3007. result = Pxr_SetConfigFloatArray(type, fovData, 4);
  3008. }
  3009. #endif
  3010. PLog.d(TAG, string.Format("UPxr_SetEyeFOV Pxr_SetConfigFloatArray type = {0}, fovData[0] = {1}, fovData[1] = {2}, fovData[2] = {3}, fovData[3] = {4}, result = {5}", type, fovData[0], fovData[1], fovData[2], fovData[3], result));
  3011. return result;
  3012. }
  3013. public static void UPxr_CreateLayer(IntPtr layerParam)
  3014. {
  3015. PLog.d(TAG, "UPxr_CreateLayer() ");
  3016. #if UNITY_ANDROID && !UNITY_EDITOR
  3017. Pxr_CreateLayer(layerParam);
  3018. #endif
  3019. }
  3020. public static void UPxr_CreateLayerParam(PxrLayerParam layerParam)
  3021. {
  3022. PLog.d(TAG, "UPxr_CreateLayerParam() ");
  3023. #if UNITY_ANDROID && !UNITY_EDITOR
  3024. Pxr_CreateLayerParam(layerParam);
  3025. #endif
  3026. }
  3027. public static int UPxr_GetLayerNextImageIndex(int layerId, ref int imageIndex)
  3028. {
  3029. int result = 0;
  3030. #if UNITY_ANDROID && !UNITY_EDITOR
  3031. result = Pxr_GetLayerNextImageIndex(layerId, ref imageIndex);
  3032. #endif
  3033. PLog.d(TAG, "UPxr_GetLayerNextImageIndex() layerId:" + layerId + " imageIndex:" + imageIndex + " result:" + result);
  3034. return result;
  3035. }
  3036. public static int UPxr_GetLayerImageCount(int layerId, EyeType eye, ref UInt32 imageCount)
  3037. {
  3038. int result = 0;
  3039. #if UNITY_ANDROID && !UNITY_EDITOR
  3040. result = Pxr_GetLayerImageCount(layerId, eye, ref imageCount);
  3041. #endif
  3042. PLog.d(TAG, "UPxr_GetLayerImageCount() layerId:" + layerId + " eye:" + eye + " imageCount:" + imageCount + " result:" + result);
  3043. return result;
  3044. }
  3045. public static int UPxr_GetLayerImage(int layerId, EyeType eye, int imageIndex, ref UInt64 image)
  3046. {
  3047. int result = 0;
  3048. #if UNITY_ANDROID && !UNITY_EDITOR
  3049. result = Pxr_GetLayerImage(layerId, eye, imageIndex, ref image);
  3050. #endif
  3051. PLog.d(TAG, "UPxr_GetLayerImage() layerId:" + layerId + " eye:" + eye + " imageIndex:" + imageIndex + " image:" + image + " result:" + result);
  3052. return result;
  3053. }
  3054. public static void UPxr_GetLayerImagePtr(int layerId, EyeType eye, int imageIndex, ref IntPtr image)
  3055. {
  3056. #if UNITY_ANDROID && !UNITY_EDITOR
  3057. Pxr_GetLayerImagePtr(layerId, eye, imageIndex, ref image);
  3058. #endif
  3059. PLog.d(TAG, "UPxr_GetLayerImagePtr() layerId:" + layerId + " eye:" + eye + " imageIndex:" + imageIndex + " image:" + image);
  3060. }
  3061. public static int UPxr_SetConfigIntArray(int[] configSetData)
  3062. {
  3063. #if UNITY_ANDROID && !UNITY_EDITOR
  3064. if (PXR_Plugin.System.UPxr_GetAPIVersion() >= 0x2000300)
  3065. {
  3066. return Pxr_SetConfigIntArray(ConfigType.PxrAndroidLayerDimensions, configSetData, 3);
  3067. }
  3068. #endif
  3069. return 0;
  3070. }
  3071. public static int UPxr_SetConfigFloatArray(ConfigType configIndex, float[] configSetData, int dataCount)
  3072. {
  3073. #if UNITY_ANDROID && !UNITY_EDITOR
  3074. if (PXR_Plugin.System.UPxr_GetAPIVersion() >= 0x2000300)
  3075. {
  3076. return Pxr_SetConfigFloatArray(configIndex, configSetData, dataCount);
  3077. }
  3078. #endif
  3079. return 0;
  3080. }
  3081. public static int UPxr_GetLayerAndroidSurface(int layerId, EyeType eye, ref IntPtr androidSurface)
  3082. {
  3083. int result = 0;
  3084. #if UNITY_ANDROID && !UNITY_EDITOR
  3085. result = Pxr_GetLayerAndroidSurface(layerId, eye, ref androidSurface);
  3086. #endif
  3087. PLog.d(TAG, "UPxr_GetLayerAndroidSurface() layerId:" + layerId + " eye:" + eye + " androidSurface:" + androidSurface + " result:" + result);
  3088. return result;
  3089. }
  3090. public static int UPxr_DestroyLayer(int layerId)
  3091. {
  3092. int result = 0;
  3093. #if UNITY_ANDROID && !UNITY_EDITOR
  3094. result = Pxr_DestroyLayer(layerId);
  3095. #endif
  3096. PLog.d(TAG, "UPxr_DestroyLayer() layerId:" + layerId + " result:" + result);
  3097. return result;
  3098. }
  3099. public static void UPxr_DestroyLayerByRender(int layerId)
  3100. {
  3101. PLog.d(TAG, "UPxr_DestroyLayerByRender() layerId:" + layerId);
  3102. #if UNITY_ANDROID && !UNITY_EDITOR
  3103. Pxr_DestroyLayerByRender(layerId);
  3104. #endif
  3105. }
  3106. public static int UPxr_SubmitLayer(IntPtr layer)
  3107. {
  3108. int result = 0;
  3109. #if UNITY_ANDROID && !UNITY_EDITOR
  3110. result = Pxr_SubmitLayer(layer);
  3111. #endif
  3112. PLog.d(TAG, "UPxr_SubmitLayer() layer:" + layer + " result:" + result);
  3113. return result;
  3114. }
  3115. public static int UPxr_SubmitLayerQuad(PxrLayerQuad layer)
  3116. {
  3117. int result = 0;
  3118. #if UNITY_ANDROID && !UNITY_EDITOR
  3119. result = Pxr_SubmitLayerQuad(layer);
  3120. #endif
  3121. PLog.d(TAG, "UPxr_SubmitLayerQuad() layer:" + layer + " result:" + result);
  3122. return result;
  3123. }
  3124. public static bool UPxr_SubmitLayerQuad2(PxrLayerQuad2 layer)
  3125. {
  3126. int result = 0;
  3127. #if UNITY_ANDROID && !UNITY_EDITOR
  3128. result = Pxr_SubmitLayerQuad2(layer);
  3129. #endif
  3130. PLog.d(TAG, "UPxr_SubmitLayerQuad2() layer:" + layer + " result:" + result);
  3131. return result == -8;
  3132. }
  3133. public static int UPxr_SubmitLayerCylinder(PxrLayerCylinder layer)
  3134. {
  3135. int result = 0;
  3136. #if UNITY_ANDROID && !UNITY_EDITOR
  3137. result = Pxr_SubmitLayerCylinder(layer);
  3138. #endif
  3139. PLog.d(TAG, "UPxr_SubmitLayerCylinder() layer:" + layer + " result:" + result);
  3140. return result;
  3141. }
  3142. public static bool UPxr_SubmitLayerCylinder2(PxrLayerCylinder2 layer)
  3143. {
  3144. int result = 0;
  3145. #if UNITY_ANDROID && !UNITY_EDITOR
  3146. result = Pxr_SubmitLayerCylinder2(layer);
  3147. #endif
  3148. PLog.d(TAG, "UPxr_SubmitLayerCylinder2() layer:" + layer + " result:" + result);
  3149. return result == -8;
  3150. }
  3151. public static bool UPxr_SubmitLayerEquirect(PxrLayerEquirect layer) // shape 3
  3152. {
  3153. int result = 0;
  3154. #if UNITY_ANDROID && !UNITY_EDITOR
  3155. result = Pxr_SubmitLayerEquirect(layer);
  3156. #endif
  3157. PLog.d(TAG, "UPxr_SubmitLayerEquirect() layer:" + layer + " result:" + result);
  3158. return result == -8;
  3159. }
  3160. public static bool UPxr_SubmitLayerEquirect2(PxrLayerEquirect2 layer) // shape 4
  3161. {
  3162. int result = 0;
  3163. #if UNITY_ANDROID && !UNITY_EDITOR
  3164. result = Pxr_SubmitLayerEquirect2(layer);
  3165. #endif
  3166. PLog.d(TAG, "UPxr_SubmitLayerEquirect2() layer:" + layer + " result:" + result);
  3167. return result == -8;
  3168. }
  3169. public static int UPxr_SubmitLayerCube2(PxrLayerCube2 layer)
  3170. {
  3171. int result = 0;
  3172. #if UNITY_ANDROID && !UNITY_EDITOR
  3173. result = Pxr_SubmitLayerCube2(layer);
  3174. #endif
  3175. PLog.d(TAG, "UPxr_SubmitLayerCube2() layer:" + layer + " result:" + result);
  3176. return result;
  3177. }
  3178. public static int UPxr_SubmitLayerEac2(PxrLayerEac2 layer)
  3179. {
  3180. int result = 0;
  3181. #if UNITY_ANDROID && !UNITY_EDITOR
  3182. result = Pxr_SubmitLayerEac2(layer);
  3183. #endif
  3184. PLog.d(TAG, "UPxr_SubmitLayerEac2() layer:" + layer + " result:" + result);
  3185. return result;
  3186. }
  3187. public static void UPxr_SetLayerBlend(bool enable, PxrLayerBlend layerBlend)
  3188. {
  3189. PLog.d(TAG, "UPxr_SetLayerBlend() enable:" + enable + " layerBlend.srcColor:" + layerBlend.srcColor + " dstColor:" + layerBlend.dstColor + " srcAlpha:" + layerBlend.srcAlpha + " dstAlpha:" + layerBlend.dstAlpha);
  3190. #if UNITY_ANDROID && !UNITY_EDITOR
  3191. Pxr_SetLayerBlend(enable, layerBlend);
  3192. #endif
  3193. }
  3194. public static void UPxr_SetSpaceWarp(bool value)
  3195. {
  3196. #if UNITY_ANDROID && !UNITY_EDITOR
  3197. Pxr_SetSpaceWarp(value?1:0);
  3198. #endif
  3199. PLog.d(TAG, "UPxr_SetSpaceWarp " + value);
  3200. }
  3201. public static void UPxr_SetAppSpacePosition(float x, float y, float z)
  3202. {
  3203. #if UNITY_ANDROID && !UNITY_EDITOR
  3204. Pxr_SetAppSpacePosition(x, y, z);
  3205. #endif
  3206. }
  3207. public static void UPxr_SetAppSpaceRotation(float x, float y, float z, float w)
  3208. {
  3209. #if UNITY_ANDROID && !UNITY_EDITOR
  3210. Pxr_SetAppSpaceRotation(x, y, z, w);
  3211. #endif
  3212. }
  3213. public static void UPxr_EnablePremultipliedAlpha(bool enable)
  3214. {
  3215. #if UNITY_ANDROID && !UNITY_EDITOR
  3216. Pxr_EnablePremultipliedAlpha(enable);
  3217. #endif
  3218. PLog.i(TAG, "Pxr_EnablePremultipliedAlpha " + enable);
  3219. }
  3220. }
  3221. public static class Sensor
  3222. {
  3223. private const string TAG = "[PXR_Plugin/Sensor]";
  3224. #if UNITY_ANDROID && !UNITY_EDITOR
  3225. private static AndroidJavaClass unityPlayer = new AndroidJavaClass("com.unity3d.player.UnityPlayer");
  3226. private static AndroidJavaObject currentActivity = unityPlayer.GetStatic<AndroidJavaObject>("currentActivity");
  3227. private static AndroidJavaClass sysActivity = new AndroidJavaClass("com.psmart.aosoperation.SysActivity");
  3228. #endif
  3229. public static int UPxr_ResetSensor(ResetSensorOption resetSensorOption)
  3230. {
  3231. PLog.d(TAG, string.Format("UPxr_ResetSensor : {0}", resetSensorOption));
  3232. int result = 0;
  3233. #if UNITY_ANDROID && !UNITY_EDITOR
  3234. result = Pxr_ResetSensor(resetSensorOption);
  3235. #endif
  3236. PLog.d(TAG, string.Format("UPxr_ResetSensor result: {0}", result));
  3237. return result;
  3238. }
  3239. public static int UPvr_Enable6DofModule(bool enable)
  3240. {
  3241. PLog.d(TAG, string.Format("UPvr_Enable6DofModule : {0}", enable));
  3242. #if UNITY_ANDROID && !UNITY_EDITOR
  3243. return Pxr_SetConfigInt(ConfigType.Ability6Dof, enable?1:0);
  3244. #else
  3245. return 0;
  3246. #endif
  3247. }
  3248. public static void UPxr_InitPsensor()
  3249. {
  3250. PLog.d(TAG, "UPxr_InitPsensor()");
  3251. #if UNITY_ANDROID && !UNITY_EDITOR
  3252. try
  3253. {
  3254. sysActivity.CallStatic("initPsensor", currentActivity);
  3255. }
  3256. catch (Exception e)
  3257. {
  3258. PLog.e(TAG, "Error :" + e.ToString());
  3259. }
  3260. #endif
  3261. }
  3262. public static int UPxr_GetPSensorState()
  3263. {
  3264. PLog.d(TAG, "UPxr_GetPSensorState()");
  3265. int psensor = -1;
  3266. #if UNITY_ANDROID && !UNITY_EDITOR
  3267. try
  3268. {
  3269. psensor = sysActivity.CallStatic<int>("getPsensorState");
  3270. }
  3271. catch (Exception e)
  3272. {
  3273. PLog.e(TAG, "Error :" + e.ToString());
  3274. }
  3275. #endif
  3276. PLog.d(TAG, "UPxr_GetPSensorState() psensor:" + psensor);
  3277. return psensor;
  3278. }
  3279. public static void UPxr_UnregisterPsensor()
  3280. {
  3281. PLog.d(TAG, "UPxr_UnregisterPsensor()");
  3282. #if UNITY_ANDROID && !UNITY_EDITOR
  3283. try
  3284. {
  3285. sysActivity.CallStatic("unregisterListener");
  3286. }
  3287. catch (Exception e)
  3288. {
  3289. PLog.e(TAG, "Error :" + e.ToString());
  3290. }
  3291. #endif
  3292. }
  3293. public static int UPxr_SetSensorLostCustomMode(bool value)
  3294. {
  3295. #if UNITY_ANDROID && !UNITY_EDITOR
  3296. return Pxr_SetSensorLostCustomMode(value);
  3297. #else
  3298. return 0;
  3299. #endif
  3300. }
  3301. public static int UPxr_SetSensorLostCMST(bool value)
  3302. {
  3303. #if UNITY_ANDROID && !UNITY_EDITOR
  3304. return Pxr_SetSensorLostCMST(value);
  3305. #else
  3306. return 0;
  3307. #endif
  3308. }
  3309. }
  3310. public static class PlatformSetting
  3311. {
  3312. private const string TAG = "[PXR_Plugin/PlatformSetting]";
  3313. #if UNITY_ANDROID && !UNITY_EDITOR
  3314. private static AndroidJavaClass MRCCalibration = new AndroidJavaClass("com.psmart.aosoperation.MRCCalibration");
  3315. private static AndroidJavaClass unityPlayer = new AndroidJavaClass("com.unity3d.player.UnityPlayer");
  3316. private static AndroidJavaObject currentActivity = unityPlayer.GetStatic<AndroidJavaObject>("currentActivity");
  3317. #endif
  3318. public static float[] UPxr_MRCCalibration(string path)
  3319. {
  3320. float[] MRCdata = new float[10];
  3321. if (PXR_Plugin.System.UPxr_GetAPIVersion() >= 0x2000300)
  3322. {
  3323. AndroidJavaObject MrcCalibration = new AndroidJavaObject("com.psmart.aosoperation.MRCCalibration");
  3324. #if UNITY_ANDROID && !UNITY_EDITOR
  3325. MRCdata = MrcCalibration.Call<float[]>("readCalibrationData",path);
  3326. #endif
  3327. }
  3328. return MRCdata;
  3329. }
  3330. }
  3331. public static class Controller
  3332. {
  3333. private const string TAG = "[PXR_Plugin/Controller]";
  3334. public static int UPxr_SetControllerVibration(UInt32 hand, float strength, int time)
  3335. {
  3336. #if UNITY_ANDROID && !UNITY_EDITOR
  3337. return Pxr_SetControllerVibration(hand,strength, time);
  3338. #else
  3339. return 0;
  3340. #endif
  3341. }
  3342. public static int UPxr_SetControllerEnableKey(bool isEnable, PxrControllerKeyMap Key)
  3343. {
  3344. #if UNITY_ANDROID && !UNITY_EDITOR
  3345. return Pxr_SetControllerEnableKey(isEnable, Key);
  3346. #else
  3347. return 0;
  3348. #endif
  3349. }
  3350. public static int UPxr_GetBodyTrackingPose(double predictTime, ref BodyTrackerResult bodyTrackerResult)
  3351. {
  3352. int state = 1;
  3353. #if UNITY_ANDROID && !UNITY_EDITOR
  3354. state = Pxr_GetBodyTrackingPose(predictTime,ref bodyTrackerResult);
  3355. for (int i = 0; i < 24; i++) {
  3356. bodyTrackerResult.trackingdata[i].localpose.PosZ = -bodyTrackerResult.trackingdata[i].localpose.PosZ;
  3357. bodyTrackerResult.trackingdata[i].localpose.RotQz = -bodyTrackerResult.trackingdata[i].localpose.RotQz;
  3358. bodyTrackerResult.trackingdata[i].localpose.RotQw = -bodyTrackerResult.trackingdata[i].localpose.RotQw;
  3359. bodyTrackerResult.trackingdata[i].velo[2] = -bodyTrackerResult.trackingdata[i].velo[2];
  3360. bodyTrackerResult.trackingdata[i].acce[2] = -bodyTrackerResult.trackingdata[i].acce[2];
  3361. bodyTrackerResult.trackingdata[i].wvelo[2] = -bodyTrackerResult.trackingdata[i].wvelo[2];
  3362. bodyTrackerResult.trackingdata[i].wacce[2] = -bodyTrackerResult.trackingdata[i].wacce[2];
  3363. }
  3364. #endif
  3365. return state;
  3366. }
  3367. public static int UPxr_SetBodyTrackingMode(int mode) {
  3368. #if UNITY_ANDROID && !UNITY_EDITOR
  3369. return Pxr_SetBodyTrackingMode(mode);
  3370. #endif
  3371. return 0;
  3372. }
  3373. public static int UPxr_GetFitnessBandConnectState(ref PxrFitnessBandConnectState state)
  3374. {
  3375. #if UNITY_ANDROID && !UNITY_EDITOR
  3376. return Pxr_GetFitnessBandConnectState(ref state);
  3377. #endif
  3378. return 0;
  3379. }
  3380. public static int UPxr_GetFitnessBandBattery(int trackerId, ref int battery) {
  3381. #if UNITY_ANDROID && !UNITY_EDITOR
  3382. return Pxr_GetFitnessBandBattery(trackerId, ref battery);
  3383. #endif
  3384. return 0;
  3385. }
  3386. public static int UPxr_GetFitnessBandCalibState(ref int calibrated) {
  3387. #if UNITY_ANDROID && !UNITY_EDITOR
  3388. return Pxr_GetFitnessBandCalibState(ref calibrated);
  3389. #endif
  3390. return 0;
  3391. }
  3392. public static int UPxr_SetSwiftMode(int mode)
  3393. {
  3394. if (System.UPxr_GetAPIVersion() >= 0x200030C)
  3395. {
  3396. #if UNITY_ANDROID && !UNITY_EDITOR
  3397. BodyTrackingAlgParam pxrBodyTrackingAlgParam = new BodyTrackingAlgParam();
  3398. pxrBodyTrackingAlgParam.BodyJointSet = mode;
  3399. return Pxr_SetBodyTrackingAlgParam(BodyTrackingAlgParamType.SWIFT_MODE, ref pxrBodyTrackingAlgParam);
  3400. #endif
  3401. }
  3402. return 0;
  3403. }
  3404. public static int UPxr_SetBodyTrackingBoneLength(BodyTrackingBoneLength boneLength)
  3405. {
  3406. if (System.UPxr_GetAPIVersion() >= 0x200030C)
  3407. {
  3408. #if UNITY_ANDROID && !UNITY_EDITOR
  3409. BodyTrackingAlgParam pxrBodyTrackingAlgParam = new BodyTrackingAlgParam();
  3410. pxrBodyTrackingAlgParam.BodyJointSet = 1;
  3411. pxrBodyTrackingAlgParam.BoneLength = boneLength;
  3412. return Pxr_SetBodyTrackingAlgParam(BodyTrackingAlgParamType.BONE_PARAM, ref pxrBodyTrackingAlgParam);
  3413. #endif
  3414. }
  3415. return 0;
  3416. }
  3417. public static int UPxr_SetControllerVibrationEvent(UInt32 hand, int frequency, float strength, int time)
  3418. {
  3419. if (PXR_Plugin.System.UPxr_GetAPIVersion() >= 0x2000305)
  3420. {
  3421. #if UNITY_ANDROID && !UNITY_EDITOR
  3422. return Pxr_SetControllerVibrationEvent(hand, frequency,strength, time);
  3423. #endif
  3424. }
  3425. return 0;
  3426. }
  3427. public static int UPxr_GetControllerType()
  3428. {
  3429. var type = 0;
  3430. #if UNITY_ANDROID && !UNITY_EDITOR
  3431. PxrControllerCapability capability = new PxrControllerCapability();
  3432. Pxr_GetControllerCapabilities(0,ref capability);
  3433. type = (int)capability.type;
  3434. #endif
  3435. PLog.d(TAG, "UPxr_GetControllerType()" + type);
  3436. return type;
  3437. }
  3438. //Pxr_StopControllerVCMotor
  3439. public static int UPxr_StopControllerVCMotor(int id)
  3440. {
  3441. if (PXR_Plugin.System.UPxr_GetAPIVersion() >= 0x2000308)
  3442. {
  3443. #if UNITY_ANDROID && !UNITY_EDITOR
  3444. Debug.Log("[VCMotor_SDK] StopControllerVCMotor :" + id.ToString());
  3445. return Pxr_StopControllerVCMotor(id);
  3446. #endif
  3447. }
  3448. return 0;
  3449. }
  3450. public static int UPxr_StartControllerVCMotor(string file, int slot)
  3451. {
  3452. //0-Left And Right 1-Left 2-Right 3-Left And Right
  3453. //0-Reversal 1-No Reversal
  3454. if (PXR_Plugin.System.UPxr_GetAPIVersion() >= 0x2000308)
  3455. {
  3456. #if UNITY_ANDROID && !UNITY_EDITOR
  3457. Debug.Log("[VCMotor_SDK] StartControllerVCMotor " + file + " slot: " + slot.ToString());
  3458. return Pxr_StartControllerVCMotor(file,slot);
  3459. #endif
  3460. }
  3461. return 0;
  3462. }
  3463. public static int UPxr_SetControllerAmp(float mode)
  3464. {
  3465. if (PXR_Plugin.System.UPxr_GetAPIVersion() >= 0x2000305)
  3466. {
  3467. #if UNITY_ANDROID && !UNITY_EDITOR
  3468. return Pxr_SetControllerAmp(mode);
  3469. #endif
  3470. }
  3471. return 0;
  3472. }
  3473. public static int UPxr_SetControllerDelay()
  3474. {
  3475. if (PXR_Plugin.System.UPxr_GetAPIVersion() >= 0x2000305)
  3476. {
  3477. #if UNITY_ANDROID && !UNITY_EDITOR
  3478. int delay = 3;
  3479. int Length;
  3480. int num;
  3481. AudioSettings.GetDSPBufferSize(out Length, out num);
  3482. if (Length == 256)
  3483. {
  3484. delay = 1;
  3485. }
  3486. else if (Length == 512) {
  3487. delay = 2;
  3488. } else if (Length == 1024) {
  3489. delay = 3;
  3490. }
  3491. Debug.Log("[VCMotor_SDK] UPxr_SetControllerDelay " + delay.ToString());
  3492. return Pxr_SetControllerDelay(delay);
  3493. #endif
  3494. }
  3495. return 0;
  3496. }
  3497. public static string UPxr_GetVibrateDelayTime(ref int x)
  3498. {
  3499. if (PXR_Plugin.System.UPxr_GetAPIVersion() >= 0x2000305)
  3500. {
  3501. #if UNITY_ANDROID && !UNITY_EDITOR
  3502. return Pxr_GetVibrateDelayTime(ref x);
  3503. #endif
  3504. }
  3505. return " ";
  3506. }
  3507. public static int UPxr_StartVibrateBySharem(float[] data, int slot, int buffersize, int sampleRate, int channelMask, int bitrate ,int channelFlip, ref int sourceId)
  3508. {
  3509. if (PXR_Plugin.System.UPxr_GetAPIVersion() >= 0x2000308)
  3510. {
  3511. #if UNITY_ANDROID && !UNITY_EDITOR
  3512. AudioClipData audioClipData = new AudioClipData();
  3513. audioClipData.slot = slot;
  3514. audioClipData.channelCounts = channelMask;
  3515. audioClipData.buffersize = (UInt64)buffersize;
  3516. audioClipData.sampleRate = sampleRate;
  3517. audioClipData.reversal = channelFlip;
  3518. audioClipData.bitrate = bitrate;
  3519. audioClipData.isCache = 0;
  3520. Debug.Log("[VCMotor_SDK] Pxr_StartVibrateBySharem " + " slot: " + audioClipData.slot.ToString() + " buffersize:" + audioClipData.buffersize.ToString() + " sampleRate" + audioClipData.sampleRate.ToString() + " channelCounts:" + audioClipData.channelCounts.ToString()+" bitrate:" + audioClipData.bitrate.ToString());
  3521. return Pxr_StartVibrateBySharemF(data, ref audioClipData, ref sourceId);
  3522. #endif
  3523. }
  3524. return 0;
  3525. }
  3526. public static int UPxr_SaveVibrateByCache(float[] data, int slot, int buffersize, int sampleRate, int channelMask, int bitrate, int slotconfig, int enableV , ref int sourceId)
  3527. {
  3528. if (PXR_Plugin.System.UPxr_GetAPIVersion() >= 0x2000308)
  3529. {
  3530. #if UNITY_ANDROID && !UNITY_EDITOR
  3531. AudioClipData audioClipData = new AudioClipData();
  3532. audioClipData.slot = slot;
  3533. audioClipData.buffersize = (UInt64)buffersize;
  3534. audioClipData.sampleRate = sampleRate;
  3535. audioClipData.channelCounts = channelMask;
  3536. audioClipData.bitrate = bitrate;
  3537. audioClipData.reversal = slotconfig;
  3538. audioClipData.isCache = enableV;
  3539. Debug.Log("[VCMotor_SDK] UPxr_SaveVibrateByCache " + " slot: " + audioClipData.slot.ToString() + " buffersize:" + audioClipData.buffersize.ToString() + " sampleRate" + audioClipData.sampleRate.ToString() + " channelMask:" + audioClipData.channelCounts.ToString() + " bitrate:" + audioClipData.bitrate.ToString());
  3540. return Pxr_StartVibrateBySharemF(data, ref audioClipData, ref sourceId);
  3541. #endif
  3542. }
  3543. return 0;
  3544. }
  3545. public static int UPxr_StartVibrateByCache(int clicpid)
  3546. {
  3547. if (PXR_Plugin.System.UPxr_GetAPIVersion() >= 0x2000308)
  3548. {
  3549. #if UNITY_ANDROID && !UNITY_EDITOR
  3550. Debug.Log("[VCMotor_SDK] UPxr_StartVibrateByCache " + clicpid.ToString());
  3551. return Pxr_StartVibrateByCache(clicpid);
  3552. #endif
  3553. }
  3554. return 0;
  3555. }
  3556. public static int UPxr_ClearVibrateByCache(int clicpid)
  3557. {
  3558. if (PXR_Plugin.System.UPxr_GetAPIVersion() >= 0x2000308)
  3559. {
  3560. #if UNITY_ANDROID && !UNITY_EDITOR
  3561. Debug.Log("[VCMotor_SDK] UPxr_ClearVibrateByCache " + clicpid.ToString());
  3562. return Pxr_ClearVibrateByCache(clicpid);
  3563. #endif
  3564. }
  3565. return 0;
  3566. }
  3567. public static int UPxr_StartVibrateByPHF(string data, int buffersize, ref int sourceId, int slot, int reversal, float amp) {
  3568. if (PXR_Plugin.System.UPxr_GetAPIVersion() >= 0x2000308)
  3569. {
  3570. #if UNITY_ANDROID && !UNITY_EDITOR
  3571. VibrateInfo vibrateInfo = new VibrateInfo();
  3572. vibrateInfo.slot = (uint)slot;
  3573. vibrateInfo.reversal = (uint)reversal;
  3574. vibrateInfo.amp = amp;
  3575. Debug.Log("[VCMotor_SDK] Pxr_StartVibrateByPHF " + buffersize.ToString());
  3576. return Pxr_StartVibrateByPHF(data, buffersize, ref sourceId, ref vibrateInfo);
  3577. #endif
  3578. }
  3579. return 0;
  3580. }
  3581. public static int UPxr_PauseVibrate(int sourceID) {
  3582. if (PXR_Plugin.System.UPxr_GetAPIVersion() >= 0x2000308)
  3583. {
  3584. #if UNITY_ANDROID && !UNITY_EDITOR
  3585. Debug.Log("[VCMotor_SDK] Pxr_PauseVibrate " + sourceID.ToString());
  3586. return Pxr_PauseVibrate(sourceID);
  3587. #endif
  3588. }
  3589. return 0;
  3590. }
  3591. public static int UPxr_ResumeVibrate(int sourceID) {
  3592. if (PXR_Plugin.System.UPxr_GetAPIVersion() >= 0x2000308)
  3593. {
  3594. #if UNITY_ANDROID && !UNITY_EDITOR
  3595. Debug.Log("[VCMotor_SDK] Pxr_ResumeVibrate " + sourceID.ToString());
  3596. return Pxr_ResumeVibrate(sourceID);
  3597. #endif
  3598. }
  3599. return 0;
  3600. }
  3601. public static int UPxr_UpdateVibrateParams(int clicp_id,int slot, int reversal, float amp) {
  3602. if (PXR_Plugin.System.UPxr_GetAPIVersion() >= 0x2000308)
  3603. {
  3604. #if UNITY_ANDROID && !UNITY_EDITOR
  3605. VibrateInfo vibrateInfo = new VibrateInfo();
  3606. vibrateInfo.slot = (uint)slot;
  3607. vibrateInfo.reversal = (uint)reversal;
  3608. vibrateInfo.amp = amp;
  3609. Debug.Log("[VCMotor_SDK] UPxr_UpdateVibrateParams " + clicp_id.ToString() + " solt: " + slot.ToString() + " reversal:" + reversal.ToString() + " AMP:" + amp.ToString());
  3610. return Pxr_UpdateVibrateParams(clicp_id, ref vibrateInfo);
  3611. #endif
  3612. }
  3613. return 0;
  3614. }
  3615. public static int UPxr_CreateHapticStream(string phfVersion, UInt32 frameDurationMs, ref VibrateInfo hapticInfo, float speed, ref int id) {
  3616. if (PXR_Plugin.System.UPxr_GetAPIVersion() >= 0x200030A)
  3617. {
  3618. #if UNITY_ANDROID && !UNITY_EDITOR
  3619. Debug.Log("[VCMotor_SDK] UPxr_CreateHapticStream ");
  3620. return Pxr_CreateHapticStream(phfVersion, frameDurationMs, ref hapticInfo, speed, ref id);
  3621. #endif
  3622. }
  3623. return 0;
  3624. }
  3625. public static int UPxr_WriteHapticStream(int id, ref PxrPhfParamsNum frames, UInt32 numFrames) {
  3626. if (PXR_Plugin.System.UPxr_GetAPIVersion() >= 0x200030A)
  3627. {
  3628. #if UNITY_ANDROID && !UNITY_EDITOR
  3629. Debug.Log("[VCMotor_SDK] UPxr_WriteHapticStream ");
  3630. return Pxr_WriteHapticStream( id, ref frames, numFrames);
  3631. #endif
  3632. }
  3633. return 0;
  3634. }
  3635. public static int UPxr_SetPHFHapticSpeed(int id, float speed) {
  3636. if (PXR_Plugin.System.UPxr_GetAPIVersion() >= 0x200030A)
  3637. {
  3638. #if UNITY_ANDROID && !UNITY_EDITOR
  3639. Debug.Log("[VCMotor_SDK] UPxr_SetPHFHapticSpeed ");
  3640. return Pxr_SetPHFHapticSpeed( id, speed);
  3641. #endif
  3642. }
  3643. return 0;
  3644. }
  3645. public static int UPxr_GetPHFHapticSpeed(int id, ref float speed) {
  3646. if (PXR_Plugin.System.UPxr_GetAPIVersion() >= 0x200030A)
  3647. {
  3648. #if UNITY_ANDROID && !UNITY_EDITOR
  3649. Debug.Log("[VCMotor_SDK] UPxr_GetPHFHapticSpeed ");
  3650. return Pxr_GetPHFHapticSpeed( id, ref speed);
  3651. #endif
  3652. }
  3653. return 0;
  3654. }
  3655. public static int UPxr_GetCurrentFrameSequence(int id, ref UInt64 frameSequence) {
  3656. if (PXR_Plugin.System.UPxr_GetAPIVersion() >= 0x200030A)
  3657. {
  3658. #if UNITY_ANDROID && !UNITY_EDITOR
  3659. Debug.Log("[VCMotor_SDK] UPxr_GetCurrentFrameSequence ");
  3660. return Pxr_GetCurrentFrameSequence( id, ref frameSequence);
  3661. #endif
  3662. }
  3663. return 0;
  3664. }
  3665. public static int UPxr_StartPHFHaptic(int source_id) {
  3666. if (PXR_Plugin.System.UPxr_GetAPIVersion() >= 0x200030A)
  3667. {
  3668. #if UNITY_ANDROID && !UNITY_EDITOR
  3669. Debug.Log("[VCMotor_SDK] UPxr_StartPHFHaptic ");
  3670. return Pxr_StartPHFHaptic(source_id);
  3671. #endif
  3672. }
  3673. return 0;
  3674. }
  3675. public static int UPxr_StopPHFHaptic(int source_id) {
  3676. if (PXR_Plugin.System.UPxr_GetAPIVersion() >= 0x200030A)
  3677. {
  3678. #if UNITY_ANDROID && !UNITY_EDITOR
  3679. Debug.Log("[VCMotor_SDK] UPxr_StopPHFHaptic ");
  3680. return Pxr_StopPHFHaptic(source_id);
  3681. #endif
  3682. }
  3683. return 0;
  3684. }
  3685. public static int UPxr_RemovePHFHaptic(int source_id) {
  3686. if (PXR_Plugin.System.UPxr_GetAPIVersion() >= 0x200030A)
  3687. {
  3688. #if UNITY_ANDROID && !UNITY_EDITOR
  3689. Debug.Log("[VCMotor_SDK] UPxr_RemovePHFHaptic ");
  3690. return Pxr_RemovePHFHaptic(source_id);
  3691. #endif
  3692. }
  3693. return 0;
  3694. }
  3695. public static int UPxr_SetControllerMainInputHandle(UInt32 hand)
  3696. {
  3697. #if UNITY_ANDROID && !UNITY_EDITOR
  3698. return Pxr_SetControllerMainInputHandle(hand);
  3699. #else
  3700. return 0;
  3701. #endif
  3702. }
  3703. public static PXR_Input.Controller UPxr_GetControllerMainInputHandle()
  3704. {
  3705. var hand = 0;
  3706. #if UNITY_ANDROID && !UNITY_EDITOR
  3707. Pxr_GetControllerMainInputHandle(ref hand);
  3708. #endif
  3709. PLog.d(TAG, "Pxr_GetControllerMainInputHandle()" + hand.ToString());
  3710. return (PXR_Input.Controller)hand;
  3711. }
  3712. public static int UPxr_GetControllerTrackingState(UInt32 deviceID, double predictTime, float[] headSensorData, ref PxrControllerTracking tracking)
  3713. {
  3714. #if UNITY_ANDROID && !UNITY_EDITOR
  3715. return Pxr_GetControllerTrackingState(deviceID,predictTime,headSensorData, ref tracking);
  3716. #else
  3717. return 0;
  3718. #endif
  3719. }
  3720. public static void UPxr_SetControllerOriginOffset(int controllerID, Vector3 offset)
  3721. {
  3722. #if UNITY_ANDROID && !UNITY_EDITOR
  3723. Pxr_SetControllerOriginOffset(controllerID, offset);
  3724. #endif
  3725. }
  3726. public static void UPxr_ResetController()
  3727. {
  3728. if (System.UPxr_GetAPIVersion() >= 0x200030B)
  3729. {
  3730. #if UNITY_ANDROID && !UNITY_EDITOR
  3731. Pxr_ResetController(0);
  3732. #endif
  3733. }
  3734. }
  3735. public static void UPxr_SetArmModelParameters(PxrGazeType gazetype, PxrArmModelType armmodeltype, float elbowHeight, float elbowDepth, float pointerTiltAngle)
  3736. {
  3737. if (System.UPxr_GetAPIVersion() >= 0x200030B)
  3738. {
  3739. #if UNITY_ANDROID && !UNITY_EDITOR
  3740. Pxr_SetArmModelParameters(gazetype, armmodeltype, elbowHeight, elbowDepth, pointerTiltAngle);
  3741. #endif
  3742. }
  3743. }
  3744. public static void UPxr_GetControllerHandness(ref int deviceID)
  3745. {
  3746. if (System.UPxr_GetAPIVersion() >= 0x200030B)
  3747. {
  3748. #if UNITY_ANDROID && !UNITY_EDITOR
  3749. Pxr_GetControllerHandness(ref deviceID);
  3750. #endif
  3751. }
  3752. }
  3753. }
  3754. public static class HandTracking
  3755. {
  3756. [DllImport(PXR_API_DLL, CallingConvention = CallingConvention.Cdecl)]
  3757. private static extern int Pxr_GetHandTrackerSettingState(ref bool settingState);
  3758. [DllImport(PXR_API_DLL, CallingConvention = CallingConvention.Cdecl)]
  3759. private static extern int Pxr_GetHandTrackerActiveInputType(ref ActiveInputDevice activeInputDevice);
  3760. [DllImport(PXR_PLATFORM_DLL, CallingConvention = CallingConvention.Cdecl)]
  3761. private static extern int Pxr_GetHandTrackerAimState(HandType hand, ref HandAimState aimState);
  3762. [DllImport(PXR_PLATFORM_DLL, CallingConvention = CallingConvention.Cdecl)]
  3763. private static extern int Pxr_GetHandTrackerJointLocations(HandType hand, ref HandJointLocations jointLocations);
  3764. public static bool UPxr_GetHandTrackerSettingState()
  3765. {
  3766. bool val = false;
  3767. if (System.UPxr_GetAPIVersion() >= 0x2000306)
  3768. {
  3769. #if !UNITY_EDITOR && UNITY_ANDROID
  3770. Pxr_GetHandTrackerSettingState(ref val);
  3771. #endif
  3772. }
  3773. return val;
  3774. }
  3775. public static ActiveInputDevice UPxr_GetHandTrackerActiveInputType()
  3776. {
  3777. ActiveInputDevice val = ActiveInputDevice.HeadActive;
  3778. if (System.UPxr_GetAPIVersion() >= 0x2000307)
  3779. {
  3780. #if !UNITY_EDITOR && UNITY_ANDROID
  3781. Pxr_GetHandTrackerActiveInputType(ref val);
  3782. #endif
  3783. }
  3784. return val;
  3785. }
  3786. public static bool UPxr_GetHandTrackerAimState(HandType hand, ref HandAimState aimState)
  3787. {
  3788. bool val = false;
  3789. if (System.UPxr_GetAPIVersion() >= 0x2000306)
  3790. {
  3791. #if !UNITY_EDITOR && UNITY_ANDROID
  3792. val = Pxr_GetHandTrackerAimState(hand,ref aimState) == 0;
  3793. #endif
  3794. }
  3795. return val;
  3796. }
  3797. public static bool UPxr_GetHandTrackerJointLocations(HandType hand, ref HandJointLocations jointLocations)
  3798. {
  3799. bool val = false;
  3800. if (System.UPxr_GetAPIVersion() >= 0x2000306)
  3801. {
  3802. #if !UNITY_EDITOR && UNITY_ANDROID
  3803. val = Pxr_GetHandTrackerJointLocations(hand, ref jointLocations) == 0;
  3804. #endif
  3805. }
  3806. return val;
  3807. }
  3808. }
  3809. public static class MotionTracking
  3810. {
  3811. #region Eye Tracking
  3812. [DllImport(PXR_API_DLL, CallingConvention = CallingConvention.Cdecl)]
  3813. private static extern int Pxr_WantEyeTrackingService();
  3814. [DllImport(PXR_API_DLL, CallingConvention = CallingConvention.Cdecl)]
  3815. private static extern int Pxr_GetEyeTrackingSupported(ref bool supported, ref int supportedModesCount, ref EyeTrackingMode supportedModes);
  3816. [DllImport(PXR_API_DLL, CallingConvention = CallingConvention.Cdecl)]
  3817. private static extern int Pxr_StartEyeTracking1(ref EyeTrackingStartInfo startInfo);
  3818. [DllImport(PXR_API_DLL, CallingConvention = CallingConvention.Cdecl)]
  3819. private static extern int Pxr_StopEyeTracking1(ref EyeTrackingStopInfo stopInfo);
  3820. [DllImport(PXR_API_DLL, CallingConvention = CallingConvention.Cdecl)]
  3821. private static extern int Pxr_GetEyeTrackingState(ref bool isTracking, ref EyeTrackingState state);
  3822. [DllImport(PXR_API_DLL, CallingConvention = CallingConvention.Cdecl)]
  3823. private static extern int Pxr_GetEyeTrackingData1(ref EyeTrackingDataGetInfo getInfo, ref EyeTrackingData data);
  3824. [DllImport(PXR_PLATFORM_DLL, CallingConvention = CallingConvention.Cdecl)]
  3825. private static extern int Pxr_GetEyeOpenness(ref float leftEyeOpenness, ref float rightEyeOpenness);
  3826. [DllImport(PXR_PLATFORM_DLL, CallingConvention = CallingConvention.Cdecl)]
  3827. private static extern int Pxr_GetEyePupilInfo(ref EyePupilInfo eyePupilPosition);
  3828. [DllImport(PXR_PLATFORM_DLL, CallingConvention = CallingConvention.Cdecl)]
  3829. private static extern int Pxr_GetPerEyePose(ref long timestamp, ref Posef leftEyePose, ref Posef rightPose);
  3830. [DllImport(PXR_PLATFORM_DLL, CallingConvention = CallingConvention.Cdecl)]
  3831. private static extern int Pxr_GetEyeBlink(ref long timestamp, ref bool isLeftBlink, ref bool isRightBlink);
  3832. public static int UPxr_WantEyeTrackingService()
  3833. {
  3834. int val = 0;
  3835. if (System.UPxr_GetAPIVersion() >= 0x200030C)
  3836. {
  3837. #if !UNITY_EDITOR && UNITY_ANDROID
  3838. val = Pxr_WantEyeTrackingService();
  3839. #endif
  3840. }
  3841. return val;
  3842. }
  3843. public static int UPxr_GetEyeTrackingSupported(ref bool supported, ref int supportedModesCount, ref EyeTrackingMode supportedModes)
  3844. {
  3845. int val = -1;
  3846. if (System.UPxr_GetAPIVersion() >= 0x200030C)
  3847. {
  3848. #if !UNITY_EDITOR && UNITY_ANDROID
  3849. val = Pxr_GetEyeTrackingSupported(ref supported, ref supportedModesCount, ref supportedModes);
  3850. #endif
  3851. }
  3852. return val;
  3853. }
  3854. public static int UPxr_StartEyeTracking1(ref EyeTrackingStartInfo startInfo)
  3855. {
  3856. int val = -1;
  3857. if (System.UPxr_GetAPIVersion() >= 0x200030C)
  3858. {
  3859. #if !UNITY_EDITOR && UNITY_ANDROID
  3860. val = Pxr_StartEyeTracking1(ref startInfo);
  3861. #endif
  3862. }
  3863. return val;
  3864. }
  3865. public static int UPxr_StopEyeTracking1(ref EyeTrackingStopInfo stopInfo)
  3866. {
  3867. int val = -1;
  3868. if (System.UPxr_GetAPIVersion() >= 0x200030C)
  3869. {
  3870. #if !UNITY_EDITOR && UNITY_ANDROID
  3871. val = Pxr_StopEyeTracking1(ref stopInfo);
  3872. #endif
  3873. }
  3874. return val;
  3875. }
  3876. public static int UPxr_GetEyeTrackingState(ref bool isTracking, ref EyeTrackingState state)
  3877. {
  3878. int val = -1;
  3879. if (System.UPxr_GetAPIVersion() >= 0x200030C)
  3880. {
  3881. #if !UNITY_EDITOR && UNITY_ANDROID
  3882. val = Pxr_GetEyeTrackingState(ref isTracking, ref state);
  3883. #endif
  3884. }
  3885. return val;
  3886. }
  3887. public static int UPxr_GetEyeTrackingData1(ref EyeTrackingDataGetInfo getInfo, ref EyeTrackingData data)
  3888. {
  3889. int val = -1;
  3890. if (System.UPxr_GetAPIVersion() >= 0x200030C)
  3891. {
  3892. #if !UNITY_EDITOR && UNITY_ANDROID
  3893. val = Pxr_GetEyeTrackingData1(ref getInfo, ref data);
  3894. #endif
  3895. }
  3896. return val;
  3897. }
  3898. public static int UPxr_GetEyeOpenness(ref float leftEyeOpenness, ref float rightEyeOpenness)
  3899. {
  3900. int val = 0;
  3901. if (System.UPxr_GetAPIVersion() >= 0x200030C)
  3902. {
  3903. #if !UNITY_EDITOR && UNITY_ANDROID
  3904. val = Pxr_GetEyeOpenness(ref leftEyeOpenness, ref rightEyeOpenness);
  3905. #endif
  3906. }
  3907. return val;
  3908. }
  3909. public static int UPxr_GetEyePupilInfo(ref EyePupilInfo eyePupilPosition)
  3910. {
  3911. int val = 0;
  3912. if (System.UPxr_GetAPIVersion() >= 0x200030C)
  3913. {
  3914. #if !UNITY_EDITOR && UNITY_ANDROID
  3915. val = Pxr_GetEyePupilInfo(ref eyePupilPosition);
  3916. #endif
  3917. }
  3918. return val;
  3919. }
  3920. public static int UPxr_GetPerEyePose(ref long timestamp, ref Posef leftEyePose, ref Posef rightPose)
  3921. {
  3922. int val = 0;
  3923. if (System.UPxr_GetAPIVersion() >= 0x200030C)
  3924. {
  3925. #if !UNITY_EDITOR && UNITY_ANDROID
  3926. val = Pxr_GetPerEyePose(ref timestamp, ref leftEyePose, ref rightPose);
  3927. #endif
  3928. }
  3929. return val;
  3930. }
  3931. public static int UPxr_GetEyeBlink(ref long timestamp, ref bool isLeftBlink, ref bool isRightBlink)
  3932. {
  3933. int val = 0;
  3934. if (System.UPxr_GetAPIVersion() >= 0x200030C)
  3935. {
  3936. #if !UNITY_EDITOR && UNITY_ANDROID
  3937. val = Pxr_GetEyeBlink(ref timestamp, ref isLeftBlink, ref isRightBlink);
  3938. #endif
  3939. }
  3940. return val;
  3941. }
  3942. #endregion
  3943. #region Face Tracking
  3944. [DllImport(PXR_API_DLL, CallingConvention = CallingConvention.Cdecl)]
  3945. private static extern int Pxr_WantFaceTrackingService();
  3946. [DllImport(PXR_API_DLL, CallingConvention = CallingConvention.Cdecl)]
  3947. private static extern int Pxr_GetFaceTrackingSupported(ref bool supported, ref int supportedModesCount, ref FaceTrackingSupportedMode supportedModes);
  3948. [DllImport(PXR_API_DLL, CallingConvention = CallingConvention.Cdecl)]
  3949. private static extern int Pxr_StartFaceTracking(ref FaceTrackingStartInfo startInfo);
  3950. [DllImport(PXR_API_DLL, CallingConvention = CallingConvention.Cdecl)]
  3951. private static extern int Pxr_StopFaceTracking(ref FaceTrackingStopInfo stopInfo);
  3952. [DllImport(PXR_API_DLL, CallingConvention = CallingConvention.Cdecl)]
  3953. private static extern int Pxr_GetFaceTrackingState(ref bool isTracking, ref FaceTrackingState state);
  3954. [DllImport(PXR_API_DLL, CallingConvention = CallingConvention.Cdecl)]
  3955. private static extern int Pxr_GetFaceTrackingData1(ref FaceTrackingDataGetInfo getInfo, ref FaceTrackingData data);
  3956. public static int UPxr_WantFaceTrackingService()
  3957. {
  3958. int val = -1;
  3959. if (System.UPxr_GetAPIVersion() >= 0x200030C)
  3960. {
  3961. #if !UNITY_EDITOR && UNITY_ANDROID
  3962. val = Pxr_WantFaceTrackingService();
  3963. #endif
  3964. }
  3965. return val;
  3966. }
  3967. public static int UPxr_GetFaceTrackingSupported(ref bool supported, ref int supportedModesCount, ref FaceTrackingSupportedMode supportedModes)
  3968. {
  3969. int val = -1;
  3970. if (System.UPxr_GetAPIVersion() >= 0x200030C)
  3971. {
  3972. #if !UNITY_EDITOR && UNITY_ANDROID
  3973. val = Pxr_GetFaceTrackingSupported(ref supported, ref supportedModesCount, ref supportedModes);
  3974. #endif
  3975. }
  3976. return val;
  3977. }
  3978. public static int UPxr_StartFaceTracking(ref FaceTrackingStartInfo startInfo)
  3979. {
  3980. int val = -1;
  3981. if (System.UPxr_GetAPIVersion() >= 0x200030C)
  3982. {
  3983. #if !UNITY_EDITOR && UNITY_ANDROID
  3984. val = Pxr_StartFaceTracking(ref startInfo);
  3985. #endif
  3986. }
  3987. return val;
  3988. }
  3989. public static int UPxr_StopFaceTracking(ref FaceTrackingStopInfo stopInfo)
  3990. {
  3991. int val = -1;
  3992. if (System.UPxr_GetAPIVersion() >= 0x200030C)
  3993. {
  3994. #if !UNITY_EDITOR && UNITY_ANDROID
  3995. val = Pxr_StopFaceTracking(ref stopInfo);
  3996. #endif
  3997. }
  3998. return val;
  3999. }
  4000. public static int UPxr_GetFaceTrackingState(ref bool isTracking, ref FaceTrackingState state)
  4001. {
  4002. int val = -1;
  4003. if (System.UPxr_GetAPIVersion() >= 0x200030C)
  4004. {
  4005. #if !UNITY_EDITOR && UNITY_ANDROID
  4006. val = Pxr_GetFaceTrackingState(ref isTracking, ref state);
  4007. #endif
  4008. }
  4009. return val;
  4010. }
  4011. public static int UPxr_GetFaceTrackingData1(ref FaceTrackingDataGetInfo getInfo, ref FaceTrackingData data)
  4012. {
  4013. int val = -1;
  4014. if (System.UPxr_GetAPIVersion() >= 0x200030C)
  4015. {
  4016. #if !UNITY_EDITOR && UNITY_ANDROID
  4017. val = Pxr_GetFaceTrackingData1(ref getInfo, ref data);
  4018. #endif
  4019. }
  4020. return val;
  4021. }
  4022. #endregion
  4023. }
  4024. public static class MixedReality
  4025. {
  4026. private const string TAG = "[PXR_Plugin/MixedReality]";
  4027. public static int UPxr_EnableVideoSeeThroughEffect(bool value)
  4028. {
  4029. #if UNITY_ANDROID && !UNITY_EDITOR
  4030. return Pxr_EnablePassthroughStyle(value);
  4031. #else
  4032. return -1;
  4033. #endif
  4034. }
  4035. public static int UPxr_SetVideoSeeThroughEffect(PxrLayerEffect type, float value, float duration)
  4036. {
  4037. #if UNITY_ANDROID && !UNITY_EDITOR
  4038. return Pxr_SetPassthroughStyle(type, value, duration);
  4039. #else
  4040. return -1;
  4041. #endif
  4042. }
  4043. public static int UPxr_SetVideoSeeThroughLUT(ref byte[] data, int width, int height, int row, int col)
  4044. {
  4045. #if UNITY_ANDROID && !UNITY_EDITOR
  4046. return Pxr_SetPassthroughLUT(ref data, width, height, row, col);
  4047. #else
  4048. return -1;
  4049. #endif
  4050. }
  4051. public static PxrResult UPxr_CreateAnchorEntity(ref PxrAnchorEntityCreateInfo info, out ulong anchorHandle)
  4052. {
  4053. anchorHandle = ulong.MinValue;
  4054. #if UNITY_ANDROID && !UNITY_EDITOR
  4055. return Pxr_CreateAnchorEntity(ref info,out anchorHandle);
  4056. #else
  4057. return PxrResult.TIMEOUT_EXPIRED;
  4058. #endif
  4059. }
  4060. public static PxrResult UPxr_DestroyAnchorEntity(ref PxrAnchorEntityDestroyInfo info)
  4061. {
  4062. #if UNITY_ANDROID && !UNITY_EDITOR
  4063. return Pxr_DestroyAnchorEntity(ref info);
  4064. #else
  4065. return PxrResult.TIMEOUT_EXPIRED;
  4066. #endif
  4067. }
  4068. public static PxrResult UPxr_PersistAnchorEntity(ref PxrAnchorEntityPersistInfo info, out ulong taskId)
  4069. {
  4070. taskId = ulong.MinValue;
  4071. #if UNITY_ANDROID && !UNITY_EDITOR
  4072. return Pxr_PersistAnchorEntity(ref info, out taskId);
  4073. #else
  4074. return PxrResult.TIMEOUT_EXPIRED;
  4075. #endif
  4076. }
  4077. public static PxrResult UPxr_UnpersistAnchorEntity(ref PxrAnchorEntityUnPersistInfo info, out ulong taskId)
  4078. {
  4079. taskId = ulong.MinValue;
  4080. #if UNITY_ANDROID && !UNITY_EDITOR
  4081. return Pxr_UnpersistAnchorEntity(ref info, out taskId);
  4082. #else
  4083. return PxrResult.TIMEOUT_EXPIRED;
  4084. #endif
  4085. }
  4086. public static PxrResult UPxr_ClearPersistedAnchorEntity(ref PxrAnchorEntityClearInfo info, out ulong taskId)
  4087. {
  4088. taskId = ulong.MinValue;
  4089. #if UNITY_ANDROID && !UNITY_EDITOR
  4090. return Pxr_ClearPersistedAnchorEntity(ref info, out taskId);
  4091. #else
  4092. return PxrResult.TIMEOUT_EXPIRED;
  4093. #endif
  4094. }
  4095. public static PxrResult UPxr_GetAnchorPose(ulong anchorHandle, PxrTrackingOrigin origin, out PxrPosef pose)
  4096. {
  4097. pose = new PxrPosef();
  4098. #if UNITY_ANDROID && !UNITY_EDITOR
  4099. return Pxr_GetAnchorPose(anchorHandle,origin, out pose);
  4100. #else
  4101. return PxrResult.TIMEOUT_EXPIRED;
  4102. #endif
  4103. }
  4104. public static PxrResult UPxr_GetAnchorEntityUuid(ulong anchorHandle, out PxrUuid uuid)
  4105. {
  4106. uuid = new PxrUuid();
  4107. #if UNITY_ANDROID && !UNITY_EDITOR
  4108. return Pxr_GetAnchorEntityUuid(anchorHandle, out uuid);
  4109. #else
  4110. return PxrResult.TIMEOUT_EXPIRED;
  4111. #endif
  4112. }
  4113. public static PxrResult UPxr_GetAnchorComponentFlags(ulong anchorHandle, out ulong flag)
  4114. {
  4115. flag = UInt64.MinValue;
  4116. #if UNITY_ANDROID && !UNITY_EDITOR
  4117. return Pxr_GetAnchorComponentFlags(anchorHandle, out flag);
  4118. #else
  4119. return PxrResult.TIMEOUT_EXPIRED;
  4120. #endif
  4121. }
  4122. public static PxrResult UPxr_LoadAnchorEntity(ref PxrAnchorEntityLoadInfo info, out ulong taskId)
  4123. {
  4124. taskId = ulong.MinValue;
  4125. #if UNITY_ANDROID && !UNITY_EDITOR
  4126. return Pxr_LoadAnchorEntity(ref info, out taskId);
  4127. #else
  4128. return PxrResult.TIMEOUT_EXPIRED;
  4129. #endif
  4130. }
  4131. public static PxrResult UPxr_GetAnchorEntityLoadResults(ulong taskId, ref PxrAnchorEntityLoadResults result)
  4132. {
  4133. #if UNITY_ANDROID && !UNITY_EDITOR
  4134. return Pxr_GetAnchorEntityLoadResults(taskId, ref result);
  4135. #else
  4136. return PxrResult.TIMEOUT_EXPIRED;
  4137. #endif
  4138. }
  4139. public static PxrResult UPxr_StartSpatialSceneCapture(out ulong taskId)
  4140. {
  4141. taskId = ulong.MinValue;
  4142. #if UNITY_ANDROID && !UNITY_EDITOR
  4143. return Pxr_StartSpatialSceneCapture(out taskId);
  4144. #else
  4145. return PxrResult.TIMEOUT_EXPIRED;
  4146. #endif
  4147. }
  4148. public static PxrResult UPxr_GetAnchorVolumeInfo(ulong anchorHandle, ref PxrAnchorVolumeInfo info)
  4149. {
  4150. #if UNITY_ANDROID && !UNITY_EDITOR
  4151. return Pxr_GetAnchorBoxInfo(anchorHandle, ref info);
  4152. #else
  4153. return PxrResult.TIMEOUT_EXPIRED;
  4154. #endif
  4155. }
  4156. public static PxrResult UPxr_GetAnchorPlanePolygonInfo(ulong anchorHandle, ref PxrAnchorPlanePolygonInfo info)
  4157. {
  4158. #if UNITY_ANDROID && !UNITY_EDITOR
  4159. return Pxr_GetAnchorPlanePolygonInfo(anchorHandle, ref info);
  4160. #else
  4161. return PxrResult.TIMEOUT_EXPIRED;
  4162. #endif
  4163. }
  4164. public static PxrResult UPxr_GetAnchorPlaneBoundaryInfo(ulong anchorHandle, ref PxrAnchorPlaneBoundaryInfo info)
  4165. {
  4166. #if UNITY_ANDROID && !UNITY_EDITOR
  4167. return Pxr_GetAnchorPlaneBoundaryInfo(anchorHandle, ref info);
  4168. #else
  4169. return PxrResult.TIMEOUT_EXPIRED;
  4170. #endif
  4171. }
  4172. public static PxrResult UPxr_GetAnchorSceneLabel(ulong anchorHandle, out PxrSceneLabel label)
  4173. {
  4174. label = PxrSceneLabel.UnKnown;
  4175. #if UNITY_ANDROID && !UNITY_EDITOR
  4176. return Pxr_GetAnchorSceneLabel(anchorHandle, out label);
  4177. #else
  4178. return PxrResult.TIMEOUT_EXPIRED;
  4179. #endif
  4180. }
  4181. #region Deprecate
  4182. public static int UPxr_StartHumanOcclusion()
  4183. {
  4184. #if UNITY_ANDROID && !UNITY_EDITOR
  4185. return Pxr_StartHumanOcclusion();
  4186. #else
  4187. return -1;
  4188. #endif
  4189. }
  4190. public static int UPxr_AcquireMeshingInfo(IntPtr maskBuffer, IntPtr verticesBuffer, out uint verticesSize, IntPtr facetsBuffer, out uint facetSize, out bool haveRead)
  4191. {
  4192. #if UNITY_ANDROID && !UNITY_EDITOR
  4193. return Pxr_AcquireMeshingInfo(maskBuffer,verticesBuffer, out verticesSize, facetsBuffer, out facetSize, out haveRead);
  4194. #else
  4195. verticesSize = 0;
  4196. facetSize = 0;
  4197. haveRead = false;
  4198. return -1;
  4199. #endif
  4200. }
  4201. public static int UPxr_StopHumanOcclusion()
  4202. {
  4203. #if UNITY_ANDROID && !UNITY_EDITOR
  4204. return Pxr_StopHumanOcclusion();
  4205. #else
  4206. return -1;
  4207. #endif
  4208. }
  4209. public static int UPxr_CreateSpatialAnchor(ref PxrSpatialAnchorCreateInfo info, ref UInt64 handle)
  4210. {
  4211. #if UNITY_ANDROID && !UNITY_EDITOR
  4212. return Pxr_CreateSpatialAnchor(ref info,ref handle);
  4213. #else
  4214. return -1;
  4215. #endif
  4216. }
  4217. public static int UPxr_DestroySpatialAnchor(UInt64 handle)
  4218. {
  4219. #if UNITY_ANDROID && !UNITY_EDITOR
  4220. return Pxr_DestroySpatialAnchor(handle);
  4221. #else
  4222. return -1;
  4223. #endif
  4224. }
  4225. public static int UPxr_SaveSpatialAnchor(ref PxrSpatialAnchorSaveInfo info, ref UInt64 requestId)
  4226. {
  4227. #if UNITY_ANDROID && !UNITY_EDITOR
  4228. return Pxr_SaveSpatialAnchor(ref info,ref requestId);
  4229. #else
  4230. return -1;
  4231. #endif
  4232. }
  4233. public static int UPxr_DeleteSpatialAnchor(ref PxrSpatialAnchorDeleteInfo info, ref UInt64 requestId)
  4234. {
  4235. #if UNITY_ANDROID && !UNITY_EDITOR
  4236. return Pxr_DeleteSpatialAnchor(ref info,ref requestId);
  4237. #else
  4238. return -1;
  4239. #endif
  4240. }
  4241. public static int UPxr_LoadSpatialAnchorById(ref PxrSpatialInstanceLoadByIdInfo info, ref UInt64 requestId)
  4242. {
  4243. #if UNITY_ANDROID && !UNITY_EDITOR
  4244. return Pxr_LoadSpatialAnchorById(ref info,ref requestId);
  4245. #else
  4246. return -1;
  4247. #endif
  4248. }
  4249. public static int UPxr_GetSpatialAnchorLoadResults(UInt64 requestId, ref PxrSpatialAnchorLoadResults results)
  4250. {
  4251. #if UNITY_ANDROID && !UNITY_EDITOR
  4252. return Pxr_GetSpatialAnchorLoadResults(requestId,ref results);
  4253. #else
  4254. return -1;
  4255. #endif
  4256. }
  4257. public static int UPxr_GetSpatialAnchorPose(UInt64 handle, double predictDisplayTime, PxrReferenceType type, ref PxrPosef pose)
  4258. {
  4259. #if UNITY_ANDROID && !UNITY_EDITOR
  4260. return Pxr_GetSpatialAnchorPose(handle, predictDisplayTime, type, ref pose);
  4261. #else
  4262. return -1;
  4263. #endif
  4264. }
  4265. public static int UPxr_GetSpatialAnchorUuid(UInt64 handle, ref PxrSpatialInstanceUuid uuid)
  4266. {
  4267. #if UNITY_ANDROID && !UNITY_EDITOR
  4268. return Pxr_GetSpatialAnchorUuid(handle, ref uuid);
  4269. #else
  4270. return -1;
  4271. #endif
  4272. }
  4273. public static int UPxr_CreateRoomSceneData(PxrSpatialInstanceUuid anchorUuid, IntPtr roomSceneData, int dataLen, ref ulong roomSceneDataHandle)
  4274. {
  4275. #if UNITY_ANDROID && !UNITY_EDITOR
  4276. return Pxr_CreateRoomSceneData(anchorUuid, roomSceneData, dataLen, ref roomSceneDataHandle);
  4277. #else
  4278. return -1;
  4279. #endif
  4280. }
  4281. public static int UPxr_DestroyRoomSceneData(ulong roomSceneDataHandle)
  4282. {
  4283. #if UNITY_ANDROID && !UNITY_EDITOR
  4284. return Pxr_DestroyRoomSceneData(roomSceneDataHandle);
  4285. #else
  4286. return -1;
  4287. #endif
  4288. }
  4289. public static int UPxr_SaveRoomSceneData(ref PxrRoomSceneDataSaveInfo saveInfo, ref ulong requestId)
  4290. {
  4291. #if UNITY_ANDROID && !UNITY_EDITOR
  4292. return Pxr_SaveRoomSceneData(ref saveInfo, ref requestId);
  4293. #else
  4294. return -1;
  4295. #endif
  4296. }
  4297. public static int UPxr_DeleteRoomSceneData(ref PxrRoomSceneDataDeleteInfo deleteInfo, ref ulong requestId)
  4298. {
  4299. #if UNITY_ANDROID && !UNITY_EDITOR
  4300. return Pxr_DeleteRoomSceneData(ref deleteInfo, ref requestId);
  4301. #else
  4302. return -1;
  4303. #endif
  4304. }
  4305. public static int UPxr_LoadRoomScene(ref PxrRoomSceneLoadInfo loadInfo, ref ulong requestId)
  4306. {
  4307. #if UNITY_ANDROID && !UNITY_EDITOR
  4308. return Pxr_LoadRoomScene(ref loadInfo, ref requestId);
  4309. #else
  4310. return -1;
  4311. #endif
  4312. }
  4313. public static int UPxr_GetRoomSceneLoadResults(ulong requestId, ref PxrRoomSceneLoadResults results)
  4314. {
  4315. #if UNITY_ANDROID && !UNITY_EDITOR
  4316. return Pxr_GetRoomSceneLoadResults(requestId, ref results);
  4317. #else
  4318. return -1;
  4319. #endif
  4320. }
  4321. public static int UPxr_StartRoomCapture()
  4322. {
  4323. #if UNITY_ANDROID && !UNITY_EDITOR
  4324. return Pxr_StartRoomCapture();
  4325. #else
  4326. return -1;
  4327. #endif
  4328. }
  4329. #endregion
  4330. private const int MAX_EVENT = 20;
  4331. private static IntPtr[] eventArrayHandle = new IntPtr[MAX_EVENT];
  4332. public static bool UPxr_PollEventQueue(ref List<PxrEventDataBuffer> bufferList)
  4333. {
  4334. bool ret = false;
  4335. #if UNITY_ANDROID && !UNITY_EDITOR
  4336. int eventNum = 0;
  4337. ret = Pxr_PollEventFromXRPlugin(ref eventNum, eventArrayHandle);
  4338. if (ret)
  4339. {
  4340. for (int i = 0; i < eventNum; i++)
  4341. {
  4342. PxrEventDataBuffer buffer = (PxrEventDataBuffer)Marshal.PtrToStructure(eventArrayHandle[i], typeof(PxrEventDataBuffer));
  4343. bufferList.Add(buffer);
  4344. }
  4345. }
  4346. #endif
  4347. return ret;
  4348. }
  4349. }
  4350. }
  4351. }
粤ICP备19079148号