OROCHI
 
Loading...
Searching...
No Matches
GxResModel.h
Go to the documentation of this file.
1//===========================================================================
10//===========================================================================
11#pragma once
12
13GX_CORE_NAMESPACE_BEGIN()
14class GxResMaterial;
15
16//===========================================================================
18//===========================================================================
19class GxResModel : public GxResBase
20{
21 //-----------------------------------------------------------
23 //-----------------------------------------------------------
25public:
26 // RTTI定義
27 GX_RTTI_RESOURCE_ICON(GxResModel, GxResBase, GxRtti::ICON_TYPE::MESH)
28 // ClassBaseReference継承クラス用禁止宣言
30
31
32 enum class LOD
33 {
34 SUPER_HIGH,
35 HIGH,
36 MIDDLE,
37 LOW,
38 SUPER_LOW,
39 AUTO,
40 MAX = AUTO,
41 DISTANCE_MAX = MAX - 1,
42 };
43#if GX_DEVELOP
45 GX_ENUM_TABLE_COUNT(LOD, static_cast<s32>(LOD::MAX) + 1)
46#endif //GX_DEVELOP
47
50 {
53 TEXCOORD,
57 BINORMAL_TANGENT = BINORMAL,
58 BLEND_WEIGHT,
59 BLEND_INDICES,
61 };
65 {
66 FLOAT,
67 HALF,
68 MAX,
69 };
70#if GX_DEVELOP
73#endif //GX_DEVELOP
74
77 {
78 //-----------------------------------------------------------
80 //-----------------------------------------------------------
82 public:
83 // RTTI定義
84 GX_RTTI_STRUCT(GxResModel::GxImportSetting)
85
86
87 //-----------------------------------------------------------
89 //-----------------------------------------------------------
91
93 GxImportSetting(void);
94
96 //-----------------------------------------------------------
98 //-----------------------------------------------------------
100#if GX_DEVELOP
102 b32 write(GxStreamWriter& writer);
103#endif //GX_DEVELOP
104
106 //-----------------------------------------------------------
108 //-----------------------------------------------------------
113 f32 _lodDistance[static_cast<s32>(LOD::DISTANCE_MAX)];
115
117 };
118
119#include "GxResModel.inl"
120
126
128 //-----------------------------------------------------------
130 //-----------------------------------------------------------
132protected:
134 GxResModel(void);
135public:
137 void cleanup(void) override;
138
140 //-----------------------------------------------------------
142 //-----------------------------------------------------------
144public:
146 b32 load(GxStream& stream, u32 dataSize);
147#if GX_DEVELOP
149 b32 save(GxStream& stream);
150#endif // GX_DEVELOP
153 void* mapPartsVertexBuffer(u32 index, u16 vertexStream, u32 /*RENDER_MAPPING*/ mappingType);
155 void unmapPartsVertexBuffer(u32 index, u16 vertexStream);
157 void* mapPartsIndexBuffer(u32 index, u32 /*RENDER_MAPPING*/ mappingType);
159 void unmapPartsIndexBuffer(u32 index);
162 void createCallback(void* pUser);
163
164protected:
166 b32 loadMesh(const GxMeshFile* pMeshFile);
168 b32 loadMeshGroup(const GxMeshGroupFile* pMeshGroupFile, const void* pVertexBufferFile, const void* pIndexBufferFile, const GxRenderVertexElement* pVertexElementFile);
169
170#if GX_DEVELOP
172 b32 saveMesh(GxMeshFile* pMeshFile);
174 b32 saveMeshGroup(GxMeshGroupFile* pMeshGroupFile, void* pVertexBufferFile, void* pIndexBufferFile, GxRenderVertexElement* pVertexElementFile);
176 b32 loadImportSetting(void);
178 void saveImportSetting(void);
179#endif // GX_DEVELOP
180
182 //-----------------------------------------------------------
184 //-----------------------------------------------------------
186public:
187#if GX_DEVELOP
188#if GX_EDITOR
190 void getToolRtti(GxArray& arrayTool) const override;
191#endif //GX_EDITOR
193 GxRtti* getUnitRtti(void) override;
194#endif // GX_DEVELOP
196 constexpr const GX_CHAR* getStringTable(void) const { return _pStringTable; }
198 constexpr u32 getJointCount(void) const { return _pHeader ? _pHeader->_jointCount : 0; }
200 constexpr GxJoint* getJoint(u32 index) const { GX_ASSERT(index < getJointCount(), "指定されたインデックスがオーバーしています"); return &_pJoint[index]; }
202 constexpr GxMatrixAffine* getOrientMatrix(u32 index) const { GX_ASSERT(index < getJointCount(), "指定されたインデックスがオーバーしています"); return &_pOrientMatrix[index]; }
204 constexpr GxMatrixAffine* getInversMatrix(u32 index) const { GX_ASSERT(index < getJointCount(), "指定されたインデックスがオーバーしています"); return &_pInversMatrix[index]; }
206 constexpr u32 getPartsCount(void) const { return _pHeader ? _pHeader->_partsCount : 0; }
208 s32 getPartsIndex(GX_CSTR partsName) const;
210 constexpr u32 getMeshCount(void) const { return _pHeader ? _pHeader->_meshCount : 0; }
212 constexpr const GxMesh* getMesh(u32 index) const { GX_ASSERT(index < getMeshCount(), "指定されたインデックスがオーバーしています"); return &_pMesh[index]; }
214 constexpr u32 getMeshGroupCount(void) const { return _pHeader ? _pHeader->_meshGroupCount : 0; }
216 constexpr GxMeshGroup* getMeshGroup(u32 index) const { GX_ASSERT(index < getMeshGroupCount(), "指定されたインデックスがオーバーしています"); return &_pMeshGroup[index]; }
218 constexpr u32 getMaterialCount(void) const { return _pHeader ? _pHeader->_materialCount : 0; }
220 constexpr GxCriticalSection* getMaterialCriticalSection(void) { return &_materialCriticalSection; }
222 GX_FORCE_INLINE b32 isEnableRemapVertexBuffer(void) { return _enableRemapVertexBuffer; }
223
225 u32 getMeshIndexFromPartsIndex(u32 partsIndex) const;
227 u32 getMeshGroupIndexFromMeshIndex(u32 meshIndex) const;
229 GxRenderVertexDeclaration* getPartsVertexDeclaration(u32 index) const;
231 u32 getPartsVertexCount(u32 index) const;
233 u32 getPartsVertexStride(u32 index, u16 vertexStream) const;
235 RENDER_INDEX_TYPE getPartsIndexType(u32 index) const;
237 u32 getPartsIndexOffset(u32 index) const;
239 u32 getPartsIndexCount(u32 index) const;
241 u32 getPartsIndexMinimum(u32 index) const;
243 GX_FORCE_INLINE const GxVector3& getBoundingSphereCenter(void) const { return _pHeader ? _pHeader->_importSetting._boundingSphereCenter : GxVector3::ZERO; }
245 GX_FORCE_INLINE void setBoundingSphereCenter(const GxVector3& center) { _pHeader->_importSetting._boundingSphereCenter = center; }
247 constexpr f32 getBoundingSphereRadius(void) const { return _pHeader ? _pHeader->_importSetting._boundingSphereRadius : 0; }
249 constexpr void setBoundingSphereRadius(f32 radius) { _pHeader->_importSetting._boundingSphereRadius = radius; }
251 GX_FORCE_INLINE f32 getLodDistance(u32 index) const
252 {
253 GX_ASSERT(index < static_cast<s32>(GxResModel::LOD::DISTANCE_MAX), "範囲外のインデックスにアクセスしました");
254 return _pHeader->_importSetting._lodDistance[index];
255 }
257 GX_FORCE_INLINE void setLodDistance(u32 index, f32 distance)
258 {
259 GX_ASSERT(index < static_cast<s32>(GxResModel::LOD::DISTANCE_MAX), "範囲外のインデックスにアクセスしました");
260 _pHeader->_importSetting._lodDistance[index] = distance;
261 }
262#if GX_DEVELOP
265 {
266 GX_ASSERT(static_cast<s32>(index) < static_cast<s32>(GxResModel::VERTEX_DECLARATION_ELEMENT_PRECISION_GROUP::MAX), "範囲外のインデックスにアクセスしました");
267 return _pHeader->_importSetting._vertexDeclarationPrecisionType[static_cast<s32>(index)];
268 }
270 GX_FORCE_INLINE void setVertexDeclarationPrecisionType(GxResModel::VERTEX_DECLARATION_ELEMENT_PRECISION_GROUP index, GxResModel::VERTEX_DECLARATION_ELEMENT_PRECISION_TYPE accuracyType)
271 {
272 GX_ASSERT(static_cast<s32>(index) < static_cast<s32>(GxResModel::VERTEX_DECLARATION_ELEMENT_PRECISION_GROUP::MAX), "範囲外のインデックスにアクセスしました");
273 _pHeader->_importSetting._vertexDeclarationPrecisionType[static_cast<s32>(index)] = accuracyType;
274 }
275#endif // GX_DEVELOP
276#if GX_DEVELOP
278 static void getImportSettingPath(GxString& path, GX_CSTR resourcePath);
279#endif // GX_DEVELOP
280
282 //-----------------------------------------------------------
284 //-----------------------------------------------------------
286protected:
288 void* _pFinalizedData;
291 GX_CHAR* _pStringTable;
293 GxJoint* _pJoint;
294 GxMatrixAffine* _pOrientMatrix;
295 GxMatrixAffine* _pInversMatrix;
297 GxMesh* _pMesh;
298 GxMeshGroup* _pMeshGroup;
301#if GX_DEVELOP
302 GxImportSetting _importSetting;
303#endif //GX_DEVELOP
304
306};
307
308GX_CORE_NAMESPACE_END()
#define GX_PROHIBIT_CLASS_BASE_REFERENCE(__CLASS__)
GxClassBaseReference継承の禁止宣言(new以外の生成禁止 + コピー禁止)
Definition GxBase.h:244
@ MAX
定義数
@ NORMAL
法線(VS入力,VS→PS)
@ BINORMAL
従法線(VS入力専用)
@ TANGENT
接線(VS入力専用)
@ POSITION
位置データ(VS入力,VS出力)
@ COLOR
4D パック済み 正規化される u8(GxColor形式)
RENDER_INDEX_TYPE
インデックスバッファ形式
Definition GxRender.h:147
モデルリソース
配列クラス
Definition GxArray.h:18
クリティカルセクションクラス
Definition GxThread.h:20
頂点シェーダに渡す頂点の宣言を管理する
Definition GxRenderVertexDeclaration.h:22
リソース基底クラス
Definition GxResBase.h:23
マテリアルリソース
Definition GxResMaterial.h:18
モデルリソースクラス
Definition GxResModel.h:20
VERTEX_DECLARATION_ELEMENT_PRECISION_GROUP
頂点データの精度グループの定義
Definition GxResModel.h:50
constexpr GxCriticalSection * getMaterialCriticalSection(void)
マテリアル構築に関わる処理に対するクリティカルセクション取得
Definition GxResModel.h:220
u32 _finalizedDataSize
データサイズ
Definition GxResModel.h:287
constexpr u32 getPartsCount(void) const
パーツ数を取得
Definition GxResModel.h:206
constexpr f32 getBoundingSphereRadius(void) const
バウンディングスフィアの半径を取得
Definition GxResModel.h:247
b32 _enableRemapVertexBuffer
頂点バッファの再mapを使うかどうか
Definition GxResModel.h:300
constexpr u32 getMeshGroupCount(void) const
メッシュグループ数を取得
Definition GxResModel.h:214
u16 * _pJointIndexTable
関節インデックステーブル
Definition GxResModel.h:292
constexpr const GxMesh * getMesh(u32 index) const
メッシュデータを取得
Definition GxResModel.h:212
constexpr u32 getMeshCount(void) const
メッシュ数を取得
Definition GxResModel.h:210
GxHeader * _pHeader
ヘッダ
Definition GxResModel.h:290
u32 * _pDestructionPartsCount
破壊用パーツ数
Definition GxResModel.h:296
constexpr GxMatrixAffine * getInversMatrix(u32 index) const
逆行列を取得
Definition GxResModel.h:204
LOD
LOD定義
Definition GxResModel.h:33
@ DISTANCE_MAX
LOD距離の定義数
constexpr u32 getMaterialCount(void) const
マテリアル数を取得
Definition GxResModel.h:218
GX_FORCE_INLINE f32 getLodDistance(u32 index) const
LOD距離を取得
Definition GxResModel.h:251
GX_FORCE_INLINE void setLodDistance(u32 index, f32 distance)
LOD距離を設定
Definition GxResModel.h:257
GX_FORCE_INLINE b32 isEnableRemapVertexBuffer(void)
頂点バッファの書き換え可否を取得
Definition GxResModel.h:222
GxCriticalSection _materialCriticalSection
マテリアル構築に関わる処理に対するクリティカルセクション
Definition GxResModel.h:299
GX_CHAR * _pStringTable
文字列テーブル
Definition GxResModel.h:291
constexpr GxMeshGroup * getMeshGroup(u32 index) const
メッシュグループデータを取得
Definition GxResModel.h:216
VERTEX_DECLARATION_ELEMENT_PRECISION_TYPE
頂点データの精度タイプの定義
Definition GxResModel.h:65
constexpr void setBoundingSphereRadius(f32 radius)
バウンディングスフィアの半径を設定
Definition GxResModel.h:249
@ MESH
メッシュ
ストリーム基礎クラス
Definition GxStream.h:20
ストリーム書き込みクラス
Definition GxStreamWriter.h:19
アフィン変換行列(行優先)
Definition GxMatrix.h:330
頂点宣言に使用する、頂点要素を定義するための構造体
Definition GxRenderVertexDeclaration.h:125
モデルリソースヘッダ構造体
Definition GxResModel.h:17
インポート設定
Definition GxResModel.h:77
GxVector3 _boundingSphereCenter
内包球の中心
Definition GxResModel.h:111
f32 _boundingSphereRadius
内包球の半径
Definition GxResModel.h:112
モデルリソース関節構造体
Definition GxResModel.h:71
モデルリソースメッシュ構造体(ファイル用)
Definition GxResModel.h:161
モデルリソースメッシュグループ構造体(ファイル用)
Definition GxResModel.h:255
モデルリソースメッシュグループ構造体
Definition GxResModel.h:211
モデルリソースメッシュ構造体
Definition GxResModel.h:122
作成時コールバック用データ
Definition GxResModel.h:123
b32 _enableRemapVertexBuffer
リマップ頂点バッファ有効フラグ
Definition GxResModel.h:124
文字列型クラス
Definition GxString.h:18
Definition GxBase.h:24
3次元ベクトル
Definition GxVector.h:245
static const GxVector3 ZERO
(0, 0, 0)
Definition GxVector.h:256
32bitブーリアン
Definition GxDefine.h:173