1 /*---------------------------------------------------------------------------*
2   Project:  NintendoWare
3   File:     gfx_CameraProjectionUpdater.h
4 
5   Copyright (C)2009-2010 Nintendo Co., Ltd./HAL Laboratory, Inc.  All rights reserved.
6 
7   These coded instructions, statements, and computer programs contain
8   proprietary information of Nintendo of America Inc. and/or Nintendo
9   Company Ltd., and are protected by Federal copyright law.  They may
10   not be disclosed to third parties or copied or duplicated in any form,
11   in whole or in part, without the prior written consent of Nintendo.
12 
13   $Revision: 27365 $
14  *---------------------------------------------------------------------------*/
15 
16 #ifndef NW_GFX_CAMERAPROJECTIONUPDATER_H_
17 #define NW_GFX_CAMERAPROJECTIONUPDATER_H_
18 
19 #include <nw/gfx/gfx_GfxObject.h>
20 #include <nw/gfx/res/gfx_ResCamera.h>
21 
22 namespace nw
23 {
24 
25 namespace math
26 {
27     struct VEC2;
28     struct Transform3;
29     struct MTX34;
30 }
31 
32 namespace ut
33 {
34     struct Rect;
35 }
36 
37 namespace gfx
38 {
39 
40 //---------------------------------------------------------------------------
41 //! @brief        プロジェクションマトリクスを更新するインタフェースです。
42 //!
43 //! ICameraProjectionUpdater は廃止され CameraProjectionUpdater に変更されました。
44 //---------------------------------------------------------------------------
45 class CameraProjectionUpdater : public GfxObject
46 {
47 private:
48     NW_DISALLOW_COPY_AND_ASSIGN(CameraProjectionUpdater);
49 
50 public:
51     NW_UT_RUNTIME_TYPEINFO;
52 
53     //----------------------------------------
54     //! @name プロジェクションマトリクス
55     //@{
56 
57     //---------------------------------------------------------------------------
58     //! @brief        プロジェクションマトリクスを更新します。
59     //!
60     //! @param[in]    projectionMatrix  更新するプロジェクションマトリクスです。
61     //! @param[in]    textureProjectionMatrix 更新するプロジェクションテクスチャ用射影行列です。
62     //---------------------------------------------------------------------------
63     virtual void Update(math::MTX44* projectionMatrix, math::Matrix34* textureProjectionMatrix) = 0;
64 
65     //@}
66 
67     //----------------------------------------
68     //! @name ピボット
69     //@{
70 
71     //! @brief 画面の上方向を設定します。
72     //!
73     //! @param[in] pivot 画面の上方向です。
SetPivotDirection(math::PivotDirection pivot)74     void SetPivotDirection( math::PivotDirection pivot) { this->m_Pivot = pivot; }
75 
76     //! @brief 画面の上方向を取得します。
77     //!
78     //! @return 画面の上方向です。
GetPivotDirection()79     math::PivotDirection GetPivotDirection() const { return this->m_Pivot; }
80 
81     //@}
82 
83     //! 動的に生成されたアップデータかどうかのフラグを取得します。
IsDynamic()84     bool IsDynamic()
85     {
86         return this->m_IsDynamic;
87     }
88 
89     //----------------------------------------
90     //! @name リソース
91     //@{
92 
93     //! プロジェクションアップデータのリソースを取得します。
94     virtual ResCameraProjectionUpdater GetResource() = 0;
95 
96     //! プロジェクションアップデータのリソースを取得します。
97     virtual const ResCameraProjectionUpdater GetResource() const = 0;
98 
99     //@}
100 
101     //----------------------------------------
102     //! @name テクスチャ
103     //@{
104 
105     //! @brief テクスチャのスケールを取得します。
TextureScale()106     math::VEC2& TextureScale() { return m_TextureScale; }
107 
108     //! @brief テクスチャのスケールを取得します。
TextureScale()109     const math::VEC2& TextureScale() const { return m_TextureScale; }
110 
111     //! @brief テクスチャの平行移動を取得します。
TextureTranslate()112     math::VEC2& TextureTranslate() { return m_TextureTranslate; }
113 
114     //! @brief テクスチャの平行移動を取得します。
TextureTranslate()115     const math::VEC2& TextureTranslate() const { return m_TextureTranslate; }
116 
117     //@}
118 
119     //! @brief ProjectionUpdaterの種類を取得します。
120     virtual anim::ResCameraAnimData::ProjectionUpdaterKind Kind() const = 0;
121 
122 protected:
123 
124     //! @brief コンストラクタです。
CameraProjectionUpdater(os::IAllocator * allocator,bool isDynamic)125     CameraProjectionUpdater(os::IAllocator* allocator, bool isDynamic)
126         : GfxObject(allocator),
127         m_Pivot(math::PIVOT_NONE),
128         m_IsDynamic(isDynamic),
129         m_TextureScale(0.5f, 0.5f),
130         m_TextureTranslate(0.5f, 0.5f)
131     {}
132 
133     //! @brief デストラクタです。
~CameraProjectionUpdater()134     virtual ~CameraProjectionUpdater(){}
135 
136 private:
137     math::PivotDirection m_Pivot;
138     bool m_IsDynamic;
139     math::VEC2 m_TextureScale;
140     math::VEC2 m_TextureTranslate;
141 
142 protected:
143     //! ニアクリップのデフォルト値です。
144     static const float PROJECTION_NEAR_CLIP;
145     //! ファークリップのデフォルト値です。
146     static const float PROJECTION_FAR_CLIP;
147     //! FOVのY方向のデフォルト値です。
148     static const float PROJECTION_FOVY_RADIAN;
149     //! アスペクト比のデフォルト値です。
150     static const float PROJECTION_ASPECT_RATIO;
151     //! ニアクリップ面での中心座標のデフォルト値です。
152     static const math::VEC2 PROJECTION_CENTER;
153     //! ニアクリップ面での高さのデフォルト値です。
154     static const float PROJECTION_HEIGHT;
155     //! ニアクリップ面での表示矩形のデフォルト値です。
156     static const ResProjectionRect PROJECTION_RECT;
157 };
158 
159 } // namespace gfx
160 } // namespace nw
161 
162 #endif // NW_GFX_CAMERAPROJECTIONUPDATER_H_
163