1 /*---------------------------------------------------------------------------*
2   Project:  NintendoWare
3   File:     gfx_Light.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: 23822 $
14  *---------------------------------------------------------------------------*/
15 
16 #ifndef NW_GFX_LIGHT_H_
17 #define NW_GFX_LIGHT_H_
18 
19 #include <nw/gfx/gfx_TransformNode.h>
20 #include <nw/gfx/res/gfx_ResLight.h>
21 
22 namespace nw
23 {
24 namespace gfx
25 {
26 
27 //---------------------------------------------------------------------------
28 //! @brief        ライトを表すクラスです。
29 //---------------------------------------------------------------------------
30 class Light : public TransformNode
31 {
32 private:
33     NW_DISALLOW_COPY_AND_ASSIGN(Light);
34 
35 public:
36     NW_UT_RUNTIME_TYPEINFO;
37 
38     //! @brief 設定内容です。
39     struct Description : public TransformNode::Description
40     {
41         //! @brief コンストラクタです。
DescriptionDescription42         Description(){}
43     };
44 
45 
46     //----------------------------------------
47     //! @name シーンツリー
48     //@{
49 
50     //! @brief        ビジターを受け付けます。
51     //!
52     //! @param[in]    visitor ビジターです。
53     //!
54     virtual void Accept(ISceneVisitor* visitor);
55 
56     //@}
57 
58     //----------------------------------------
59     //! @name アニメーション
60     //@{
61 
62     //! @brief アニメーショングループを取得します。
63     //!
64     //! ライトを DynamicBuilder で生成した場合は NULL を返します。
65     //! その場合、アニメーションは設定できません。
GetAnimGroup()66     AnimGroup* GetAnimGroup() { return m_AnimGroup; }
67 
68     //! @brief アニメーショングループを取得します。
69     //!
70     //! ライトを DynamicBuilder で生成した場合は NULL を返します。
71     //! その場合、アニメーションは設定できません。
GetAnimGroup()72     const AnimGroup* GetAnimGroup() const { return m_AnimGroup; }
73 
74     //! @brief アニメーションオブジェクトを取得します。
GetAnimObject()75     AnimObject* GetAnimObject()
76     {
77         NW_NULL_ASSERT(m_AnimBinding);
78         return m_AnimBinding->GetAnimObject(0);
79     }
80 
81     //! @brief アニメーションオブジェクトを取得します。
GetAnimObject()82     const AnimObject* GetAnimObject() const
83     {
84         NW_NULL_ASSERT(m_AnimBinding);
85         return m_AnimBinding->GetAnimObject(0);
86     }
87 
88     //! @brief アニメーションオブジェクトを設定します。
SetAnimObject(AnimObject * animObject)89     void SetAnimObject(AnimObject* animObject)
90     {
91         NW_NULL_ASSERT(m_AnimBinding);
92         m_AnimBinding->SetAnimObject(0, animObject);
93     }
94 
95     //@}
96 
97 protected:
98     //----------------------------------------
99     //! @name コンストラクタ/デストラクタ
100     //@{
101 
102     //! コンストラクタです。
Light(os::IAllocator * allocator,ResTransformNode resObj,const Light::Description & description)103     Light(
104         os::IAllocator* allocator,
105         ResTransformNode resObj,
106         const Light::Description& description)
107     : TransformNode(
108         allocator,
109         resObj,
110         description),
111       m_OriginalValue(NULL),
112       m_AnimGroup(NULL)
113     {}
114 
115     //! デストラクタです。
~Light()116     virtual ~Light()
117     {
118         ut::SafeDestroy(m_AnimGroup);
119     }
120 
121     //@}
122 
123     //! @brief アニメーショングループを作成します。
124     Result CreateAnimGroup(os::IAllocator* allocator);
125 
126     //! @brief アニメーションに登録するモデルデータのポインタを取得します。
127     void* GetAnimTargetObject(const anim::ResAnimGroupMember& anim);
128 
129     //! @brief OriginalValueを破棄します。
130     void DestroyOriginalValue();
131 
132     ResLight m_OriginalValue;
133     math::Transform3 m_OriginalTransform;
134 
135 private:
136     AnimGroup* m_AnimGroup;
137 };
138 
139 } // namespace gfx
140 } // namespace nw
141 
142 #endif // NW_GFX_LIGHT_H_
143