unity3d體感游戲開發(fā)指南_第1頁
unity3d體感游戲開發(fā)指南_第2頁
unity3d體感游戲開發(fā)指南_第3頁
unity3d體感游戲開發(fā)指南_第4頁
unity3d體感游戲開發(fā)指南_第5頁
已閱讀5頁,還剩36頁未讀 繼續(xù)免費閱讀

下載本文檔

版權說明:本文檔由用戶提供并上傳,收益歸屬內容提供方,若內容存在侵權,請進行舉報或認領

文檔簡介

版本/HandIsUseDepth含義IsUseImage用自定義參數強制設置設備輸出分辨率,但是輸入的分辨LabelMapBackRemovalLabelMap的羽化增加對Windows平臺的調序,可以在Windows下的Unity3DSDK進行WindowsAstraPro只支持Astra。SDK添加Windows1.添加Windows下安裝底SDKstaticboolHasOrbbecDevice()接口說明,可判斷是否有Orbbec前 Windows下驅動安裝和Unity編輯器調試搭 插 3.1.場景 3.2.場景 3.3.場景 3.4.場景 API詳 類 類 類 類 常見問 Unity編輯器提示找不到 標定骨架時動作做好了卻依舊無法識 運行過程拔出設備程序卡 Unity3DV4.7.xUnity5.3.632bitWindowsUnityUnityAstraAstraPro進行調試。vcredist_x86Vs2013的運行庫。X646464unity32位的編輯器,只要正32位編輯器就可以正常運行Astra體感游戲1.11.11.1.0更新:紋理更新轉入底層直接更新,少了原來的中間環(huán)節(jié),在彩2.1Plugins文件顯示2.2Orbbec文件顯示圖2.1Plugins顯示 圖2.2Orbbec顯示Windows支持Astra。PluginsScriptsOrbbecCommonunity3d須放置于此)不變其他的東西,我們都挪到Frameworks方面對舊方案完全兼容。OrbbecManager本節(jié)主要對提供實例中不同Scene中的相應功能進行介紹,主要有API3.1.此場景將UserSkeletonPositionMain綁定到MainCamera中并對此腳本中ImageTex(彩,DepthTex(深度圖)的對象進行了賦值。首先,將體感頭擺好正對自己,并能在場景中顯示的深度圖中看到人其次做雙手投降進行標定標定成功出現球人此時可以控制球人彩和深度publicvoid{publicvoid{Instance=OrbbecManagerParamParam=newOrbbecManagerParam();//--1Param.OrbbecInitResourceCallBack+=OnDeviceReady;//--2}Awake1Param,Paramvoid{if(DepthTex!=void{if(DepthTex!={}if(ImageTex!={}IsInit3DCameraRes=}OnDeviceReady1DepthTex,位置2處將獲取彩紋理對象賦值予ImageTex。UserSkeletonPositionMainUpdatevoidvoid{ {Log.Print(Log.Level.Log,Log.Print(Log.Level.Log,"OrbbecManagerDestroyInEscapeStart");Log.Print(Log.Level.Log,"OrbbecManagerDestroyInEscapeDictionary<int,OrbbecUser>UserTable=OrbbecManager.Instance.TrackingUsers;//--2UserTrackercur=UserTracker.Head;Dictionary<int,OrbbecUser>.EnumeratorElem=UserTable.GetEnumerator();while(Elem.MoveNext()){if(cur=={GameObjectobj=newcur}cur.UserID=Elem.Current.Key;//--3cur=}}}TrackingUsers4處指定當前獲取的curUser對象。步驟二:執(zhí)行UserTracker中Awake函數和Update函void{intSkeletonPointNum=SkeletonPoints=newList<GameObject>(SkeletonPointNum);for(inti=0;i<SkeletonPointNum;++i){GameObjectobj=GameObject.CreatePrimitive(PrimitiveType.Sphere);//--2MeshRendererrefMeshRenderer= refMeshRenderer.material.color=Color.red;obj.transform.parent=transform;}}voidUpdate{if(UserID==0||curUser==null)if{UserID=0;curUser=null;}for(inti=0;i<SkeletonPoints.Count;{}}3SkeletonPoints3.2此場景主要對彩像和深度圖像的顯示以及可以根據獲取的骨架點來控,DepthTex(,DressUser(骨架點數組對象,DummyName7)"L_Elbow":左在SkeletonControl場景中人物模型對象Carl,Carl對象綁定了組件DummyName)DummyNameDressUser腳本中的GetChildTranformObj首先,將體感頭擺好正對自己,并能在場景中顯示的深度圖中看到人其次,做雙手投降進行標定,標定成功后可以控制人物模型彩和深度{{Instance=OrbbecManagerParamParam=newOrbbecManagerParam();//--1Param.IsUseCatch=false;Param.OrbbecInitResourceCallBack+=OnDeviceReady;//--2}Awake1Param,Paramvoid{if(DepthTex!={void{if(DepthTex!={}if(ImageTex!={}IsInit3DCameraRes=}OnDeviceReady1DepthTex,位置2處將獲取彩紋理對象賦值予ImageTex。 中的Update函voidvoidUpdate{if{Log.Print(Log.Level.Log,"OrbbecManagerDestroyInEscapeStart");if(OrbbecManager.Instance){}Log.Print(Log.Level.Log,"OrbbecManagerDestroyInEscapeDictionary<int,OrbbecUser>UserTable=OrbbecManager.Instance.TrackingUsers;//--2if(curDressUser){while(curUserEnum.MoveNext()){{OrbbecUsercurUser=curUserEnum.Current.Value;if(curUser==null)curDressUser.curOrbbecUser=curUser;//--3}}}型對象指定被識別到的用戶對象curUser。void{if(OrbbecManager.Instance==null)void{if(OrbbecManager.Instance==null)if(curOrbbecUser==null||curOrbbecUser.UserID==0)UpdateBoneInfo(curOrbbecUser);//--2}在Update函數位置1處,初始化相關的骨架點屬性信息并根據人物模型子節(jié)點模型對象的name獲取指定的骨架點信息(請查看位置1代碼詳解位置2處獲取被用戶骨架點旋轉位置信息賦值于BoneRotation集合對象,位置3處為已經綁定的子節(jié)點模型指定位置坐標信息位置4獲取用戶的 void{ifvoid{if(IsInitSkeletonControl)=TestObjDummyPoint=new outHeadIndex); outNeckIndex); outTorsoIndex); out outLElbowIndex);refJointToIntDict.TryGetValue(SkeletonType.LeftShoulder,outLShoulderIndex); outLHipIndex); outLKneeIndex); outLFootIndex); outRHandIndex); outRElbowIndex); outRShoulderIndex); outRHipIndex); outRKneeIndex); outRFootIndex);IsInitSkeletonControl=}void{for(inti=0;i<refAvailableJoints.Count;{stringcurDummyName=DummyName[(int)Type];if(curDummyName==""){}TestObjDummyPoint[i]=new}TransformrootBone=transform;//--for(inti=0;i<refAvailableJoints.Count;{stringcurDummyName=DummyName[(int)Type];if(curDummyName==""){ObjDummyPoint[i]=null;} if(ObjDummyPoint[i]==null)initialPositions[i]=ObjDummyPoint[i].transform.position;//--4}}53.3此場景主要對彩像和深度圖像的顯示Hand識別和Hand抓握等功此場景將HandsControlMain綁定到MainCamera中,并對此中首先,將體感頭擺好正對自己,并能在場景中顯示的深度圖中看到人hand,hand制的手的光標,hand識別后微微抬起胳膊使手做不停的抓握,抓握識別后彩和深度void{Instance=this;void{Instance=this;//Param.IsUseCatch=false;Param.IsTrackingSkeleton=false;Param.OrbbecInitResourceCallBack+=OnDeviceReady;//--3if(HandTex){}if(EnZhTranBtn!={}if(UsingCatchBtn!={}}化時會調用(安卓會在獲得USB后調用)位置4處OrbbecManager根據Param3voidvoid{if(DepthTex!={}if(ImageTex!={}IsInit3DCameraRes=}位置2處將獲取彩紋理對象賦值予ImageTex。publicvoid{publicvoid{if(curTextManager==null){}intNextIndex=curTextManager.CurLanguageIndex+1;ifintNextIndex=curTextManager.CurLanguageIndex+1;if(NextIndex>=curTextManager.LanguageName.Length)NextIndex=for(inti=0;i<GameText.Length;++i){if(curText==null)}}處設置當前切換的語言下標信息,位置3處設備界面中顯示的文本信publicvoidpublicvoid{}OnOffCatching1步驟一:執(zhí)行 中的Update函void{if{Log.Print(Log.Level.Log,"OrbbecManagerDestroyInEscapeStart");if(OrbbecManager.Instance){}Log.Print(Log.Level.Log,"OrbbecManagerDestroyInEscape//FPSif{FPSText.text="FPS:"+1.0f/Time.deltaTime;//--}if{}if{//Hand的Dictionary<int,OrbbecHand>.EnumeratorHandElem=TrackingHands.GetEnumerator();IsTrackingHands=HandElem.MoveNext();if{OrbbecHandcurHand=Vector3HandPos=HandPos.z=HandPos.x=Screen.width*0.5f-HandPos.y+=Screen.height*}}}handTrackingHands5狀態(tài),位置7處將識別到的hand位置坐標信息賦值于hand的光標對象3.4.場景此場景將BackgroundRemovalMain綁定到MainCameraAPI控制深度圖、彩、骨架、手等模塊的開關//IsUsethehands//是否使用手publicboolIsUseHandsTracker=//IsUsetheUser//是否使用用戶publicboolIsUseUserGenerator=//IsTrackingtheSkeletonofuser,ifthisistrueIsUseUserGeneratorwillbeturned//是否骨架如果此項被開啟用戶將被強制開publicboolIsTrackingSkeleton=//IsUseDepth//publicboolIsUseDepth=//IsUseUserImage//是否更新彩紋publicboolIsUseUserImage=//IsUpdateBackRemovalTexture.PCwilluseanotherwaytoupdate,justfor//PCpublicboolIsUseBackRemoval=//IsUseUserLabel//是否更新用戶圖紋publicboolIsUseUserLabel=//IsUseGrablib,onlyworkon//publicboolIsUseCatch=//////IsExittheapplicationwhenon//////publicbool itOnPause=//////Back///publicboolIitOnBack=//Isapplicationnever//publicboolIsNeverSleep=//Callbackfunction,it'llbecalledwhenthedeviceisalreadytoinitlize.(AfterUSBpermissionispermittedinandroid)//回調函數,在設備準備初始化時會調用(安卓會在獲得USB后調用publicOnOrbbecInitCallBackFunc//CustomResolution,thismaymakesomethingrunnotnormal,justlike////640x480//320x240160x120publicboolIsCustomResolution=false;//自定義分辨率結構只有自定義分辨率選項為truepublicCustomResolutionCurResolution=new//Handpositionwillbecreatedbythis//Nowitcanbe//手點將使用此來創(chuàng)建其值可以是"RaiseHand"--抬手,"Wave"--揮(左右////publicstring[]HandGesture=//Handpositionmaxnumber.defaultisone,thisversionstillhavesomenotfixedbugformorethanonehand.//手點數量,默認為一個手點,此版本對多手處理依舊存在一些尚未解決的問publicintMaxHandNum=//////Callbackfunction,it'llbecalledwhenyoutrytoexit//////publicOnOrbbecExitApp此類為深度圖,彩,hand識別,用戶骨架信息識別業(yè)務控類//TheSkeletonoftheuserhavetheconfidencepointlessthanthisnumberwillstop//用戶骨架當其可信點低于以下個數將會停止用戶這個值可在初始//publicstaticintLostUserConfidenceNum=//Isupdatetheuserskeletonscreenpositionper//publicstaticboolIsUpdateUserScreenPos=//Themaxtrackinguser//最大的用戶數量這個值可在初始化結束后根據需求實時修publicintMaxTrackingUserNum=//Currenttrackinguser//當前的用戶數publicintCurTrackingUserNum=//Thetableoftracking//用戶的列 //Hand的列 //骨架枚舉類型在不同底層庫支持可到的骨架點的個數會有所不//15publicenum{ = =頭 = =胸 = = = =左 = = =// =// =// =//右 =// =// =// =// =//Lef =// =// =// =// = //右腳踝暫未支 //}publicenum{UnCatch0,//未識別抓握狀態(tài)Catching=2,//識別抓握狀態(tài)Release=3,//釋放抓握}voidCreateOrbbecManager(OrbbecManagerParam2.2CatchStateGetHandCatchState(intHnadIDHandShort[]voidGetDepthSize(outintXSize,outintYSize,outint獲取深度圖尺寸,Z將真實世界坐標轉換成屏幕(投影)/LabelMapXYZ值依舊為轉換前的實際物理距離單位毫米將屏幕(投影)獲取用戶信息紋理對象Short[]GetUserLabel獲取用戶信息內存結返回值:UserLabelshort獲取彩紋理對象Texture2DGetBackRemovalMap 來,否則生成只摳容器中的ID對應的人,此列表可在主線隨時根據需要進行更新,比如一個雙人游戲僅僅將兩個骨骼的人摳出來。HandIDhand返回值:HandIDHandIDhand返回值:HandIDboolIsTrackingHand(int判斷HandID是否已經被識返回值:true已識 false未識void對識別到的hand信息進行實時登記,以及對丟失的Hand信息進行移 (intboolIsRisingHands(int根據到的用戶UserID,判斷其是否進行了舉手標定返回值:tr

溫馨提示

  • 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
  • 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯系上傳者。文件的所有權益歸上傳用戶所有。
  • 3. 本站RAR壓縮包中若帶圖紙,網頁內容里面會有圖紙預覽,若沒有圖紙預覽就沒有圖紙。
  • 4. 未經權益所有人同意不得將文件中的內容挪作商業(yè)或盈利用途。
  • 5. 人人文庫網僅提供信息存儲空間,僅對用戶上傳內容的表現方式做保護處理,對用戶上傳分享的文檔內容本身不做任何修改或編輯,并不能對任何下載內容負責。
  • 6. 下載文件中如有侵權或不適當內容,請與我們聯系,我們立即糾正。
  • 7. 本站不保證下載資源的準確性、安全性和完整性, 同時也不承擔用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。

評論

0/150

提交評論