ACLoader: add support for reading more than one texture per object
parent
8c6b3fe69a
commit
88ef9eecc1
|
@ -227,7 +227,9 @@ void AC3DImporter::LoadObjectSection(std::vector<Object> &objects) {
|
||||||
}
|
}
|
||||||
} else if (TokenMatch(buffer, "texture", 7)) {
|
} else if (TokenMatch(buffer, "texture", 7)) {
|
||||||
SkipSpaces(&buffer);
|
SkipSpaces(&buffer);
|
||||||
buffer = AcGetString(buffer, obj.texture);
|
std::string texture;
|
||||||
|
buffer = AcGetString(buffer, texture);
|
||||||
|
obj.textures.push_back(texture);
|
||||||
} else if (TokenMatch(buffer, "texrep", 6)) {
|
} else if (TokenMatch(buffer, "texrep", 6)) {
|
||||||
SkipSpaces(&buffer);
|
SkipSpaces(&buffer);
|
||||||
buffer = TAcCheckedLoadFloatArray(buffer, "", 0, 2, &obj.texRepeat);
|
buffer = TAcCheckedLoadFloatArray(buffer, "", 0, 2, &obj.texRepeat);
|
||||||
|
@ -351,8 +353,8 @@ void AC3DImporter::ConvertMaterial(const Object &object,
|
||||||
s.Set(matSrc.name);
|
s.Set(matSrc.name);
|
||||||
matDest.AddProperty(&s, AI_MATKEY_NAME);
|
matDest.AddProperty(&s, AI_MATKEY_NAME);
|
||||||
}
|
}
|
||||||
if (object.texture.length()) {
|
if (!object.textures.empty()) {
|
||||||
s.Set(object.texture);
|
s.Set(object.textures[0]);
|
||||||
matDest.AddProperty(&s, AI_MATKEY_TEXTURE_DIFFUSE(0));
|
matDest.AddProperty(&s, AI_MATKEY_TEXTURE_DIFFUSE(0));
|
||||||
|
|
||||||
// UV transformation
|
// UV transformation
|
||||||
|
@ -532,7 +534,7 @@ aiNode *AC3DImporter::ConvertObjectSection(Object &object,
|
||||||
// allocate UV coordinates, but only if the texture name for the
|
// allocate UV coordinates, but only if the texture name for the
|
||||||
// surface is not empty
|
// surface is not empty
|
||||||
aiVector3D *uv = nullptr;
|
aiVector3D *uv = nullptr;
|
||||||
if (object.texture.length()) {
|
if (!object.textures.empty()) {
|
||||||
uv = mesh->mTextureCoords[0] = new aiVector3D[mesh->mNumVertices];
|
uv = mesh->mTextureCoords[0] = new aiVector3D[mesh->mNumVertices];
|
||||||
mesh->mNumUVComponents[0] = 2;
|
mesh->mNumUVComponents[0] = 2;
|
||||||
}
|
}
|
||||||
|
|
|
@ -125,7 +125,6 @@ public:
|
||||||
type(World),
|
type(World),
|
||||||
name(),
|
name(),
|
||||||
children(),
|
children(),
|
||||||
texture(),
|
|
||||||
texRepeat(1.f, 1.f),
|
texRepeat(1.f, 1.f),
|
||||||
texOffset(0.0f, 0.0f),
|
texOffset(0.0f, 0.0f),
|
||||||
rotation(),
|
rotation(),
|
||||||
|
@ -151,7 +150,8 @@ public:
|
||||||
std::vector<Object> children;
|
std::vector<Object> children;
|
||||||
|
|
||||||
// texture to be assigned to all surfaces of the object
|
// texture to be assigned to all surfaces of the object
|
||||||
std::string texture;
|
// the .acc format supports up to 4 textures
|
||||||
|
std::vector<std::string> textures;
|
||||||
|
|
||||||
// texture repat factors (scaling for all coordinates)
|
// texture repat factors (scaling for all coordinates)
|
||||||
aiVector2D texRepeat, texOffset;
|
aiVector2D texRepeat, texOffset;
|
||||||
|
|
Loading…
Reference in New Issue