------------------------------------------------------------------------------------------------
| 361 | |
| 362 | // ------------------------------------------------------------------------------------------------ |
| 363 | aiReturn aiGetMaterialTexture(const C_STRUCT aiMaterial *mat, |
| 364 | aiTextureType type, |
| 365 | unsigned int index, |
| 366 | C_STRUCT aiString *path, |
| 367 | aiTextureMapping *_mapping /*= nullptr*/, |
| 368 | unsigned int *uvindex /*= nullptr*/, |
| 369 | ai_real *blend /*= nullptr*/, |
| 370 | aiTextureOp *op /*= nullptr*/, |
| 371 | aiTextureMapMode *mapmode /*= nullptr*/, |
| 372 | unsigned int *flags /*= nullptr*/ |
| 373 | ) { |
| 374 | ai_assert(nullptr != mat); |
| 375 | ai_assert(nullptr != path); |
| 376 | |
| 377 | // Get the path to the texture |
| 378 | if (AI_SUCCESS != aiGetMaterialString(mat, AI_MATKEY_TEXTURE(type, index), path)) { |
| 379 | return AI_FAILURE; |
| 380 | } |
| 381 | |
| 382 | // Determine mapping type |
| 383 | int mapping_ = aiTextureMapping_UV; |
| 384 | aiGetMaterialInteger(mat, AI_MATKEY_MAPPING(type, index), &mapping_); |
| 385 | aiTextureMapping mapping = static_cast<aiTextureMapping>(mapping_); |
| 386 | if (_mapping) |
| 387 | *_mapping = mapping; |
| 388 | |
| 389 | // Get UV index |
| 390 | if (aiTextureMapping_UV == mapping && uvindex) { |
| 391 | aiGetMaterialInteger(mat, AI_MATKEY_UVWSRC(type, index), (int *)uvindex); |
| 392 | } |
| 393 | // Get blend factor |
| 394 | if (blend) { |
| 395 | aiGetMaterialFloat(mat, AI_MATKEY_TEXBLEND(type, index), blend); |
| 396 | } |
| 397 | // Get texture operation |
| 398 | if (op) { |
| 399 | aiGetMaterialInteger(mat, AI_MATKEY_TEXOP(type, index), (int *)op); |
| 400 | } |
| 401 | // Get texture mapping modes |
| 402 | if (mapmode) { |
| 403 | aiGetMaterialInteger(mat, AI_MATKEY_MAPPINGMODE_U(type, index), (int *)&mapmode[0]); |
| 404 | aiGetMaterialInteger(mat, AI_MATKEY_MAPPINGMODE_V(type, index), (int *)&mapmode[1]); |
| 405 | } |
| 406 | // Get texture flags |
| 407 | if (flags) { |
| 408 | aiGetMaterialInteger(mat, AI_MATKEY_TEXFLAGS(type, index), (int *)flags); |
| 409 | } |
| 410 | |
| 411 | return AI_SUCCESS; |
| 412 | } |
| 413 | |
| 414 | static constexpr unsigned int DefaultNumAllocated = 5; |
| 415 |
no test coverage detected