Browse Source

Clean up repo and add other file formats

master
Skia 3 years ago
parent
commit
ba9249b247
13 changed files with 2560 additions and 426 deletions
  1. +0
    -1
      boneAnim.h
  2. +0
    -102
      boneState.h
  3. +0
    -70
      interpolation.h
  4. +0
    -51
      keyframe.h
  5. +0
    -1
      mesh.h
  6. BIN
      res/dragon_from_scratch/dragon.3ds
  7. +2560
    -0
      res/dragon_from_scratch/dragon.dae
  8. BIN
      res/dragon_from_scratch/dragon.fbx
  9. +0
    -60
      rotInterpolation.h
  10. +0
    -39
      rotKey.h
  11. +0
    -2
      scene.h
  12. +0
    -61
      vectInterpolation.h
  13. +0
    -39
      vectorKey.h

+ 0
- 1
boneAnim.h View File

@@ -8,7 +8,6 @@
#include <vertice.h>
#include <bone.h>
#include <mesh.h>
#include <interpolation.h>

class BoneAnim
{

+ 0
- 102
boneState.h View File

@@ -1,102 +0,0 @@
#ifndef __BONESTATE_H__
#define __BONESTATE_H__

#include <assimp/cimport.h>
#include <assimp/scene.h>
#include <assimp/postprocess.h>

#include <vertice.h>
#include <bone.h>
#include <mesh.h>
#include <vectInterpolation.h>
#include <rotInterpolation.h>

class BoneState{
private:

aiString boneName;

aiVector3D* currTrans;
aiVector3D* currScale;
aiQuaternion* currRot;

VectInterpolation* transInter;
VectInterpolation* scalInter;
RotInterpolation* rotInter;

int iT,iS,iR;
public:
BoneState(aiString name){
boneName=name;
}

void initTrans(aiVectorKey* prev, aiVectorKey* next, float tps){
int newIndex = (int)next->mTime*tps;
transInter = new VectInterpolation(*prev, *next, 1, newIndex);
currTrans = transInter->InterpolateVect(1);
iT=2;
}

void initScal(aiVectorKey* prev, aiVectorKey* next, float tps){
int newIndex = (int)next->mTime * tps;
scalInter = new VectInterpolation(*prev, *next, 1, newIndex);
currScale = scalInter->InterpolateVect(1);
iS=2;
}


void initRot(aiQuatKey* prev, aiQuatKey* next, float tps){
int newIndex = (int)next->mTime*tps;
rotInter = new RotInterpolation(*prev, *next, 1, newIndex);
currRot = rotInter->InterpolateRot(1);
iR=2;
}

void updateTransLastKey(aiVectorKey* key, float tps){
int newIndex = (int)key->mTime * tps;
transInter->Update(*key,newIndex);
iT++;
}

void updateScalLastKey(aiVectorKey* key, float tps){
int newIndex = (int)key->mTime * tps;
scalInter->Update(*key,newIndex);
iS++;
}

void updateRotLastKey(aiQuatKey* key, float tps){
int newIndex = (int)key->mTime * tps;
rotInter->Update(*key,newIndex);
iR++;
}

int getiT(){return iT;};
int getiR(){return iR;};
int getiS(){return iS;};

void updateTransValue(int index){
currTrans=transInter->InterpolateVect(index);
}

void updateScalValue(int index){
currScale=scalInter->InterpolateVect(index);
}

void updateRotValue(int index){
currRot=rotInter->InterpolateRot(index);
}

int getTransLastIndex(){return transInter->getLastIndex();};
int getScalLastIndex(){return scalInter->getLastIndex();};
int getRotLastIndex(){return rotInter->getLastIndex();};


aiVector3D* getCurrTrans(){return currTrans;};
aiVector3D* getCurrScal(){return currScale;};
aiQuaternion* getCurrRot(){return currRot;};

aiString &getName(){ return boneName; };

};

#endif

+ 0
- 70
interpolation.h View File

@@ -1,70 +0,0 @@
#ifndef __INTERPOLATION_H__
#define __INTERPOLATION_H__

#include <iostream>

#include <GL/gl.h>

#include <assimp/cimport.h>
#include <assimp/scene.h>
#include <assimp/postprocess.h>

#include <vectors.h>
#include <vertice.h>
#include <bone.h>
#include <keyframe.h>

class Interpolation{
private:
Keyframe prevKeyframe;
int indexPrevKeyframe;
Keyframe nextKeyframe;
int indexNextKeyframe;
int dist;

public:
Interpolation(Keyframe prev, Keyframe next, int prevI, int nextI){
prevKeyframe = prev;
nextKeyframe = next;
indexPrevKeyframe = prevI;
indexNextKeyframe = nextI;
dist = indexNextKeyframe - indexPrevKeyframe;
};

void Update(Keyframe newK, int index){
prevKeyframe = nextKeyframe;
indexPrevKeyframe = indexNextKeyframe;
nextKeyframe = newK;
indexNextKeyframe = index;
dist = indexNextKeyframe - indexPrevKeyframe;
};

float getFactor(int currentIndex){
float fact;
fact = (float)((currentIndex-indexPrevKeyframe)/dist);
return fact;
};

aiQuaternion interpolateRot(int index){
aiQuaternion rot;
rot.Interpolate(rot,prevKeyframe.getRotation().mValue,nextKeyframe.getRotation().mValue, getFactor(index) );
return rot;
}

aiVector3D InterpolatePos(int index){
aiVector3D pos;
float t = getFactor(index);
pos= (1-t)*prevKeyframe.getPosition().mValue + t*nextKeyframe.getPosition().mValue;
return pos;
}

aiVector3D InterpolateScal(int index){
aiVector3D scal;
float t = getFactor(index);
scal = (1-t)*prevKeyframe.getScaling().mValue + t*nextKeyframe.getScaling().mValue;
return scal;
}


};
#endif

+ 0
- 51
keyframe.h View File

@@ -1,51 +0,0 @@
#ifndef __KEYFRAME_H__
#define __KEYFRAME_H__

#include <iostream>

#include <GL/gl.h>

#include <assimp/cimport.h>
#include <assimp/scene.h>
#include <assimp/postprocess.h>

#include <vectors.h>
#include <vertice.h>
#include <bone.h>

class Keyframe{
private:
int index;
aiVectorKey position;
aiVectorKey scaling;
aiQuatKey rotation;

public:
Keyframe(int i,aiVectorKey scal,aiQuatKey rot, aiVectorKey pos){
index=i;
scaling=scal;
rotation=rot;
position=pos;
};

Keyframe(){
};

aiQuatKey getRotation(){
return rotation;
};

aiVectorKey getPosition(){
return position;
};

aiVectorKey getScaling(){
return scaling;
};

int getIndex(){
return index;
}

};
#endif

+ 0
- 1
mesh.h View File

@@ -12,7 +12,6 @@
#include <vectors.h>
#include <vertice.h>
#include <bone.h>
#include <boneState.h>
#include <animation.h>
#include <utils.h>


BIN
res/dragon_from_scratch/dragon.3ds View File


+ 2560
- 0
res/dragon_from_scratch/dragon.dae
File diff suppressed because it is too large
View File


BIN
res/dragon_from_scratch/dragon.fbx View File


+ 0
- 60
rotInterpolation.h View File

@@ -1,60 +0,0 @@
#ifndef __ROTINTERPOLATION_H__
#define __ROTINTERPOLATION_H__

#include <iostream>

#include <GL/gl.h>

#include <assimp/cimport.h>
#include <assimp/scene.h>
#include <assimp/postprocess.h>

#include <vectors.h>
#include <vertice.h>
#include <bone.h>

class RotInterpolation{
private:
aiQuatKey prevKeyframe;
int indexPrevKeyframe;
aiQuatKey nextKeyframe;
int indexNextKeyframe;
int dist;

public:
RotInterpolation(aiQuatKey prev, aiQuatKey next, int prevI, int nextI){
prevKeyframe = prev;
nextKeyframe = next;
indexPrevKeyframe = prevI;
indexNextKeyframe = nextI;
dist = indexNextKeyframe - indexPrevKeyframe;
};

RotInterpolation(){

};

void Update(aiQuatKey newK, int index){
prevKeyframe = nextKeyframe;
indexPrevKeyframe = indexNextKeyframe;
nextKeyframe = newK;
indexNextKeyframe = index;
dist = indexNextKeyframe - indexPrevKeyframe;
};

float getFactor(int currentIndex){
float fact;
fact = (float)((currentIndex-indexPrevKeyframe)/dist);
return fact;
};

aiQuaternion *InterpolateRot(int index){
aiQuaternion *rot = new aiQuaternion();
rot->Interpolate(*rot, prevKeyframe.mValue, nextKeyframe.mValue, getFactor(index) );
return rot;
}

int getLastIndex(){return indexNextKeyframe;};

};
#endif

+ 0
- 39
rotKey.h View File

@@ -1,39 +0,0 @@
#ifndef __ROTKEY_H__
#define __ROTKEY_H__

#include <iostream>

#include <GL/gl.h>

#include <assimp/cimport.h>
#include <assimp/scene.h>
#include <assimp/postprocess.h>

#include <vectors.h>
#include <vertice.h>
#include <bone.h>

class RotKey{
private:
int index;
aiQuatKey key;

public:
RotKey(int i,aiQuatKey k){
index=i;
key=k;
};

RotKey(){
};

aiQuatKey getKey(){
return key;
};

int getIndex(){
return index;
}

};
#endif

+ 0
- 2
scene.h View File

@@ -10,8 +10,6 @@ class SceneHandler;
#include <vertice.h>
#include <bone.h>
#include <mesh.h>
#include <interpolation.h>
#include <keyframe.h>
#include <boneAnim.h>
#include <utils.h>


+ 0
- 61
vectInterpolation.h View File

@@ -1,61 +0,0 @@
#ifndef __VECTINTERPOLATION_H__
#define __VECTINTERPOLATION_H__

#include <iostream>

#include <GL/gl.h>

#include <assimp/cimport.h>
#include <assimp/scene.h>
#include <assimp/postprocess.h>

#include <vectors.h>
#include <vertice.h>
#include <bone.h>

class VectInterpolation{
private:
aiVectorKey prevKeyframe;
int indexPrevKeyframe;
aiVectorKey nextKeyframe;
int indexNextKeyframe;
int dist;

public:
VectInterpolation() {};
VectInterpolation(aiVectorKey &prev, aiVectorKey &next, int prevI, int nextI){
prevKeyframe = prev;
nextKeyframe = next;
indexPrevKeyframe = prevI;
indexNextKeyframe = nextI;
dist = indexNextKeyframe - indexPrevKeyframe;
};

void Update(aiVectorKey newK, int index){
std::cout << "Index: " << index << "\n";
prevKeyframe = nextKeyframe;
indexPrevKeyframe = indexNextKeyframe;
nextKeyframe = newK;
indexNextKeyframe = index;
dist = indexNextKeyframe - indexPrevKeyframe;
};

float getFactor(int currentIndex){
float fact;
fact = (float)((currentIndex-indexPrevKeyframe)/dist);
return fact;
};

aiVector3D *InterpolateVect(int index){
aiVector3D* pos = new aiVector3D();
float t = getFactor(index);
*pos = (1-t)*prevKeyframe.mValue + t*nextKeyframe.mValue;
return pos;
}

int getLastIndex(){return indexNextKeyframe;};



};
#endif

+ 0
- 39
vectorKey.h View File

@@ -1,39 +0,0 @@
#ifndef __VECTORKEY_H__
#define __VECTORKEY_H__

#include <iostream>

#include <GL/gl.h>

#include <assimp/cimport.h>
#include <assimp/scene.h>
#include <assimp/postprocess.h>

#include <vectors.h>
#include <vertice.h>
#include <bone.h>

class VectorKey{
private:
int index;
aiVectorKey key;

public:
VectorKey(int i,aiVectorKey k){
index=i;
key=k;
};

VectorKey(){
};

aiVectorKey getKey(){
return key;
};

int getIndex(){
return index;
}

};
#endif

Loading…
Cancel
Save