Exemple #1
0
        // remove SO from scene.
        // bDestroy means that SO is actually deleted, otherwise just added
        // to internal Deleted set, so it can be recovered by undo.
        public void RemoveSceneObject(SceneObject so, bool bDestroy)
        {
            DebugUtil.Log(1, "[Scene.AddSceneObject] removing {0} (destroy: {1})", so.Name, bDestroy);

            if (vSelected.Contains(so))
            {
                Deselect(so);
            }
            vObjects.Remove(so);
            OnSceneChanged(so, SceneChangeType.Removed);

            if (so.RootGameObject != null)
            {
                if (bDestroy)
                {
                    SceneUtil.DestroySO(so);
                }
                else
                {
                    // add to deleted set
                    vDeleted.Add(so);
                    UnityUtil.AddChild(deleted_objects, so.RootGameObject, true);
                    so.RootGameObject.SetVisible(false);
                }
            }
        }
        // pass bIsScaled=false if the localFrame is not in the un-scaled space of the primitive
        //   (eg like if you computed positions relative to an un-scaled bounding box)
        public void AddSphereL(Frame3f localFrame, float fVisualRadiusDeg, Material mat, bool bIsScaled = true)
        {
            GameObject go     = new GameObject("sphere");
            Vector3f   vScale = parentSO.GetLocalScale();

            go.AddComponent <MeshFilter>();
            go.SetMesh(UnityUtil.GetPrimitiveMesh(PrimitiveType.Sphere));
            var goRen = go.AddComponent <MeshRenderer>();

            goRen.material          = mat;
            go.transform.localScale = new Vector3(1, 1, 1);
            // we are going to be parented to SO, so we will inherit its local scale.
            // assumption is that frames passed in are already in scaled coordinates,
            // so we need to undo that scale
            if (bIsScaled)
            {
                go.transform.position = localFrame.Origin / vScale;
            }
            else
            {
                go.transform.position = localFrame.Origin;
            }
            go.layer = FPlatform.WidgetOverlayLayer;

            UnityUtil.AddChild(parentGO, go, false);

            vObjects.Add(new IndicatorInfo()
            {
                go = go, fVisualRadiusDeg = fVisualRadiusDeg
            });
        }
Exemple #3
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);
        }
        public void Initialize()
        {
            parentGO = new GameObject(parentSO.Name + "_indicators");
            UnityUtil.AddChild(parentSO.RootGameObject, parentGO, false);

            helper = new PreRenderHelper("indicators_helper")
            {
                PreRenderF = () => { this.PreRender(parentSO.GetScene().ActiveCamera.GetPosition()); }
            };
            parentSO.GetScene().AddUIElement(helper);
        }
        public override void AddIndicator(Indicator i)
        {
            base.AddIndicator(i);
            CoordSpace eSpace = i.InSpace;

            if (eSpace == CoordSpace.ObjectCoords || eSpace == CoordSpace.WorldCoords)
            {
                throw new Exception("SOSceneIndicatorSet.AddIndicator: only scene-space indicators not supported!");
            }

            UnityUtil.AddChild(sceneParentGO, i.RootGameObject, false);
        }
Exemple #6
0
 public void RestoreDeletedSceneObject(SceneObject so)
 {
     if (vDeleted.Find((x) => x == so) == null)
     {
         return;
     }
     vDeleted.Remove(so);
     vObjects.Add(so);
     so.RootGameObject.SetVisible(true);
     UnityUtil.AddChild(scene_objects, so.RootGameObject, true);
     so.SetCurrentTime(currentTime);
 }
Exemple #7
0
        public override void AddIndicator(Indicator i)
        {
            base.AddIndicator(i);
            CoordSpace eSpace = i.InSpace;

            if (eSpace == CoordSpace.ObjectCoords)
            {
                throw new Exception("ToolIndicatorSet.AddIndicator: object-space indicators not supported!");
            }
            if (eSpace == CoordSpace.SceneCoords)
            {
                UnityUtil.AddChild(sceneParentGO, i.RootGameObject, false);
            }
            else
            {
                UnityUtil.AddChild(worldParentGO, i.RootGameObject, true);
            }
        }
Exemple #8
0
 public virtual void Initialize()
 {
     worldParentGO = GameObjectFactory.CreateParentGO(parentTool.Name + "_indicators_world");
     sceneParentGO = GameObjectFactory.CreateParentGO(parentTool.Name + "_indicators_scene");
     UnityUtil.AddChild(Scene.TransientObjectsParent, sceneParentGO, false);
 }
Exemple #9
0
        public FScene(FContext context)
        {
            this.context = context;

            history      = new ChangeHistory();
            TypeRegistry = new SORegistry();

            vObjects       = new List <SceneObject> ();
            vSelected      = new List <SceneObject> ();
            vUIElements    = new List <SceneUIElement> ();
            vBoundsObjects = new List <GameObject> ();
            ObjectAnimator = new GenericAnimator();

            sceneRoot = new GameObject("Scene");
            // for animation playbacks
            sceneRoot.AddComponent <SceneAnimator>().Scene = this;
            sceneRoot.AddComponent <UnityPerFrameAnimationBehavior>().Animator = ObjectAnimator;

            scene_objects = new GameObject("scene_objects");
            UnityUtil.AddChild(sceneRoot, scene_objects, false);

            deleted_objects = new GameObject("deleted_objects");
            UnityUtil.AddChild(sceneRoot, deleted_objects, false);
            vDeleted = new List <SceneObject>();

            // initialize materials
            DefaultSOMaterial = new SOMaterial()
            {
                Name = "DefaultSO",
                Type = SOMaterial.MaterialType.StandardRGBColor, RGBColor = ColorUtil.StandardBeige
            };
            DefaultCurveSOMaterial = new SOMaterial()
            {
                Name = "DefaultCurveSO",
                Type = SOMaterial.MaterialType.UnlitRGBColor, RGBColor = Colorf.DarkSlateGrey
            };
            DefaultMeshSOMaterial = new SOMaterial()
            {
                Name = "DefaultMeshSO",
                Type = SOMaterial.MaterialType.PerVertexColor, RGBColor = Colorf.White
            };
            NewSOMaterial = new SOMaterial()
            {
                Name = "NewSO",
                Type = SOMaterial.MaterialType.StandardRGBColor, RGBColor = Colorf.CornflowerBlue
            };
            TransparentNewSOMaterial = new SOMaterial()
            {
                Name = "NewSO",
                Type = SOMaterial.MaterialType.TransparentRGBColor, RGBColor = new Colorf(Colorf.CornflowerBlue, 0.5f)
            };
            PivotSOMaterial = new SOMaterial()
            {
                Name = "PivotSO",
                Type = SOMaterial.MaterialType.TransparentRGBColor, RGBColor = ColorUtil.PivotYellow.SetAlpha(0.75f)
            };

            SelectedMaterial = MaterialUtil.CreateStandardMaterial(ColorUtil.SelectionGold);
            FrameMaterial    = MaterialUtil.CreateStandardMaterial(ColorUtil.DarkGrey);
            PivotMaterial    = MaterialUtil.ToUnityMaterial(PivotSOMaterial);

            defaultPrimitiveType = SOTypes.Cylinder;
        }