mirror of
https://github.com/ApfelTeeSaft/vb01.git
synced 2026-08-26 19:33:45 +00:00
material animation
This commit is contained in:
+7
-1
@@ -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};
|
||||
|
||||
@@ -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");
|
||||
|
||||
+8
-5
@@ -1,13 +1,15 @@
|
||||
#ifndef MATERIAL_H
|
||||
#define MATERIAL_H
|
||||
|
||||
#include"shader.h"
|
||||
#include"texture.h"
|
||||
#include"vector.h"
|
||||
#include<vector>
|
||||
#include "shader.h"
|
||||
#include "texture.h"
|
||||
#include "vector.h"
|
||||
#include "animatable.h"
|
||||
|
||||
#include <vector>
|
||||
|
||||
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);
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -4,10 +4,11 @@
|
||||
#include <string>
|
||||
#include <ft2build.h>
|
||||
#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;}
|
||||
|
||||
Reference in New Issue
Block a user