Example #1
0
        public BoxEntity(string name, PulsarScene scene, DebugRenderer debugRenderer, bool inDesign)
        {
            _name  = name;
            _scene = scene;

            if (_scene != null)
            {
                _node = _scene.CreateChild(_name);
                if (_node != null)
                {
                    _baseEntity             = _node.CreateComponent <BaseEntity>();
                    _baseEntity.Name        = name;
                    _baseEntity.Node        = _node;
                    _baseEntity.PulsarScene = scene;
                    _baseEntity.SetDebugRenderer(debugRenderer);
                    InDesign             = inDesign;
                    _baseEntity.InDesign = inDesign;
                    base.BaseEntity      = _baseEntity;
                    CreateEntity();
                }
            }
            PulsarComponentClass = ComponentClass.Node;
            PulsarComponentType  = ComponentType.NodeProperties;

            RegisterForMessages();
        }
Example #2
0
        public BaseEntity(string name, PulsarScene scene, DebugRenderer debugRenderer, Vector3 position, Vector3 rotation, Vector3 scale)
        {
            _components          = new List <PulsarComponent>();
            _componentProperties = new List <PulsarComponent>();

            _name          = name;
            _scene         = scene;
            _debugRenderer = debugRenderer;

            if (scene != null)
            {
                _node = scene.CreateChild(_name);
                if (_node != null)
                {
                    _node.AddComponent(this);
                    _pulsarActions = new PulsarActions(_node);
                }
            }

            SetPosition(position);
            SetRotation(rotation);
            SetScale(scale);
            CreateEntity();
            ReceiveSceneUpdates = true;
        }
Example #3
0
        public void CreateGizmo()
        {
            Node gizmoNode;

            try
            {
                gizmoNode = _scene.CreateChild(_node.Name + "_gizmo");
            }
            catch (PulsarGizmoException sceneNodeCreateException)
            {
                sceneNodeCreateException.Source  = "[BaseEntity:CreateGizmo]";
                sceneNodeCreateException.Message = "Failed to create Gizmo child node in Scene.";
                throw sceneNodeCreateException;
            }

            try
            {
                _gizmo = new Gizmo(_node.Name + "_gizmo", _scene, gizmoNode, this);
            }
            catch (PulsarGizmoException createGizmoException)
            {
                createGizmoException.Source  = "[BaseEntity:CreateGizmo]";
                createGizmoException.Message = "Failed to create Gizmo component.";
                throw createGizmoException;
            }

            gizmoNode.AddComponent(_gizmo);

            if (_gizmo.Node != null)
            {
                _gizmo.Node.Position = _node.Position;
            }
            //grab the bounds of the entity
            _gizmo.Size = Vector3.One;

            try
            {
                _gizmo.Initialise();
            }
            catch (PulsarGizmoException initialiseGizmoException)
            {
                initialiseGizmoException.Source  = "[BaseEntity:CreateGizmo]";
                initialiseGizmoException.Message = "Failed to initialise Gizmo.";
                throw initialiseGizmoException;
            }

            _hasGizmo = true;
        }
Example #4
0
        public BaseEntity(string name, PulsarScene scene)
        {
            _components          = new List <PulsarComponent>();
            _componentProperties = new List <PulsarComponent>();

            _name  = name;
            _scene = scene;

            if (scene != null)
            {
                _node = scene.CreateChild(_name);
                if (_node != null)
                {
                    _node.AddComponent(this);
                }
            }
        }
Example #5
0
        private void CreateGizmo()
        {
            var gizmoNode = _scene.CreateChild(_node.Name + "_gizmo");

            _gizmo = new Gizmo(_node.Name + "_gizmo", _scene, gizmoNode, this);
            gizmoNode.AddComponent(_gizmo);
            _gizmo.Node.Position = _node.Position;

            //grab the bounds of the entity
            _gizmo.Size         = Vector3.One;
            _gizmo.GizmoEnabled = false;
            Debug.Print("BaseEntity.CreateGizmo - Set GizmoEnabled to false for gizmo '" + _gizmo.Name + "'");
            _gizmo.Initialise();
            Debug.Print("BaseEntity.CreateGizmo - Called gizmo.Initialisecfor gizmo '" + _gizmo.Name + "'");
            _gizmo.SetGizmoVisible(false);
            Debug.Print("BaseEntity.CreateGizmo - Called gizmo SetGizmoVisible with value false");

            _hasGizmo = true;
        }
Example #6
0
        public BaseEntity(string name, PulsarScene scene)
        {
            _components          = new List <PulsarComponent>();
            _componentProperties = new List <PulsarComponent>();

            _name  = name;
            _scene = scene;

            if (scene != null)
            {
                _node = scene.CreateChild(_name);
                if (_node != null)
                {
                    _node.AddComponent(this);
                    _pulsarActions = new PulsarActions(_node);
                }
            }
            ReceiveSceneUpdates = true;
        }
Example #7
0
        public BaseEntity(string name, PulsarScene scene, DebugRenderer debugRenderer, Vector3 position)
        {
            _components          = new List <PulsarComponent>();
            _componentProperties = new List <PulsarComponent>();

            _name          = name;
            _scene         = scene;
            _debugRenderer = debugRenderer;

            if (scene != null)
            {
                _node = scene.CreateChild(_name);
                if (_node != null)
                {
                    _node.AddComponent(this);
                }
            }

            SetPosition(position);
            CreateEntity();
        }
Example #8
0
        public void CreateEntity()
        {
            if (_node == null)
            {
                if (_scene != null)
                {
                    _node = _scene.CreateChild(_name);
                }
            }

            if (_node != null)
            {
                if (_baseEntity == null)
                {
                    _baseEntity = _node.CreateComponent <BaseEntity>();
                }
            }

            _wirePlane = new Urho.WirePlane()
            {
                Scale = _scale,
                Size  = _size,
                Color = _color
            };

            if (_node != null)
            {
                _node.AddComponent(_wirePlane);
            }

            if (!InDesign)
            {
                RigidBody rigidBody = Node.CreateComponent <RigidBody>();
                rigidBody.Mass = 1.0f;
                rigidBody.SetAngularFactor(Vector3.Zero);
                CollisionShape planeShape = Node.CreateComponent <CollisionShape>(CreateMode.Local);
                planeShape.SetStaticPlane(Position, Quaternion.Identity);
                rigidBody.DrawDebugGeometry(DebugRenderer, false);
            }
        }
Example #9
0
 public void CreateEntity()
 {
     _node = _scene.CreateChild(_name);
 }