Example #1
0
        private void CreateSceneLight()
        {
            SceneLight = new PulsarLight("MainDirectionalLight", this, SceneDebugRenderer)
            {
                PulsarComponentClass = PulsarComponent.ComponentClass.Node,
                PulsarComponentType  = PulsarComponent.ComponentType.Light,
                InDesign             = _inDesign
            };

            PulsarModel model = new PulsarModel(SceneLight.GetEntityName());

            SceneLight.BaseEntity.AddComponent(model);
            //baseEntity.AddComponent(model);
            model.SetModel("Models/Box.mdl");

            PulsarMaterial material = new PulsarMaterial(SceneLight.GetEntityName());

            SceneLight.BaseEntity.AddComponent(material);
            //baseEntity.AddComponent(material);
            material.SetMaterial("Materials/StoneTiled.xml");

            model.SetMaterial(material);
            SceneLight.CreateEntity();

            SceneLight.SetDirection(new Vector3(0.6f, -1.0f, 0.8f));
            SceneLight.SetPosition(new Vector3(0, 10, 0));

            SceneLight.Light.LightType   = LightType.Directional;
            SceneLight.Light.Brightness  = 1.1f;
            SceneLight.Light.CastShadows = true;

            SceneLight.SetExtendedProperties();
            SceneLight.BaseEntity.SetupProperties();
        }
Example #2
0
        public void ResetGizmosAndMaterials()
        {
            if (_selectedObjects.Count == 0)
            {
                return;
            }

            foreach (SelectedObject selectedObject in _selectedObjects)
            {
                if (selectedObject != null)
                {
                    if (!selectedObject.SelectedNode.IsDeleted)
                    {
                        PulsarModel pulsarModel = selectedObject.SelectedNode.GetComponent <PulsarModel>();
                        if (pulsarModel != null)
                        {
                            BaseEntity baseEntity = pulsarModel.GetBaseEntity();
                            if (baseEntity != null)
                            {
                                baseEntity.UnSelect();
                            }
                        }
                    }
                }
            }
        }
Example #3
0
        private void DrawSelectedObjects()
        {
            if (DisplayScene.SelectedSceneObjects.SelectedObjectCount > 0)
            {
                foreach (SelectedObject selectedObject in DisplayScene.SelectedSceneObjects.ObjectList)
                {
                    if (selectedObject != null)
                    {
                        if (!selectedObject.Drawable.IsDeleted)
                        {
                            BoundingBox bounds = selectedObject.Drawable.WorldBoundingBox;
                            DisplayScene.SceneDebugRenderer.AddBoundingBox(bounds, Color.Red);
                            PulsarModel pulsarModel = selectedObject.SelectedNode.GetComponent <PulsarModel>();
                            if (pulsarModel != null)
                            {
                                var baseEntity = pulsarModel.GetBaseEntity();
                                var gizmoNode  = DisplayScene.GetChild(selectedObject.SelectedNode.Name + "_gizmo");
                                if (baseEntity != null)
                                {
                                    if (!baseEntity.IsSelected)
                                    {
                                        baseEntity.SetAsSelected();
                                    }
                                    else
                                    {
                                        //make sure the gizmo node has the correct orientation based on type
                                        switch (DragType)
                                        {
                                        case DragType.Translate:
                                            if (gizmoNode != null)
                                            {
                                                gizmoNode.Rotation = new Quaternion(0, 0, 0);
                                            }
                                            break;

                                        case DragType.Rotate:
                                        case DragType.Scale:
                                            if (gizmoNode != null)
                                            {
                                                gizmoNode.Rotation = selectedObject.SelectedNode.Rotation;
                                            }
                                            break;
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
Example #4
0
        public void CreateBox()
        {
            _createdEntity = new BoxEntity("box" + _currentEntityIndex++.ToString(), this, SceneDebugRenderer, _inDesign)
            {
                Scale = new Vector3(5.0f, 5.0f, 5.0f),
                PulsarComponentClass = PulsarComponent.ComponentClass.Node,
                PulsarComponentType  = PulsarComponent.ComponentType.Box,
                InDesign             = _inDesign
            };

            _createdEntity.BaseEntity.Name = ((BoxEntity)_createdEntity).GetEntityName();
            _createdEntity.BaseEntity.SetPosition(new Vector3(0, 3, 0));
            _createdEntity.BaseEntity.SetRotation(new Vector3(0, 0, 0));
            _createdEntity.BaseEntity.SetScale(((BoxEntity)_createdEntity).Scale);

            _createdEntity.BaseEntity.AddComponent(_createdEntity);

            PulsarModel model = new PulsarModel(((BoxEntity)_createdEntity).GetEntityName())
            {
                PulsarComponentClass = PulsarComponent.ComponentClass.Node,
                PulsarComponentType  = PulsarComponent.ComponentType.Model
            };

            _createdEntity.BaseEntity.AddComponent(model);
            model.SetModel("Models/Box.mdl");

            PulsarMaterial material = new PulsarMaterial(((BoxEntity)_createdEntity).GetEntityName())
            {
                PulsarComponentClass = PulsarComponent.ComponentClass.Node,
                PulsarComponentType  = PulsarComponent.ComponentType.Material
            };

            _createdEntity.BaseEntity.AddComponent(material);
            material.SetMaterial("Materials/StoneTiled.xml");

            model.SetMaterial(material);
            ((BoxEntity)_createdEntity).CreateEntity();

            _createdEntity.BaseEntity.SetupProperties();

            //ensure the gizmo is not visible on first creation
            _createdEntity.BaseEntity.GetGizmo().SetGizmoVisible(false);

            Gizmo gizmo = _createdEntity.BaseEntity.GetGizmo();

            if (gizmo != null)
            {
                gizmo.GizmoEnabled = false;
            }
            //_createdEntity.BaseEntity.GetGizmo().Enabled = false;
        }
Example #5
0
        public void ResetGizmosAndMaterials()
        {
            Debug.Print("ResetGizmosAndMaterials - entered...");
            if (_selectedObjects.Count == 0)
            {
                Debug.Print("ResetGizmosAndMaterials - returning because _selectedObjects.Count was zero!");
                return;
            }

            Debug.Print("ResetGizmosAndMaterials - Processing " + _selectedObjects.Count.ToString() + " selected objects...");
            foreach (SelectedObject selectedObject in _selectedObjects)
            {
                if (selectedObject != null)
                {
                    if (!selectedObject.SelectedNode.IsDeleted)
                    {
                        PulsarModel pulsarModel = selectedObject.SelectedNode.GetComponent <PulsarModel>();
                        if (pulsarModel != null)
                        {
                            BaseEntity baseEntity = pulsarModel.GetBaseEntity();
                            if (baseEntity != null)
                            {
                                Debug.Print("ResetGizmosAndMaterials - Calling baseEntity.UnSelect...");
                                baseEntity.UnSelect();
                            }
                            else
                            {
                                Debug.Print("ResetGizmosAndMaterials - baseEntity of pulsarModel " + pulsarModel.Node.Name + " was null - unable to UnSelect!!!");
                            }
                        }
                        else
                        {
                            Debug.Print("ResetGizmosAndMaterials - pulsarModel of " + selectedObject.SelectedNode.Name + " was null!");
                        }
                    }
                    else
                    {
                        Debug.Print("ResetGizmosAndMaterials - selectedObject.SelectedNode was deleted!");
                    }
                }
                else
                {
                    Debug.Print("ResetGizmosAndMaterials - selectedObject was null!");
                }
            }
        }
Example #6
0
        public void CreateSphere()
        {
            _createdEntity = new SphereEntity("sphere" + _currentEntityIndex++.ToString(), this, SceneDebugRenderer, InDesign)
            {
                Scale = new Vector3(5.0f, 5.0f, 5.0f),
                PulsarComponentClass = PulsarComponent.ComponentClass.Node,
                PulsarComponentType  = PulsarComponent.ComponentType.Sphere,
                InDesign             = _inDesign,
                Diameter             = 5.0f
            };

            _createdEntity.BaseEntity.Name = ((SphereEntity)_createdEntity).GetEntityName();
            _createdEntity.BaseEntity.SetPosition(new Vector3(10, 3, 0));
            _createdEntity.BaseEntity.SetRotation(new Vector3(0, 0, 0));
            _createdEntity.BaseEntity.SetScale(((SphereEntity)_createdEntity).Scale);

            _createdEntity.BaseEntity.AddComponent(_createdEntity);

            PulsarModel model = new PulsarModel(((SphereEntity)_createdEntity).GetEntityName())
            {
                PulsarComponentClass = PulsarComponent.ComponentClass.Node,
                PulsarComponentType  = PulsarComponent.ComponentType.Model
            };

            _createdEntity.BaseEntity.AddComponent(model);
            model.SetModel("Models/Sphere.mdl");

            PulsarMaterial material = new PulsarMaterial(((SphereEntity)_createdEntity).GetEntityName())
            {
                PulsarComponentClass = PulsarComponent.ComponentClass.Node,
                PulsarComponentType  = PulsarComponent.ComponentType.Material
            };

            _createdEntity.BaseEntity.AddComponent(material);
            material.SetMaterial("Materials/StoneTiled.xml");

            model.SetMaterial(material);
            ((SphereEntity)_createdEntity).CreateEntity();

            _createdEntity.BaseEntity.SetupProperties();

            //ensure the gizmo is not visible on first creation
            _createdEntity.BaseEntity.GetGizmo().SetGizmoVisible(false);
        }
Example #7
0
        public void CreateCone()
        {
            var entity = new ConeEntity("cone" + _currentEntityIndex++.ToString())
            {
                PulsarComponentClass = PulsarComponent.ComponentClass.Node,
                PulsarComponentType  = PulsarComponent.ComponentType.Cone,
                InDesign             = _inDesign,
                Diameter             = 5.0f,
                Height = 5.0f,
                Scale  = new Vector3(5, 5, 5)
            };

            BaseEntity baseEntity = new BaseEntity
                                    (
                entity.GetEntityName(),
                this,
                SceneDebugRenderer,
                new Vector3(10, 2.5f, 0),
                new Vector3(0, 0, 0),
                entity.Scale
                                    )
            {
                InDesign = _inDesign
            };

            baseEntity.AddComponent(entity);

            PulsarModel model = new PulsarModel(entity.GetEntityName());

            baseEntity.AddComponent(model);
            model.SetModel("Models/Cone.mdl");

            PulsarMaterial material = new PulsarMaterial(entity.GetEntityName());

            baseEntity.AddComponent(material);
            material.SetMaterial("Materials/StoneTiled.xml");

            model.SetMaterial(material);
            entity.CreateEntity();

            //ensure the gizmo is not visible on first creation
            baseEntity.GetGizmo().SetGizmoVisible(false);
        }
Example #8
0
        public void CreateCylinder()
        {
            var entity = new CylinderEntity("cylinder" + _currentEntityIndex++.ToString())
            {
                PulsarComponentClass = PulsarComponent.ComponentClass.Node,
                PulsarComponentType  = PulsarComponent.ComponentType.Cylinder,
                InDesign             = _inDesign,
                Diameter             = 5.0f,
                Height = 5.0f,
                Scale  = new Vector3(1, 1, 1)
            };

            BaseEntity baseEntity = new BaseEntity
                                    (
                entity.GetEntityName(),
                this,
                SceneDebugRenderer,
                new Vector3(-5, 2.5f, 0),
                new Vector3(0, 0, 0),
                entity.Scale
                                    )
            {
                InDesign = _inDesign
            };

            baseEntity.AddComponent(entity);

            PulsarModel model = new PulsarModel(entity.GetEntityName());

            baseEntity.AddComponent(model);
            model.SetModel("Models/Cylinder.mdl");

            PulsarMaterial material = new PulsarMaterial(entity.GetEntityName());

            baseEntity.AddComponent(material);
            material.SetMaterial("Materials/StoneTiled.xml");

            model.SetMaterial(material);
            entity.CreateEntity();
        }
Example #9
0
        public void CreateBox()
        {
            _createdEntity = new BoxEntity("box" + _currentEntityIndex++.ToString(), this, SceneDebugRenderer, _inDesign)
            {
                Scale = new Vector3(1.0f, 1.0f, 1.0f),
                PulsarComponentClass = PulsarComponent.ComponentClass.Node,
                PulsarComponentType  = PulsarComponent.ComponentType.Box,
                InDesign             = _inDesign
            };

            _createdEntity.BaseEntity.Name = ((BoxEntity)_createdEntity).GetEntityName();
            _createdEntity.BaseEntity.SetPosition(new Vector3(0, 3, 0));
            _createdEntity.BaseEntity.SetRotation(new Vector3(0, 0, 0));
            _createdEntity.BaseEntity.SetScale(((BoxEntity)_createdEntity).Scale);

            _createdEntity.BaseEntity.AddComponent(_createdEntity);

            PulsarModel model = new PulsarModel(((BoxEntity)_createdEntity).GetEntityName())
            {
                PulsarComponentClass = PulsarComponent.ComponentClass.Node,
                PulsarComponentType  = PulsarComponent.ComponentType.Model
            };

            _createdEntity.BaseEntity.AddComponent(model);
            model.SetModel("Models/Box.mdl");

            PulsarMaterial material = new PulsarMaterial(((BoxEntity)_createdEntity).GetEntityName())
            {
                PulsarComponentClass = PulsarComponent.ComponentClass.Node,
                PulsarComponentType  = PulsarComponent.ComponentType.Material
            };

            _createdEntity.BaseEntity.AddComponent(material);
            material.SetMaterial("Materials/StoneTiled.xml");

            model.SetMaterial(material);
            ((BoxEntity)_createdEntity).CreateEntity();

            _createdEntity.BaseEntity.SetupProperties();
        }