Beispiel #1
0
        public virtual PivotSO Create(SOMaterial shapeMaterial, SOMaterial frameMaterial = null, int nShapeLayer = -1)
        {
            // [TODO] replace frame geometry with line renderer ?
            // [TODO] still cast shadows  (semitransparent objects don't cast shadows, apparently)
            // [TODO] maybe render solid when not obscured by objects? use raycast in PreRender?

            AssignSOMaterial(shapeMaterial);       // need to do this to setup BaseSO material stack

            pivotGO = GameObjectFactory.CreateParentGO(UniqueNames.GetNext("Pivot"));

            shapeGO = create_pivot_shape();
            AppendNewGO(shapeGO, pivotGO, false);

            pivotGO.AddChild(shapeGO);

            if (frameMaterial != null)
            {
                this.frameMaterial = frameMaterial;

                frameGO = UnityUtil.CreateMeshGO("pivotFrame", "icon_meshes/axis_frame", 1.0f,
                                                 UnityUtil.MeshAlignOption.NoAlignment, MaterialUtil.ToUnityMaterial(frameMaterial), false);
                MaterialUtil.SetIgnoreMaterialChanges(frameGO);
                MaterialUtil.DisableShadows(frameGO);
                AppendNewGO(frameGO, pivotGO, false);
            }

            if (nShapeLayer >= 0)
            {
                shapeGO.SetLayer(nShapeLayer);
            }

            increment_timestamp();
            return(this);
        }
Beispiel #2
0
        public PivotSO Create(SOMaterial sphereMaterial, Material frameMaterial, int nSphereLayer = -1)
        {
            // [TODO] replace frame geometry with line renderer ?
            // [TODO] still cast shadows  (semitransparent objects don't cast shadows, apparently)
            // [TODO] maybe render solid when not obscured by objects? use raycast in PreRender?

            AssignSOMaterial(sphereMaterial);       // need to do this to setup BaseSO material stack

            pivot  = new GameObject(UniqueNames.GetNext("Pivot"));
            meshGO = AppendUnityPrimitiveGO("pivotMesh", PrimitiveType.Sphere, CurrentMaterial, pivot);
            meshGO.transform.localScale = 0.9f * Vector3.one;

            if (frameMaterial != null)
            {
                frameMesh = UnityUtil.CreateMeshGO("pivotFrame", "icon_meshes/axis_frame", 1.0f,
                                                   UnityUtil.MeshAlignOption.NoAlignment, frameMaterial, false);
                frameMesh.AddComponent <IgnoreMaterialChanges>();
                MaterialUtil.DisableShadows(frameMesh);
                AppendNewGO(frameMesh, pivot, false);
            }

            if (nSphereLayer >= 0)
            {
                meshGO.SetLayer(nSphereLayer);
            }

            increment_timestamp();
            return(this);
        }
Beispiel #3
0
        public virtual void Create()
        {
            rootGO = new GameObject(UniqueNames.GetNext("HUDSlider"));

            fMaterial useMaterial = MaterialUtil.CreateFlatMaterialF(bgColor);

            backgroundGO = GameObjectFactory.CreateRectangleGO("background",
                                                               SliderWidth, SliderHeight, useMaterial, true, true);
            MaterialUtil.DisableShadows(backgroundGO);
            backgroundGO.RotateD(Vector3f.AxisX, -90.0f); // ??
            AppendNewGO(backgroundGO, rootGO, false);

            handleMaterial = MaterialUtil.CreateFlatMaterialF(handleColor);
            handleGO       = create_handle_go(handleMaterial);
            if (handleGO != null)
            {
                handleGO.Translate(0.001f * Vector3f.AxisY, true);
                AppendNewGO(handleGO, rootGO, false);
                handleStart = handleGO.GetLocalFrame();
            }

            create_visuals_geometry();

            TickMaterial = MaterialUtil.CreateFlatMaterialF(tickColor);

            update_geometry();
        }
Beispiel #4
0
 override public void DisableShadows()
 {
     MaterialUtil.DisableShadows(meshGO, true, true);
     if (frameMesh != null)
     {
         MaterialUtil.DisableShadows(frameMesh, true, true);
     }
 }
Beispiel #5
0
 public override void Setup()
 {
     sphereGO       = GameObjectFactory.CreateMeshGO("sphere", UnityUtil.GetSphereMesh(), false);
     sphereMaterial = MaterialF();
     sphereGO.SetMaterial(sphereMaterial);
     sphereMaterial.color = ColorF();
     MaterialUtil.DisableShadows(sphereGO);
 }
Beispiel #6
0
 override public void DisableShadows()
 {
     MaterialUtil.DisableShadows(shapeGO, true, true);
     if (frameGO != null)
     {
         MaterialUtil.DisableShadows(frameGO, true, true);
     }
 }
Beispiel #7
0
        /// <summary>
        /// Create the GO that acts as the "handle", ie identifies selected position on timelin
        /// Default is a kind of ugly large triangle underneath midline...
        /// Override to provide your own visuals. Return null for no handle.
        /// </summary>
        protected virtual fGameObject create_handle_go(fMaterial handleMaterial)
        {
            fTriangleGameObject handle = GameObjectFactory.CreateTriangleGO(
                "handle", Height, Height, handleMaterial.color, true);

            MaterialUtil.DisableShadows(handle);
            handle.RotateD(Vector3f.AxisX, -90.0f); // ??
            return(handle);
        }
Beispiel #8
0
        /// <summary>
        /// Create GO / geometry for a single tick, centered at origin
        /// </summary>
        protected virtual fGameObject create_tick_go(Vector2f tickSize, fMaterial baseMaterial)
        {
            fRectangleGameObject go = GameObjectFactory.CreateRectangleGO("tick", tickSize.x, tickSize.y,
                                                                          baseMaterial, true, false);

            MaterialUtil.DisableShadows(go);
            go.RotateD(Vector3f.AxisX, -90.0f);
            return(go);
        }
Beispiel #9
0
 public override void Setup()
 {
     planeGO       = GameObjectFactory.CreateMeshGO("section_plane", UnityUtil.GetTwoSidedPlaneMesh(), false);
     planeMaterial = MaterialF();
     planeGO.SetMaterial(planeMaterial);
     planeMaterial.color = ColorF();
     MaterialUtil.DisableShadows(planeGO);
     //planeGO.SetLayer(FPlatform.WidgetOverlayLayer);
 }
Beispiel #10
0
        // creates a button that is just the mesh
        public void Create(fMesh mesh, fMaterial meshMaterial, float fScale, Quaternionf transform)
        {
            button = GameObjectFactory.CreateParentGO(UniqueNames.GetNext("HUDButton"));

            iconMesh = AppendMeshGO("shape", mesh, meshMaterial, button);
            iconMesh.SetLocalScale(new Vector3f(fScale, fScale, fScale));
            iconMesh.SetLocalRotation(iconMesh.GetLocalRotation() * transform);
            MaterialUtil.DisableShadows(iconMesh);

            standard_mat = new fMaterial(meshMaterial);
        }
        public void Start()
        {
            ShowTarget = false;

            targetGO        = GameObject.CreatePrimitive(PrimitiveType.Sphere);
            visibleMaterial = MaterialUtil.CreateTransparentMaterial(Color.red, 0.8f);
            hiddenMaterial  = MaterialUtil.CreateTransparentMaterial(Color.red, 0.4f);
            targetGO.GetComponent <MeshRenderer>().material = hiddenMaterial;
            targetGO.SetLayer(FPlatform.WidgetOverlayLayer);
            MaterialUtil.DisableShadows(targetGO);
            targetGO.SetName("camera_target");
        }
Beispiel #12
0
        // creates a button that is just the mesh
        public void Create(Mesh mesh, Material meshMaterial, float fScale, Quaternion transform)
        {
            button = new GameObject(UniqueNames.GetNext("HUDButton"));

            GameObject meshGO = AppendMeshGO("shape", mesh, meshMaterial, button);

            meshGO.transform.localScale     = new Vector3(fScale, fScale, fScale);
            meshGO.transform.localRotation *= transform;
            MaterialUtil.DisableShadows(meshGO);

            standard_mat = new fMaterial(meshMaterial);
        }
Beispiel #13
0
        // creates a button that is just the mesh, basically same as above but without the background disc
        public void Create(PrimitiveType eType, Material primMaterial, float fPrimScale = 1.0f)
        {
            button = new GameObject(UniqueNames.GetNext("HUDButton"));

            buttonMesh = AppendUnityPrimitiveGO(UniqueNames.GetNext("HUDButton"), eType, primMaterial, button);
            float primSize = Shape.EffectiveRadius() * fPrimScale;

            buttonMesh.transform.localScale = new Vector3(primSize, primSize, primSize);
            buttonMesh.transform.Translate(0.0f, 0.0f, -primSize);
            buttonMesh.transform.Rotate(-15.0f, 45.0f, 0.0f, Space.Self);
            MaterialUtil.DisableShadows(buttonMesh);

            standard_mat = new fMaterial(primMaterial);
        }
Beispiel #14
0
        // creates a button in the desired geometry shape
        public void Create(Material defaultMaterial, Material disabledMaterial = null)
        {
            button     = new GameObject(UniqueNames.GetNext("HUDButton"));
            buttonMesh = AppendMeshGO("disc", make_button_body_mesh(),
                                      defaultMaterial, button);

            buttonMesh.transform.Rotate(Vector3.right, -90.0f);              // ??
            MaterialUtil.DisableShadows(buttonMesh);

            standard_mat = new fMaterial(defaultMaterial);
            if (disabledMaterial != null)
            {
                disabled_mat = new fMaterial(disabledMaterial);
            }
        }
Beispiel #15
0
        // creates a button in the desired geometry shape
        public void Create()
        {
            entry = GameObjectFactory.CreateParentGO(UniqueNames.GetNext("HUDLabel"));

            bgMesh = AppendMeshGO("background", HUDUtil.MakeBackgroundMesh(Shape),
                                  MaterialUtil.CreateFlatMaterialF(BackgroundColor),
                                  entry);
            bgMesh.RotateD(Vector3f.AxisX, -90.0f);


            if (EnableBorder)
            {
                HUDShape borderShape = Shape;
                borderShape.Radius += BorderWidth;
                borderShape.Height += 2 * BorderWidth;
                borderShape.Width  += 2 * BorderWidth;
                border              = AppendMeshGO("border", HUDUtil.MakeBackgroundMesh(borderShape),
                                                   MaterialUtil.CreateFlatMaterialF(BorderColor), entry);
                border.RotateD(Vector3f.AxisX, -90.0f);
                border.Translate(-0.001f * Vector3f.AxisY, true);
            }

            BoxPosition horzAlign = BoxPosition.CenterLeft;

            if (AlignmentHorz == HorizontalAlignment.Center)
            {
                horzAlign = BoxPosition.Center;
            }
            else if (AlignmentHorz == HorizontalAlignment.Right)
            {
                horzAlign = BoxPosition.CenterRight;
            }

            textMesh =
                GameObjectFactory.CreateTextMeshGO(
                    "text", Text, TextColor, TextHeight, horzAlign, SceneGraphConfig.TextLabelZOffset);

            textMesh.TextObject.SetFixedWidth(Shape.Width);
            textMesh.TextObject.SetOverflowMode(TextOverflowMode.Ellipses);

            Vector2f toPos = BoxModel.GetBoxPosition(this, horzAlign);

            BoxModel.Translate(textMesh, Vector2f.Zero, toPos);

            AppendNewGO(textMesh, entry, false);

            MaterialUtil.DisableShadows(RootGameObject);
        }
Beispiel #16
0
 public virtual void SetShadowsEnabled(bool enabled)
 {
     if (enabled != enable_shadows)
     {
         if (enabled)
         {
             enable_shadows = true;
             MaterialUtil.EnableShadows(parentGO, true, true, true);
         }
         else
         {
             enable_shadows = false;
             MaterialUtil.DisableShadows(parentGO, true, true, true);
         }
     }
 }
Beispiel #17
0
        // creates a button with a background shape and a foreground mesh
        public void Create(fMaterial bgMaterial, fMesh mesh, fMaterial meshMaterial, float fScale, Frame3f deltaF)
        {
            button = GameObjectFactory.CreateParentGO(UniqueNames.GetNext("HUDButton"));

            buttonMesh = AppendMeshGO("shape", HUDUtil.MakeBackgroundMesh(this.Shape), bgMaterial, button);
            buttonMesh.RotateD(Vector3f.AxisX, -90.0f); // ??
            MaterialUtil.DisableShadows(buttonMesh);

            iconMesh = AppendMeshGO("shape", mesh, meshMaterial, button);
            iconMesh.SetLocalScale(new Vector3f(fScale, fScale, fScale));
            iconMesh.SetLocalPosition(deltaF.Origin);
            iconMesh.SetLocalRotation(deltaF.Rotation);
            MaterialUtil.DisableShadows(iconMesh);

            standard_mat = new fMaterial(bgMaterial);
        }
Beispiel #18
0
        public void AddComponent(MeshDecomposition.Component C)
        {
            fMesh           submesh    = new fMesh(C.triangles, mesh, C.source_vertices, true, true, true);
            fMeshGameObject submesh_go = GameObjectFactory.CreateMeshGO("component", submesh, false);

            submesh_go.SetMaterial(new fMaterial(CurrentMaterial));
            displayComponents.Add(new DisplayMeshComponent()
            {
                go = submesh_go, source_vertices = C.source_vertices
            });
            if (enable_shadows == false)
            {
                MaterialUtil.DisableShadows(submesh_go, true, true);
            }
            AppendNewGO(submesh_go, parentGO, false);
        }
Beispiel #19
0
        // creates a button with a floating primitive in front of the button shape
        public void Create(PrimitiveType eType, Material bgMaterial, Material primMaterial, float fPrimScale = 0.7f)
        {
            button     = new GameObject(UniqueNames.GetNext("HUDButton"));
            buttonMesh = AppendMeshGO("disc", make_button_body_mesh(), bgMaterial, button);
            buttonMesh.transform.Rotate(Vector3.right, -90.0f);              // ??
            MaterialUtil.DisableShadows(buttonMesh);

            GameObject prim     = AppendUnityPrimitiveGO("primitive", eType, primMaterial, button);
            float      primSize = Shape.EffectiveRadius() * fPrimScale;

            prim.transform.localScale = new Vector3(primSize, primSize, primSize);
            prim.transform.Translate(0.0f, 0.0f, -primSize);
            prim.transform.Rotate(-15.0f, 45.0f, 0.0f, Space.Self);
            MaterialUtil.DisableShadows(prim);

            standard_mat = new fMaterial(bgMaterial);
        }
Beispiel #20
0
        public void AddComponent(MeshDecomposition.Component C)
        {
            fMesh           submesh    = new fMesh(C.triangles, mesh, C.source_vertices, true, true, true);
            fMeshGameObject submesh_go = GameObjectFactory.CreateMeshGO("component", submesh, true);

            submesh_go.SetMaterial(SourceSO.CurrentMaterial, true);
            submesh_go.SetLayer(SourceSO.RootGameObject.GetLayer());
            displayComponents.Add(new DisplayMeshComponent()
            {
                go = submesh_go, source_vertices = C.source_vertices
            });
            if (SourceSO.ShadowsEnabled == false)
            {
                MaterialUtil.DisableShadows(submesh_go, true, true);
            }
            SourceSO.AppendNewGO(submesh_go, SourceSO.RootGameObject, false);
        }
Beispiel #21
0
        // creates a button with a background shape and a foreground mesh
        public void Create(Material bgMaterial, Mesh mesh, Material meshMaterial, float fScale, Frame3f deltaF)
        {
            button = new GameObject(UniqueNames.GetNext("HUDButton"));

            buttonMesh = AppendMeshGO("disc", make_button_body_mesh(), bgMaterial, button);
            buttonMesh.transform.Rotate(Vector3.right, -90.0f); // ??
            MaterialUtil.DisableShadows(buttonMesh);

            GameObject meshGO = AppendMeshGO("shape", mesh, meshMaterial, button);

            meshGO.transform.localScale    = new Vector3(fScale, fScale, fScale);
            meshGO.transform.localPosition = deltaF.Origin;
            meshGO.transform.localRotation = deltaF.Rotation;
            MaterialUtil.DisableShadows(meshGO);

            standard_mat = new fMaterial(bgMaterial);
        }
Beispiel #22
0
        // creates a button in the desired geometry shape
        public void Create(fMaterial defaultMaterial, fMaterial disabledMaterial = null, fMaterial hoverMaterial = null)
        {
            button     = GameObjectFactory.CreateParentGO(UniqueNames.GetNext("HUDButton"));
            buttonMesh = AppendMeshGO("shape", HUDUtil.MakeBackgroundMesh(this.Shape),
                                      defaultMaterial, button);
            buttonMesh.RotateD(Vector3f.AxisX, -90.0f); // ??
            MaterialUtil.DisableShadows(buttonMesh);

            standard_mat = defaultMaterial;
            if (disabledMaterial != null)
            {
                disabled_mat = disabledMaterial;
            }
            if (hoverMaterial != null)
            {
                hover_mat = hoverMaterial;
            }
        }
Beispiel #23
0
        // creates a button that is just the mesh, basically same as above but without the background disc
        public void Create(UnityEngine.PrimitiveType eType, fMaterial primMaterial, float fPrimScale = 1.0f)
        {
            button = GameObjectFactory.CreateParentGO(UniqueNames.GetNext("HUDButton"));

            buttonMesh = AppendUnityPrimitiveGO(UniqueNames.GetNext("HUDButton"), eType, primMaterial, button);
            float primSize = Shape.EffectiveRadius() * fPrimScale;

            buttonMesh.SetLocalScale(new Vector3f(primSize, primSize, primSize));
            buttonMesh.Translate(new Vector3f(0.0f, 0.0f, -primSize), false);
            Quaternionf rot = buttonMesh.GetLocalRotation();

            rot = rot * Quaternionf.AxisAngleD(Vector3f.AxisY, 45.0f);
            rot = rot * Quaternionf.AxisAngleD(Vector3f.AxisX, -15.0f);
            buttonMesh.SetLocalRotation(rot);
            //buttonMesh.transform.Rotate(-15.0f, 45.0f, 0.0f, Space.Self);
            MaterialUtil.DisableShadows(buttonMesh);

            standard_mat = new fMaterial(primMaterial);
        }
Beispiel #24
0
 static public GameObject EmitDebugCursorSphere(string name, float diameter, Color color)
 {
     if (FContext.ActiveContext_HACK.MouseCameraController is VRMouseCursorController)
     {
         GameObject sphere = GameObject.CreatePrimitive(PrimitiveType.Sphere);
         sphere.SetName(name);
         sphere.transform.position =
             (FContext.ActiveContext_HACK.MouseCameraController as VRMouseCursorController).CurrentCursorPosWorld;
         sphere.transform.localScale = new Vector3(diameter, diameter, diameter);
         sphere.GetComponent <MeshRenderer>().material =
             MaterialUtil.CreateTransparentMaterial(color, 0.5f);
         MaterialUtil.DisableShadows(sphere);
         sphere.SetLayer(FPlatform.HUDLayer);
         return(sphere);
     }
     else
     {
         throw new Exception("DebugUtil.EmitDebugCursorSphere: only works for VRMouseCursorController!");
     }
 }
Beispiel #25
0
        public virtual void ValidateViewMeshes()
        {
            if (decomp_valid)
            {
                return;
            }

            fMesh unityMesh = UnityUtil.DMeshToUnityMesh(mesh, false, true);

            viewMeshGO = GameObjectFactory.CreateMeshGO("component", unityMesh, false, true);
            viewMeshGO.SetMaterial(SourceSO.CurrentMaterial, true);
            viewMeshGO.SetLayer(SourceSO.RootGameObject.GetLayer());
            if (SourceSO.ShadowsEnabled == false)
            {
                MaterialUtil.DisableShadows(viewMeshGO, true, true);
            }
            SourceSO.AppendNewGO(viewMeshGO, SourceSO.RootGameObject, false);

            decomp_valid = true;
        }
        public override void Create()
        {
            base.Create();

            backgroundGO = GameObjectFactory.CreateDiscGO(rootGO.GetName() + "_bg",
                                                          radius, bgColor, true);
            MaterialUtil.DisableShadows(backgroundGO);
            backgroundGO.RotateD(Vector3f.AxisX, -90.0f);   // make vertical
            AppendNewGO(backgroundGO, rootGO, false);

            progressGO = GameObjectFactory.CreateDiscGO(rootGO.GetName() + "_progress",
                                                        radius, completedColor, true);
            progressGO.SetStartAngleDeg(89.0f);
            progressGO.SetEndAngleDeg(90.0f);

            MaterialUtil.DisableShadows(progressGO);
            progressGO.RotateD(Vector3f.AxisX, -90.0f);   // make vertical
            progressGO.Translate(0.001f * Vector3f.AxisY, true);
            AppendNewGO(progressGO, rootGO, false);

            update_geometry();
        }
        virtual public ITransformGizmo Create(FScene parentScene, List <SceneObject> targets)
        {
            this.parentScene = parentScene;
            this.targets     = targets;
            gizmo            = new GameObject("BaseGizmo");

            BuildGizmo();

            // disable shadows on widget components
            foreach (var go in GameObjects)
            {
                MaterialUtil.DisableShadows(go);
            }

            // set layer
            SetLayer(FPlatform.WidgetOverlayLayer);

            InitializeTargetWrapper();
            targetWrapper.Target.OnTransformModified += onTransformModified;
            onTransformModified(null);

            return(this);
        }
        // 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;
        }
Beispiel #29
0
 override public void DisableShadows()
 {
     MaterialUtil.DisableShadows(meshGO, true, false);
 }
Beispiel #30
0
 override public void DisableShadows()
 {
     enable_shadows = false;
     MaterialUtil.DisableShadows(parentGO, true, true);
 }