1 /*---------------------------------------------------------------------------*
2   Project:  NintendoWare
3   File:     gfx_BillboardUpdater.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: 22912 $
14  *---------------------------------------------------------------------------*/
15 
16 #ifndef NW_GFX_BILLBOARDUPDATER_H_
17 #define NW_GFX_BILLBOARDUPDATER_H_
18 
19 #include <nw/gfx/gfx_GfxObject.h>
20 #include <nw/gfx/res/gfx_ResSkeleton.h>
21 
22 namespace nw
23 {
24 namespace os
25 {
26 class IAllocator;
27 } // namesapce os
28 
29 namespace gfx
30 {
31 
32 class Matrix34;
33 
34 //---------------------------------------------------------------------------
35 //! @brief        ビルボードを計算するためのクラスです。
36 //---------------------------------------------------------------------------
37 class BillboardUpdater : public GfxObject
38 {
39 private:
40     NW_DISALLOW_COPY_AND_ASSIGN(BillboardUpdater);
41 
42 public:
43     //---------------------------------------------------------------------------
44     //! @brief        ビルボードアップデータを生成します。
45     //!
46     //! @param[in]    allocator アロケータです。
47     //!
48     //! @return       生成したビルボードアップデータを返します。
49     //---------------------------------------------------------------------------
50     static BillboardUpdater* Create(os::IAllocator* allocator);
51 
52     //---------------------------------------------------------------------------
53     //! @brief        ビルボード計算を行い、ワールドマトリクスを更新します。
54     //!
55     //! @param[out]    worldMatrix        更新するワールドマトリクスです。
56     //! @param[in]     viewMatrix         ビューマトリクスです。
57     //! @param[in]     inverseViewMatrix  ビューマトリクスの逆行列です。
58     //! @param[in]     cameraPosition     カメラ座標です。
59     //! @param[in]     worldTransform     ボーンのワールドトランスフォームです。
60     //! @param[in]     localTransform     ボーンのローカルトランスフォームです。
61     //! @param[in]     billboardMode      適応するビルボードの種類です。
62     //---------------------------------------------------------------------------
63     void Update(
64         math::MTX34* worldMatrix,
65         const math::MTX34& viewMatrix,
66         const math::MTX34& inverseViewMatrix,
67         const math::VEC3& cameraPosition,
68         const CalculatedTransform& worldTransform,
69         const CalculatedTransform& localTransform,
70         ResBone::BillboardMode billboardMode) const;
71 
72 private:
73     //! コンストラクタです。
74     BillboardUpdater(os::IAllocator* allocator);
75 
76     //! デストラクタです。
77     virtual ~BillboardUpdater();
78 
79     void CalculateLocalMatrix(
80         math::MTX34* localMatrix,
81         const CalculatedTransform& transform,
82         math::VEC3 zAxis,
83         bool recalculateYAxis = true) const;
84 
85     void CalculateScreenLocalMatrix(
86         math::MTX34* localMatrix,
87         const CalculatedTransform& transform,
88         const math::MTX34& inverseViewMatrix,
89         math::VEC3 yAxis,
90         math::VEC3& zAxis) const;
91 };
92 
93 } // namespace gfx
94 } // namespace nw
95 
96 #endif // NW_GFX_BILLBOARDUPDATER_H_
97