1 /*---------------------------------------------------------------------------*
2   Project:  NintendoWare
3   File:     gfx_LookAtTargetViewUpdater.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: 27868 $
14  *---------------------------------------------------------------------------*/
15 
16 #ifndef NW_GFX_LOOKATTARGETVIEWUPDATER_H_
17 #define NW_GFX_LOOKATTARGETVIEWUPDATER_H_
18 
19 #include <nw/gfx/gfx_CameraViewUpdater.h>
20 #include <nw/ut/ut_Preprocessor.h>
21 
22 namespace nw
23 {
24 namespace os
25 {
26 class IAllocator;
27 } // namespace os
28 namespace gfx
29 {
30 
31 //---------------------------------------------------------------------------
32 //! @brief        カメラターゲットの座標と上方向ベクトルを用いてビューマトリクスを更新するクラスです。
33 //---------------------------------------------------------------------------
34 class LookAtTargetViewUpdater : public CameraViewUpdater
35 {
36 private:
37     NW_DISALLOW_COPY_AND_ASSIGN(LookAtTargetViewUpdater);
38 
39 public:
40     NW_UT_RUNTIME_TYPEINFO;
41 
42     //----------------------------------------
43     //! @name 作成/破棄
44     //@{
45 
46     //---------------------------------------------------------------------------
47     //! @brief        ビューマトリクスのアップデータを生成します。
48     //!
49     //! @param[in]    allocator アロケータです。
50     //!
51     //! @return       生成したビューマトリクスのアップデータです。
52     //---------------------------------------------------------------------------
53     static LookAtTargetViewUpdater* Create(os::IAllocator* allocator);
54 
55     //---------------------------------------------------------------------------
56     //! @brief        リソースからビューマトリクスのアップデータを生成します。
57     //!
58     //! @param[in]    allocator  アロケータです。
59     //! @param[in]    resUpdater アップデータのリソースです。
60     //!
61     //! @return       生成したビューマトリクスのアップデータです。
62     //---------------------------------------------------------------------------
63     static LookAtTargetViewUpdater* Create(
64         os::IAllocator* allocator,
65         ResLookAtTargetViewUpdater resUpdater);
66 
67     //! @details :private
GetMemorySizeInternal(os::MemorySizeCalculator * pSize,bool isDynamicBuild)68     static void GetMemorySizeInternal(
69         os::MemorySizeCalculator* pSize,
70         bool isDynamicBuild)
71     {
72         os::MemorySizeCalculator& size = *pSize;
73 
74         size += sizeof(LookAtTargetViewUpdater);
75         if (isDynamicBuild)
76         {
77             size += sizeof(ResLookAtTargetViewUpdaterData);
78         }
79     }
80 
81     //@}
82 
83     //----------------------------------------
84     //! @name ビューマトリクス
85     //@{
86 
87     //---------------------------------------------------------------------------
88     //! @brief        ビューマトリクスを更新します。
89     //!
90     //! @param[out]   viewMatrix      更新するビューマトリクスです。
91     //! @param[in]    worldMatrix     カメラのワールドマトリクスです。
92     //! @param[in]    cameraPosition  カメラ位置です。
93     //---------------------------------------------------------------------------
94     void virtual Update(
95         math::MTX34* viewMatrix,
96         const math::MTX34& worldMatrix,
97         const math::VEC3& cameraPosition);
98 
99     //@}
100 
101     //----------------------------------------
102     //! @name リソース
103     //@{
104 
105     //! ビューアップデータのリソースを取得します。
GetResource()106     virtual ResCameraViewUpdater GetResource()
107     {
108         return this->m_Resource;
109     }
110 
111     //! ビューアップデータのリソースを取得します。
GetResource()112     virtual const ResCameraViewUpdater GetResource() const
113     {
114         return this->m_Resource;
115     }
116 
117     //@}
118 
119     //! @brief ViewUpdaterの種類を取得します。
Kind()120     virtual anim::ResCameraAnimData::ViewUpdaterKind Kind() const
121     {
122         return anim::ResCameraAnimData::VIEW_UPDATER_LOOKAT;
123     }
124 
125 private:
126     //----------------------------------------
127     //! @name コンストラクタ/デストラクタ
128     //@{
129     //---------------------------------------------------------------------------
130     //! @brief        コンストラクタです。
131     //---------------------------------------------------------------------------
132     LookAtTargetViewUpdater(
133         os::IAllocator* pAllocator,
134         bool isDynamic,
135         ResLookAtTargetViewUpdater resUpdater);
136 
137     //---------------------------------------------------------------------------
138     //! @brief        デストラクタです。
139     //---------------------------------------------------------------------------
140     virtual ~LookAtTargetViewUpdater();
141     //@}
142 
143     ResLookAtTargetViewUpdater m_Resource;
144 };
145 
146 } // namespace gfx
147 } // namespace nw
148 
149 #endif // NW_GFX_LOOKATTARGETVIEWUPDATER_H_
150