2014-10-19 3 views
2

OBJ/MTL 파일 컴포넌트를로드하기 위해 'Assimp'librairy를 통합했습니다.Wavefront 리소스 자료 형식의 간단한 호기심

모두 제대로 작동합니다.

그러나의는 다음 MTL 파일 예제에 초점을 보자 :

# Blender MTL File: 'plane.blend' 
# Material Count: 1 

newmtl PlaneMtl 
Ns 96.078431 
Ka 0.000000 0.000000 0.000000 
Kd 0.640000 0.640000 0.640000 
Ks 0.500000 0.500000 0.500000 
Ni 1.000000 
d 1.000000 
illum 2 

map_Ka ambient_texture.jpg 
map_Kd diffuse_texture.jpg 
map_Ks specular_texture.jpg 
map_Bump bump_texture.jpg 

을 그리고의 다음 코드를 살펴 보자 : 당신으로

ambient_texture.jpg 
diffuse_texture.jpg 
specular_texture.jpg 
bump_texture.jpg 

: 여기

aiMesh *pMesh = scene->mMeshes[idz]; 
aiMaterial *pMaterial = scene->mMaterials[pMesh->mMaterialIndex]; 

aiString ambient_texture_path, diffuse_texture_path, specular_texture_path, bump_texture_path; 
pMaterial->GetTexture(aiTextureType_AMBIENT, 0, &ambient_texture_path); 
pMaterial->GetTexture(aiTextureType_DIFFUSE, 0, &diffuse_texture_path); 
pMaterial->GetTexture(aiTextureType_SPECULAR, 0, &specular_texture_path); 
pMaterial->GetTexture(aiTextureType_HEIGHT, 0, &bump_texture_path); 

std::cout << "AmbientTexture: " << ambient_texture_path.C_Str() << std::endl; 
std::cout << "DiffuseTexture: " << diffuse_texture_path.C_Str() << std::endl; 
std::cout << "SpecularTexture: " << specular_texture_path.C_Str() << std::endl; 
std::cout << "BumpTexture: " << bump_texture_path.C_Str() << std::endl; 

출력의 모든 작품을 완벽하게 볼 수 있으며 키워드 'map_Ka, map_Kd, map_Ks 및 map_Bump'는 주변, 확산, 반사 및 범프 (높이)지도. 따라서이 키워드는 정확합니다.

하지만 일반 텍스처 (일반 매핑의 경우)와 위치 변경 텍스처 (위치 변경 매핑의 경우)는 어떻게됩니까? 그래서 키워드를

NormalTexture: 
DispTexture: 

:

aiString normal_texture_path, displacement_texture_path; 

pMaterial->GetTexture(aiTextureType_NORMALS, 0, &normal_texture_path); 
pMaterial->GetTexture(aiTextureType_DISPLACEMENT, 0, &displacement_texture_path); 

std::cout << "NormalTexture: " << normal_texture_path.C_Str() << std::endl; 
std::cout << "DispTexture: " << displacement_texture_path.C_Str() << std::endl; 

출력 : 코드를 사용하여

map_Normal normal_texture.jpg 
map_Disp disp_texture.jpg 

:

나는 시험에 내 MTL 파일에 다음 줄을 추가하려 'map_Normal'과 'map_Disp'은 정확하지 않으므로 Wavefront MTL 문서의 일부가 아닙니다.

WaveFront MTL 형식에 대한 정확하고 공식적인 문서를 찾을 수 없었습니다 (위키 피 디아 또는 자습서의 공식 및 공식 내용은 공식 및 완전하지 않음).

모든 키워드가 설명 된 Wavefront MTL 및 OBJ 형식에 대한 공식 문서가 있습니까?

사실이 아닌 경우 누구나 정상 및 변위 텍스처에 대한 키워드를 알고 있습니까?

답변

0

Alias ​​/ Wavefront는 이제 너무 오래되어 매우 많은 소유 기업을 통과했으며 어디에서나 공식적인 사양을 찾을 수 있을지 의심 스럽습니다.

나는 범프 및 변위 맵에 대한 키워드 세부 정보가 포함 된 Paul Bourke의 우수한 글을 제안합니다. (하지만 노멀 맵 - 나는 그들이 이제까지 OBJ 공식 있었다 생각하지 않는다)이 도움이

http://paulbourke.net/dataformats/mtl/

희망을.

+0

확인. 고맙습니다. 어떤 형식으로 나에게 제안 할 수 있니? – user1364743

+1

당신이 편안하고 수입하고자하는 것에 달려 있습니다. Collada는 매우 유연한 3D 교환 형식으로 설계되었습니다. –

2

이 질문은 오래된 질문인데 노멀 맵을 사용해야하고 Assimp 및 OBJ 파일을 사용하므로 이에 대한 답변을 찾았습니다.Assimp의 소스 코드를보고 후에는 assimp/code/ObjFileMtlImporter.cpp에서 볼 수 있습니다

static const std::string DiffuseTexture  = "map_Kd"; 
static const std::string AmbientTexture  = "map_Ka"; 
static const std::string SpecularTexture  = "map_Ks"; 
static const std::string OpacityTexture  = "map_d"; 
static const std::string EmissiveTexture = "map_emissive"; 
static const std::string EmissiveTexture_1 = "map_Ke"; 
static const std::string BumpTexture1  = "map_bump"; 
static const std::string BumpTexture2  = "map_Bump"; 
static const std::string BumpTexture3  = "bump"; 
static const std::string NormalTexture  = "map_Kn"; 
static const std::string ReflectionTexture = "refl"; 
static const std::string DisplacementTexture = "disp"; 
static const std::string SpecularityTexture = "map_ns"; 

그래서 당신이 볼 수 있듯이, Assimp 내가 수정 한 후 모델을로드 할 때 확인 정상적인 질감과 변위 텍스처 disp (참조 할 map_Kn을 사용하여 그 MTL).