Esempio n. 1
0
        public virtual void Start()
        {
            Manager._structureManager = this;
            if (this.MainCamera != null)
            {
                Manager._MainCamera = this.MainCamera;
            }

            //check if we need to make a GameLog.
            if (this.ShowDebugLog && this.GetComponent<GameLog>() == null)
            {
                this.gameObject.AddComponent<GameLog>();
                GameLog.ShowGameLog = this.ShowDebugLog;
            }

            //tell the game to run at 30 fps rather than at max.
            //otherwise the game might be running faster
            //than the camera.
            Application.targetFrameRate = 30;

            //check Main Camera for StructurePOV
            if (!FreezePOV)
            {
                POV sPOV = this.MainCamera.GetComponent<POV>();
                if (sPOV == null)
                {
                    //assign one if it doesn't already have one.
                    this.structurePOV = this.MainCamera.gameObject.AddComponent<POV>();
                } else
                {
                    //get a reference to the component if it does have one.
                    this.structurePOV = sPOV;
                }
            }

            //initialize this game manager to recieve events
            //from the plug-in. Anything else you want to have listen to
            //the plugin can be done through here.
            StructureARPlugin.StructureEvent += this.HandleStructureEvent;

			StructureARPlugin.setCallbacks();

            //object loader to build the mesh in the game world.
            this.structureObjectLoader = new ObjectLoader();
            
            GameLog.Log(this.ToString() + this.structureObjectLoader);
            
            
            //provide the scanned mesh a place to live in the game world.
            this.scanObject = new GameObject("ScanObject");
			this.scanObject.AddComponent<DontDestroy>();
            Manager._ScanObject = this.scanObject;
            Wireframe wf = this.scanObject.AddComponent<Wireframe>();
            wf.lineColor = this.ScanMeshWireColor;

            GameLog.Log(this.ToString() + this.scanObject);

            //setup the POV camera in game to match the projection
            //of the rear camera of the device
            StructureARPlugin.initStructureAR(this.MainCamera.projectionMatrix);
                        
            //Make color camera back plane
            this.MainCamera.clearFlags = CameraClearFlags.Depth;
            this.cameraView = new CameraViewScript(this.MainCamera, 1f);
            this.cameraView.CameraObject.transform.parent = this.MainCamera.transform;

            //should also set the camera FOV to 45
            this.MainCamera.fieldOfView = 45.0f;

            //do minor setup here, hide things, change UI etc.
            if (this.gameState == SensorState.CameraAccessRequired)
            {
                return;
            }

            // We need to update our status based on whether or not
            // the sensor is connected since we don't want to scan
            // without the sensor attached.
            if (StructureARPlugin.isStructureConnected())
            {
                this.gameState = SensorState.DeviceReady;
            } else
            {
                this.gameState = SensorState.DeviceNotReady;
            }

            //tracking is always false in DeviceReady and DeviceNotReady states
            this.trackingIsGood = false;
        }
Esempio n. 2
0
        public virtual void Start()
        {
            Manager._structureManager = this;
            if (this.MainCamera != null)
            {
                Manager._MainCamera = this.MainCamera;
            }

            //check if we need to make a GameLog.
            if (this.ShowDebugLog && this.GetComponent <GameLog>() == null)
            {
                this.gameObject.AddComponent <GameLog>();
                GameLog.ShowGameLog = this.ShowDebugLog;
            }

            //tell the game to run at 30 fps rather than at max.
            //otherwise the game might be running faster
            //than the camera.
            Application.targetFrameRate = 30;

            //check Main Camera for StructurePOV
            if (!FreezePOV)
            {
                POV sPOV = this.MainCamera.GetComponent <POV>();
                if (sPOV == null)
                {
                    //assign one if it doesn't already have one.
                    this.structurePOV = this.MainCamera.gameObject.AddComponent <POV>();
                }
                else
                {
                    //get a reference to the component if it does have one.
                    this.structurePOV = sPOV;
                }
            }

            //initialize this game manager to recieve events
            //from the plug-in. Anything else you want to have listen to
            //the plugin can be done through here.
            StructureARPlugin.StructureEvent += this.HandleStructureEvent;

            StructureARPlugin.setCallbacks();

            //object loader to build the mesh in the game world.
            this.structureObjectLoader = new ObjectLoader();

            GameLog.Log(this.ToString() + this.structureObjectLoader);


            //provide the scanned mesh a place to live in the game world.
            this.scanObject     = new GameObject("ScanObject");
            Manager._ScanObject = this.scanObject;
            Wireframe wf = this.scanObject.AddComponent <Wireframe>();

            wf.lineColor = this.ScanMeshWireColor;

            GameLog.Log(this.ToString() + this.scanObject);

            //Make color camera back plane
            this.MainCamera.clearFlags = CameraClearFlags.Depth;
            this.cameraView            = new CameraViewScript(this.MainCamera, 1f);
            this.cameraView.CameraObject.transform.parent = this.MainCamera.transform;

            //should also set the camera FOV to 45
            this.MainCamera.fieldOfView = 45.0f;

            //setup the POV camera in game to match the projection
            //of the rear camera of the device
            StructureARPlugin.initStructureAR(this.MainCamera.projectionMatrix);

            //do minor setup here, hide things, change UI etc.
            if (this.gameState == SensorState.CameraAccessRequired)
            {
                return;
            }

            // We need to update our status based on whether or not
            // the sensor is connected since we don't want to scan
            // without the sensor attached.
            if (StructureARPlugin.isStructureConnected())
            {
                this.gameState = SensorState.DeviceReady;
            }
            else
            {
                this.gameState = SensorState.DeviceNotReady;
            }

            //tracking is always false in DeviceReady and DeviceNotReady states
            this.trackingIsGood = false;
        }