loadTex loads textures described in the material descriptor into the specified material
(mat *material.Material, desc *Material)
| 371 | // loadTex loads textures described in the material descriptor into the |
| 372 | // specified material |
| 373 | func (dec *Decoder) loadTex(mat *material.Material, desc *Material) error { |
| 374 | |
| 375 | // Checks if material descriptor specified texture |
| 376 | if desc.MapKd == "" { |
| 377 | return nil |
| 378 | } |
| 379 | |
| 380 | // Get texture file path |
| 381 | // If texture file path is not absolute assumes it is relative |
| 382 | // to the directory of the material file |
| 383 | var texPath string |
| 384 | if filepath.IsAbs(desc.MapKd) { |
| 385 | texPath = desc.MapKd |
| 386 | } else { |
| 387 | texPath = filepath.Join(dec.mtlDir, desc.MapKd) |
| 388 | } |
| 389 | |
| 390 | // Try to load texture from image file |
| 391 | tex, err := texture.NewTexture2DFromImage(texPath) |
| 392 | if err != nil { |
| 393 | return err |
| 394 | } |
| 395 | mat.AddTexture(tex) |
| 396 | return nil |
| 397 | } |
| 398 | |
| 399 | // parse reads the lines from the specified reader and dispatch them |
| 400 | // to the specified line parser. |
no test coverage detected