diff --git a/CMakeLists.txt b/CMakeLists.txt index 04b3ba7..1f0d9a7 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -16,7 +16,7 @@ set(utils util.cpp) set(math quaternion.cpp vector.cpp matrix.cpp ray.cpp) set(render particleEmitter.cpp camera.cpp light.cpp material.cpp mesh.cpp model.cpp node.cpp quad.cpp box.cpp root.cpp shader.cpp texture.cpp) set(model modelReader.cpp assimpModelReader.cpp vbModelReader.cpp) -set(anim animationController.cpp animationChannel.cpp animation.cpp keyframeChannel.cpp animatable.cpp driver.cpp) +set(anim animationController.cpp animationChannel.cpp animation.cpp animatable.h keyframeChannel.cpp driver.cpp) set(armature skeleton.cpp bone.cpp ikSolver.cpp) set(library ${render} ${math} ${model} ${utils} ${gui} ${armature} ${assetManager} ${anim}) diff --git a/animatable.cpp b/animatable.cpp deleted file mode 100644 index 280f0ab..0000000 --- a/animatable.cpp +++ /dev/null @@ -1,7 +0,0 @@ -#include "animatable.h" -#include "animationController.h" - -namespace vb01{ - Animatable::Animatable(){ - } -} diff --git a/animatable.h b/animatable.h index 9f05df2..b4efcb8 100644 --- a/animatable.h +++ b/animatable.h @@ -1,17 +1,13 @@ #ifndef ANIMATABLE_H #define ANIMATABLE_H -#include "animation.h" +#include "keyframeChannel.h" namespace vb01{ - class AnimationController; - class Animatable{ public: - Animatable(); + Animatable(){} virtual void animate(float, KeyframeChannel){} - private: - protected: }; } diff --git a/animation.cpp b/animation.cpp index c724716..4b4b58e 100644 --- a/animation.cpp +++ b/animation.cpp @@ -1,4 +1,4 @@ -#include"animation.h" +#include "animation.h" using namespace std; diff --git a/animation.h b/animation.h index 693bd8f..2b7a5e1 100644 --- a/animation.h +++ b/animation.h @@ -3,6 +3,7 @@ #include #include + #include "keyframeChannel.h" namespace vb01{ diff --git a/animationController.h b/animationController.h index 7648610..30bfdb4 100644 --- a/animationController.h +++ b/animationController.h @@ -3,6 +3,7 @@ #include #include + #include "animation.h" namespace vb01{ diff --git a/assimpModelReader.cpp b/assimpModelReader.cpp index ea69803..97be523 100644 --- a/assimpModelReader.cpp +++ b/assimpModelReader.cpp @@ -1,8 +1,9 @@ -#include"assimpModelReader.h" -#include"mesh.h" -#include -#include -#include +#include "assimpModelReader.h" +#include "mesh.h" + +#include +#include +#include using namespace std; using namespace Assimp; diff --git a/assimpModelReader.h b/assimpModelReader.h index bcf380e..cffb9b2 100644 --- a/assimpModelReader.h +++ b/assimpModelReader.h @@ -1,7 +1,7 @@ #ifndef ASSIMP_MODEL_READER_H #define ASSIMP_MODEL_READER_H -#include"modelReader.h" +#include "modelReader.h" class aiNode; class aiMesh; diff --git a/bone.cpp b/bone.cpp index 58915d1..d47e39a 100644 --- a/bone.cpp +++ b/bone.cpp @@ -1,5 +1,5 @@ -#include"bone.h" -#include"skeleton.h" +#include "bone.h" +#include "skeleton.h" using namespace std; diff --git a/bone.h b/bone.h index a0e7da1..1c6948e 100644 --- a/bone.h +++ b/bone.h @@ -2,6 +2,7 @@ #define BONE_H #include "node.h" + #include namespace vb01{ diff --git a/box.cpp b/box.cpp index b063844..f033e1f 100755 --- a/box.cpp +++ b/box.cpp @@ -1,4 +1,4 @@ -#include"box.h" +#include "box.h" namespace vb01{ Box::Box(Vector3 size){ diff --git a/box.h b/box.h index e5abdda..c6b3bd0 100755 --- a/box.h +++ b/box.h @@ -1,7 +1,7 @@ #ifndef BOX_H #define BOX_H -#include"mesh.h" +#include "mesh.h" namespace vb01{ class Box : public Mesh{ diff --git a/camera.cpp b/camera.cpp index 7c450a2..8dc8c44 100755 --- a/camera.cpp +++ b/camera.cpp @@ -1,4 +1,4 @@ -#include"camera.h" +#include "camera.h" namespace vb01{ Camera::Camera(){ @@ -12,8 +12,8 @@ namespace vb01{ } void Camera::lookAt(Vector3 direction, Vector3 up){ - this->direction=direction; - this->up=up; - left=direction.cross(up); + this->direction = direction; + this->up = up; + left = direction.cross(up); } } diff --git a/camera.h b/camera.h index 0011da0..fd31457 100755 --- a/camera.h +++ b/camera.h @@ -1,7 +1,7 @@ #ifndef CAMERA_H #define CAMERA_H -#include"vector.h" +#include "vector.h" namespace vb01{ class Camera{ @@ -9,20 +9,20 @@ namespace vb01{ Camera(); ~Camera(); void update(); - void setPosition(Vector3 position){this->position=position;} - void lookAt(Vector3, Vector3=Vector3(0,1,0)); + void setPosition(Vector3 position){this->position = position;} + void lookAt(Vector3, Vector3 = Vector3::VEC_J); inline Vector3 getPosition(){return position;} inline Vector3 getDirection(){return direction;} inline Vector3 getLeft(){return left;} inline Vector3 getUp(){return up;} - inline void setNearPlane(float near){this->nearPlane=near;} - inline void setFarPlane(float far){this->farPlane=far;} + inline void setNearPlane(float near){this->nearPlane = near;} + inline void setFarPlane(float far){this->farPlane = far;} inline float getFov(){return fov;} inline float getNearPlane(){return nearPlane;} inline float getFarPlane(){return farPlane;} private: - Vector3 position=Vector3(0,0,0),direction=Vector3(0,0,-1),left=Vector3(1,0,0),up=Vector3(0,1,0); - float fov=45,nearPlane=.1,farPlane=100; + Vector3 position = Vector3::VEC_ZERO, direction = Vector3(0,0,-1), left = Vector3::VEC_I, up = Vector3::VEC_J; + float fov = 45, nearPlane = .1, farPlane = 100; }; } diff --git a/cameraTest.cpp b/cameraTest.cpp index 3c93adb..6f0df0c 100644 --- a/cameraTest.cpp +++ b/cameraTest.cpp @@ -1,4 +1,5 @@ #include "cameraTest.h" + #include #include #include diff --git a/driver.h b/driver.h index 110a25e..474d14b 100644 --- a/driver.h +++ b/driver.h @@ -2,6 +2,7 @@ #define DRIVER #include "keyframeChannel.h" + #include namespace vb01{ diff --git a/ikSolverTest.h b/ikSolverTest.h index 1b134d1..360b6e6 100644 --- a/ikSolverTest.h +++ b/ikSolverTest.h @@ -3,6 +3,7 @@ #include #include + #include "bone.h" namespace vb01{ diff --git a/light.h b/light.h index dfd9ae5..6240e1d 100755 --- a/light.h +++ b/light.h @@ -13,7 +13,6 @@ namespace vb01{ class Shader; class Material; - class Light : public Animatable{ public: enum Type{POINT, DIRECTIONAL, SPOT, AMBIENT}; diff --git a/material.cpp b/material.cpp index cab3b1b..086e928 100755 --- a/material.cpp +++ b/material.cpp @@ -1,6 +1,6 @@ -#include"material.h" -#include"shader.h" -#include"root.h" +#include "material.h" +#include "shader.h" +#include "root.h" using namespace std; diff --git a/matrix.cpp b/matrix.cpp index 052e6bb..2312f5e 100644 --- a/matrix.cpp +++ b/matrix.cpp @@ -1,199 +1,200 @@ -#include"matrix.h" -#include +#include "matrix.h" + +#include using namespace std; namespace vb01{ - Matrix::Matrix(float **matrix,int rows,int columns){ - this->dim[0]=rows; - this->dim[1]=columns; + Matrix::Matrix(float **matrix, int rows, int columns){ + this->dim[0] = rows; + this->dim[1] = columns; - this->matrix=new float*[rows]; - for(int i=0;imatrix[i]=new float[columns]; - for(int j=0;jmatrix[i][j]=matrix[i][j]; + this->matrix = new float*[rows]; + for(int i = 0; i < dim[0]; i++){ + this->matrix[i] = new float[columns]; + for(int j = 0; j < dim[1]; j++) + this->matrix[i][j] = matrix[i][j]; } } - Matrix::Matrix(Vector3 v1,Vector3 v2,Vector3 v3){ - dim[0]=3; - dim[1]=3; + Matrix::Matrix(Vector3 v1, Vector3 v2, Vector3 v3){ + dim[0] = 3; + dim[1] = 3; matrix=new float*[3]; - matrix[0]=new float[3]; - matrix[0][0]=v1.x; - matrix[0][1]=v1.y; - matrix[0][2]=v1.z; - matrix[1]=new float[3]; - matrix[1][0]=v2.x; - matrix[1][1]=v2.y; - matrix[1][2]=v2.z; - matrix[2]=new float[3]; - matrix[2][0]=v3.x; - matrix[2][1]=v3.y; - matrix[2][2]=v3.z; + matrix[0] = new float[3]; + matrix[0][0] = v1.x; + matrix[0][1] = v1.y; + matrix[0][2] = v1.z; + matrix[1] = new float[3]; + matrix[1][0] = v2.x; + matrix[1][1] = v2.y; + matrix[1][2] = v2.z; + matrix[2] = new float[3]; + matrix[2][0] = v3.x; + matrix[2][1] = v3.y; + matrix[2][2] = v3.z; } Matrix& Matrix::operator+(Matrix &m){ - if(dim[0]==m.dim[0]&&dim[1]==m.dim[1]){ - for(int i=0;imatrix[i][k]*m.matrix[k][j]; - return Matrix(matrix,dim[0],dim[1]); + for(int i = 0; i < dim[0]; i++) + for(int j = 0; j < dim[1]; j++) + for(int k = 0; k < dim[0]; k++) + matrix[i][j] += this->matrix[i][k] * m.matrix[k][j]; + return Matrix(matrix, dim[0], dim[1]); } else{ - cout<<"Incompatible matrix dimensions for multiplication.\n"; + cout << "Incompatible matrix dimensions for multiplication.\n"; exit(-1); } } Vector3 Matrix::operator* (Vector3 v){ - float **matrix=new float*[3]; - matrix[0]=new float[1]; - matrix[0][0]=v.x; - matrix[1]=new float[1]; - matrix[1][0]=v.y; - matrix[2]=new float[1]; - matrix[2][0]=v.z; + float **matrix = new float*[3]; + matrix[0] = new float[1]; + matrix[0][0] = v.x; + matrix[1] = new float[1]; + matrix[1][0] = v.y; + matrix[2] = new float[1]; + matrix[2][0] = v.z; - Matrix vMat(matrix,3,1); - vMat=(*this)*vMat; - return Vector3(vMat[0][0],vMat[1][0],vMat[2][0]); + Matrix vMat(matrix, 3, 1); + vMat = (*this) * vMat; + return Vector3(vMat[0][0], vMat[1][0], vMat[2][0]); } template Matrix& Matrix::operator+(T s){ - for(int i=0;i Matrix& Matrix::operator-(T s){ - for(int i=0;i Matrix& Matrix::operator*(T s){ - for(int i=0;i Matrix& Matrix::operator/(T s){ - for(int i=0;imatrix[j][i]; - this->matrix=matrix; + float **matrix = new float*[dim[1]]; + for(int i = 0; i < dim[1]; i++) + matrix[i] = new float[dim[0]]; + for(int i = 0; i < dim[0]; i++) + for(int j = 0; j < dim[1]; j++) + matrix[i][j] = this->matrix[j][i]; + this->matrix = matrix; } - Matrix Matrix::getSubMatrix(int row,int column){ - int newRows=dim[0]-1,newColumns=dim[1]-1; - float **matrix=new float*[dim[0]]; - bool offsetRows=false,offsetColumns=false; + Matrix Matrix::getSubMatrix(int row, int column){ + int newRows = dim[0] - 1, newColumns = dim[1] - 1; + float **matrix = new float*[dim[0]]; + bool offsetRows = false, offsetColumns = false; - for(int i=0;imatrix[i][j]; + for(int j = 0; j < dim[1]; j++) + if(i != row && j != column){ + int a = (offsetRows && i != 0 ? i - 1 : i), b = (offsetColumns && j != 0 ? j - 1 : j); + matrix[a][b] = this->matrix[i][j]; } - else if(i==row) offsetRows=true; - else if(j==column) offsetColumns=true; + else if(i == row) offsetRows = true; + else if(j == column) offsetColumns = true; } - return Matrix(matrix,newRows,newColumns); + return Matrix(matrix, newRows, newColumns); } void Matrix::invert(){ transpose(); - float **matrix=new float*[dim[0]]; + float **matrix = new float*[dim[0]]; - for(int i=0;imatrix[i]; delete[] this->matrix; - this->matrix=matrix; - *this/getDeterminant(); + this->matrix = matrix; + *this / getDeterminant(); } - float Matrix::getMinor(int row,int column){ - return getSubMatrix(row,column).getDeterminant(); + float Matrix::getMinor(int row, int column){ + return getSubMatrix(row, column).getDeterminant(); } - float Matrix::getCofactor(int row,int column){ - return ((row+column+2)%2==0?1:-1)*getMinor(row,column); + float Matrix::getCofactor(int row, int column){ + return ((row + column + 2) % 2 == 0 ? 1 : -1) * getMinor(row, column); } float Matrix::getDeterminant(){ - if(dim[0]!=dim[1]){ - cout<<"Matrix not square.\n"; + if(dim[0] != dim[1]){ + cout << "Matrix not square.\n"; exit(-1); } - if(dim[0]==1) + if(dim[0] == 1) return matrix[0][0]; - else if(dim[0]==2) - return matrix[0][0]*matrix[1][1]-matrix[1][0]*matrix[0][1]; + else if(dim[0] == 2) + return matrix[0][0] * matrix[1][1] - matrix[1][0] * matrix[0][1]; else{ - float det=0; - for(int i=0;i Matrix& operator* (T); template Matrix& operator/ (T); void transpose(); - Matrix getSubMatrix(int,int); + Matrix getSubMatrix(int, int); void invert(); - float getMinor(int,int); - float getCofactor(int,int); + float getMinor(int, int); + float getCofactor(int, int); float getDeterminant(); }; } diff --git a/mesh.cpp b/mesh.cpp index 822dbad..1a4037d 100755 --- a/mesh.cpp +++ b/mesh.cpp @@ -4,6 +4,7 @@ #include "texture.h" #include "skeleton.h" #include "animation.h" + #include #include #include diff --git a/modelReader.cpp b/modelReader.cpp index ba01250..c361f0f 100644 --- a/modelReader.cpp +++ b/modelReader.cpp @@ -1,7 +1,8 @@ -#include"modelReader.h" -#include"model.h" -#include -#include +#include "modelReader.h" +#include "model.h" + +#include +#include using namespace std; diff --git a/modelReader.h b/modelReader.h index f9992e6..d04a0e5 100644 --- a/modelReader.h +++ b/modelReader.h @@ -2,6 +2,7 @@ #define MODEL_READER #include + #include "model.h" namespace vb01{ diff --git a/quaternion.cpp b/quaternion.cpp index f4b1ca8..600b7e6 100755 --- a/quaternion.cpp +++ b/quaternion.cpp @@ -1,4 +1,4 @@ -#include"quaternion.h" +#include "quaternion.h" namespace vb01{ const Quaternion Quaternion::QUAT_W(1, 0, 0, 0); diff --git a/quaternion.h b/quaternion.h index 17f279b..8c2d322 100755 --- a/quaternion.h +++ b/quaternion.h @@ -1,8 +1,9 @@ #ifndef QUATERNION_H #define QUATERNION_H -#include -#include"vector.h" +#include + +#include "vector.h" namespace vb01{ class Quaternion{ diff --git a/ray.cpp b/ray.cpp index 0ea0308..fa2bd93 100644 --- a/ray.cpp +++ b/ray.cpp @@ -1,7 +1,8 @@ -#include -#include"ray.h" -#include"mesh.h" -#include"node.h" +#include + +#include "ray.h" +#include "mesh.h" +#include "node.h" using namespace std; diff --git a/ray.h b/ray.h index 9eb3951..9efa9a7 100644 --- a/ray.h +++ b/ray.h @@ -1,6 +1,7 @@ -#include"vector.h" -#include"util.h" -#include +#include "vector.h" +#include "util.h" + +#include namespace vb01{ class Node; diff --git a/root.cpp b/root.cpp index 2ed46b5..1215e08 100755 --- a/root.cpp +++ b/root.cpp @@ -1,13 +1,14 @@ -#include"stb_image.h" -#include"root.h" -#include"node.h" -#include"shader.h" -#include"box.h" -#include"quad.h" -#include -#include -#include -#include +#include "stb_image.h" +#include "root.h" +#include "node.h" +#include "shader.h" +#include "box.h" +#include "quad.h" + +#include +#include +#include +#include using namespace std; diff --git a/root.h b/root.h index 10fe133..ae3a0ab 100755 --- a/root.h +++ b/root.h @@ -1,9 +1,10 @@ #ifndef ROOT_H #define ROOT_H -#include"camera.h" -#include -#include +#include "camera.h" + +#include +#include class GLFWwindow; diff --git a/shader.cpp b/shader.cpp index fd22200..a5bebd5 100755 --- a/shader.cpp +++ b/shader.cpp @@ -1,11 +1,12 @@ -#include -#include -#include -#include -#include -#include"shader.h" -#include -#include +#include +#include +#include +#include +#include + +#include "shader.h" +#include +#include using namespace std; using namespace glm; diff --git a/shader.h b/shader.h index eeb7c83..14145a9 100755 --- a/shader.h +++ b/shader.h @@ -1,10 +1,11 @@ #ifndef SHADER_H #define SHADER_H -#include -#include -#include"vector.h" -#include"util.h" +#include +#include + +#include "vector.h" +#include "util.h" namespace vb01{ class Shader{ diff --git a/skeleton.cpp b/skeleton.cpp index d7c3114..a1f76c2 100644 --- a/skeleton.cpp +++ b/skeleton.cpp @@ -3,6 +3,7 @@ #include "animationController.h" #include "box.h" #include "ikSolver.h" + #include #include diff --git a/skeleton.h b/skeleton.h index f3afe57..fc17ddd 100644 --- a/skeleton.h +++ b/skeleton.h @@ -3,6 +3,7 @@ #include #include + #include "bone.h" namespace vb01{ diff --git a/texture.cpp b/texture.cpp index c542fb6..1b7bd5a 100755 --- a/texture.cpp +++ b/texture.cpp @@ -1,9 +1,12 @@ #define STB_IMAGE_IMPLEMENTATION -#include"stb_image.h" -#include -#include -#include"texture.h" -#include + +#include "stb_image.h" + +#include "texture.h" + +#include +#include +#include using namespace std; diff --git a/texture.h b/texture.h index 7443505..3e31330 100755 --- a/texture.h +++ b/texture.h @@ -3,6 +3,7 @@ #include #include + #include "util.h" #include "animatable.h" #include FT_FREETYPE_H diff --git a/util.cpp b/util.cpp index 4f70b31..f6496e3 100755 --- a/util.cpp +++ b/util.cpp @@ -1,5 +1,6 @@ -#include"util.h" -#include +#include "util.h" + +#include using namespace std; diff --git a/util.h b/util.h index 5369f17..81944d1 100755 --- a/util.h +++ b/util.h @@ -1,10 +1,10 @@ #ifndef UTIL_H #define UTIL_H -#include -#include -#include -#include +#include +#include +#include +#include namespace vb01{ typedef char s8; diff --git a/vector.cpp b/vector.cpp index a80c9b9..a840fc8 100755 --- a/vector.cpp +++ b/vector.cpp @@ -1,4 +1,4 @@ -#include"vector.h" +#include "vector.h" namespace vb01{ const Vector2 Vector2::VEC_IJ(1,1); diff --git a/vector.h b/vector.h index 2c9665f..a852ede 100755 --- a/vector.h +++ b/vector.h @@ -1,8 +1,8 @@ #ifndef VECTOR_H #define VECTOR_H -#include -#include +#include +#include namespace vb01{ struct Vector4{