obj文件是wavefront公司定義的3d模型文本格式數據文件
只支持模型三角面數據和材質信息,無動畫功能支持
其中幾何信息由.obj文件提供,材質信息由.mtl文件定義
文件以行為單位表示一條數據,可以根據行開頭的字符判斷后續的內容
其中 # 字符表示注釋行
OBJ格式
mtllib filename 材質文件
v 1 1 1 頂點數據
vn 0 1 0 法線
vt 0 1 0 紋理坐標
g Box001 #開始圖元(group name),一個obj可含多個group
usemtl wire_224086086 #當前圖元所使用材質名
f 1 2 3 4 #四邊形,索引起始於1
f 1 2 3 #三角形
f 1/1 2/2 3/3 #頂點索引/紋理索引
f 1//1 2//2 3//3 #頂點索引//法線索引
f 1/1/1 2/2/1 3/3/1 4/4/1 #頂點索引/紋理索引/法線索引
說明:頂點、紋理坐標、法線個數之間沒有對應關系,多個點可共用不同的紋理或法線
索引均開始於1。
另外obj支持曲面等功能,不常用,這里不做介紹
MTL格式
newmtl wire
//Ns 32 #反射
// d 1 #不透明度
// Tr 0 透明度(1-d)
// Tf 1 1 1 濾光投射率
// illum 2 光照模型
// Ka 0.8784 0.3373 0.3373
// Kd 0.8784 0.3373 0.3373
// Ks 0.3500 0.3500 0.3500
// Ke 0.0 0.0 0.0
// map_Ka C:\b.jpg
// map_Kd C:\tb.jpg
map_Ks lemur.tga # specular color texture map
map_Ns lemur_spec.tga # specular highlight component
map_d lemur_alpha.tga # the alpha texture map
map_bump lemur_bump.tga # some implementations use 'map_bump' instead of 'bump' below
