diff --git a/keyframeChannel.h b/keyframeChannel.h index 7d940a5..71274be 100644 --- a/keyframeChannel.h +++ b/keyframeChannel.h @@ -22,11 +22,17 @@ namespace vb01{ SHAPE_KEY_MIN, SHAPE_KEY_VALUE, SHAPE_KEY_MAX, + DIFFUSE_COLOR_W, DIFFUSE_COLOR_X, DIFFUSE_COLOR_Y, DIFFUSE_COLOR_Z, + SPECULAR_COLOR_W, + SPECULAR_COLOR_X, + SPECULAR_COLOR_Y, + SPECULAR_COLOR_Z, SPOTLIGHT_INNER_ANGLE, - SPOTLIGHT_OUTER_ANGLE + SPOTLIGHT_OUTER_ANGLE. + TEXTURE_MIX_RATIO }; struct Keyframe{ enum Interpolation{CONSTANT, LINEAR, BEZIER}; diff --git a/material.cpp b/material.cpp index 3df0645..7320b84 100755 --- a/material.cpp +++ b/material.cpp @@ -52,6 +52,35 @@ namespace vb01{ shader = new Shader(basePath + shaderName + "vert", basePath + shaderName + "frag"); } + void Material::animate(float value, KeyframeChannel keyframeChannel){ + switch(keyframeChannel.type){ + case KeyframeChannel::DIFFUSE_COLOR_W: + diffuseColor.w = value; + break; + case KeyframeChannel::DIFFUSE_COLOR_X: + diffuseColor.x = value; + break; + case KeyframeChannel::DIFFUSE_COLOR_Y: + diffuseColor.y = value; + break; + case KeyframeChannel::DIFFUSE_COLOR_Z: + diffuseColor.z = value; + break; + case KeyframeChannel::SPECULAR_COLOR_W: + specularColor.w = value; + break; + case KeyframeChannel::SPECULAR_COLOR_X: + specularColor.x = value; + break; + case KeyframeChannel::SPECULAR_COLOR_Y: + specularColor.y = value; + break; + case KeyframeChannel::SPECULAR_COLOR_Z: + specularColor.z = value; + break; + } + } + void Material::update(){ shader->use(); shader->setBool(texturingEnabled, "texturingEnabled"); diff --git a/material.h b/material.h index 0940488..422f105 100755 --- a/material.h +++ b/material.h @@ -1,13 +1,15 @@ #ifndef MATERIAL_H #define MATERIAL_H -#include"shader.h" -#include"texture.h" -#include"vector.h" -#include +#include "shader.h" +#include "texture.h" +#include "vector.h" +#include "animatable.h" + +#include namespace vb01{ - class Material{ + class Material : public Animatable{ public: enum Type{MATERIAL_2D, MATERIAL_PARTICLE, MATERIAL_SKYBOX, MATERIAL_GUI, MATERIAL_POST, MATERIAL_TEXT}; @@ -62,6 +64,7 @@ namespace vb01{ Shader *shader = nullptr; void initShader(); + void animate(float, KeyframeChannel); }; } diff --git a/texture.cpp b/texture.cpp index 73f8894..298b40a 100755 --- a/texture.cpp +++ b/texture.cpp @@ -148,6 +148,14 @@ namespace vb01{ } } + void Texture::animate(float value, KeyframeChannel keyframeChannel){ + switch(keyframeChannel.type){ + case KeyframeChannel::TEXTURE_MIX_RATIO: + mixRatio = value; + break; + } + } + void Texture::update(int id){ //updateFrame(); select(id); diff --git a/texture.h b/texture.h index 4329099..a6469a2 100755 --- a/texture.h +++ b/texture.h @@ -4,10 +4,11 @@ #include #include #include "util.h" +#include "animatable.h" #include FT_FREETYPE_H namespace vb01{ - class Texture{ + class Texture : public Animatable{ public: enum TextureType{TEXTURE_2D, TEXTURE_CUBEMAP}; enum TextureTypeId{DIFFUSE, NORMAL, SPECULAR, PARALLAX, ENVIRONMENT}; @@ -20,6 +21,7 @@ namespace vb01{ Texture(FT_Face&, char); void select(int = 0, int = 0); void update(int = 0); + void animate(float, KeyframeChannel); inline unsigned int* getTexture(int i = 0){return &(texture[i]);} inline std::string getPath(){return path;} inline int getNumFrames(){return numFrames;}