animatable types

This commit is contained in:
devZoGok
2022-03-26 15:46:29 +02:00
parent ab9bb1f0e3
commit 910833cc4d
14 changed files with 47 additions and 17 deletions
+2 -1
View File
@@ -3,7 +3,8 @@
namespace vb01{
using namespace std;
Animatable::Animatable(string name){
Animatable::Animatable(Type type, string name){
this->type = type;
this->name = name;
}
}
+14 -1
View File
@@ -6,11 +6,24 @@
namespace vb01{
class Animatable{
public:
Animatable(std::string = "");
enum Type{
NONE,
NODE,
BONE,
SHAPE_KEY,
LIGHT,
PARTICLE_EMITTER,
MATERIAL_UNIFORM,
TEXTURE
};
Animatable(Type, std::string = "");
virtual void animate(float, KeyframeChannel){}
inline std::string getName(){return name;}
inline Type getType(){return type;}
protected:
std::string name;
Type type = Type::NONE;
};
}
+2 -1
View File
@@ -4,9 +4,10 @@
using namespace std;
namespace vb01{
Bone::Bone(string name, float length, Vector3 pos, Quaternion rot, Vector3 scale) : Node(pos, rot, scale, name){
Bone::Bone(string name, float length, Vector3 pos, Quaternion rot, Vector3 scale) : Node(pos, rot, scale, name, Animatable::BONE){
this->name = name;
this->length = length;
this->type = Animatable::BONE;
}
void Bone::lookAt(Vector3 newDir, Vector3 newUp){
+1 -1
View File
@@ -15,7 +15,7 @@ using namespace glm;
using namespace std;
namespace vb01{
Light::Light(Type t, string name) : Animatable(name){
Light::Light(Type t, string name) : Animatable(Animatable::LIGHT, name){
this->type = t;
initDepthMap();
+2 -2
View File
@@ -12,7 +12,7 @@
namespace vb01{
class Texture;
class Material : public Animatable{
class Material{
public:
struct Uniform : public Animatable{
enum Type{
@@ -25,7 +25,7 @@ namespace vb01{
TEXTURE
};
Uniform(std::string name, Type type) : Animatable(name){
Uniform(std::string name, Type type) : Animatable(Animatable::MATERIAL_UNIFORM, name){
this->name = name;
this->type = type;
}
+7
View File
@@ -17,6 +17,13 @@ namespace vb01{
}
}
MeshData::ShapeKey::ShapeKey(string name, float value, float minValue, float maxValue) : Animatable(Animatable::SHAPE_KEY, name){
this->name = name;
this->value = value;
this->minValue = minValue;
this->maxValue = maxValue;
}
MeshData::MeshData(Vertex *vertices, u32 *indices, int numTris, string *vertexGroups, int numVertexGroups, string fullSkeletonName, ShapeKey *shapeKeys, int numShapeKeys){
this->vertices = vertices;
this->indices = indices;
+2
View File
@@ -14,6 +14,8 @@ namespace vb01{
std::string name;
float minValue, value, maxValue;
ShapeKey(std::string, float, float, float);
ShapeKey() : Animatable(Animatable::SHAPE_KEY){}
void animate(float, KeyframeChannel);
};
+4 -1
View File
@@ -16,10 +16,13 @@ using namespace std;
using namespace glm;
namespace vb01{
Node::Node(Vector3 pos, Quaternion orientation, Vector3 scale, string name) : Animatable(name){
Node::Node(Vector3 pos, Quaternion orientation, Vector3 scale, string name, Animatable::Type type) : Animatable(type, name){
this->pos = pos;
this->scale = scale;
this->orientation = orientation;
if(type == Animatable::NONE)
type = Animatable::NODE;
}
Node::~Node(){
+1 -1
View File
@@ -20,7 +20,7 @@ namespace vb01{
class Node : public Animatable{
public:
Node(Vector3 = Vector3::VEC_ZERO, Quaternion = Quaternion::QUAT_W, Vector3 = Vector3::VEC_IJK, std::string = "");
Node(Vector3 = Vector3::VEC_ZERO, Quaternion = Quaternion::QUAT_W, Vector3 = Vector3::VEC_IJK, std::string = "", Animatable::Type = Animatable::NODE);
virtual ~Node();
Node* clone();
void addSkeleton(Skeleton*);
+1 -1
View File
@@ -15,7 +15,7 @@ using namespace glm;
using namespace std;
namespace vb01{
ParticleEmitter::ParticleEmitter(int numParticles){
ParticleEmitter::ParticleEmitter(int numParticles) : Animatable(Animatable::PARTICLE_EMITTER){
this->numParticles = numParticles;
Vertex v1, v2, v3, v4, v5, v6;
+1 -1
View File
@@ -14,8 +14,8 @@ namespace vb01{
class ParticleEmitter : public Animatable{
public:
ParticleEmitter(){}
ParticleEmitter(int);
ParticleEmitter() : Animatable(Animatable::NONE){}
~ParticleEmitter();
void update();
inline void setMaterial(Material *mat){this->material = mat;}
+2
View File
@@ -10,6 +10,7 @@ namespace vb01{
particleEmitter = new ParticleEmitter();
particleEmitter->numParticles = numParticles;
particleEmitter->particles = new ParticleEmitter::Particle*[numParticles];
for(int i = 0; i < numParticles; i++){
ParticleEmitter::Particle *particle = new ParticleEmitter::Particle;
particle->distToCamPlane = rand() % 1000;
@@ -22,6 +23,7 @@ namespace vb01{
void ParticleEmitterTest::testHeapSort(){
particleEmitter->heapSort();
for(int i = 1; i < numParticles; i++){
ParticleEmitter::Particle *prevPart = particleEmitter->particles[i - 1];
ParticleEmitter::Particle *currPart = particleEmitter->particles[i];
+4 -4
View File
@@ -15,7 +15,7 @@
using namespace std;
namespace vb01{
Texture::Texture(int width, int height, bool shadowMap) : Animatable(){
Texture::Texture(int width, int height, bool shadowMap) : Animatable(Animatable::TEXTURE){
this->width = width;
this->height = height;
texture = new u32;
@@ -42,7 +42,7 @@ namespace vb01{
}
}
Texture::Texture(string paths[], int numPaths, bool cubemap, int mipmapLevel, bool flip, string name) : Animatable(name){
Texture::Texture(string paths[], int numPaths, bool cubemap, int mipmapLevel, bool flip, string name) : Animatable(Animatable::TEXTURE, name){
this->cubemap = cubemap;
this->paths = new string[numPaths];
@@ -86,7 +86,7 @@ namespace vb01{
}
}
Texture::Texture(int width, bool depth, int mipmapLevel, string name) : Animatable(name){
Texture::Texture(int width, bool depth, int mipmapLevel, string name) : Animatable(Animatable::TEXTURE, name){
this->width = width;
this->mipmapLevel = mipmapLevel;
this->cubemap = true;
@@ -127,7 +127,7 @@ namespace vb01{
glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
}
Texture::Texture(FT_Face face) : Animatable(){
Texture::Texture(FT_Face face) : Animatable(Animatable::TEXTURE){
texture = new u32;
glGenTextures(1, &texture[0]);
+4 -3
View File
@@ -136,9 +136,10 @@ namespace vb01{
MeshData::ShapeKey *shapeKeys = new MeshData::ShapeKey[numShapeKeys];
for(XMLElement *shapeKeyEl = meshEl->FirstChildElement(tagName); shapeKeyEl && strcmp(shapeKeyEl->Name(), tagName) == 0; shapeKeyEl = shapeKeyEl->NextSiblingElement(), i++){
shapeKeys[i].name = shapeKeyEl->Attribute("name");
shapeKeys[i].minValue = atof(shapeKeyEl->Attribute("min"));
shapeKeys[i].maxValue = atof(shapeKeyEl->Attribute("max"));
string name = shapeKeyEl->Attribute("name");
float minValue = atof(shapeKeyEl->Attribute("min"));
float maxValue = atof(shapeKeyEl->Attribute("max"));
shapeKeys[i] = MeshData::ShapeKey(name, minValue, minValue, maxValue);
XMLElement *driverEl = shapeKeyEl->FirstChildElement("driver");
KeyframeChannel channel = processKeyframeChannells(driverEl)[0];