Beispiel #1
0
        /// <summary>
        /// Deserializes the object and populates it from the input.
        /// </summary>
        /// <param name="input">Savable input</param>
        public virtual void Read(ISavableReader input)
        {
            _name                      = input.ReadString();
            _localTransform            = input.ReadSavable <Transform>();
            _sceneHints                = input.ReadSavable <SceneHints>();
            _sceneHints.HintableSource = this;
            _localLights               = input.ReadSavable <LightCollection>();
            _localLights._spatial      = this;

            bool hasControllers = input.ReadBoolean();

            _controllers = new TeslaList <ISpatialController>(1);

            if (hasControllers)
            {
                ISavable[] savableControllers = input.ReadSavableArray <ISavable>();
                for (int i = 0; i < savableControllers.Length; i++)
                {
                    ISpatialController controller = savableControllers[i] as ISpatialController;
                    if (controller != null)
                    {
                        _controllers.Add(controller);
                    }
                }
            }

            _worldTransform   = new Transform(_localTransform);
            _frustumIntersect = ContainmentType.Intersects;
            _parent           = null;
            _dirtyMark        = DirtyMark.Bounding | DirtyMark.Transform | DirtyMark.Lighting;
        }
Beispiel #2
0
        /// <summary>
        /// Creates a new spatial with the specified name.
        /// </summary>
        /// <param name="name"></param>
        public Spatial(String name)
        {
            _name = name;

            _parent         = null;
            _localTransform = new Transform();
            _worldTransform = new Transform();
            _controllers    = new TeslaList <ISpatialController>(1);
            _dirtyMark      = DirtyMark.Bounding | DirtyMark.Transform | DirtyMark.Lighting;
            _sceneHints     = new SceneHints(this);
            _localLights    = new LightCollection(this);
        }
Beispiel #3
0
        /// <summary>
        /// Deserializes the object and populates it from the input.
        /// </summary>
        /// <param name="input">Savable input</param>
        public override void Read(ISavableReader input)
        {
            base.Read(input);

            Spatial[] spatials = input.ReadSavableArray <Spatial>();
            _children = new TeslaList <Spatial>();

            for (int i = 0; i < spatials.Length; i++)
            {
                Spatial spatial = spatials[i];
                if (spatial != null)
                {
                    spatial.Parent = this;
                    _children.Add(spatial);
                }
            }
        }
Beispiel #4
0
 /// <summary>
 /// Creates a new instance of <see cref="InputLayer"/> which is by default enabled.
 /// </summary>
 public InputLayer()
 {
     _triggers  = new TeslaList <InputTrigger>();
     _isEnabled = true;
 }
Beispiel #5
0
 /// <summary>
 /// Creates a new instance of Node with initial child capacity of 1.
 /// </summary>
 /// <param name="name">Name of the node</param>
 public Node(String name)
     : base(name)
 {
     _children = new TeslaList <Spatial>(1);
 }
Beispiel #6
0
 /// <summary>
 /// Creates a new instance of Node with the specified name and initial child capacity.
 /// </summary>
 /// <param name="name">Name of the node</param>
 /// <param name="initialChildCapacity">Initial child capacity</param>
 public Node(String name, int initialChildCapacity)
     : base(name)
 {
     _children = new TeslaList <Spatial>(initialChildCapacity);
 }