OROCHI
 
Loading...
Searching...
No Matches
GxUnitSoftbodySimulation.h
Go to the documentation of this file.
1//===========================================================================
10//===========================================================================
11#pragma once
12
13// デフォルトユニットライン
14#define USBS_DEFAULT_UNIT_PROCESS_NUMBER_SIMULATION (4)
15#define USBS_DEFAULT_UNIT_LIST_NUMBER_SIMULATION (20)
16
17GX_UTILITY_NAMESPACE_BEGIN()
20//===========================================================================
22//===========================================================================
24{
25 //-----------------------------------------------------------
27 //-----------------------------------------------------------
29public:
30 // RTTI宣言
31 GX_RTTI_CLASS_NAME(GxUnitSoftbodySimulation, GxUnitBase, "ソフトボディシミュレーション")
32 // ClassBaseReference継承クラス用禁止宣言
34
35#if SOFTBODY_USE_REPLAY
37 enum class USBS_REPLAY_STATE
38 {
39 NONE,
40 REPLAYING,
41 WRITING,
42
43 MAX,
44 };
45#endif // SOFTBODY_USE_REPLAY
46
48 //-----------------------------------------------------------
50 //-----------------------------------------------------------
52
55
57 virtual u32 initialize(GxResSoftbodySimulation* pResource, GxUnitModelBase* pParent, u32 unitProcessNumber, u32 unitListNumber, GxRtti& chainUnitRtti, GxRtti& clothUnitRtti);
58
60 void cleanup(void) override;
61
63 //-----------------------------------------------------------
65 //-----------------------------------------------------------
67
69 void kill(void) override;
70protected:
72 void asyncUpdate(void) override;
74 void sequentialUpdate(void) override;
75
76public:
77#if SOFTBODY_USE_REPLAY
79 void startReplayingData(u32 replayNumber = 0, b32 isRepeat = false);
81 void endReplayingData(void);
83 void startWritingReplayData(u32 replayNumber = 0, u32 saveFrame = 0xFFFFFFFF);
85 void endWritingReplayData(void);
86#endif // SOFTBODY_USE_REPLAY
87
89 //-----------------------------------------------------------
91 //-----------------------------------------------------------
93public:
95 void updateMatrix(GxUnitModelBase::GxJoint* pNow);
96
98 constexpr u32 getChainCount(void) const { return _chainCount; }
99
101 constexpr GxUnitChainModel* getChainUnit(u32 index) const { return _ppChainList[index]; }
103 GxUnitChainModel* getChainUnitFromID(u32 id) const;
104
106 constexpr u32 getClothCount(void) const { return _clothCount; }
107
109 constexpr GxUnitClothModel* getClothUnit(u32 index) const { return _ppClothList[index]; }
111 GxUnitClothModel* getClothUnitFromID(u32 id) const;
112
114 GxUnitSoftbodyCollision* getCollision(void) const;
116 void setCollision(GxUnitSoftbodyCollision* pCollision);
117
119 b32 isSimulation(void) const;
121 b32 isSimulationChain(u32 index) const;
123 b32 isSimulationCloth(u32 index) const;
125
129 void setIsSimulation(b32 enable);
130
132 b32 isInterpolateToMotion(void) const;
134 b32 isInterpolateToMotionChain(u32 index) const;
136 b32 isInterpolateToMotionCloth(u32 index) const;
137
139 void forceDisableSimulation(void);
140
142 f32 getInterpolateTime(void) const;
144 void setInterpolateTime(f32 time);
145
147 b32 isMotionGravity(void) const;
149 void setIsMotionGravity(b32 enable);
151
158 void setMotionGravity(b32 enable, f32 gravityForce, const GxVector3& gravityDirection = -GxVector3::AXIS_Y);
159
161 GX_FORCE_INLINE GxVector3 getGravity(void) const { return getGravityForce() * getGravityDirection(); }
163 void setGravity(const GxVector3 & gravity);
165 f32 getGravityForce(void) const;
167 void setGravityForce(f32 force);
169 const GxVector3& getGravityDirection(void) const;
171 void setGravityDirection(const GxVector3& direction);
172
174 GX_FORCE_INLINE GxVector3 getWind(void) const { return getWindForce() * getWindDirection(); }
176 void setWind(const GxVector3& wind);
178 f32 getWindForce(void) const;
180 void setWindForce(f32 force);
182 const GxVector3& getWindDirection(void) const;
184 void setWindDirection(const GxVector3& direction);
185
187 GX_FORCE_INLINE b32 isUpdateAllMatrix(void) const { return _isUpdateAllMatrix; }
189 GX_FORCE_INLINE void setIsUpdateAllMatrix(b32 is) { _isUpdateAllMatrix = is; }
190
191#if GX_DEVELOP
193 GX_FORCE_INLINE virtual b32 isDevelopRender(void) const { return _isDevelopRender; }
195 virtual void setDevelopRender(b32 enable);
197 virtual void setDevelopRenderMassPoint(b32 enable);
199 virtual void setForceDevelopRender(b32 enable);
200
202 GX_FORCE_INLINE void getPropertyWindForce(void* const pValue) const { *static_cast<f32*>(pValue) = getWindForce(); }
204 GX_FORCE_INLINE void setPropertyWindForce(const void* const pValue) { setWindForce(*static_cast<f32*>(const_cast<void*>(pValue))); }
206 GX_FORCE_INLINE void getPropertyWindDirection(void* const pValue) const { *static_cast<GxVector3*>(pValue) = getWindDirection(); }
208 GX_FORCE_INLINE void setPropertyWindDirection(const void* const pValue) { setWindDirection( *static_cast<GxVector3*>(const_cast<void*>(pValue)) ); }
209#endif // GX_DEVELOP
210
212 //-----------------------------------------------------------
214 //-----------------------------------------------------------
216protected:
224
226
227#if SOFTBODY_USE_REPLAY
228 b32 _startReplayRead;
229 b32 _endReplayRead;
230 b32 _startReplayWrite;
231 b32 _endReplayWrite;
232 u32 _replayState;
233 u32 _replayNumber;
234 u32 _replayFrame;
235 u32 _saveFrame;
236 b32 _isRepeat;
237 b32 _enableOld;
238 GxString _path;
239 GxResSoftbodySimulationReplay* _pReplayResource;
240 GxResSoftbodySimulationReplayXml* _pReplayResourceXml;
241#endif // SOFTBODY_USE_REPLAY
242
243#if GX_DEVELOP
244 b32 _enable;
245 b32 _isDevelopRender;
246#endif // GX_DEVELOP
247
249};
250
251GX_UTILITY_NAMESPACE_END()
#define GX_PROHIBIT_CLASS_BASE_REFERENCE(__CLASS__)
GxClassBaseReference継承の禁止宣言(new以外の生成禁止 + コピー禁止)
Definition GxBase.h:244
@ MAX
定義数
@ NONE
何もしない
モデル対応物理シミュレーション統合リソースクラス
Definition GxResSoftbodySimulation.h:18
実行時型情報クラス
Definition GxRtti.h:154
ユニット基礎クラス
Definition GxUnitBase.h:45
モデルベース鎖クラス
Definition GxUnitChainModel.h:18
モデルベース布クラス
Definition GxUnitClothModel.h:18
モデル基礎クラス
Definition GxUnitModelBase.h:19
クロスシミュレーション用コリジョンクラス
Definition GxUnitSoftbodyCollision.h:18
モデル対応シミュレーション統合ユニットクラス
Definition GxUnitSoftbodySimulation.h:24
constexpr u32 getChainCount(void) const
鎖ユニットの個数取得
Definition GxUnitSoftbodySimulation.h:98
GX_FORCE_INLINE GxVector3 getWind(void) const
風取得
Definition GxUnitSoftbodySimulation.h:174
u32 _chainCount
チェーンシミュレーション数
Definition GxUnitSoftbodySimulation.h:221
GX_FORCE_INLINE void setIsUpdateAllMatrix(b32 is)
重力を修正してモーションへ収束させるか設定
Definition GxUnitSoftbodySimulation.h:189
GX_FORCE_INLINE GxVector3 getGravity(void) const
重力取得
Definition GxUnitSoftbodySimulation.h:161
GxUnitSoftbodyCollision * _pCollision
シミュレーションが使用するコリジョン
Definition GxUnitSoftbodySimulation.h:225
u32 _clothCount
クロスシミュレーション数
Definition GxUnitSoftbodySimulation.h:222
constexpr GxUnitChainModel * getChainUnit(u32 index) const
指定番号の鎖ユニット取得
Definition GxUnitSoftbodySimulation.h:101
b32 _isUpdateAllMatrix
全関節行列更新するかフラグ // for 枝分かれ関節
Definition GxUnitSoftbodySimulation.h:223
GX_FORCE_INLINE b32 isUpdateAllMatrix(void) const
重力を修正してモーションへ収束させるか設定
Definition GxUnitSoftbodySimulation.h:187
GxUnitModelBase * _pParentModel
シミュレートするモデル
Definition GxUnitSoftbodySimulation.h:218
constexpr GxUnitClothModel * getClothUnit(u32 index) const
指定番号の布ユニット取得
Definition GxUnitSoftbodySimulation.h:109
constexpr u32 getClothCount(void) const
布ユニットの個数取得
Definition GxUnitSoftbodySimulation.h:106
GxResSoftbodySimulation * _pResource
シミュレーションリソース
Definition GxUnitSoftbodySimulation.h:217
GxUnitClothModel ** _ppClothList
クロスシミュレーションユニットリスト
Definition GxUnitSoftbodySimulation.h:220
GxUnitChainModel ** _ppChainList
チェーンシミュレーションユニットリスト
Definition GxUnitSoftbodySimulation.h:219
文字列型クラス
Definition GxString.h:18
関節構造体
Definition GxUnitModelBase.h:795
3次元ベクトル
Definition GxVector.h:245
static const GxVector3 AXIS_Y
(0, 1, 0)
Definition GxVector.h:262
32bitブーリアン
Definition GxDefine.h:173