Custom Animations should now work. We also save color values if there's no texture.
This commit is contained in:
@@ -21,7 +21,7 @@ void DrawFinalPass::InitializeShaderPrograms()
|
||||
m_ForwardPlusProgram->Compile();
|
||||
m_ForwardPlusProgram->Link();
|
||||
}
|
||||
|
||||
static double tempTime = 0.0;
|
||||
void DrawFinalPass::Draw(RenderScene& scene)
|
||||
{
|
||||
GLERROR("DrawFinalPass::Draw: Pre");
|
||||
@@ -53,14 +53,14 @@ void DrawFinalPass::Draw(RenderScene& scene)
|
||||
glActiveTexture(GL_TEXTURE0);
|
||||
glBindTexture(GL_TEXTURE_2D, m_WhiteTexture->m_Texture);
|
||||
}
|
||||
|
||||
tempTime += 0.01f;
|
||||
//TODO: Fixa så att modelsJobs kan spela upp olika animationer och så att den kan få in en tid istället för 1.0f - Hälsningar Johan och Andreas :)
|
||||
if (modelJob->Model->m_RawModel->m_Skeleton != nullptr) {
|
||||
auto animation = modelJob->Model->m_RawModel->m_Skeleton->GetAnimation("running");
|
||||
if (animation != nullptr) {
|
||||
std::vector<glm::mat4> frameBones = modelJob->Model->m_RawModel->m_Skeleton->GetFrameBones(
|
||||
*animation,
|
||||
1.0f
|
||||
tempTime
|
||||
);
|
||||
glUniformMatrix4fv(glGetUniformLocation(shaderHandle, "Bones"), frameBones.size(), GL_FALSE, glm::value_ptr(frameBones[0]));
|
||||
}
|
||||
|
||||
@@ -129,8 +129,8 @@ void RawModelCustom::ReadMaterialSingle(unsigned int &offset, char* fileData, un
|
||||
unsigned int* nameLengths = (unsigned int*)(fileData + offset);
|
||||
offset += sizeof(unsigned int) * 4;
|
||||
|
||||
if (offset + sizeof(float) * 2 > fileByteSize) {
|
||||
throw Resource::FailedLoadingException("Reading Material specular and reflection values failed");
|
||||
if (offset + sizeof(float) * 11 + sizeof(unsigned int) * 2 > fileByteSize) {
|
||||
throw Resource::FailedLoadingException("Reading Material specular, reflection, color and start and end index values failed");
|
||||
}
|
||||
|
||||
newMaterial.SpecularExponent = *(float*)(fileData + offset);
|
||||
@@ -138,9 +138,12 @@ void RawModelCustom::ReadMaterialSingle(unsigned int &offset, char* fileData, un
|
||||
newMaterial.ReflectionFactor = *(float*)(fileData + offset);
|
||||
offset += sizeof(float);
|
||||
|
||||
if (offset + sizeof(unsigned int) * 2 > fileByteSize) {
|
||||
throw Resource::FailedLoadingException("Reading Material start and end index values failed");
|
||||
}
|
||||
memcpy(newMaterial.DiffuseColor, fileData + offset, sizeof(float) * 3);
|
||||
offset += sizeof(float) * 3;
|
||||
memcpy(newMaterial.SpecularColor, fileData + offset, sizeof(float) * 3);
|
||||
offset += sizeof(float) * 3;
|
||||
memcpy(newMaterial.IncandescenceColor, fileData + offset, sizeof(float) * 3);
|
||||
offset += sizeof(float) * 3;
|
||||
|
||||
newMaterial.StartIndex = *(unsigned int*)(fileData + offset);
|
||||
offset += sizeof(unsigned int);
|
||||
@@ -202,7 +205,7 @@ void RawModelCustom::ReadAnimationFile(std::string filePath)
|
||||
|
||||
if (!in.is_open()) {
|
||||
//throw Resource::FailedLoadingException("Open animation file failed");
|
||||
return; // AJABAJA!!!!!!!!
|
||||
return;
|
||||
}
|
||||
|
||||
unsigned int fileByteSize = in.tellg();
|
||||
|
||||
Reference in New Issue
Block a user