mirror of
https://github.com/bloeys/assimp-go.git
synced 2025-12-29 08:28:20 +00:00
Handle (embedded)textures
This commit is contained in:
@ -24,6 +24,10 @@ enum aiReturn aiGetMaterialTexture(
|
||||
unsigned int* flags);
|
||||
*/
|
||||
import "C"
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
)
|
||||
|
||||
type Material struct {
|
||||
cMat *C.struct_aiMaterial
|
||||
@ -59,12 +63,35 @@ type MaterialProperty struct {
|
||||
*/
|
||||
TypeInfo MatPropertyTypeInfo
|
||||
|
||||
/** Binary buffer to hold the property's value.
|
||||
* The size of the buffer is always mDataLength.
|
||||
*/
|
||||
//Binary buffer to hold the property's value.
|
||||
Data []byte
|
||||
}
|
||||
|
||||
func GetMaterialTextureCount(m *Material, texType TextureType) int {
|
||||
return int(C.aiGetMaterialTextureCount(m.cMat, uint32(texType)))
|
||||
}
|
||||
|
||||
type GetMatTexInfo struct {
|
||||
Path string
|
||||
}
|
||||
|
||||
func GetMaterialTexture(m *Material, texType TextureType, texIndex uint) (*GetMatTexInfo, error) {
|
||||
|
||||
outCPath := &C.struct_aiString{}
|
||||
status := aiReturn(C.aiGetMaterialTexture(m.cMat, uint32(texType), C.uint(texIndex), outCPath, nil, nil, nil, nil, nil, nil))
|
||||
if status == aiReturnSuccess {
|
||||
return &GetMatTexInfo{
|
||||
Path: parseAiString(*outCPath),
|
||||
}, nil
|
||||
}
|
||||
|
||||
if status == aiReturnFailure {
|
||||
return nil, errors.New("get texture failed: " + getAiErr().Error())
|
||||
}
|
||||
|
||||
if status == aiReturnOutofMemory {
|
||||
return nil, errors.New("get texture failed: out of memory")
|
||||
}
|
||||
|
||||
return nil, errors.New("get texture failed: unknown error with code " + fmt.Sprintf("%v", status))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user