Logo
ModelData.h
1#pragma once
2
3#include "Types.h"
4
5#include "gfx/mdl/ModelData.h"
6#include "gfx/Material.h"
7#include "Physics/Physics.h"
8
9namespace SharpKmyGfx
10{
11 ref class Render;
12 ref class Material;
13 ref class MaterialInstance;
14
15 public ref class MaterialInfo
16 {
17 kmyGfx::mtlInfo *obj = nullptr;
18
19 System::String^ convert(const char* ptr)
20 {
21 if (*ptr == '\0')return nullptr;
22
23 return gcnew System::String(ptr);
24 }
25
26 public:
27 MaterialInfo(kmyGfx::mtlInfo *base)
28 {
29 obj = base;
30 }
31
32 //TODO 200820 文字コードを考慮したい
33 System::String^ getName()
34 {
35 return convert(obj->m_name.cstr());
36 }
37
38 System::String^ getDiffuseTextureName()
39 {
40 return convert(obj->m_diffuseTextureName.cstr());
41 }
42
43 System::String^ getAmbientTextureName()
44 {
45 return convert(obj->m_ambientTextureName.cstr());
46 }
47
48 System::String^ getEmissionTextureName()
49 {
50 return convert(obj->m_emissionTextureName.cstr());
51 }
52
53 System::String^ getNormalTextureName()
54 {
55 return convert(obj->m_normalTextureName.cstr());
56 }
57
58 System::String^ getSpecularTextureName()
59 {
60 return convert(obj->m_specularTextureName.cstr());
61 }
62 };
63
64 public ref class ModelData
65 {
66 public:
67 kmyGfx::ModelData *obj;
68 bool own = false;
69
70 ModelData(System::String^ path, System::Guid guid);
71 ModelData(System::String^ path);
72
73 ModelData(kmyGfx::ModelData *o)
74 {
75 obj = o;
76 }
77
78 ~ModelData();
79
80 void load();
81 void unload();
82 MaterialInfo^ getMaterialInfo(int index);
83
85 if (own) {
86 obj->unload();
87 kmyGfx::GfxObject::sync();
88 }
89 }
90
91 void initializeByDef(System::String ^path);
92 void renamePath(System::String^ path);
93
96 static SharpKmyMath::Vector3 getCenterImpl(kmyGfx::ModelData *obj);
97
98 void setBlendType(System::String ^mtlname, int type);
99 int getMaterialIndex(System::String ^name);
100 int getMeshClusterMaterialIndex(int index);
101 size_t getIndexCount(int index);
102 int getBoneCount(int index);
103 Material^ getMaterial(u32 index);
104 bool isOverInfluenceCount(int index);
105 array<System::String^> ^getTextureNameList();
106 System::Collections::Generic::List<System::String^>^ getMotionNameList();
107 System::Collections::Generic::Dictionary<System::String^, SharpKmyMath::Vector2>^ getMotion();
108 System::String^ getPath();
109 void saveDefFile(System::String^ path);
110 bool isModified();
111 void reconstruct();
113 bool evalMaterialCount() { return obj ? obj->evalMaterialCount() : true; }
114 void validateVertexDesc() { if (obj)obj->validateVertexDesc(); }
115 void clearMaterialGUID() { if (obj)obj->clearMaterialGUID(); }
116 void setMaterialGUID(int index, System::Guid id);
117 void setVertexCompressMode(bool compress);
119 float getStartTime();
120 float getEndTime();
123 array<SharpKmyMath::Vector3> ^getMeshCollisionVertices();
124 array<System::String^> ^getNodeNameList();
125
128 if (obj)obj->setSkinnedBoundSphereRadiusScale(v);
129 }
131 return obj ? obj->getSkinnedBoundSphereRadiusScale() : 1.0f;
132 }
133
134 void saveNativeModel(System::String^ path);
135 void setNativeModelPath(System::String^ path);
136
137 private:
138 void loadForImportTest();
139 void unloadForImportTest();
140
141#ifdef KMY_USE_VRM
142 public:
143 ModelExporter::ModelDataWrap^ GetModelData();
144 bool isVrm();
145 int vrmGetTextureNum();
146 System::String^ vrmGetTextureName(int index);
147 void vrmStoreTextureToFile(int index, System::String^ path);
148
149 System::String^ vrmGetMaterialDef(int index);
150#endif
151
152 };
153
154
155
156
157}
Definition: Material.h:26
Definition: ModelData.h:16
System::String getEmissionTextureName()
Definition: ModelData.h:48
System::String getDiffuseTextureName()
Definition: ModelData.h:38
System::String convert(const char *ptr)
Definition: ModelData.h:19
System::String getSpecularTextureName()
Definition: ModelData.h:58
System::String getName()
Definition: ModelData.h:33
kmyGfx::mtlInfo * obj
Definition: ModelData.h:17
System::String getNormalTextureName()
Definition: ModelData.h:53
MaterialInfo(kmyGfx::mtlInfo *base)
Definition: ModelData.h:27
System::String getAmbientTextureName()
Definition: ModelData.h:43
Definition: ModelData.h:65
System::Collections::Generic::List< System::String^> getMotionNameList()
Definition: ModelData.cpp:227
float getStartTime()
Definition: ModelData.cpp:259
void setMaterialGUID(int index, System::Guid id)
Definition: ModelData.cpp:422
array< System::String^> getTextureNameList()
Definition: ModelData.cpp:176
void renamePath(System::String^ path)
Definition: ModelData.cpp:83
SharpKmyMath::Vector3 getPreviewAngle()
Definition: ModelData.cpp:277
System::String getPath()
Definition: ModelData.cpp:169
void clearMaterialGUID()
Definition: ModelData.h:115
bool evalMaterialCount()
Definition: ModelData.h:113
bool getVertexCompressMode()
Definition: ModelData.cpp:436
void constructPBRMaterial()
Definition: ModelData.cpp:298
bool hasUnTriangulateMesh()
Definition: ModelData.cpp:492
void setBlendType(System::String ^mtlname, int type)
Definition: ModelData.cpp:94
SharpKmyMath::Vector3 getPreviewOffset()
Definition: ModelData.cpp:269
float getSkinnedBoundSphereRadiusScale()
Definition: ModelData.h:130
SharpKmyMath::Vector3 getSize()
Definition: ModelData.cpp:367
int getMaterialIndex(System::String ^name)
Definition: ModelData.cpp:107
array< System::String^> getNodeNameList()
Definition: ModelData.cpp:208
MaterialInfo getMaterialInfo(int index)
Definition: ModelData.cpp:63
Material getMaterial(u32 index)
Definition: ModelData.cpp:150
kmyGfx::ModelData * obj
Definition: ModelData.h:67
bool isOverInfluenceCount(int index)
Definition: ModelData.cpp:158
void load()
Definition: ModelData.cpp:43
void setNativeModelPath(System::String^ path)
Definition: ModelData.cpp:575
void ReleaseForToolWithSync()
Definition: ModelData.h:84
void reconstruct()
Definition: ModelData.cpp:290
static SharpKmyMath::Vector3 getCenterImpl(kmyGfx::ModelData *obj)
Definition: ModelData.cpp:396
int getMeshClusterMaterialIndex(int index)
Definition: ModelData.cpp:121
void setSkinnedBoundSphereRadiusScale(float v)
Definition: ModelData.h:127
void unload()
Definition: ModelData.cpp:58
float getEndTime()
Definition: ModelData.cpp:264
bool isModified()
Definition: ModelData.cpp:294
~ModelData()
Definition: ModelData.cpp:31
void validateVertexDesc()
Definition: ModelData.h:114
bool own
Definition: ModelData.h:68
ModelData(kmyGfx::ModelData *o)
Definition: ModelData.h:73
size_t getIndexCount(int index)
Definition: ModelData.cpp:134
void initializeByDef(System::String ^path)
Definition: ModelData.cpp:72
System::Collections::Generic::Dictionary< System::String^, SharpKmyMath::Vector2 > getMotion()
Definition: ModelData.cpp:242
SharpKmyMath::Vector3 getCenter()
Definition: ModelData.cpp:390
void saveDefFile(System::String^ path)
Definition: ModelData.cpp:285
int getBoneCount(int index)
Definition: ModelData.cpp:145
array< SharpKmyMath::Vector3 > getMeshCollisionVertices()
Definition: ModelData.cpp:444
void saveNativeModel(System::String^ path)
Definition: ModelData.cpp:568
ModelData(System::String^ path, System::Guid guid)
Definition: ModelData.cpp:15
void setVertexCompressMode(bool compress)
Definition: ModelData.cpp:429
Definition: Billboard.cpp:4
Definition: Vector3.h:8