private void CreateSmootherType(SmoothingTypes type, float factor, out PXCMDataSmoothing.Smoother3D smoother) { switch (type) { case SmoothingTypes.Quadratic: smoother = _dataSmoothing.Create3DQuadratic(factor); break; case SmoothingTypes.Stabilizer: smoother = _dataSmoothing.Create3DStabilizer(7, factor); break; case SmoothingTypes.Weighted: smoother = _dataSmoothing.Create3DWeighted((int)factor); break; case SmoothingTypes.Spring: default: smoother = _dataSmoothing.Create3DSpring(factor); break; } }
void InitObject(){ gesture = new Gesture[MaxHands]; for (int i = 0; i < MaxHands; i++) { smoother3D [i] = new PXCMDataSmoothing.Smoother3D[MaxJoints]; gesture[i] = new Gesture(); } for (int i = 0; i < MaxHands; i++) for (int j = 0; j < MaxJoints; j++) { smoother3D [i] [j] = dataSmoothing.Create3DWeighted (weightsNum); } }
// Use this for initialization void Start () { sm = PXCMSenseManager.CreateInstance (); if (sm == null) Debug.LogError ("SenseManager Initialization Failed"); sm.QuerySession ().CreateImpl<PXCMDataSmoothing> (out ds); joints = new JointData[4]; smoother3D = new PXCMDataSmoothing.Smoother3D[4]; LineRenderGameObject = GameObject.Find ("line2"); lineRenderer = (LineRenderer)LineRenderGameObject.GetComponent ("LineRenderer"); lineRenderer.SetVertexCount(lineLength); for (int i=0; i<=3; i++) { joints [i] = new JointData (); smoother3D [i] = ds.Create3DWeighted (10); } smoother4D = ds.Create3DWeighted (10); var senseManager = GameObject.FindObjectOfType(typeof(SenseToolkitManager)); if (senseManager == null) { Debug.LogWarning("Sense Manager Object not found and was added automatically"); senseManager = (GameObject)Instantiate(Resources.Load("SenseManager")); senseManager.name = "SenseManager"; } SetSenseOptions(); }
//Populate bones and joints gameobjects void InitializeGameobjects() { myJoints = new GameObject[MaxHands][]; myBones = new GameObject[MaxHands][]; jointData = new PXCMHandData.JointData[MaxHands][]; for (int i = 0; i < MaxHands; i++) { myJoints [i] = new GameObject[MaxJoints]; myBones [i] = new GameObject[MaxJoints]; smoother3D [i] = new PXCMDataSmoothing.Smoother3D[MaxJoints]; jointData [i] = new PXCMHandData.JointData[MaxJoints]; } for (int i = 0; i < MaxHands; i++) for (int j = 0; j < MaxJoints; j++) { smoother3D [i] [j] = ds.Create3DWeighted (weightsNum); jointData [i] [j] = new PXCMHandData.JointData (); if (j == 1) myJoints [i] [j] = (GameObject)Instantiate (PalmCenterPrefab, transform.position, Quaternion.identity); else if (j == 21 || j == 17 || j == 13 || j == 9 || j == 5) myJoints [i] [j] = (GameObject)Instantiate (TipPrefab, transform.position, Quaternion.identity); else myJoints [i] [j] = (GameObject)Instantiate (JointPrefab, transform.position, Quaternion.identity); if (j != 1) myBones [i] [j] = (GameObject)Instantiate (BonePrefab, transform.position, Quaternion.identity); } }