質問するログイン新規登録

質問編集履歴

3

情報の追加

2024/12/05 10:40

投稿

NightBaron
NightBaron

スコア2

title CHANGED
File without changes
body CHANGED
@@ -23,8 +23,8 @@
23
23
  - [ ] その他
24
24
 
25
25
  ##### 上記の詳細・結果
26
- チャットgptやGoogleで調べたところFbxSurfaceMaterial FbxFileTexture FbxLayeredTextureはlibfbxsdk.libのインクルードで使用できるとていたのでがダメでした
26
+ チャットgptやGoogleで調べたところFbxSurfaceMaterial FbxFileTexture FbxLayeredTextureはlibfbxsdk.libに含まれているようなのですが使用できません。FbxManagerやFbxInporterどは使用できていす。
27
27
 
28
+
28
29
  ### 補足
29
30
  環境変数のパスも変更してあります
30
- ![イメージ説明](https://ddjkaamml8q8x.cloudfront.net/questions/2024-12-05/cee54c96-34b7-4b50-9e6d-ca222fe1afde.png)![![![![イメージ説明](https://ddjkaamml8q8x.cloudfront.net/questions/2024-12-05/598543f0-e3a3-4336-b3bc-905cd1b2c1f7.png)](https://ddjkaamml8q8x.cloudfront.net/questions/2024-12-05/3b99d8b4-a426-4fe0-a503-2108250fdfdc.png)](https://ddjkaamml8q8x.cloudfront.net/questions/2024-12-05/2de51269-4e82-4d3c-aedd-281e7d8d3d2c.png)](https://ddjkaamml8q8x.cloudfront.net/questions/2024-12-05/84a6c22c-41ad-4bee-85a9-bb343a90c2ce.png)

2

情報の追加

2024/12/05 08:15

投稿

NightBaron
NightBaron

スコア2

title CHANGED
File without changes
body CHANGED
@@ -26,5 +26,5 @@
26
26
  チャットgptやGoogleで調べたところFbxSurfaceMaterial FbxFileTexture FbxLayeredTextureはlibfbxsdk.libのインクルードで使用できるとなっていたのですがダメでした。
27
27
 
28
28
  ### 補足
29
- ほかFbxManagerなどは使えいるのでfbxsdk.hのインクルードはできています
29
+ 環境変数パスも変更しあります
30
30
  ![イメージ説明](https://ddjkaamml8q8x.cloudfront.net/questions/2024-12-05/cee54c96-34b7-4b50-9e6d-ca222fe1afde.png)![![![![イメージ説明](https://ddjkaamml8q8x.cloudfront.net/questions/2024-12-05/598543f0-e3a3-4336-b3bc-905cd1b2c1f7.png)](https://ddjkaamml8q8x.cloudfront.net/questions/2024-12-05/3b99d8b4-a426-4fe0-a503-2108250fdfdc.png)](https://ddjkaamml8q8x.cloudfront.net/questions/2024-12-05/2de51269-4e82-4d3c-aedd-281e7d8d3d2c.png)](https://ddjkaamml8q8x.cloudfront.net/questions/2024-12-05/84a6c22c-41ad-4bee-85a9-bb343a90c2ce.png)

1

リンカーの追加のライブラリディレクトリとVC++のインクルードディレクトリ、ライブラリディレクトリ、パブリックインクルードディレクトリの設定のやり直しをしました

2024/12/05 08:11

投稿

NightBaron
NightBaron

スコア2

title CHANGED
File without changes
body CHANGED
@@ -15,360 +15,7 @@
15
15
 
16
16
  ### 該当のソースコード
17
17
 
18
- ```c++
19
- #include "directx.h"
20
- #include "FbxMeshFile.h"
21
18
 
22
- int polygonCount = 0;
23
- int vertexCount = 0;
24
- int indexCount = 0;
25
-
26
- Vertex* vertexBuffer = NULL;
27
- int* indexBuffer = NULL;
28
-
29
- int* polygonSize = NULL;
30
-
31
- UvSet uvSet;
32
-
33
-
34
-
35
- FbxMeshFile::FbxMeshFile()
36
- {
37
-
38
- }
39
-
40
- FbxMeshFile::~FbxMeshFile()
41
- {
42
- delete[] vertexBuffer;
43
- delete[] indexBuffer;
44
- delete[] polygonSize;
45
- }
46
-
47
- //FBXファイルをロードする
48
- void FbxMeshFile::FbxLoader(const char* file_name)
49
- {
50
- // FbxManager作成する
51
- FbxManager* fbx_manager = FbxManager::Create();
52
- if (fbx_manager == nullptr)
53
- {
54
- return ;
55
- }
56
-
57
- // FbxImporter作成する
58
- FbxImporter* fbx_importer = FbxImporter::Create(fbx_manager, "importer");
59
- if (fbx_importer == nullptr)
60
- {
61
- fbx_manager->Destroy();
62
- return ;
63
- }
64
-
65
- // FbxScene作成する
66
- FbxScene* fbx_scene = FbxScene::Create(fbx_manager, "scene");
67
- if (fbx_scene == nullptr)
68
- {
69
- fbx_importer->Destroy();
70
- fbx_manager->Destroy();
71
- return ;
72
- }
73
-
74
- //ファイルを開く
75
- if (fbx_importer->Initialize(file_name) == false) {
76
- fbx_importer->Destroy();
77
- fbx_scene->Destroy();
78
- fbx_manager->Destroy();
79
- return;
80
- }
81
-
82
- //Scenenにファイルの情報を読み込む
83
- if (fbx_importer->Import(fbx_scene) == false) {
84
- fbx_importer->Destroy();
85
- fbx_scene->Destroy();
86
- fbx_manager->Destroy();
87
- return;
88
- }
89
-
90
- //ロードが終わったら消去しておく
91
- fbx_importer->Destroy();
92
- fbx_scene->Destroy();
93
- fbx_manager->Destroy();
94
-
95
-
96
- }
97
-
98
- //テクスチャ名の取得
99
- void FbxMeshFile::GetTextureNames(FbxMesh* mesh)
100
- {
101
- //メッシュからノードを取得
102
- FbxNode* node = mesh->GetNode();
103
-
104
- //マテリアルの数を取得
105
- int materialCount = node->GetMaterialCount();
106
-
107
- //マテリアルの数だけ繰り返す
108
- for (int i = 0; materialCount > i; i++) {
109
-
110
- //マテリアルを取得
111
- FbxSurfaceMaterial* material = node->GetMaterial(i);
112
- FbxProperty prop = material->FindProperty(FbxSurfaceMaterial::sDiffuse);
113
-
114
- //FbxLayeredTexture の数を取得
115
- int layeredTextureCount = prop.GetSrcObjectCount();
116
-
117
- //アタッチされたテクスチャが FbxLayeredTexture の場合
118
- if (0 < layeredTextureCount) {
119
-
120
- //アタッチされたテクスチャの数だけ繰り返す
121
- for (int j = 0; layeredTextureCount > j; j++) {
122
-
123
- //テクスチャを取得
124
- FbxLayeredTexture* layeredTexture = prop.GetSrcObject<FbxLayeredTexture>(j);
125
- //レイヤー数を取得
126
- int textureCount = layeredTexture->GetSrcObjectCount<FbxFileTexture>();
127
-
128
- //レイヤー数だけ繰り返す
129
- for (int k = 0; textureCount > k; k++) {
130
- //テクスチャを取得
131
- FbxFileTexture* texture = prop.GetSrcObject<FbxFileTexture>(k);
132
-
133
- if (texture) {
134
- //テクスチャ名を取得
135
- std::string textureName = texture->GetRelativeFileName();
136
-
137
- //UVSet名を取得
138
- std::string UVSetName = texture->UVSet.Get().Buffer();
139
-
140
- //UVSet名を比較し対応しているテクスチャなら保持
141
- if (uvSet.uvSetName == UVSetName) {
142
- uvSet.textures.push_back(textureName);
143
- }
144
- }
145
- }
146
- }
147
- }
148
- else {
149
- //テクスチャ数を取得
150
- int fileTextureCount = prop.GetSrcObjectCount<FbxFileTexture>();
151
-
152
- if (0 < fileTextureCount) {
153
- //テクスチャの数だけ繰り返す
154
- for (int j = 0; fileTextureCount > j; j++) {
155
- //テクスチャを取得
156
- FbxFileTexture* texture = prop.GetSrcObject<FbxFileTexture>(j);
157
- if (texture) {
158
- //テクスチャ名を取得
159
- //std::string textureName = texture->GetName();
160
- std::string textureName = texture->GetRelativeFileName();
161
-
162
- //UVSet名を取得
163
- std::string UVSetName = texture->UVSet.Get().Buffer();
164
-
165
- //UVSet名を比較し対応しているテクスチャなら保持
166
- if (uvSet.uvSetName == UVSetName) {
167
- uvSet.textures.push_back(textureName);
168
- }
169
- }
170
- }
171
- }
172
- }
173
- }
174
- }
175
-
176
-
177
-
178
-
179
-
180
- void FbxMeshFile::GetMesh(FbxNode* node)
181
- {
182
- //ノードの属性を取得する
183
- FbxNodeAttribute* attr = node->GetNodeAttribute();
184
-
185
- if (NULL != attr) {
186
- //属性の判別
187
- switch (attr->GetAttributeType()) {
188
- //メッシュノードを見つける
189
- case FbxNodeAttribute::eMesh:
190
- {
191
- FbxMesh* mesh = node->GetMesh();
192
- GetPosition(mesh);
193
-
194
- //頂点の法線座標を取得
195
- GetVertexNormal(mesh);
196
- }
197
- break;
198
- }
199
- }
200
-
201
- //子ノードを再帰探査する
202
- int childCount = node->GetChildCount();
203
- for (int i = 0; childCount > i; i++) {
204
- GetMesh(node->GetChild(i));
205
- }
206
- }
207
-
208
- //頂点の取得関数
209
- void FbxMeshFile::GetPosition(FbxMesh* mesh)
210
- {
211
- //ポリゴン数を取得
212
- polygonCount = mesh->GetPolygonCount();
213
-
214
- //総頂点数を取得
215
- vertexCount = mesh->GetControlPointsCount();
216
-
217
- //インデックス数を取得
218
- indexCount = mesh->GetPolygonVertexCount();
219
-
220
- //頂点バッファの取得
221
- FbxVector4* vertex = mesh->GetControlPoints();
222
-
223
- //インデックスバッファの取得
224
- int* index = mesh->GetPolygonVertices();
225
-
226
- //ポリゴンサイズを取得
227
- polygonSize = new int[polygonCount];
228
-
229
- for (int i = 0; polygonCount > i; i++) {
230
- polygonSize[i] = mesh->GetPolygonSize(i);
231
- }
232
-
233
-
234
- //頂点座標のキャストとハードコピー
235
- vertexBuffer = new Vertex[vertexCount];
236
-
237
- for (int i = 0; vertexCount > i; i++) {
238
- vertexBuffer[i].pos.x = (float)vertex[i][0];
239
-
240
- vertexBuffer[i].pos.y = (float)vertex[i][1];
241
-
242
- vertexBuffer[i].pos.z = (float)vertex[i][2];
243
- }
244
-
245
- //インデックスバッファのハードコピー
246
- indexBuffer = new int[indexCount];
247
-
248
- for (int i = 0; indexCount > i; i++) {
249
- indexBuffer[i] = index[i];
250
- }
251
- }
252
-
253
- //法線の取得関数
254
- void FbxMeshFile::GetVertexNormal(FbxMesh* mesh)
255
- {
256
- //法線セット数を取得
257
- int normalLayerCount = mesh->GetElementNormalCount();
258
-
259
- //レイヤー数だけ回る
260
- for (int i = 0; normalLayerCount > i; i++) {
261
- //法線セットを取得
262
- FbxGeometryElementNormal* normal = mesh->GetElementNormal(i);
263
-
264
- //マッピングモードの取得
265
- FbxGeometryElement::EMappingMode mapping = normal->GetMappingMode();
266
- //リファレンスモードの取得
267
- FbxGeometryElement::EReferenceMode reference = normal->GetReferenceMode();
268
-
269
- //マッピングモードの判別
270
- switch (mapping) {
271
- case FbxGeometryElement::eByControlPoint:
272
- //リファレンスモードの判別
273
- switch (reference) {
274
- case FbxGeometryElement::eDirect:
275
- {
276
- //法線数を取得
277
- int normalCount = normal->GetDirectArray().GetCount();
278
-
279
- // eDirect の場合データは順番に格納されているのでそのまま保持
280
- for (int i = 0; normalCount > i; i++) {
281
- //法線の取得
282
- vertexBuffer[i].normal.x = (float)normal->GetDirectArray().GetAt(i)[0];
283
- vertexBuffer[i].normal.y = (float)normal->GetDirectArray().GetAt(i)[1];
284
- vertexBuffer[i].normal.z = (float)normal->GetDirectArray().GetAt(i)[2];
285
- }
286
- }
287
- break;
288
-
289
- case FbxGeometryElement::eIndexToDirect:
290
- break;
291
-
292
- default:
293
- break;
294
- }
295
-
296
- break;
297
- case FbxGeometryElement::eByPolygonVertex:
298
- break;
299
- default:
300
- break;
301
- }
302
- }
303
- }
304
-
305
- //UV取得関数
306
- void FbxMeshFile::GetVertexUV(FbxMesh* mesh)
307
- {
308
- //UVセット数を取得
309
- int UVLayerCount = mesh->GetElementUVCount();
310
- for (int i = 0; UVLayerCount > i; i++) {
311
- //UVバッファを取得
312
- FbxGeometryElementUV* UV = mesh->GetElementUV(i);
313
-
314
- //マッピングモードの取得
315
- FbxGeometryElement::EMappingMode mapping = UV->GetMappingMode();
316
- //リファレンスモードの取得
317
- FbxGeometryElement::EReferenceMode reference = UV->GetReferenceMode();
318
-
319
- //UV数を取得
320
- int uvCount = UV->GetDirectArray().GetCount();
321
-
322
- //マッピングモードの判別
323
- switch (mapping) {
324
- case FbxGeometryElement::eByControlPoint:
325
- break;
326
-
327
- case FbxGeometryElement::eByPolygonVertex:
328
- //リファレンスモードの判別
329
- switch (reference) {
330
- case FbxGeometryElement::eDirect:
331
- break;
332
- case FbxGeometryElement::eIndexToDirect:
333
- {
334
- FbxLayerElementArrayTemplate<FbxInt>* uvIndex = &UV->GetIndexArray();
335
- int uvIndexCount = uvIndex->GetCount();
336
-
337
- //UVを保持
338
- point2 temp;
339
- for (int i = 0; uvIndexCount > i; i++) {
340
-
341
- temp.x = (float)UV->GetDirectArray().GetAt(uvIndex->GetAt(i))[0];
342
-
343
- temp.y = 1.0f - (float)UV->GetDirectArray().GetAt(uvIndex->GetAt(i))[1];
344
-
345
- uvSet.uvBuffer.push_back(temp);
346
- }
347
-
348
- // UVSet名を取得
349
- uvSet.uvSetName = UV->GetName();
350
- }
351
- break;
352
- default:
353
- break;
354
- }
355
- break;
356
- case FbxGeometryElement::eByEdge:
357
- break;
358
- case FbxGeometryElement::eByPolygon:
359
- break;
360
- default:
361
- break;
362
- }
363
- }
364
-
365
- }
366
-
367
-
368
-
369
-
370
- ```
371
-
372
19
  ### 試したこと・調べたこと
373
20
  - [x] teratailやGoogle等で検索した
374
21
  - [ ] ソースコードを自分なりに変更した
@@ -379,4 +26,5 @@
379
26
  チャットgptやGoogleで調べたところFbxSurfaceMaterial FbxFileTexture FbxLayeredTextureはlibfbxsdk.libのインクルードで使用できるとなっていたのですがダメでした。
380
27
 
381
28
  ### 補足
382
- ほかのFbxManagerなどは使えているのでfbxsdk.hのインクルードはできています
29
+ ほかのFbxManagerなどは使えているのでfbxsdk.hのインクルードはできています
30
+ ![イメージ説明](https://ddjkaamml8q8x.cloudfront.net/questions/2024-12-05/cee54c96-34b7-4b50-9e6d-ca222fe1afde.png)![![![![イメージ説明](https://ddjkaamml8q8x.cloudfront.net/questions/2024-12-05/598543f0-e3a3-4336-b3bc-905cd1b2c1f7.png)](https://ddjkaamml8q8x.cloudfront.net/questions/2024-12-05/3b99d8b4-a426-4fe0-a503-2108250fdfdc.png)](https://ddjkaamml8q8x.cloudfront.net/questions/2024-12-05/2de51269-4e82-4d3c-aedd-281e7d8d3d2c.png)](https://ddjkaamml8q8x.cloudfront.net/questions/2024-12-05/84a6c22c-41ad-4bee-85a9-bb343a90c2ce.png)