// Initialization void Start() { //AA: Filter visalization related initializations filter = new Filter(); fv = new FilterVisualization(); fm = new FilterManager(); fv.filterOutputLocX = Screen.width / 3 - 50; fv.Initialise(); fv.DrawCircle(); m_colorTextureDictionary = new Dictionary <string, Texture2D>(); foreach (Texture2D tex in m_colorTextures) { m_colorTextureDictionary.Add(tex.name, tex); } LoadFilters(); // First set instance so Fubi.release will not be called while destroying old objects instance = this; // Remain this instance active until new one is created DontDestroyOnLoad(this); // Destroy old instance of Fubi object[] objects = GameObject.FindObjectsOfType(typeof(FubiUnity)); if (objects.Length > 1) { Destroy(((FubiUnity)objects[0])); } m_lastMouseClick = 0; m_lastGesture = 0; // Init FUBI if (!m_disableFubi) { // Only init if not already done if (!Fubi.isInitialized()) { Fubi.init(new FubiUtils.SensorOptions(new FubiUtils.StreamOptions(640, 480, 30), new FubiUtils.StreamOptions(640, 480, 30), new FubiUtils.StreamOptions(-1, -1, -1), FubiUtils.SensorType.OPENNI2), new FubiUtils.FilterOptions()); if (!Fubi.isInitialized()) { Debug.Log("Fubi: FAILED to initialize Fubi!"); } else { Debug.Log("Fubi: initialized!"); } } } else { m_disableTrackingImage = true; } // Initialize debug image // m_depthMapTexture = new Texture2D((int)(m_xRes / m_factor), (int)(m_yRes / m_factor), TextureFormat.RGBA32, false); // m_depthMapPixels = new Color[(int)((m_xRes / m_factor) * (m_yRes / m_factor))]; // m_rawImage = new byte[(int)(m_xRes * m_yRes * 4)]; m_userImageTexture = null; // Disable system cursor if (m_defaultCursor != null && m_disableFubi == false) { Screen.showCursor = false; } else { Screen.showCursor = true; } // Default mapping values m_mapping.x = -100.0f; m_mapping.y = 200.0f; m_mapping.height = 550.0f; // Get screen aspect m_aspect = (float)Screen.width / (float)Screen.height; // Calculated Map width with aspect m_mapping.width = m_mapping.height / m_aspect; if (Fubi.isInitialized()) { // Clear old gesture recognizers Fubi.clearUserDefinedRecognizers(); // And (re)load them if (Fubi.loadRecognizersFromXML("UnitySampleRecognizers.xml")) { Debug.Log("Fubi: gesture recognizers 'BarRecognizers.xml' loaded!"); } else { Debug.Log("Fubi: loading XML recognizers failed!"); } // load mouse control recognizers if (Fubi.loadRecognizersFromXML("MouseControlRecognizers.xml")) { Debug.Log("Fubi: mouse control recognizers loaded!"); } else { Debug.Log("Fubi: loading mouse control recognizers failed!"); } } }
//AA: Resizes the writeable area when screen is resized void WriteableAreaResize() { fv.filterOutputLocX = Screen.width / 3 - 50; fv.Initialise(); }