mirror of
https://github.com/ApfelTeeSaft/vb01.git
synced 2026-08-26 19:33:45 +00:00
Attachable super class
This commit is contained in:
@@ -0,0 +1,20 @@
|
||||
#ifndef ATTACHABLE_H
|
||||
#define ATTACHABLE_H
|
||||
|
||||
#include <string>
|
||||
|
||||
namespace vb01{
|
||||
class Node;
|
||||
|
||||
struct Attachable{
|
||||
std::string fullName = "";
|
||||
Node *node = nullptr;
|
||||
|
||||
Attachable(std::string fullName){this->fullName = fullName;}
|
||||
Attachable(){}
|
||||
virtual void onAttached(Node*){}
|
||||
std::string getFullName(){return fullName;}
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -3,6 +3,7 @@
|
||||
|
||||
#include "vector.h"
|
||||
#include "animatable.h"
|
||||
#include "attachable.h"
|
||||
|
||||
#include <vector>
|
||||
#include <glm.hpp>
|
||||
@@ -13,14 +14,13 @@ namespace vb01{
|
||||
class Shader;
|
||||
class Material;
|
||||
|
||||
class Light : public Animatable{
|
||||
class Light : public Animatable, public Attachable{
|
||||
public:
|
||||
enum Type{POINT, DIRECTIONAL, SPOT, AMBIENT};
|
||||
|
||||
Light(Type, std::string = "");
|
||||
~Light();
|
||||
void update();
|
||||
inline void setNode(Node *node){this->node = node;}
|
||||
inline void setColor(Vector3 color){this->color = color;}
|
||||
inline void setAttenuationValues(float a, float b, float c){
|
||||
attenuationValues.x = a;
|
||||
@@ -36,7 +36,6 @@ namespace vb01{
|
||||
inline float getOuterAngle(){return outerAngle;}
|
||||
inline float getShadowNearPlane(){return nearPlane;}
|
||||
inline float getShadowFarPlane(){return farPlane;}
|
||||
inline Node* getNode(){return node;}
|
||||
private:
|
||||
void animate(float, KeyframeChannel);
|
||||
void initDepthMap();
|
||||
@@ -46,7 +45,6 @@ namespace vb01{
|
||||
Type type;
|
||||
Shader *depthMapShader;
|
||||
Texture *depthMap = nullptr;
|
||||
Node *node = nullptr;
|
||||
Vector3 color = Vector3::VEC_IJK, attenuationValues = Vector3(1.8, .7, 1);
|
||||
float innerAngle = .707, outerAngle = .714, nearPlane = .1, farPlane = 100;
|
||||
unsigned int depthmapFBO, depthMapSize = 1024;
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
#include "vector.h"
|
||||
#include "util.h"
|
||||
#include "material.h"
|
||||
#include "animatable.h"
|
||||
#include "attachable.h"
|
||||
#include "meshData.h"
|
||||
|
||||
#include <vector>
|
||||
@@ -16,7 +16,7 @@ namespace vb01{
|
||||
class Texture;
|
||||
class Skeleton;
|
||||
|
||||
class Mesh{
|
||||
class Mesh : public Attachable{
|
||||
public:
|
||||
Mesh(MeshData);
|
||||
~Mesh();
|
||||
@@ -24,13 +24,11 @@ namespace vb01{
|
||||
virtual void update();
|
||||
void render();
|
||||
void setMaterial(Material *mat){this->material = mat;}
|
||||
inline void setNode(Node *node){this->node = node;}
|
||||
inline void setCastShadow(bool castShadow){this->castShadow = castShadow;}
|
||||
inline void setReflect(bool r){this->reflect = r;}
|
||||
inline void setReflective(bool r){this->reflective = r;}
|
||||
inline void setWireframe(bool w){this->wireframe = w;}
|
||||
inline void setSkeleton(Skeleton *sk){this->skeleton = sk;}
|
||||
inline Node* getNode(){return node;}
|
||||
inline Material* getMaterial(){return material;}
|
||||
inline bool isReflective(){return reflective;}
|
||||
inline bool isCastShadow(){return castShadow;}
|
||||
@@ -59,7 +57,6 @@ namespace vb01{
|
||||
Shader *environmentShader = nullptr, *irradianceShader = nullptr, *brdfIntegrationShader = nullptr;
|
||||
u32 preFilterFramebuffer, preFilterRenderbuffer, irrandianceFramebuffer, irradianceRenderbuffer, postFilterFramebuffer, postFilterRenderbuffer, brdfFramebuffer, brdfRenderbuffer;
|
||||
Material *material = nullptr;
|
||||
Node *node = nullptr;
|
||||
std::vector<Mesh*> meshes;
|
||||
Skeleton *skeleton = nullptr;
|
||||
protected:
|
||||
|
||||
+2
-1
@@ -24,10 +24,11 @@ namespace vb01{
|
||||
this->maxValue = maxValue;
|
||||
}
|
||||
|
||||
MeshData::MeshData(Vertex *vertices, u32 *indices, int numTris, string *vertexGroups, int numVertexGroups, string fullSkeletonName, ShapeKey *shapeKeys, int numShapeKeys){
|
||||
MeshData::MeshData(Vertex *vertices, u32 *indices, int numTris, string attachableName, string *vertexGroups, int numVertexGroups, string fullSkeletonName, ShapeKey *shapeKeys, int numShapeKeys){
|
||||
this->vertices = vertices;
|
||||
this->indices = indices;
|
||||
this->numTris = numTris;
|
||||
this->attachableName = attachableName;
|
||||
this->vertexGroups = vertexGroups;
|
||||
this->numVertexGroups = numVertexGroups;
|
||||
this->fullSkeletonName = fullSkeletonName;
|
||||
|
||||
+2
-2
@@ -32,10 +32,10 @@ namespace vb01{
|
||||
ShapeKey *shapeKeys = nullptr;
|
||||
u32 *indices, VAO, VBO, EBO;
|
||||
int numTris, numVertexGroups = 0, numShapeKeys = 0;
|
||||
std::string fullSkeletonName = "";
|
||||
std::string attachableName = "", fullSkeletonName = "";
|
||||
|
||||
MeshData(){}
|
||||
MeshData(Vertex*, u32*, int, std::string *vg = nullptr, int = 0, std::string = "", ShapeKey *sk = nullptr, int = 0);
|
||||
MeshData(Vertex*, u32*, int, std::string = "", std::string *vg = nullptr, int = 0, std::string = "", ShapeKey *sk = nullptr, int = 0);
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
+2
-2
@@ -4,6 +4,7 @@
|
||||
#include "vector.h"
|
||||
#include "util.h"
|
||||
#include "animatable.h"
|
||||
#include "attachable.h"
|
||||
|
||||
#include <glm.hpp>
|
||||
|
||||
@@ -12,7 +13,7 @@ namespace vb01{
|
||||
class Node;
|
||||
class Material;
|
||||
|
||||
class ParticleEmitter : public Animatable{
|
||||
class ParticleEmitter : public Animatable, public Attachable{
|
||||
public:
|
||||
ParticleEmitter(int);
|
||||
ParticleEmitter() : Animatable(Animatable::NONE){}
|
||||
@@ -28,7 +29,6 @@ namespace vb01{
|
||||
inline void setHighLife(float h){this->highLife = h;}
|
||||
inline void setGravity(Vector3 g){this->gravity = g;}
|
||||
inline void setSpeed(float s){this->speed = s;}
|
||||
inline Node* getNode(){return node;}
|
||||
private:
|
||||
struct Vertex{
|
||||
Vector3 pos;
|
||||
|
||||
@@ -162,6 +162,7 @@ def export(node, parentTag):
|
||||
numShapeKeys = len(mesh.shape_keys.key_blocks) - 1
|
||||
|
||||
meshTag = ET.SubElement(nodeTag, 'mesh')
|
||||
meshTag.set('name', node.name + mesh.name_full)
|
||||
meshTag.set('num_faces', str(numFaces))
|
||||
meshTag.set('num_vertex_groups', str(numGroups))
|
||||
meshTag.set('num_shape_keys', str(numShapeKeys))
|
||||
|
||||
@@ -11,10 +11,6 @@ using namespace std;
|
||||
using namespace glm;
|
||||
|
||||
namespace vb01{
|
||||
Skeleton::Skeleton(string name){
|
||||
this->name = name;
|
||||
}
|
||||
|
||||
void Skeleton::update(){
|
||||
updateIk();
|
||||
}
|
||||
|
||||
+3
-4
@@ -5,20 +5,20 @@
|
||||
#include <string>
|
||||
|
||||
#include "bone.h"
|
||||
#include "attachable.h"
|
||||
|
||||
namespace vb01{
|
||||
class Animation;
|
||||
|
||||
class Skeleton{
|
||||
class Skeleton : public Attachable{
|
||||
public:
|
||||
Skeleton(std::string = "");
|
||||
Skeleton(std::string name = "") : Attachable(name){}
|
||||
void update();
|
||||
void addBone(Bone*, Bone*);
|
||||
Bone* getBone(std::string);
|
||||
inline Bone* getBone(int i){return bones[i];}
|
||||
inline Bone* getRootBone(){return bones[0];}
|
||||
inline std::vector<Bone*>& getBones(){return bones;}
|
||||
inline std::string getName(){return name;}
|
||||
inline int getNumBones(){return bones.size();}
|
||||
private:
|
||||
void updateIk();
|
||||
@@ -26,7 +26,6 @@ namespace vb01{
|
||||
void transformIkChain(int, Bone*[], Vector3[], Bone*);
|
||||
Bone** getIkBoneChain(Bone*);
|
||||
|
||||
std::string name;
|
||||
std::vector<Bone*> bones;
|
||||
};
|
||||
}
|
||||
|
||||
@@ -3,6 +3,8 @@
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "attachable.h"
|
||||
#include "vector.h"
|
||||
#include "util.h"
|
||||
|
||||
@@ -12,7 +14,7 @@ namespace vb01{
|
||||
class Shader;
|
||||
class Material;
|
||||
|
||||
class Text{
|
||||
class Text : public Attachable{
|
||||
public:
|
||||
struct Glyph{
|
||||
u16 ch;
|
||||
|
||||
+2
-1
@@ -162,7 +162,8 @@ namespace vb01{
|
||||
}
|
||||
|
||||
const char *fullSkeletonName = meshEl->Attribute("skeleton");
|
||||
Mesh *mesh = new Mesh(MeshData(vertices, indices, numVertices / 3, vertexGroups, numVertexGroups, (fullSkeletonName ? fullSkeletonName : ""), shapeKeys, numShapeKeys));
|
||||
string name = string(meshEl->Parent()->ToElement()->Attribute("name")) + string(meshEl->Attribute("name"));
|
||||
Mesh *mesh = new Mesh(MeshData(vertices, indices, numVertices / 3, name, vertexGroups, numVertexGroups, (fullSkeletonName ? fullSkeletonName : ""), shapeKeys, numShapeKeys));
|
||||
|
||||
return mesh;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user