Skip to content

Commit

Permalink
skeletal lib
Browse files Browse the repository at this point in the history
  • Loading branch information
CracklyBody committed Jun 24, 2020
1 parent c478a1c commit b09d337
Show file tree
Hide file tree
Showing 520 changed files with 136,954 additions and 0 deletions.
21 changes: 21 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
cmake_minimum_required(VERSION 3.5)

project(skeletallib)

# Find source files
file(GLOB SOURCES src/*.cpp)

FIND_PACKAGE(OpenGL)
# Include header files
include_directories(include)

# Create shared library
add_library(${PROJECT_NAME} STATIC ${SOURCES})
LINK_DIRECTORIES(${PROJECT_NAME}/lib/*.lib)
TARGET_LINK_LIBRARIES(skeletallib ../lib/SOIL ../lib/assimp-vc142-mtd opengl32 ../lib/glfw3dll ../lib/glew32)
# Install library
install(TARGETS ${PROJECT_NAME} DESTINATION lib/${PROJECT_NAME})

# Install library headers
file(GLOB HEADERS include/*.h)
install(FILES ${HEADERS} DESTINATION include/${PROJECT_NAME})
36 changes: 36 additions & 0 deletions include/Animation.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
#pragma once

#include <iostream>
#include <string>
#include <algorithm>

//define GLEW_STATIC
#include <GL/glew.h>
#include <GLFW/glfw3.h>
#include <glm/glm.hpp>

using namespace std;
using namespace glm;

class Animation
{
public:
string name; //name of the animation

float startTime; //start time of the animation
float endTime; //end time of the animation
float speed; //speed of the animation
int priority; //priority of the animation
bool loop; //is this animation looped

Animation();
Animation(string name, vec2 times, float speed = 0.25, int priority = 10, bool loop = false);

void setName(string name);
void setTime(vec2 frames);
void setSpeed(float speed);
void setPriority(int priority);
void setLoop(bool loop);

~Animation();
};
55 changes: 55 additions & 0 deletions include/Bone.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
#pragma once

#include <iostream>
#include <vector>
#include <string>
#include <algorithm>

//#define GLEW_STATIC
#include <GL/glew.h>
#include <GLFW/glfw3.h>
#include <glm/glm.hpp>
#include <glm/gtc/matrix_transform.hpp>
#include <glm/gtx/transform.hpp>
#include <glm/gtc/type_ptr.hpp>

#include <assimp/Importer.hpp>
#include <assimp/scene.h>
#include <assimp/postprocess.h>

using namespace std;
using namespace glm;
using namespace Assimp;

class Bone
{
public:
string name; //the name of the bone
int id; //bones id in the model

aiNode* node; //the node this bone is attached to
aiNodeAnim* nodeAnim; //this bone animation node

Bone* parentBone; //parent bone
mat4 offset; //offset matrix

//keyframe data. This data is calculated in a particular period of time
vec3 pos;
quat rot;
vec3 scal;


Bone(int id, string name, mat4& offset);

mat4 getParentTransforms(); //calculates the whole transformation matrix starting with the root bone

vec3 calcInterpolatedPosition(float time); //calculates interpolated position between two keyframes
quat calcInterpolatedRotation(float time); //calculates interpolated rotation between two keyframes

int findPosition(float time); //finds the index of the keyframe with the value less then time
int findRotation(float time); //same as above

void updateKeyframeTransform(float time); //updates this bone transformation matrix

~Bone();
};
Loading

0 comments on commit b09d337

Please sign in to comment.