Animated material support.

This commit is contained in:
momo5502 2016-01-22 20:26:00 +01:00
parent bf80c3fd61
commit c55c3b7364
2 changed files with 27 additions and 1 deletions

View File

@ -30,7 +30,7 @@ namespace Assets
if (!iwi.Exists())
{
Components::Logger::Error("Loading image '%s' failed!", iwi.GetName());
Components::Logger::Error("Loading image '%s' failed!", iwi.GetName().data());
return;
}

View File

@ -45,6 +45,32 @@ namespace Assets
memcpy(material, baseMaterial, sizeof(Game::Material));
material->name = builder->GetAllocator()->DuplicateString(name);
material->textureAtlasRowCount = 0;
material->textureAtlasColumnCount = 0;
// Load animation frames
auto anims = infoData["anims"];
if (anims.is_array())
{
auto animCoords = anims.array_items();
if (animCoords.size() >= 2)
{
auto animCoordX = animCoords[0];
auto animCoordY = animCoords[1];
if (animCoordX.is_number())
{
material->textureAtlasColumnCount = (char)animCoordX.number_value() & 0xFF;
}
if (animCoordY.is_number())
{
material->textureAtlasRowCount = (char)animCoordY.number_value() & 0xFF;
}
}
}
// Load referenced textures
auto textures = infoData["textures"];
if (textures.is_array())