Exemplo n.º 1
0
        void update_indicator(CreateDropPrimitiveButton button, FScene scene)
        {
            if (button == null || buttonTypes.ContainsKey(button) == false)
            {
                return;
            }
            SOType t = buttonTypes[button];

            if (t.hasTag(SOType.TagPrimitive) == false)
            {
                return;
            }

            scene.DefaultPrimitiveType = t;

            if (indicatorButton != null)
            {
                indicatorButton.RemoveGO(indicatorGO);
            }
            indicatorButton = button;

            indicatorGO.SetPosition(Vector3f.Zero);
            indicatorGO.SetRotation(Quaternionf.Identity);
            indicatorGO.SetLocalScale(fIndicatorSize * Vector3f.One);
            indicatorGO.SetLocalPosition(
                indicatorGO.GetLocalPosition() + fIndicatorShift * (Vector3f.AxisY - 1 * Vector3f.AxisZ + Vector3f.AxisX));

            indicatorButton.AppendNewGO(indicatorGO, indicatorButton.RootGameObject, false);
            indicatorGO.Show();
        }
Exemplo n.º 2
0
        public FScene(FContext context)
        {
            this.context = context;

            history       = new ChangeHistory();
            history_stack = new List <ChangeHistory>();
            TypeRegistry  = new SORegistry();

            initialize_scene_root();

            // 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)
            };
            FrameSOMaterial = new SOMaterial()
            {
                Name = "PivotFrame",
                Type = SOMaterial.MaterialType.StandardRGBColor, RGBColor = ColorUtil.DarkGrey
            };

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

            defaultPrimitiveType = SOTypes.Cylinder;
        }
Exemplo n.º 3
0
        public void RegisterType(SOType t, SOEmitSerializationFunc serializeFunc = null,
                                 SOBuildFunc buildFunc = null)
        {
            if (knownTypes.ContainsKey(t.identifier))
            {
                throw new InvalidOperationException("SORegistry.RegisterType: type " + t.identifier + " already registered!");
            }

            SOInfo info = new SOInfo()
            {
                type       = t,
                serializer = serializeFunc,
                builder    = buildFunc
            };

            knownTypes[t.identifier] = info;
        }
Exemplo n.º 4
0
        void CreateNewPrimitive()
        {
            SOType activePrimType = scene.DefaultPrimitiveType;

            if (activePrimType == SOTypes.Sphere)
            {
                eActiveType = SupportedTypes.Sphere;
            }
            else if (activePrimType == SOTypes.Box)
            {
                eActiveType = SupportedTypes.Box;
            }
            else
            {
                eActiveType = SupportedTypes.Cylinder;
            }


            float fScale = scene.GetSceneScale();

            if (eActiveType == SupportedTypes.Cylinder)
            {
                primitive        = new MeshPrimitivePreview();
                primitive.Type   = MeshPrimitivePreview.PrimType.Cylinder;
                primitive.Center = CenterModes.Base;
                primitive.Create(scene.NewSOMaterial, scene.RootGameObject, MinDimension * fScale);
            }
            else if (eActiveType == SupportedTypes.Sphere)
            {
                primitive        = new MeshPrimitivePreview();
                primitive.Type   = MeshPrimitivePreview.PrimType.Sphere;
                primitive.Center = CenterModes.Origin;
                primitive.Create(scene.NewSOMaterial, scene.RootGameObject, MinDimension * fScale);
            }
            else if (eActiveType == SupportedTypes.Box)
            {
                primitive        = new MeshPrimitivePreview();
                primitive.Type   = MeshPrimitivePreview.PrimType.Box;
                primitive.Center = CenterModes.Corner;
                primitive.Create(scene.NewSOMaterial, scene.RootGameObject, MinDimension * fScale);
            }
            else
            {
                throw new NotImplementedException("DrawPrimitivesTool.Create: unsupported type");
            }
        }
Exemplo n.º 5
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 <fGameObject>();
            ObjectAnimator = new GenericAnimator();
            LinkManager    = new SOLinkManager(this);

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

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

            deleted_objects = GameObjectFactory.CreateParentGO("deleted_objects");
            sceneRoot.AddChild(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)
            };
            FrameSOMaterial = new SOMaterial()
            {
                Name = "PivotFrame",
                Type = SOMaterial.MaterialType.StandardRGBColor, RGBColor = ColorUtil.DarkGrey
            };

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

            defaultPrimitiveType = SOTypes.Cylinder;
        }