@@ -150,7 +150,9 @@ bool ModelLoader::loadSkybox(const std::string &filepath) {
150
150
texData.width = skyboxTex[0 ]->getWidth ();
151
151
texData.height = skyboxTex[0 ]->getHeight ();
152
152
texData.data = std::move (skyboxTex);
153
- texData.wrapMode = Wrap_CLAMP_TO_EDGE;
153
+ texData.wrapModeU = Wrap_CLAMP_TO_EDGE;
154
+ texData.wrapModeV = Wrap_CLAMP_TO_EDGE;
155
+ texData.wrapModeW = Wrap_CLAMP_TO_EDGE;
154
156
} else {
155
157
skyboxTex.resize (1 );
156
158
skyboxTex[0 ] = loadTextureFile (filepath);
@@ -160,7 +162,9 @@ bool ModelLoader::loadSkybox(const std::string &filepath) {
160
162
texData.width = skyboxTex[0 ]->getWidth ();
161
163
texData.height = skyboxTex[0 ]->getHeight ();
162
164
texData.data = std::move (skyboxTex);
163
- texData.wrapMode = Wrap_CLAMP_TO_EDGE;
165
+ texData.wrapModeU = Wrap_CLAMP_TO_EDGE;
166
+ texData.wrapModeV = Wrap_CLAMP_TO_EDGE;
167
+ texData.wrapModeW = Wrap_CLAMP_TO_EDGE;
164
168
}
165
169
166
170
skyboxMaterialCache_[filepath] = material;
@@ -349,7 +353,7 @@ void ModelLoader::processMaterial(const aiMaterial *ai_material,
349
353
return ;
350
354
}
351
355
for (size_t i = 0 ; i < ai_material->GetTextureCount (textureType); i++) {
352
- aiTextureMapMode texMapMode[2 ];
356
+ aiTextureMapMode texMapMode[2 ]; // [u, v]
353
357
aiString texPath;
354
358
aiReturn retStatus = ai_material->GetTexture (textureType, i, &texPath,
355
359
nullptr , nullptr , nullptr , nullptr ,
@@ -384,27 +388,13 @@ void ModelLoader::processMaterial(const aiMaterial *ai_material,
384
388
385
389
auto buffer = loadTextureFile (absolutePath);
386
390
if (buffer) {
387
- WrapMode mode;
388
- switch (texMapMode[0 ]) {
389
- case aiTextureMapMode_Wrap:
390
- mode = Wrap_REPEAT;
391
- break ;
392
- case aiTextureMapMode_Clamp:
393
- mode = Wrap_CLAMP_TO_EDGE;
394
- break ;
395
- case aiTextureMapMode_Mirror:
396
- mode = Wrap_MIRRORED_REPEAT;
397
- break ;
398
- default :
399
- mode = Wrap_REPEAT;
400
- break ;
401
- }
402
391
auto &texData = material.textureData [texType];
403
392
texData.tag = absolutePath;
404
393
texData.width = buffer->getWidth ();
405
394
texData.height = buffer->getHeight ();
406
395
texData.data = {buffer};
407
- texData.wrapMode = mode;
396
+ texData.wrapModeU = convertTexWrapMode (texMapMode[0 ]);
397
+ texData.wrapModeV = convertTexWrapMode (texMapMode[1 ]);
408
398
} else {
409
399
LOGE (" load texture failed: %s, path: %s" , Material::materialTexTypeStr (texType), absolutePath.c_str ());
410
400
}
@@ -428,6 +418,26 @@ BoundingBox ModelLoader::convertBoundingBox(const aiAABB &aabb) {
428
418
return ret;
429
419
}
430
420
421
+ WrapMode ModelLoader::convertTexWrapMode (const aiTextureMapMode &mode) {
422
+ WrapMode retWrapMode;
423
+ switch (mode) {
424
+ case aiTextureMapMode_Wrap:
425
+ retWrapMode = Wrap_REPEAT;
426
+ break ;
427
+ case aiTextureMapMode_Clamp:
428
+ retWrapMode = Wrap_CLAMP_TO_EDGE;
429
+ break ;
430
+ case aiTextureMapMode_Mirror:
431
+ retWrapMode = Wrap_MIRRORED_REPEAT;
432
+ break ;
433
+ default :
434
+ retWrapMode = Wrap_REPEAT;
435
+ break ;
436
+ }
437
+
438
+ return retWrapMode;
439
+ }
440
+
431
441
glm::mat4 ModelLoader::adjustModelCenter (BoundingBox &bounds) {
432
442
glm::mat4 modelTransform (1 .0f );
433
443
glm::vec3 trans = (bounds.max + bounds.min ) / -2 .f ;
0 commit comments