Exemplo n.º 1
0
        //!
        //! Use this for initialization
        //!
        void Start()
        {
            activeMode = Mode.idle;

            //find & attach cached GameObjects
            ui    = GameObject.Find("UI").GetComponent <UI>();
            scene = GameObject.Find("Scene");

            translateModifier   = GameObject.Find("TranslateModifier");
            rotationModifier    = GameObject.Find("RotationModifier");
            scaleModifier       = GameObject.Find("ScaleModifier");
            pointToMoveModifier = GameObject.Find("PointToMoveModifier");


            planeCollider    = GameObject.Find("TranslationQuad").GetComponent <Collider>();
            rotationCollider = GameObject.Find("RotationSphere").GetComponent <Collider>();
            helperCollider   = planeCollider;

            //cache reference to keyframe Sphere container
            frameSphereContainer = GameObject.Find("FrameSphereContainer");

            undoRedoController  = GameObject.Find("UndoRedoController").GetComponent <UndoRedoController>();
            animationController = GameObject.Find("AnimationController").GetComponent <AnimationController>();

            camObject = GameObject.Find("camera");

            cameraRig = Camera.main.transform.parent;
            print("Camera Rig is: " + cameraRig);

            currentSelection = null;


            // Set ambient light
            setAmbientIntensity(VPETSettings.Instance.ambientLight);


            // Splash Widget
            // Here all starts
            SplashWidget splashWidget = ui.drawSplashWidget();

            splashWidget.OnFinishEvent.AddListener(this.splashFinished);


            // HACK store command buffers
            // to restore them when disabling AR mode on Tango
            //bufBeforeForwardOpaque = Camera.main.GetCommandBuffers(CameraEvent.BeforeForwardOpaque);
            //bufBeforeGBuffer = Camera.main.GetCommandBuffers(CameraEvent.BeforeGBuffer);
        }
Exemplo n.º 2
0
 //!
 //! Use this for initialization
 //!
 void Start()
 {
     groundPlane        = GameObject.Find("GroundPlane").GetComponent <Collider>();
     undoRedoController = GameObject.Find("UndoRedoController").GetComponent <UndoRedoController> ();
 }
Exemplo n.º 3
0
        //!
        //! Use this for initialization
        //!
        void Start()
        {
            if (transform.childCount > 0)
            {
                lightTarget = transform.GetChild(0);
                if (lightTarget != null)
                {
                    sourceLight = lightTarget.GetComponent <Light>();
                }
            }

            // if (this.transform.parent.transform.GetComponent<Light>())

            if (sourceLight)
            {
                // target = this.transform.parent;
                target = this.transform;

                initialLightColor     = sourceLight.color;
                initialLightColor.a   = 0.25f;
                initialLightIntensity = sourceLight.intensity;

                if (sourceLight.type == LightType.Directional)
                {
                    isDirectionalLight = true;
                    lightGeo           = lightTarget.FindChild("Arrow");
                }
                else if (sourceLight.type == LightType.Spot)
                {
                    isSpotLight       = true;
                    initialLightRange = sourceLight.range;
                    initialSpotAngle  = sourceLight.spotAngle;
                    lightGeo          = lightTarget.FindChild("Cone");
                }
                else if (sourceLight.type == LightType.Point)
                {
                    isPointLight      = true;
                    initialLightRange = sourceLight.range;
                    lightGeo          = lightTarget.FindChild("Sphere");
                }
            }
            else
            {
                target = this.transform;
            }

            //initalize cached references
            animationController = GameObject.Find("AnimationController").GetComponent <AnimationController>();
            mainController      = GameObject.Find("MainController").GetComponent <MainController>();
            serverAdapter       = GameObject.Find("ServerAdapter").GetComponent <ServerAdapter>();
            undoRedoController  = GameObject.Find("UndoRedoController").GetComponent <UndoRedoController> ();

            //cache Reference to animation data
            animData = AnimationData.Data;

            //update initial parameters
            initialPosition = target.position;
            initialRotation = target.rotation;
            initialScale    = target.localScale;

            lastPosition = initialPosition;
            lastRotation = initialRotation;


            //generate colliding volumes
            if (generateBoxCollider)
            {
                //calculate bounds
                //target.position = new Vector3(-3000,-3000,-3000);
                //target.localScale = new Vector3(1, 1, 1);
                bounds = new Bounds(Vector3.zero, Vector3.zero);
                //set rotation to 0
                // this.transform.rotation = Quaternion.Euler(Vector3.zero);


                bool       hasBounds = false;
                Renderer[] renderers = this.gameObject.GetComponentsInChildren <Renderer>();
                foreach (Renderer render in renderers)
                {
                    if (hasBounds)
                    {
                        bounds.Encapsulate(render.bounds);
                    }
                    else
                    {
                        bounds    = render.bounds;
                        hasBounds = true;
                    }
                }

                BoxCollider col = this.gameObject.AddComponent <BoxCollider>();

                if (sourceLight)
                {
                    // BoxCollider col_lightquad = lightTarget.FindChild("LightQuad").GetComponent<BoxCollider>();
                    // col.size = col_lightquad.size;
                    // col.center = col_lightquad.center;
                    LightIcon iconScript = lightTarget.FindChild("LightQuad").GetComponent <LightIcon>();
                    iconScript.TargetCollider = col;

                    iconScript.TargetScale = target.localScale;
                }
                else
                {
                    col.center              = new Vector3((bounds.center.x - this.transform.position.x) / this.transform.lossyScale.x, (bounds.center.y - this.transform.position.y) / this.transform.lossyScale.y, (bounds.center.z - this.transform.position.z) / this.transform.lossyScale.z);
                    col.size                = new Vector3(bounds.size.x / this.transform.lossyScale.x, bounds.size.y / this.transform.lossyScale.y, bounds.size.z / this.transform.lossyScale.z);
                    col.material            = new PhysicMaterial();
                    col.material.bounciness = 1.0f;
                }

                //target.position = initialPosition;
                // target.localScale = initialScale;
                // target.rotation = initialRotation;
            }
            if (!isDirectionalLight && !isPointLight && !isSpotLight && this.name != "camera")
            {
                this.gameObject.AddComponent <Rigidbody>();
                this.gameObject.GetComponent <Rigidbody>().mass = 100.0f;
                this.gameObject.GetComponent <Rigidbody>().drag = 2.5f;



                // this.gameObject.GetComponent<Rigidbody>().useGravity = false;
            }

            //Initalize animation loading if animation available
            AnimationSerializer asScript = target.gameObject.AddComponent <AnimationSerializer>();

            if (asScript.loadData())
            {
                //register the object in the animation Controller
                GameObject.Find("AnimationController").GetComponent <AnimationController>().registerAnimatedObject(gameObject.GetComponent <SceneObject>());
                gameObject.GetComponent <SceneObject>().setKinematic(true, false);
                updateAnimationCurves();
            }
        }