/** * Start function used to initialize variables. Sets up the textures * to be used, identifies the memory to be passed to the plugin, and * sets specific properties of the transaction. */ void Start() { try { usingTwoCams = false; if (usingTwoCams) { capture_resolution_left = start_capture_left(0); capture_resolution_right = start_capture_right(1); } else { capture_resolution_left = start_capture(0); capture_resolution_right.width = capture_resolution_left.width; capture_resolution_right.height = capture_resolution_left.height; } // initialize fingertips left_fingertips = new Coordinate[5]; right_fingertips = new Coordinate[5]; tmpleft_fingertips = new Coordinate[5]; tmpright_fingertips = new Coordinate[5]; for (int i = 0; i < 5; i++) { left_fingertips[i].x = 0; left_fingertips[i].y = 0; left_fingertips[i].z = 0; right_fingertips[i].x = 0; right_fingertips[i].x = 0; right_fingertips[i].x = 0; tmpleft_fingertips[i].x = 0; tmpleft_fingertips[i].y = 0; tmpleft_fingertips[i].z = 0; tmpright_fingertips[i].x = 0; tmpright_fingertips[i].x = 0; tmpright_fingertips[i].x = 0; } // Make both textures m_Texture_Left = new Texture2D(640, 480, TextureFormat.ARGB32, false); m_Texture_Right = new Texture2D(640, 480, TextureFormat.ARGB32, false); // create the arrays for the pixels data pixel_data_Left = m_Texture_Left.GetPixels32(0); pixel_data_Right = m_Texture_Right.GetPixels32(0); // Allocates memory in the GPU for the pixel data to write to m_pixelsHandle_Left = GCHandle.Alloc(pixel_data_Left, GCHandleType.Pinned); m_pixelsHandle_Right = GCHandle.Alloc(pixel_data_Right, GCHandleType.Pinned); // Give the address in memory to the IntPtr ptrLeft = m_pixelsHandle_Left.AddrOfPinnedObject(); ptrRight = m_pixelsHandle_Right.AddrOfPinnedObject(); left_plane = GameObject.Find("LeftPlane"); right_plane = GameObject.Find("RightPlane"); // default properties prop_left = new Properties(); prop_left.seg_method = 2; prop_left.track_method = 1; prop_right = new Properties(); prop_right.seg_method = 2; prop_right.track_method = 1; // default plane layout plane_layout = new Plane_Orientaion(); plane_layout.left_plane = 1; plane_layout.right_plane = 1; if (left_plane.renderer) { left_plane.renderer.material.mainTexture = m_Texture_Left; } else { UnityEngine.Debug.Log("Left Plane renderer not ready.."); } if (right_plane.renderer) { right_plane.renderer.material.mainTexture = m_Texture_Right; } else { UnityEngine.Debug.Log("Right Plane renderer not ready.."); } } catch (Exception e) { UnityEngine.Debug.Log("Error in start function (data transfer): " + e.ToString()); } }
/** * Start function used to initialize variables. Sets up the textures * to be used, identifies the memory to be passed to the plugin, and * sets specific properties of the transaction. */ void Start() { try { usingTwoCams = false; if (usingTwoCams) { capture_resolution_left = start_capture_left(0); capture_resolution_right = start_capture_right(1); } else { capture_resolution_left = start_capture(0); capture_resolution_right.width = capture_resolution_left.width; capture_resolution_right.height = capture_resolution_left.height; } // initialize fingertips left_fingertips = new Coordinate[5]; right_fingertips = new Coordinate[5]; tmpleft_fingertips = new Coordinate[5]; tmpright_fingertips = new Coordinate[5]; for(int i=0; i<5; i++) { left_fingertips[i].x = 0; left_fingertips[i].y = 0; left_fingertips[i].z = 0; right_fingertips[i].x = 0; right_fingertips[i].x = 0; right_fingertips[i].x = 0; tmpleft_fingertips[i].x = 0; tmpleft_fingertips[i].y = 0; tmpleft_fingertips[i].z = 0; tmpright_fingertips[i].x = 0; tmpright_fingertips[i].x = 0; tmpright_fingertips[i].x = 0; } // Make both textures m_Texture_Left = new Texture2D (640, 480, TextureFormat.ARGB32, false); m_Texture_Right = new Texture2D (640, 480, TextureFormat.ARGB32, false); // create the arrays for the pixels data pixel_data_Left = m_Texture_Left.GetPixels32(0); pixel_data_Right = m_Texture_Right.GetPixels32(0); // Allocates memory in the GPU for the pixel data to write to m_pixelsHandle_Left = GCHandle.Alloc(pixel_data_Left, GCHandleType.Pinned); m_pixelsHandle_Right = GCHandle.Alloc(pixel_data_Right, GCHandleType.Pinned); // Give the address in memory to the IntPtr ptrLeft = m_pixelsHandle_Left.AddrOfPinnedObject(); ptrRight = m_pixelsHandle_Right.AddrOfPinnedObject(); left_plane = GameObject.Find("LeftPlane"); right_plane = GameObject.Find("RightPlane"); // default properties prop_left = new Properties(); prop_left.seg_method = 2; prop_left.track_method = 1; prop_right = new Properties(); prop_right.seg_method = 2; prop_right.track_method = 1; // default plane layout plane_layout = new Plane_Orientaion(); plane_layout.left_plane = 1; plane_layout.right_plane = 1; if (left_plane.renderer) { left_plane.renderer.material.mainTexture = m_Texture_Left; } else { UnityEngine.Debug.Log ("Left Plane renderer not ready.."); } if (right_plane.renderer) { right_plane.renderer.material.mainTexture = m_Texture_Right; } else { UnityEngine.Debug.Log ("Right Plane renderer not ready.."); } } catch (Exception e) { UnityEngine.Debug.Log("Error in start function (data transfer): " + e.ToString()); } }