// Use this for initialization
        public void Start()
        {
            fCursorSpeedNormalization = 1.0f;
            fCurPlaneX      = 0;
            fCurPlaneY      = 0;
            vPlaneCursorPos = Vector3.zero;
            vSceneCursorPos = vPlaneCursorPos;

            CursorDefaultMaterial = MaterialUtil.CreateTransparentMaterial(Color.grey, 0.6f);
            //CursorHitMaterial = MaterialUtil.CreateTransparentMaterial (Color.yellow, 0.8f);
            CursorHitMaterial       = MaterialUtil.CreateStandardMaterial(Color.yellow);
            CursorCapturingMaterial = MaterialUtil.CreateTransparentMaterial(Color.yellow, 0.75f);

            CursorVisualAngleInDegrees = 1.5f;

            standardCursorMesh = MeshGenerators.Create3DArrow(1.0f, 1.0f, 1.0f, 0.5f, 16);
            UnityUtil.TranslateMesh(standardCursorMesh, 0, -2.0f, 0);
            activeToolCursorMesh = MeshGenerators.Create3DArrow(1.0f, 1.0f, 1.0f, 1.0f, 16);
            UnityUtil.TranslateMesh(activeToolCursorMesh, 0, -2.0f, 0);

            Cursor = UnityUtil.CreateMeshGO("cursor", standardCursorMesh, CursorDefaultMaterial);
            Cursor.SetSharedMesh(standardCursorMesh);
            Cursor.transform.localScale    = new Vector3(0.3f, 0.3f, 0.3f);
            Cursor.transform.localRotation = Quaternion.AngleAxis(45.0f, new Vector3(1, 0, 1).normalized);
            MaterialUtil.DisableShadows(Cursor);

            xformObject = GameObject.CreatePrimitive(PrimitiveType.Plane);
            xformObject.SetName("cursor_plane");
            MaterialUtil.DisableShadows(xformObject);
            xformObject.GetComponent <MeshRenderer>().material
                = MaterialUtil.CreateTransparentMaterial(Color.cyan, 0.2f);
            xformObject.GetComponent <MeshRenderer>().enabled = false;

            lastMouseEventTime = FPlatform.RealTime();
            mouseInactiveState = false;
        }
Exemple #2
0
        void InitializeSpatialInput()
        {
            Left  = new SpatialDevice();
            Right = new SpatialDevice();

            Left.CursorDefaultMaterial   = MaterialUtil.CreateTransparentMaterial(ColorUtil.ForestGreen, 0.6f);
            Left.CursorHitMaterial       = MaterialUtil.CreateStandardMaterial(ColorUtil.SelectionGold);
            Left.CursorCapturingMaterial = MaterialUtil.CreateTransparentMaterial(ColorUtil.SelectionGold, 0.75f);
            Left.HandMaterial            = MaterialUtil.CreateTransparentMaterial(ColorUtil.ForestGreen, 0.3f);

            Right.CursorDefaultMaterial   = MaterialUtil.CreateTransparentMaterial(Colorf.DarkRed, 0.6f);
            Right.CursorHitMaterial       = MaterialUtil.CreateStandardMaterial(ColorUtil.PivotYellow);
            Right.CursorCapturingMaterial = MaterialUtil.CreateTransparentMaterial(ColorUtil.PivotYellow, 0.75f);
            Right.HandMaterial            = MaterialUtil.CreateTransparentMaterial(ColorUtil.CgRed, 0.3f);

            CursorVisualAngleInDegrees = 1.5f;

            standardCursorMesh = MeshGenerators.Create3DArrow(1.0f, 1.0f, 1.0f, 0.5f, 16);
            UnityUtil.TranslateMesh(standardCursorMesh, 0, -2.0f, 0);
            activeToolCursorMesh = MeshGenerators.Create3DArrow(1.0f, 1.0f, 1.0f, 1.0f, 16);
            UnityUtil.TranslateMesh(activeToolCursorMesh, 0, -2.0f, 0);

            Left.Cursor = UnityUtil.CreateMeshGO("left_cursor", standardCursorMesh, Left.CursorDefaultMaterial);
            Left.Cursor.transform.localScale    = 0.3f * Vector3.one;
            Left.Cursor.transform.localRotation = Quaternion.AngleAxis(45.0f, new Vector3(1, 0, 1).normalized);
            MaterialUtil.DisableShadows(Left.Cursor);
            Left.Cursor.SetLayer(FPlatform.CursorLayer);
            Left.SmoothedHandFrame = Frame3f.Identity;

            var leftHandMesh = MeshGenerators.Create3DArrow(1.0f, 1.0f, 1.0f, 0.5f, 16);

            Left.Hand = UnityUtil.CreateMeshGO("left_hand", leftHandMesh, Left.HandMaterial);
            UnityUtil.TranslateMesh(leftHandMesh, 0, -1.0f, 0);
            Left.Hand.transform.localScale = 0.1f * Vector3.one;
            Left.Hand.transform.rotation   = Quaternion.FromToRotation(Vector3.up, Vector3.forward);
            Left.Hand.SetLayer(FPlatform.HUDLayer);

            Left.Laser    = new GameObject("left_laser");
            Left.LaserRen = Left.Laser.AddComponent <LineRenderer>();
            Left.LaserRen.SetPositions(new Vector3[2] {
                Vector3.zero, 100 * Vector3.up
            });
            Left.LaserRen.startWidth = Left.LaserRen.endWidth = 0.01f;
            Left.LaserRen.material   = MaterialUtil.CreateFlatMaterial(ColorUtil.ForestGreen, 0.2f);
            Left.Laser.SetLayer(FPlatform.CursorLayer);
            Left.Laser.transform.parent = Left.Cursor.transform;

            Right.Cursor = UnityUtil.CreateMeshGO("right_cursor", standardCursorMesh, Right.CursorDefaultMaterial);
            Right.Cursor.transform.localScale    = 0.3f * Vector3.one;
            Right.Cursor.transform.localRotation = Quaternion.AngleAxis(45.0f, new Vector3(1, 0, 1).normalized);
            MaterialUtil.DisableShadows(Right.Cursor);
            Right.Cursor.SetLayer(FPlatform.CursorLayer);
            Right.SmoothedHandFrame = Frame3f.Identity;

            var rightHandMesh = MeshGenerators.Create3DArrow(1.0f, 1.0f, 1.0f, 0.5f, 16);

            Right.Hand = UnityUtil.CreateMeshGO("right_hand", rightHandMesh, Right.HandMaterial);
            UnityUtil.TranslateMesh(rightHandMesh, 0, -1.0f, 0);
            Right.Hand.transform.localScale = 0.1f * Vector3.one;
            Right.Hand.transform.rotation   = Quaternion.FromToRotation(Vector3.up, Vector3.forward);
            Right.Hand.SetLayer(FPlatform.HUDLayer);

            Right.Laser    = new GameObject("right_laser");
            Right.LaserRen = Right.Laser.AddComponent <LineRenderer>();
            Right.LaserRen.SetPositions(new Vector3[2] {
                Vector3.zero, 100 * Vector3.up
            });
            Right.LaserRen.startWidth = Right.LaserRen.endWidth = 0.01f;
            Right.LaserRen.material   = MaterialUtil.CreateFlatMaterial(ColorUtil.CgRed, 0.2f);
            Right.Laser.SetLayer(FPlatform.CursorLayer);
            Right.Laser.transform.parent = Right.Cursor.transform;

            spatialInputInitialized = true;
        }