Example #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;
        }
Example #2
0
        /// <summary>
        /// Collects all the lights from this Spatial up to the root, copying all lights at each node.
        /// </summary>
        /// <param name="lights">Light collection that will contain the copied lights</param>
        protected void CollectLights(LightCollection lights)
        {
            lights.CopyLights(_localLights);

            if (_parent != null)
            {
                _parent.CollectLights(lights);
            }
        }
Example #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);
     //  _material = input.ReadExternal<Material>();
     _meshData    = input.ReadSavable <MeshData>();
     _modelBound  = input.ReadSavable <BoundingVolume>();
     _worldLights = new LightCollection();
     SetModelBound(_modelBound);
 }
Example #4
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);
        }
Example #5
0
 /// <summary>
 /// Creates a new Mesh using the supplied MeshData object, which may or may not be null. Useful
 /// if multiple meshes are to share the same geometry.
 /// </summary>
 /// <param name="name">Mesh name.</param>
 /// <param name="meshData">Mesh data, may be null</param>
 public Mesh(String name, MeshData meshData)
     : base(name)
 {
     _meshData    = meshData;
     _worldLights = new LightCollection();
 }