using System;
using System.Collections.Generic;
using System.Text;
using Microsoft.DirectX;
using Microsoft.DirectX.Direct3D;
using Microsoft.Samples.DirectX.UtilityToolkit;

namespace DXGfxLib
{
    /// <summary>
    /// This is a MeshObject which uses a MeshRessource.
    /// </summary>
    public class ObjectFromMeshRessource : MeshObject
    {
        /// <summary>
        /// Most of the time we are going to attach full framework Mesh to our scene object so we keep a possible ref to that 
        /// in the base SceneObject class. This might be moved to a derive class in the future but it does suit my current needs.
        /// </summary>
        protected MeshRessource meshRessource = null;

        /// <summary>
        /// This method is used to associate a FrameworkMesh instance to the SceneObject.
        /// </summary>
        /// <param name="meshToAttach"></param>
        public void Attach(MeshRessource meshRessource)
        {
            this.meshRessource = meshRessource;
            base.Attach(meshRessource.GetDXMesh());
        }



        /// <summary>
        /// In its draw method the scene will call the Draw method on all scene object (or derived class instances) that
        /// have registered to be rendered in the AttachForRendering method.
        /// </summary>
        /// <param name="device"></param>
        public override void Draw(Device device)
        {
            device.SetTransform(TransformType.World, worldMat);
            meshRessource.Draw(device);
        }
    }
}
