Draw.h

#pragma once


// DirectXのライブラリによる const/volatile 修飾子の使用の警告を抑制する
#pragma warning( disable : 4400 )


namespace Core
{
    ref class DrawModel;
    ref class DrawScene;

    ref class Distinction;


    /// 描画
    public ref class Draw
    {
    // Construction --------------------------------------------------------
    public:
        Draw();

        ~Draw() { Draw::!Draw(); }
        !Draw();


    // Operation -----------------------------------------------------------
    public:
        bool Initialize( System::Windows::Forms::Control^ control, System::Object^ obj );
        void SetupScreenSize( int width, int height);

        void RotateViewpoint( float azimuthAngle, float zenithAngle );
        void TranslateViewpoint( float x, float y );

        void Render();

        bool SelectObject( System::Drawing::Point positionToSelect );

    private:
        bool IsDeviceEnable();

        void SetupLights();
        void SetupView();
        void SetupCamera();
        void Clear( System::Drawing::Color color );


    // Event Handler -------------------------------------------------------
    private:
        void ResetDevice( System::Object^ sender, System::EventArgs^ e );


    // Attribute ===========================================================
    private:
        Microsoft::DirectX::Direct3D::Device^ m_device;     ///< デバイス

        DrawModel^ m_drawModel;     ///< モデルの描画
        DrawScene^ m_drawScene;     ///< 背景の描画

        float m_azimuthAngle;       ///< 方位角[ red ]
        float m_zenithAngle;        ///< 天頂角[ red ]

        Microsoft::DirectX::Vector3 m_viewPoint; ///< 視点
        float m_scale;                           ///< 縮尺

        System::Drawing::Color m_lightColor;     ///< ライトの色


    // Property ------------------------------------------------------------
    public:
        /// 視点
        property Microsoft::DirectX::Vector3 Viewpoint
        {
        private:
            Microsoft::DirectX::Vector3 get();
        }

        /// 縮尺
        property float Scale
        {
            float get()
            {
                return m_scale;
            }
            void set( float value );
        }


        /// モデル
        property DrawModel^ Model
        {
            DrawModel^ get()
            {
                return m_drawModel;
            }
        }
    };
}