forked from a1928370421/Bongobs-Cat-Plugin
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathModel.hpp
More file actions
211 lines (176 loc) · 7.93 KB
/
Copy pathModel.hpp
File metadata and controls
211 lines (176 loc) · 7.93 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
/**
* Copyright(c) Live2D Inc. All rights reserved.
*
* Use of this source code is governed by the Live2D Open Software license
* that can be found at https://www.live2d.com/eula/live2d-open-software-license-agreement_en.html.
*/
#pragma once
#include <CubismFramework.hpp>
#include <Model/CubismUserModel.hpp>
#include <ICubismModelSetting.hpp>
#include <Type/csmRectF.hpp>
#include <Rendering/OpenGL/CubismOffscreenSurface_OpenGLES2.hpp>
/**
* @brief ユーザーが実際に使用するモデルの実装クラス<br>
* モデル生成、機能コンポーネント生成、更新処理とレンダリングの呼び出しを行う。
*
*/
class Model : public Csm::CubismUserModel
{
public:
/**
* @brief コンストラクタ
*/
Model();
/**
* @brief デストラクタ
*
*/
virtual ~Model();
/**
* @brief model3.jsonが置かれたディレクトリとファイルパスからモデルを生成する
*
*/
Csm::csmBool LoadAssets(const Csm::csmChar* dir, const Csm::csmChar* fileName);
/**
* @brief レンダラを再構築する
*
*/
void ReloadRenderer();
/**
* @brief モデルの更新処理。モデルのパラメータから描画状態を決定する。
*
*/
void Update(Csm::csmUint16 _id);
/**
* @brief モデルを描画する処理。モデルを描画する空間のView-Projection行列を渡す。
*
* @param[in] matrix View-Projection行列
*/
void Draw(Csm::CubismMatrix44& matrix);
/**
* @brief 引数で指定したモーションの再生を開始する。
*
* @param[in] group モーショングループ名
* @param[in] no グループ内の番号
* @param[in] priority 優先度
* @param[in] onFinishedMotionHandler モーション再生終了時に呼び出されるコールバック関数。NULLの場合、呼び出されない。
* @return 開始したモーションの識別番号を返す。個別のモーションが終了したか否かを判定するIsFinished()の引数で使用する。開始できない時は「-1」
*/
Csm::CubismMotionQueueEntryHandle StartMotion(const Csm::csmChar* group, Csm::csmInt32 no, Csm::csmInt32 priority, Csm::ACubismMotion::FinishedMotionCallback onFinishedMotionHandler = NULL);
/**
* @brief ランダムに選ばれたモーションの再生を開始する。
*
* @param[in] group モーショングループ名
* @param[in] priority 優先度
* @param[in] onFinishedMotionHandler モーション再生終了時に呼び出されるコールバック関数。NULLの場合、呼び出されない。
* @return 開始したモーションの識別番号を返す。個別のモーションが終了したか否かを判定するIsFinished()の引数で使用する。開始できない時は「-1」
*/
Csm::CubismMotionQueueEntryHandle StartRandomMotion(Csm::csmInt32 priority, Csm::ACubismMotion::FinishedMotionCallback onFinishedMotionHandler = NULL);
/**
* @brief 引数で指定した表情モーションをセットする
*
* @param expressionID 表情モーションのID
*/
void SetExpression(const Csm::csmChar* expressionID);
/**
* @brief ランダムに選ばれた表情モーションをセットする
*
*/
void SetRandomExpression();
/**
* @brief イベントの発火を受け取る
*
*/
virtual void MotionEventFired(const Live2D::Cubism::Framework::csmString& eventValue);
/**
* @brief 別ターゲットに描画する際に使用するバッファの取得
*/
Csm::Rendering::CubismOffscreenFrame_OpenGLES2& GetRenderBuffer();
void UpdataSetting(Csm::csmBool _randomMotion, Csm::csmFloat32 _delayTime,
Csm::csmBool _isBreath, Csm::csmBool _isEyeBlink,
Csm::csmBool _isTrack,Csm::csmBool _isMouseHorizontalFlip,
Csm::csmBool _IsMouseVerticalFlip);
void UpdateMouseState(Csm::csmFloat32 mouseX,Csm::csmFloat32 mouseY,
Csm::csmBool _lButton, Csm::csmBool _rButton);
Csm::csmFloat32 GetDeltaTime();
void UpdateTime();
protected:
/**
* @brief モデルを描画する処理。モデルを描画する空間のView-Projection行列を渡す。
*
*/
void DoDraw();
private:
/**
* @brief model3.jsonからモデルを生成する。<br>
* model3.jsonの記述に従ってモデル生成、モーション、物理演算などのコンポーネント生成を行う。
*
* @param[in] setting ICubismModelSettingのインスタンス
*
*/
Csm::csmBool SetupModel(Csm::ICubismModelSetting *setting);
/**
* @brief OpenGLのテクスチャユニットにテクスチャをロードする
*
*/
void SetupTextures();
/**
* @brief モーションデータをグループ名から一括でロードする。<br>
* モーションデータの名前は内部でModelSettingから取得する。
*
* @param[in] group モーションデータのグループ名
*/
Csm::csmBool PreloadMotionGroup(const Csm::csmChar* group);
/**
* @brief モーションデータをグループ名から一括で解放する。<br>
* モーションデータの名前は内部でModelSettingから取得する。
*
* @param[in] group モーションデータのグループ名
*/
void ReleaseMotionGroup(const Csm::csmChar* group) const;
/**
* @brief すべてのモーションデータの解放
*
* すべてのモーションデータを解放する。
*/
void ReleaseMotions();
/**
* @brief すべての表情データの解放
*
* すべての表情データを解放する。
*/
void ReleaseExpressions();
Csm::ICubismModelSetting* _modelSetting; ///< モデルセッティング情報
Csm::csmString _modelHomeDir; ///< モデルセッティングが置かれたディレクトリ
Csm::csmFloat32 _userTimeSeconds; ///< デルタ時間の積算値[秒]
Csm::csmVector<Csm::CubismIdHandle> _eyeBlinkIds; ///< モデルに設定されたまばたき機能用パラメータID
Csm::csmVector<Csm::CubismIdHandle> _lipSyncIds; ///< モデルに設定されたリップシンク機能用パラメータID
Csm::csmMap<Csm::csmString, Csm::ACubismMotion*> _motions; ///< 読み込まれているモーションのリスト
Csm::csmMap<Csm::csmString, Csm::ACubismMotion*> _expressions; ///< 読み込まれている表情のリスト
const Csm::CubismId* _idParamAngleX; ///< パラメータID: ParamAngleX
const Csm::CubismId* _idParamAngleY; ///< パラメータID: ParamAngleX
const Csm::CubismId* _idParamAngleZ; ///< パラメータID: ParamAngleX
const Csm::CubismId* _idParamBodyAngleX; ///< パラメータID: ParamBodyAngleX
const Csm::CubismId* _idParamEyeBallX; ///< パラメータID: ParamEyeBallX
const Csm::CubismId* _idParamEyeBallY; ///< パラメータID: ParamEyeBallXY
const Csm::CubismId *_idParamMouseX;
const Csm::CubismId *_idParamMouseY;
const Csm::CubismId *_idParamLeftButton;
const Csm::CubismId *_idParamRightButton;
Csm::Rendering::CubismOffscreenFrame_OpenGLES2 _renderBuffer; ///< フレームバッファ以外の描画先
Csm::csmFloat32 mouseX;
Csm::csmFloat32 mouseY;
Csm::csmBool randomMotion;
Csm::csmFloat32 delayTime;
Csm::csmBool isBreath;
Csm::csmBool isEyeBlink;
Csm::csmBool lButton;
Csm::csmBool rButton;
Csm::csmBool isTrack;
Csm::csmBool isMouseHorizontalFlip;
Csm::csmBool IsMouseVerticalFlip;
Csm::csmFloat32 s_currentFrame;
Csm::csmFloat32 s_lastFrame;
Csm::csmFloat32 s_deltaTime;
};