1 /*---------------------------------------------------------------------------*
2   Project:  NintendoWare
3   File:     gfx_BillboardUpdater.h
4 
5   Copyright (C)2009-2011 Nintendo/HAL Laboratory, Inc.  All rights reserved.
6 
7   These coded instructions, statements, and computer programs contain proprietary
8   information of Nintendo and/or its licensed developers and are protected by
9   national and international copyright laws. They may not be disclosed to third
10   parties or copied or duplicated in any form, in whole or in part, without the
11   prior written consent of Nintendo.
12 
13   The content herein is highly confidential and should be handled accordingly.
14 
15   $Revision: 31311 $
16  *---------------------------------------------------------------------------*/
17 
18 #ifndef NW_GFX_BILLBOARDUPDATER_H_
19 #define NW_GFX_BILLBOARDUPDATER_H_
20 
21 #include <nw/gfx/gfx_GfxObject.h>
22 #include <nw/gfx/res/gfx_ResSkeleton.h>
23 
24 namespace nw
25 {
26 namespace os
27 {
28 class IAllocator;
29 } // namesapce os
30 
31 namespace gfx
32 {
33 
34 class Matrix34;
35 
36 //---------------------------------------------------------------------------
37 //! @brief        ビルボードを計算するためのクラスです。
38 //---------------------------------------------------------------------------
39 class BillboardUpdater : public GfxObject
40 {
41 private:
42     NW_DISALLOW_COPY_AND_ASSIGN(BillboardUpdater);
43 
44 public:
45     //---------------------------------------------------------------------------
46     //! @brief        ビルボードアップデータを生成します。
47     //!
48     //! @param[in]    allocator アロケータです。
49     //!
50     //! @return       生成したビルボードアップデータを返します。
51     //---------------------------------------------------------------------------
52     static BillboardUpdater* Create(os::IAllocator* allocator);
53 
54     //---------------------------------------------------------------------------
55     //! @brief        ビルボード計算を行い、ワールドマトリクスを更新します。
56     //!
57     //! @param[out]    worldMatrix        更新するワールドマトリクスです。
58     //! @param[in]     viewMatrix         ビューマトリクスです。
59     //! @param[in]     inverseViewMatrix  ビューマトリクスの逆行列です。
60     //! @param[in]     cameraPosition     カメラ座標です。
61     //! @param[in]     worldTransform     ボーンのワールドトランスフォームです。
62     //! @param[in]     localTransform     ボーンのローカルトランスフォームです。
63     //! @param[in]     billboardMode      適応するビルボードの種類です。
64     //---------------------------------------------------------------------------
65     void Update(
66         math::MTX34* worldMatrix,
67         const math::MTX34& viewMatrix,
68         const math::MTX34& inverseViewMatrix,
69         const math::VEC3& cameraPosition,
70         const CalculatedTransform& worldTransform,
71         const CalculatedTransform& localTransform,
72         ResBone::BillboardMode billboardMode) const;
73 
74 private:
75     //! コンストラクタです。
76     BillboardUpdater(os::IAllocator* allocator);
77 
78     //! デストラクタです。
79     virtual ~BillboardUpdater();
80 
81     void CalculateLocalMatrix(
82         math::MTX34* localMatrix,
83         const CalculatedTransform& transform,
84         math::VEC3 zAxis,
85         bool recalculateYAxis = true) const;
86 
87     void CalculateScreenLocalMatrix(
88         math::MTX34* localMatrix,
89         const CalculatedTransform& transform,
90         const math::MTX34& inverseViewMatrix,
91         math::VEC3 yAxis,
92         math::VEC3& zAxis) const;
93 };
94 
95 } // namespace gfx
96 } // namespace nw
97 
98 #endif // NW_GFX_BILLBOARDUPDATER_H_
99