Distinction.h

#pragma once


namespace Core
{
    /// 識別
    public ref class Distinction
    {
    // Construction --------------------------------------------------------
    public:
        ~Distinction() { Distinction::!Distinction(); }
        !Distinction()
        {
            delete m_figure;
        }


    // Operation -----------------------------------------------------------
    protected:
        void SetupMaterial( Microsoft::DirectX::Direct3D::Device^ device )
        {
            device->RenderState->Lighting = true;   // ライトを有効
            device->Material = m_material;          // マテリアル
        }


    // Attribute ===========================================================
    private:
        System::String^ m_name;     ///< 名称

        Microsoft::DirectX::Direct3D::Mesh^ m_figure;          ///< 図形
        Microsoft::DirectX::Direct3D::Material m_material;     ///< マテリアル

        Microsoft::DirectX::Matrix m_worldTransformOfFigure;   ///< 図形のワールド変換行列


    // Property ------------------------------------------------------------
    public:
        /// 名称
        [ System::ComponentModel::Browsable( false ) ]  // 参照不可
        property System::String^ Name
        {
            System::String^ get()
            {
                return m_name;
            }
            void set( System::String^ value )
            {
                System::Diagnostics::Debug::Assert( value != System::String::Empty, "空文字ではない" );
                m_name = value;
            }
        }


        /// 図形
        [ System::ComponentModel::Browsable( false ) ]  // 参照不可
        property Microsoft::DirectX::Direct3D::Mesh^ Figure
        {
            Microsoft::DirectX::Direct3D::Mesh^ get()
            {
                return m_figure;
            }
        protected:
            void set( Microsoft::DirectX::Direct3D::Mesh^ value )
            {
                m_figure = value;
            }
        }

        /// 色
        [ System::ComponentModel::Browsable( false ) ]  // 参照不可
        property System::Drawing::Color Color
        {
        public:
            void set( System::Drawing::Color value )
            {
                m_material.Ambient = value; // 環境光に対する反射係数
                m_material.Diffuse = value; // 拡散反射係数
            }
        }

        /// 図形のワールド変換行列
        [ System::ComponentModel::Browsable( false ) ]  // 参照不可
        property Microsoft::DirectX::Matrix WorldTransformOfFigure
        {
            Microsoft::DirectX::Matrix get()
            {
                return m_worldTransformOfFigure;
            }
        protected:
            void set( Microsoft::DirectX::Matrix value )
            {
                m_worldTransformOfFigure = value;
            }
        }
    };
}