Esempio n. 1
0
        // creates a button in the desired geometry shape
        public void Create()
        {
            entry = GameObjectFactory.CreateParentGO(UniqueNames.GetNext("HUDLabel"));

            bgMesh = new fGameObject(AppendMeshGO("background", make_background_mesh(),
                                                  MaterialUtil.CreateFlatMaterialF(BackgroundColor),
                                                  entry));
            bgMesh.RotateD(Vector3f.AxisX, -90.0f);

            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);

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

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

            AppendNewGO(textMesh, entry, false);
        }
Esempio n. 2
0
        // called by FContext.PushCockpit()
        public void Start(ICockpitInitializer setup)
        {
            // create invisible plane for cockpit
            gameobject = GameObjectFactory.CreateParentGO("cockpit");

            onCameraGO = GameObjectFactory.CreateParentGO("cockpit_camera");
            gameobject.AddChild(onCameraGO, false);

            // [RMS] probably can delete this code now?
            //gameobject = GameObject.CreatePrimitive (PrimitiveType.Plane);
            //gameobject.SetName("cockpit");
            //MeshRenderer ren = gameobject.GetComponent<MeshRenderer> ();
            //ren.enabled = false;
            //gameobject.GetComponent<MeshCollider> ().enabled = false;

            // add hud animation controller
            gameobject.AddComponent <UnityPerFrameAnimationBehavior>().Animator = HUDAnimator;

            // create HUD
            try {
                setup.Initialize(this);
            } catch (Exception e) {
                DebugUtil.Log(2, "[Cockpit.Start] exception in initializer: {0}\nTrace:\n{1}", e.Message,
                              e.StackTrace);
                // if hud setup fails we still want to keep going
            }

            // position in front of camera
            UpdateTracking(true);
        }
Esempio n. 3
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);
        }
Esempio n. 4
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();
        }
Esempio n. 5
0
        public PolyCurveSO Create(SOMaterial defaultMaterial)
        {
            if (curve == null)
            {
                LineGenerator gen = new LineGenerator()
                {
                    Start = Vector3.zero, End = 10.0f * Vector3.up, StepSize = 0.1f
                };
                gen.Generate();
                curve = new DCurve3();
                gen.Make(curve);
            }

            // assumes type identifier is something like BlahBlahSO
            root = GameObjectFactory.CreateParentGO(UniqueNames.GetNext(Type.identifier.Remove(Type.identifier.Length - 2)));

            if (EnableLineRenderer)
            {
                LineRenderer ren = root.AddComponent <LineRenderer>();
                ren.startWidth    = ren.endWidth = 0.05f;
                ren.useWorldSpace = false;
            }

            AssignSOMaterial(defaultMaterial);       // need to do this to setup BaseSO material stack
            Material useMaterial = CurrentMaterial;

            Create_internal(useMaterial);

            UpdateGeometry();

            increment_timestamp();

            return(this);
        }
Esempio n. 6
0
        public static void Translate(fGameObject go, Vector2f delta, float z = 0)
        {
            Vector3f cur = go.GetLocalPosition();

            cur.x += delta.x; cur.y += delta.y; cur.z += z;
            go.SetLocalPosition(cur);
        }
Esempio n. 7
0
        protected virtual fGameObject create_pivot_shape()
        {
            fGameObject go = AppendUnityPrimitiveGO("pivotMesh", UnityEngine.PrimitiveType.Sphere, CurrentMaterial, null, true);

            go.SetLocalScale(Size * Vector3f.One);
            return(go);
        }
Esempio n. 8
0
        /// <summary>
        /// Update GO for a single tick created by CreateTickGO().
        /// This does not require positioning the tick, that happens automatically.
        /// fT is in range [0,1], can be used for styling/etc
        /// </summary>
        protected virtual void update_tick_go(int iTick, fGameObject go, Vector2f tickSize, float fT)
        {
            fRectangleGameObject rectGO = go as fRectangleGameObject;

            rectGO.SetWidth(tickSize.x);
            rectGO.SetHeight(tickSize.y);
        }
Esempio n. 9
0
        // called by FContext.PushCockpit()
        public void Start(ICockpitInitializer setup)
        {
            // create invisible plane for cockpit
            gameobject = GameObjectFactory.CreateParentGO("cockpit");

            onCameraGO = GameObjectFactory.CreateParentGO("cockpit_camera");
            gameobject.AddChild(onCameraGO, false);

            // add hud animation controller
            gameobject.AddComponent <UnityPerFrameAnimationBehavior>().Animator = HUDAnimator;

            // create HUD
            try {
                setup.Initialize(this);
            } catch (Exception e) {
                // if hud setup fails we still want to keep going
                DebugUtil.Log(2, "[Cockpit.Start] exception in initializer: {0}\nTrace:\n{1}", e.Message, e.StackTrace);
                if (FPlatform.InUnityEditor())
                {
                    throw;
                }
            }

            // position in front of camera
            UpdateTracking(true);
        }
Esempio n. 10
0
        public static GOWrapperSO CombineAnySOs(SceneObject s1, SceneObject s2, bool bDeleteExisting = true)
        {
            FScene scene = s1.GetScene();

            if (scene.IsSelected(s1))
            {
                scene.Deselect(s1);
            }
            if (scene.IsSelected(s2))
            {
                scene.Deselect(s2);
            }

            fGameObject parentGO = GameObjectFactory.CreateParentGO("combined");

            GOWrapperSO.AppendSOGeometry(parentGO, s1, true);
            GOWrapperSO.AppendSOGeometry(parentGO, s2, true);

            GOWrapperSO wrapperSO = new GOWrapperSO()
            {
                AllowMaterialChanges = false
            };

            wrapperSO.Create(parentGO);

            if (bDeleteExisting)
            {
                scene.RemoveSceneObject(s1, false);
                scene.RemoveSceneObject(s2, false);
            }

            scene.AddSceneObject(wrapperSO, false);

            return(wrapperSO);
        }
Esempio n. 11
0
        void initialize_scene_root()
        {
            vObjects       = new List <SceneObject>();
            vSelected      = new List <SceneObject>();
            vUIElements    = new List <SceneUIElement>();
            vBoundsObjects = new List <fGameObject>();
            ObjectAnimator = new GenericAnimator();
            LinkManager    = new SOLinkManager(this);
            vDeleted       = new List <SceneObject>();

            sceneRoot = GameObjectFactory.CreateParentGO("Scene");
            // for animation playbacks
            sceneRoot.AddComponent <UnityPerFrameAnimationBehavior>().Animator = ObjectAnimator;

            transient_objects = GameObjectFactory.CreateParentGO("transient");
            sceneRoot.AddChild(transient_objects, false);

            lighting_objects = GameObjectFactory.CreateParentGO("lighting_objects");
            sceneRoot.AddChild(lighting_objects, false);

            bounds_objects = GameObjectFactory.CreateParentGO("bounds_objects");
            sceneRoot.AddChild(bounds_objects, false);

            scene_objects = GameObjectFactory.CreateParentGO("scene_objects");
            sceneRoot.AddChild(scene_objects, false);

            deleted_objects = GameObjectFactory.CreateParentGO("deleted_objects");
            sceneRoot.AddChild(deleted_objects, false);
        }
Esempio n. 12
0
        public static fGameObject CreateTrackingGO(string sName, fGameObject trackGO)
        {
            GameObject          go      = new GameObject(sName);
            TrackObjectBehavior tracker = go.AddComponent <TrackObjectBehavior>();

            tracker.TrackGO = trackGO;
            return(go);
        }
Esempio n. 13
0
 public override void Setup()
 {
     sphereGO       = GameObjectFactory.CreateMeshGO("sphere", UnityUtil.GetSphereMesh(), false);
     sphereMaterial = MaterialF();
     sphereGO.SetMaterial(sphereMaterial);
     sphereMaterial.color = ColorF();
     MaterialUtil.DisableShadows(sphereGO);
 }
Esempio n. 14
0
        public fGameObjectPool(Func <T> factoryF)
        {
            Allocated = new List <T>();
            Free      = new List <T>();

            pool_parent = GameObjectFactory.CreateParentGO("pool_parent");

            AllocatorFactoryF = factoryF;
        }
Esempio n. 15
0
        public override void Setup()
        {
            measureGO = GameObjectFactory.CreateParentGO("dimension");
            measureGO.SetLayer(FPlatform.WidgetOverlayLayer);

            textGO = GameObjectFactory.CreateTextMeshGO("text", "1.0", Colorf.Black, TextHeight.SceneValuef);
            UnityUtil.AddChild(measureGO, textGO, false);
            textGO.SetLayer(FPlatform.WidgetOverlayLayer);
        }
Esempio n. 16
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);
 }
Esempio n. 17
0
        /// <summary>
        /// Update handle sizing. Width and Height here are full slider width/height
        /// </summary>
        protected virtual void update_handle_go(fGameObject handleGO, float width, float height)
        {
            if (handleGO is fTriangleGameObject == false)
            {
                DebugUtil.Error("HUDSliderBase: handle is not standard type but get_handle_offset not overloaded!");
            }

            (handleGO as fTriangleGameObject).SetHeight(height * 0.5f);
            (handleGO as fTriangleGameObject).SetWidth(height * 0.5f);
        }
Esempio n. 18
0
 public void Start()
 {
     fadeObject = new fGameObject(GameObject.CreatePrimitive(PrimitiveType.Sphere), FGOFlags.NoFlags);
     //fadeObject.transform.localScale = new Vector3(0.5f, 0.5f, 0.5f);
     fadeObject.SetMaterial(MaterialUtil.CreateFlatMaterial(Color.black, 0.0f), true);
     fadeObject.SetName("fade_sphere");
     UnityUtil.ReverseMeshOrientation(fadeObject.GetMesh());
     fadeObject.SetParent(UseCamera.GameObject(), false);
     fadeObject.SetLayer(FPlatform.HUDLayer);
 }
Esempio n. 19
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);
        }
Esempio n. 20
0
 public virtual void AppendNewGO(fGameObject go, fGameObject parent, bool bKeepPosition)
 {
     vObjects.Add(go);
     go.SetParent(parent, bKeepPosition);
     go.SetLayer(parent.GetLayer());
     foreach (GameObject child_go in go.Children())
     {
         vObjects.Add(child_go);
         child_go.SetLayer(parent.GetLayer());
     }
 }
Esempio n. 21
0
 public void SetParent(fGameObject parentGO, bool bKeepWorldPosition = false)
 {
     if (parentGO == null)
     {
         go.transform.SetParent(null, bKeepWorldPosition);
     }
     else
     {
         go.transform.SetParent(((GameObject)parentGO).transform, bKeepWorldPosition);
     }
 }
Esempio n. 22
0
        /// <summary>
        /// Get up/down shift of handle relative to midline of slider.
        /// </summary>
        protected virtual float get_handle_offset(fGameObject handleGO)
        {
            if (handleGO is fTriangleGameObject == false)
            {
                DebugUtil.Error("HUDSliderBase: handle is not standard type but get_handle_offset not overloaded!");
            }

            float h  = (handleGO as fTriangleGameObject).GetHeight();
            float dz = -(SliderHeight / 2) - h / 2;

            return(dz);
        }
Esempio n. 23
0
        public void Create(fMaterial defaultMaterial)
        {
            button     = GameObjectFactory.CreateParentGO(UniqueNames.GetNext("HUDToggleButton"));
            buttonMesh = AppendMeshGO("shape", HUDUtil.MakeBackgroundMesh(this.Shape),
                                      defaultMaterial, button);

            buttonMesh.RotateD(Vector3f.AxisX, -90.0f); // ??

            if (text.Length > 0)
            {
                UpdateText();
            }
        }
Esempio n. 24
0
        public static fGameObject Duplicate(fGameObject go)
        {
            GameObject  copy  = GameObject.Instantiate <GameObject>(go);
            fGameObject fcopy = new fGameObject(copy);

            // have to set parent fgo in PreRenderBehavior script...
            if (copy.GetComponent <PreRenderBehavior>() != null)
            {
                copy.GetComponent <PreRenderBehavior>().ParentFGO = fcopy;
            }

            return(fcopy);
        }
Esempio n. 25
0
 public virtual void initialize(fGameObject go, fMaterial material, bool bSharedMat)
 {
     r = ((GameObject)go).AddComponent <LineRenderer>();
     r.useWorldSpace = false;
     if (bSharedMat)
     {
         r.sharedMaterial = material;
     }
     else
     {
         r.material = material;
     }
 }
Esempio n. 26
0
        public void Create(fMaterial defaultMaterial)
        {
            button     = GameObjectFactory.CreateParentGO(UniqueNames.GetNext("HUDToggleButton"));
            buttonMesh = AppendMeshGO("disc", make_button_body_mesh(),
                                      defaultMaterial, button);

            buttonMesh.RotateD(Vector3f.AxisX, -90.0f); // ??

            if (text.Length > 0)
            {
                UpdateText();
            }
        }
Esempio n. 27
0
        public virtual DMeshSO Create(DMesh3 mesh, SOMaterial setMaterial)
        {
            AssignSOMaterial(setMaterial);       // need to do this to setup BaseSO material stack
            parentGO = GameObjectFactory.CreateParentGO(UniqueNames.GetNext("DMesh"));

            this.mesh = mesh;
            on_mesh_changed();

            displayComponents = new List <DisplayMeshComponent>();
            validate_decomp();

            return(this);
        }
Esempio n. 28
0
        public virtual DMeshSO Create(DMesh3 mesh, SOMaterial setMaterial)
        {
            AssignSOMaterial(setMaterial);       // need to do this to setup BaseSO material stack
            parentGO = GameObjectFactory.CreateParentGO(UniqueNames.GetNext("DMesh"));

            this.mesh = mesh;



            on_mesh_changed();
            validate_view_meshes();

            return(this);
        }
Esempio n. 29
0
        // actually create GO elements, etc
        public void Create()
        {
            entry = GameObjectFactory.CreateParentGO(UniqueNames.GetNext("HUDPopupMessage"));

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


            IBoxModelElement contentArea = BoxModel.PaddedBounds(this, Padding);

            BoxPosition titleBoxPos = BoxModel.ToPosition(TitleAlignment, VerticalAlignment.Top);

            titleTextMesh = (titleText == "") ? null : GameObjectFactory.CreateTextMeshGO(
                "title", TitleText, TextColor, TitleTextHeight, titleBoxPos, SceneGraphConfig.TextLabelZOffset);
            float fTitleHeight = 0;

            if (titleTextMesh != null)
            {
                Vector2f titleToPos = BoxModel.GetBoxPosition(contentArea, titleBoxPos);
                BoxModel.Translate(titleTextMesh, Vector2f.Zero, titleToPos);
                AppendNewGO(titleTextMesh, entry, false);
                fTitleHeight = TitleTextHeight;
            }

            IBoxModelElement messageArea = BoxModel.PaddedBounds(contentArea, 0, 0, 0, Padding + fTitleHeight);
            Vector2f         textDims    = messageArea.Size2D;

            BoxPosition textBoxPos = BoxModel.ToPosition(Alignment, VerticalAlignment.Top);

            textMesh = GameObjectFactory.CreateTextAreaGO(
                "message", Text, TextColor, TextHeight, textDims, Alignment, textBoxPos, SceneGraphConfig.TextLabelZOffset);
            Vector2f textToPos = BoxModel.GetBoxPosition(messageArea, textBoxPos);

            BoxModel.Translate(textMesh, Vector2f.Zero, textToPos);
            AppendNewGO(textMesh, entry, false);



            if (EnableClickToDismiss)
            {
                footerTextMesh = GameObjectFactory.CreateTextMeshGO(
                    "footer", DismissText, DismissTextColor, TextHeight * 0.5f,
                    BoxPosition.CenterBottom, SceneGraphConfig.TextLabelZOffset);
                BoxModel.Translate(footerTextMesh, Vector2f.Zero, BoxModel.GetBoxPosition(contentArea, BoxPosition.CenterBottom));
                AppendNewGO(footerTextMesh, entry, false);
            }
        }
Esempio n. 30
0
        public void RemoveAllUIElements(bool bDiscardTransientObjects = true)
        {
            while (vUIElements.Count > 0)
            {
                RemoveUIElement(vUIElements[0], true);
            }

            // discard any transient objects we have floating around
            if (bDiscardTransientObjects)
            {
                transient_objects.Destroy();
                transient_objects = GameObjectFactory.CreateParentGO("transient");
                sceneRoot.AddChild(transient_objects, false);
            }
        }