mirror of
https://github.com/ApfelTeeSaft/vb01.git
synced 2026-08-26 19:33:45 +00:00
Animation controller uses now the singleton pattern
This commit is contained in:
@@ -12,9 +12,9 @@ using namespace std;
|
|||||||
namespace vb01{
|
namespace vb01{
|
||||||
void AnimationChannelTest::setUp(){
|
void AnimationChannelTest::setUp(){
|
||||||
Bone *bone = new Bone("bone", 1, Vector3(0, 0, 0), Quaternion::QUAT_I, Vector3::VEC_IJK);
|
Bone *bone = new Bone("bone", 1, Vector3(0, 0, 0), Quaternion::QUAT_I, Vector3::VEC_IJK);
|
||||||
skeleton = new Skeleton(new AnimationController());
|
skeleton = new Skeleton();
|
||||||
skeleton->addBone(bone, nullptr);
|
skeleton->addBone(bone, nullptr);
|
||||||
AnimationController *controller = skeleton->getAnimationController();
|
AnimationController *controller = AnimationController::getSingleton();
|
||||||
|
|
||||||
Keyframe k1, k2;
|
Keyframe k1, k2;
|
||||||
k1.frame = 0;
|
k1.frame = 0;
|
||||||
|
|||||||
@@ -5,6 +5,15 @@
|
|||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
namespace vb01{
|
namespace vb01{
|
||||||
|
static AnimationController *animationController = nullptr;
|
||||||
|
|
||||||
|
AnimationController* AnimationController::getSingleton(){
|
||||||
|
if(!animationController)
|
||||||
|
animationController = new AnimationController();
|
||||||
|
|
||||||
|
return animationController;
|
||||||
|
}
|
||||||
|
|
||||||
void AnimationController::update(){
|
void AnimationController::update(){
|
||||||
for(AnimationChannel *channel : channels){
|
for(AnimationChannel *channel : channels){
|
||||||
channel->update();
|
channel->update();
|
||||||
@@ -14,8 +23,10 @@ namespace vb01{
|
|||||||
|
|
||||||
void AnimationController::transform(AnimationChannel *channel){
|
void AnimationController::transform(AnimationChannel *channel){
|
||||||
Animation *animation = getAnimation(channel->getAnimationName());
|
Animation *animation = getAnimation(channel->getAnimationName());
|
||||||
|
|
||||||
for(Animatable *animatable : channel->getAnimatables()){
|
for(Animatable *animatable : channel->getAnimatables()){
|
||||||
vector<KeyframeChannel> keyframeChannels = animation->getKeyframeChannelsByAnimatable(animatable);
|
vector<KeyframeChannel> keyframeChannels = animation->getKeyframeChannelsByAnimatable(animatable);
|
||||||
|
|
||||||
for(KeyframeChannel keyframeChannel : keyframeChannels){
|
for(KeyframeChannel keyframeChannel : keyframeChannels){
|
||||||
int currentFrame = channel->getCurrentFrame();
|
int currentFrame = channel->getCurrentFrame();
|
||||||
Keyframe pastKeyframe = KeyframeChannel::findKeyframe(currentFrame, keyframeChannel, true);
|
Keyframe pastKeyframe = KeyframeChannel::findKeyframe(currentFrame, keyframeChannel, true);
|
||||||
@@ -33,11 +44,13 @@ namespace vb01{
|
|||||||
|
|
||||||
Animation* AnimationController::getAnimation(string name){
|
Animation* AnimationController::getAnimation(string name){
|
||||||
Animation *anim = nullptr;
|
Animation *anim = nullptr;
|
||||||
|
|
||||||
for(Animation *a : animations)
|
for(Animation *a : animations)
|
||||||
if(a->getName() == name){
|
if(a->getName() == name){
|
||||||
anim = a;
|
anim = a;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
return anim;
|
return anim;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -15,8 +15,7 @@ namespace vb01{
|
|||||||
|
|
||||||
class AnimationController{
|
class AnimationController{
|
||||||
public:
|
public:
|
||||||
AnimationController(){}
|
static AnimationController* getSingleton();
|
||||||
~AnimationController(){}
|
|
||||||
void update();
|
void update();
|
||||||
Animation* getAnimation(std::string);
|
Animation* getAnimation(std::string);
|
||||||
void addAnimationChannel(AnimationChannel *channel);
|
void addAnimationChannel(AnimationChannel *channel);
|
||||||
@@ -26,6 +25,7 @@ namespace vb01{
|
|||||||
std::vector<Animation*> animations;
|
std::vector<Animation*> animations;
|
||||||
std::vector<AnimationChannel*> channels;
|
std::vector<AnimationChannel*> channels;
|
||||||
|
|
||||||
|
AnimationController(){}
|
||||||
void transform(AnimationChannel*);
|
void transform(AnimationChannel*);
|
||||||
protected:
|
protected:
|
||||||
void onAnimationEnd(std::string){}
|
void onAnimationEnd(std::string){}
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ namespace vb01{
|
|||||||
kg.bone = bone;
|
kg.bone = bone;
|
||||||
kg.keyframeChannels = vector<KeyframeChannel>({ch0, ch1});
|
kg.keyframeChannels = vector<KeyframeChannel>({ch0, ch1});
|
||||||
|
|
||||||
controller = skeleton->getAnimationController();
|
controller = AnimationController::getSingleton();
|
||||||
Animation *anim = new Animation("anim");
|
Animation *anim = new Animation("anim");
|
||||||
anim->addKeyframeGroup(kg);
|
anim->addKeyframeGroup(kg);
|
||||||
controller->addAnimation(anim);
|
controller->addAnimation(anim);
|
||||||
@@ -45,7 +45,7 @@ namespace vb01{
|
|||||||
|
|
||||||
void AnimationControllerTest::setUp(){
|
void AnimationControllerTest::setUp(){
|
||||||
Node *rootNode = Root::getSingleton()->getRootNode();
|
Node *rootNode = Root::getSingleton()->getRootNode();
|
||||||
skeleton = new Skeleton(new AnimationController());
|
skeleton = new Skeleton();
|
||||||
Bone *bone = new Bone("bone", 1.f, Vector3::VEC_ZERO, Quaternion::QUAT_W, Vector3::VEC_IJK);
|
Bone *bone = new Bone("bone", 1.f, Vector3::VEC_ZERO, Quaternion::QUAT_W, Vector3::VEC_IJK);
|
||||||
skeleton->addBone(bone, (Bone*)rootNode);
|
skeleton->addBone(bone, (Bone*)rootNode);
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -15,7 +15,7 @@ namespace vb01{
|
|||||||
rootNode->attachChild(modelNodeParent);
|
rootNode->attachChild(modelNodeParent);
|
||||||
modelNodeParent->attachChild(modelNode);
|
modelNodeParent->attachChild(modelNode);
|
||||||
|
|
||||||
skeleton = new Skeleton(new AnimationController());
|
skeleton = new Skeleton();
|
||||||
|
|
||||||
Bone *rootBone = new Bone("rootBone", 1, Vector3::VEC_ZERO, Quaternion::QUAT_W, Vector3::VEC_IJK);
|
Bone *rootBone = new Bone("rootBone", 1, Vector3::VEC_ZERO, Quaternion::QUAT_W, Vector3::VEC_IJK);
|
||||||
Bone *pelvis = new Bone("pelvis", 1, Vector3(0, 2, 0), Quaternion::QUAT_W, Vector3::VEC_IJK);
|
Bone *pelvis = new Bone("pelvis", 1, Vector3(0, 2, 0), Quaternion::QUAT_W, Vector3::VEC_IJK);
|
||||||
|
|||||||
+2
-2
@@ -40,7 +40,7 @@ int main(){
|
|||||||
* Populate the scene with cubes
|
* Populate the scene with cubes
|
||||||
*/
|
*/
|
||||||
Box *driverBox = new Box(Vector3(1, 1, 1) * .25);
|
Box *driverBox = new Box(Vector3(1, 1, 1) * .25);
|
||||||
Node *driver = new Node(Vector3::VEC_ZERO, Quaternion::QUAT_W, Vector3::VEC_IJK, "", new AnimationController());
|
Node *driver = new Node(Vector3::VEC_ZERO, Quaternion::QUAT_W, Vector3::VEC_IJK, "");
|
||||||
Material *driverMat = new Material(PATH + "texture");
|
Material *driverMat = new Material(PATH + "texture");
|
||||||
driverMat->addBoolUniform("texturingEnabled", false);
|
driverMat->addBoolUniform("texturingEnabled", false);
|
||||||
driverMat->addVec4Uniform("diffuseColor", Vector4(0, 1, 0, 1));
|
driverMat->addVec4Uniform("diffuseColor", Vector4(0, 1, 0, 1));
|
||||||
@@ -113,7 +113,7 @@ int main(){
|
|||||||
* The AnimationController plays the animations set in the AnimationChannel objects.
|
* The AnimationController plays the animations set in the AnimationChannel objects.
|
||||||
* AnimationChannel objects require an animation and animatable objects, e.g. textures to work.
|
* AnimationChannel objects require an animation and animatable objects, e.g. textures to work.
|
||||||
*/
|
*/
|
||||||
AnimationController *controller = driver->getAnimationController();
|
AnimationController *controller = AnimationController::getSingleton();
|
||||||
controller->addAnimation(anim);
|
controller->addAnimation(anim);
|
||||||
AnimationChannel *channel = new AnimationChannel();
|
AnimationChannel *channel = new AnimationChannel();
|
||||||
controller->addAnimationChannel(channel);
|
controller->addAnimationChannel(channel);
|
||||||
|
|||||||
+1
-1
@@ -7,7 +7,7 @@ namespace vb01{
|
|||||||
void IkSolverTest::setUp(){
|
void IkSolverTest::setUp(){
|
||||||
rootNode = Root::getSingleton()->getRootNode();
|
rootNode = Root::getSingleton()->getRootNode();
|
||||||
|
|
||||||
skeleton = new Skeleton(new AnimationController());
|
skeleton = new Skeleton();
|
||||||
|
|
||||||
Bone *boneA = new Bone("A", 1, Vector3::VEC_ZERO, Quaternion::QUAT_W, Vector3::VEC_IJK);
|
Bone *boneA = new Bone("A", 1, Vector3::VEC_ZERO, Quaternion::QUAT_W, Vector3::VEC_IJK);
|
||||||
Bone *boneB = new Bone("B", 1, Vector3::VEC_J, Quaternion::QUAT_W, Vector3::VEC_IJK);
|
Bone *boneB = new Bone("B", 1, Vector3::VEC_J, Quaternion::QUAT_W, Vector3::VEC_IJK);
|
||||||
|
|||||||
+2
-2
@@ -74,7 +74,7 @@ int main(){
|
|||||||
Light *light = new Light(Light::SPOT);
|
Light *light = new Light(Light::SPOT);
|
||||||
light->setColor(Vector3(1, 1, 1));
|
light->setColor(Vector3(1, 1, 1));
|
||||||
|
|
||||||
Node *lightNode = new Node(Vector3::VEC_ZERO, Quaternion::QUAT_W, Vector3::VEC_IJK, "", new AnimationController());
|
Node *lightNode = new Node(Vector3::VEC_ZERO, Quaternion::QUAT_W, Vector3::VEC_IJK, "");
|
||||||
lightNode->addLight(light);
|
lightNode->addLight(light);
|
||||||
rootNode->attachChild(lightNode);
|
rootNode->attachChild(lightNode);
|
||||||
lightNode->setOrientation(Quaternion(.7, Vector3(1, 0, 0)));
|
lightNode->setOrientation(Quaternion(.7, Vector3(1, 0, 0)));
|
||||||
@@ -111,7 +111,7 @@ int main(){
|
|||||||
* The AnimationController plays the animations set in the AnimationChannel objects.
|
* The AnimationController plays the animations set in the AnimationChannel objects.
|
||||||
* AnimationChannel objects require an animation and animatable objects, e.g. textures to work.
|
* AnimationChannel objects require an animation and animatable objects, e.g. textures to work.
|
||||||
*/
|
*/
|
||||||
AnimationController *controller = lightNode->getAnimationController();
|
AnimationController *controller = AnimationController::getSingleton();
|
||||||
controller->addAnimation(animation);
|
controller->addAnimation(animation);
|
||||||
AnimationChannel *channel = new AnimationChannel();
|
AnimationChannel *channel = new AnimationChannel();
|
||||||
controller->addAnimationChannel(channel);
|
controller->addAnimationChannel(channel);
|
||||||
|
|||||||
@@ -58,7 +58,7 @@ int main(){
|
|||||||
* The AnimationController plays the animations set in the AnimationChannel objects.
|
* The AnimationController plays the animations set in the AnimationChannel objects.
|
||||||
* AnimationChannel objects require an animation and animatable objects, e.g. textures to work.
|
* AnimationChannel objects require an animation and animatable objects, e.g. textures to work.
|
||||||
*/
|
*/
|
||||||
AnimationController *controller = skeleton->getAnimationController();
|
AnimationController *controller = AnimationController::getSingleton();
|
||||||
AnimationChannel *channel = new AnimationChannel();
|
AnimationChannel *channel = new AnimationChannel();
|
||||||
controller->addAnimationChannel(channel);
|
controller->addAnimationChannel(channel);
|
||||||
channel->addAnimatable(skeleton->getBone("bone"));
|
channel->addAnimatable(skeleton->getBone("bone"));
|
||||||
|
|||||||
@@ -15,12 +15,11 @@ using namespace std;
|
|||||||
using namespace glm;
|
using namespace glm;
|
||||||
|
|
||||||
namespace vb01{
|
namespace vb01{
|
||||||
Node::Node(Vector3 pos, Quaternion orientation, Vector3 scale, string name, AnimationController *controller) : Animatable(){
|
Node::Node(Vector3 pos, Quaternion orientation, Vector3 scale, string name) : Animatable(){
|
||||||
this->pos = pos;
|
this->pos = pos;
|
||||||
this->scale = scale;
|
this->scale = scale;
|
||||||
this->orientation = orientation;
|
this->orientation = orientation;
|
||||||
this->name = name;
|
this->name = name;
|
||||||
this->controller = controller;
|
|
||||||
|
|
||||||
globalAxis[0] = Vector3::VEC_I;
|
globalAxis[0] = Vector3::VEC_I;
|
||||||
globalAxis[1] = Vector3::VEC_J;
|
globalAxis[1] = Vector3::VEC_J;
|
||||||
@@ -54,8 +53,6 @@ namespace vb01{
|
|||||||
c->update();
|
c->update();
|
||||||
for(ParticleEmitter *p : emitters)
|
for(ParticleEmitter *p : emitters)
|
||||||
p->update();
|
p->update();
|
||||||
if(controller)
|
|
||||||
controller->update();
|
|
||||||
}
|
}
|
||||||
for(Driver *driver : drivers)
|
for(Driver *driver : drivers)
|
||||||
driver->drive(getDriverValue(driver->getType()));
|
driver->drive(getDriverValue(driver->getType()));
|
||||||
|
|||||||
@@ -16,11 +16,10 @@ namespace vb01{
|
|||||||
class Light;
|
class Light;
|
||||||
class ParticleEmitter;
|
class ParticleEmitter;
|
||||||
class Text;
|
class Text;
|
||||||
class AnimationController;
|
|
||||||
|
|
||||||
class Node : public Animatable{
|
class Node : public Animatable{
|
||||||
public:
|
public:
|
||||||
Node(Vector3 = Vector3::VEC_ZERO, Quaternion = Quaternion::QUAT_W, Vector3 = Vector3::VEC_IJK, std::string = "", AnimationController *c = nullptr);
|
Node(Vector3 = Vector3::VEC_ZERO, Quaternion = Quaternion::QUAT_W, Vector3 = Vector3::VEC_IJK, std::string = "");
|
||||||
virtual ~Node();
|
virtual ~Node();
|
||||||
void attachMesh(Mesh*);
|
void attachMesh(Mesh*);
|
||||||
void attachParticleEmitter(ParticleEmitter*);
|
void attachParticleEmitter(ParticleEmitter*);
|
||||||
@@ -63,14 +62,12 @@ namespace vb01{
|
|||||||
inline std::string getName(){return name;}
|
inline std::string getName(){return name;}
|
||||||
inline void setVisible(bool v){this->visible = v;}
|
inline void setVisible(bool v){this->visible = v;}
|
||||||
inline void addDriver(Driver *d){drivers.push_back(d);}
|
inline void addDriver(Driver *d){drivers.push_back(d);}
|
||||||
inline AnimationController* getAnimationController(){return controller;}
|
|
||||||
private:
|
private:
|
||||||
void adjustUp(Vector3);
|
void adjustUp(Vector3);
|
||||||
void adjustDir(Vector3);
|
void adjustDir(Vector3);
|
||||||
void updateShaders();
|
void updateShaders();
|
||||||
|
|
||||||
Quaternion adjustRot(std::vector<Node*>, Quaternion, bool);
|
Quaternion adjustRot(std::vector<Node*>, Quaternion, bool);
|
||||||
AnimationController *controller = nullptr;
|
|
||||||
std::vector<Driver*> drivers;
|
std::vector<Driver*> drivers;
|
||||||
protected:
|
protected:
|
||||||
virtual void animate(float, KeyframeChannel);
|
virtual void animate(float, KeyframeChannel);
|
||||||
|
|||||||
@@ -5,6 +5,7 @@
|
|||||||
#include "box.h"
|
#include "box.h"
|
||||||
#include "quad.h"
|
#include "quad.h"
|
||||||
#include "lineRenderer.h"
|
#include "lineRenderer.h"
|
||||||
|
#include "animationController.h"
|
||||||
|
|
||||||
#include "glad.h"
|
#include "glad.h"
|
||||||
#include <glfw3.h>
|
#include <glfw3.h>
|
||||||
@@ -150,6 +151,8 @@ namespace vb01{
|
|||||||
glCullFace(GL_BACK);
|
glCullFace(GL_BACK);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
AnimationController::getSingleton()->update();
|
||||||
|
|
||||||
rootNode->update();
|
rootNode->update();
|
||||||
|
|
||||||
LineRenderer::getSingleton()->drawLines();
|
LineRenderer::getSingleton()->drawLines();
|
||||||
|
|||||||
@@ -58,7 +58,7 @@ int main(){
|
|||||||
* The AnimationController plays the animations set in the AnimationChannel objects.
|
* The AnimationController plays the animations set in the AnimationChannel objects.
|
||||||
* AnimationChannel objects require an animation and animatable objects, e.g. textures to work.
|
* AnimationChannel objects require an animation and animatable objects, e.g. textures to work.
|
||||||
*/
|
*/
|
||||||
AnimationController *controller = skeleton->getAnimationController();
|
AnimationController *controller = AnimationController::getSingleton();
|
||||||
AnimationChannel *channel = new AnimationChannel();
|
AnimationChannel *channel = new AnimationChannel();
|
||||||
controller->addAnimationChannel(channel);
|
controller->addAnimationChannel(channel);
|
||||||
channel->addAnimatable(skeleton->getBone("handIK.R"));
|
channel->addAnimatable(skeleton->getBone("handIK.R"));
|
||||||
|
|||||||
+1
-3
@@ -11,14 +11,12 @@ using namespace std;
|
|||||||
using namespace glm;
|
using namespace glm;
|
||||||
|
|
||||||
namespace vb01{
|
namespace vb01{
|
||||||
Skeleton::Skeleton(AnimationController *controller, string name){
|
Skeleton::Skeleton(string name){
|
||||||
this->name = name;
|
this->name = name;
|
||||||
this->controller = controller;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Skeleton::update(){
|
void Skeleton::update(){
|
||||||
updateIk();
|
updateIk();
|
||||||
controller->update();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Skeleton::updateIk(){
|
void Skeleton::updateIk(){
|
||||||
|
|||||||
+1
-4
@@ -8,15 +8,13 @@
|
|||||||
|
|
||||||
namespace vb01{
|
namespace vb01{
|
||||||
class Animation;
|
class Animation;
|
||||||
class AnimationController;
|
|
||||||
|
|
||||||
class Skeleton{
|
class Skeleton{
|
||||||
public:
|
public:
|
||||||
Skeleton(AnimationController*, std::string = "");
|
Skeleton(std::string = "");
|
||||||
void update();
|
void update();
|
||||||
void addBone(Bone*, Bone*);
|
void addBone(Bone*, Bone*);
|
||||||
Bone* getBone(std::string);
|
Bone* getBone(std::string);
|
||||||
inline AnimationController* getAnimationController(){return controller;}
|
|
||||||
inline Bone* getBone(int i){return bones[i];}
|
inline Bone* getBone(int i){return bones[i];}
|
||||||
inline Bone* getRootBone(){return bones[0];}
|
inline Bone* getRootBone(){return bones[0];}
|
||||||
inline std::vector<Bone*>& getBones(){return bones;}
|
inline std::vector<Bone*>& getBones(){return bones;}
|
||||||
@@ -30,7 +28,6 @@ namespace vb01{
|
|||||||
|
|
||||||
std::string name;
|
std::string name;
|
||||||
std::vector<Bone*> bones;
|
std::vector<Bone*> bones;
|
||||||
AnimationController *controller = nullptr;
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+2
-2
@@ -65,7 +65,7 @@ int main(){
|
|||||||
text->setHorizontal(horizontal[i]);
|
text->setHorizontal(horizontal[i]);
|
||||||
text->setMaterial(textMat);
|
text->setMaterial(textMat);
|
||||||
|
|
||||||
Node *textNode = new Node(Vector3(0, 50 * (i + 1), 0), Quaternion::QUAT_W, Vector3::VEC_IJK, "", new AnimationController());
|
Node *textNode = new Node(Vector3(0, 50 * (i + 1), 0), Quaternion::QUAT_W, Vector3::VEC_IJK, "");
|
||||||
textNode->addText(text);
|
textNode->addText(text);
|
||||||
guiNode->attachChild(textNode);
|
guiNode->attachChild(textNode);
|
||||||
|
|
||||||
@@ -103,7 +103,7 @@ int main(){
|
|||||||
* The AnimationController plays the animations set in the AnimationChannel objects.
|
* The AnimationController plays the animations set in the AnimationChannel objects.
|
||||||
* AnimationChannel objects require an animation and animatable objects, e.g. textures to work.
|
* AnimationChannel objects require an animation and animatable objects, e.g. textures to work.
|
||||||
*/
|
*/
|
||||||
AnimationController *controller = textNode->getAnimationController();
|
AnimationController *controller = AnimationController::getSingleton();
|
||||||
controller->addAnimation(anim);
|
controller->addAnimation(anim);
|
||||||
AnimationChannel *channel = new AnimationChannel();
|
AnimationChannel *channel = new AnimationChannel();
|
||||||
controller->addAnimationChannel(channel);
|
controller->addAnimationChannel(channel);
|
||||||
|
|||||||
+8
-11
@@ -268,7 +268,7 @@ namespace vb01{
|
|||||||
return keyframeChannel;
|
return keyframeChannel;
|
||||||
}
|
}
|
||||||
|
|
||||||
void VbModelReader::readAnimations(Animatable *animatable, AnimationController *controller, vector<string> &animationData){
|
void VbModelReader::readAnimations(Animatable *animatable, vector<string> &animationData){
|
||||||
int numAnimations = atoi(animationData[0].substr(animationData[0].find_first_of(':') + 2).c_str());
|
int numAnimations = atoi(animationData[0].substr(animationData[0].find_first_of(':') + 2).c_str());
|
||||||
int animStartLine = 1;
|
int animStartLine = 1;
|
||||||
|
|
||||||
@@ -279,7 +279,7 @@ namespace vb01{
|
|||||||
currentAnim = data[0];
|
currentAnim = data[0];
|
||||||
|
|
||||||
Animation *animation = new Animation(currentAnim);
|
Animation *animation = new Animation(currentAnim);
|
||||||
controller->addAnimation(animation);
|
AnimationController::getSingleton()->addAnimation(animation);
|
||||||
|
|
||||||
int numKeyframeChannels = atoi(data[1].c_str());
|
int numKeyframeChannels = atoi(data[1].c_str());
|
||||||
int keyframeChannelStartLine = animStartLine + 1;
|
int keyframeChannelStartLine = animStartLine + 1;
|
||||||
@@ -331,8 +331,7 @@ namespace vb01{
|
|||||||
int animationStartLine = boneStartLine + numBones;
|
int animationStartLine = boneStartLine + numBones;
|
||||||
int driverStartLine = findDriverStartLine(skeletonData, animationStartLine);
|
int driverStartLine = findDriverStartLine(skeletonData, animationStartLine);
|
||||||
|
|
||||||
AnimationController *controller = new AnimationController();
|
Skeleton *skeleton = new Skeleton(name);
|
||||||
Skeleton *skeleton = new Skeleton(controller, name);
|
|
||||||
currentSkeleton = skeleton;
|
currentSkeleton = skeleton;
|
||||||
|
|
||||||
vector<string> skeletonSubData = vector<string>(skeletonData.begin() + boneStartLine, skeletonData.begin() + boneStartLine + numBones);
|
vector<string> skeletonSubData = vector<string>(skeletonData.begin() + boneStartLine, skeletonData.begin() + boneStartLine + numBones);
|
||||||
@@ -340,7 +339,7 @@ namespace vb01{
|
|||||||
skeletonSubData.clear();
|
skeletonSubData.clear();
|
||||||
|
|
||||||
skeletonSubData = vector<string>(skeletonData.begin() + animationStartLine, skeletonData.begin() + driverStartLine);
|
skeletonSubData = vector<string>(skeletonData.begin() + animationStartLine, skeletonData.begin() + driverStartLine);
|
||||||
readAnimations(nullptr, controller, skeletonSubData);
|
readAnimations(nullptr, skeletonSubData);
|
||||||
skeletonSubData.clear();
|
skeletonSubData.clear();
|
||||||
|
|
||||||
skeletonSubData = vector<string>(skeletonData.begin() + driverStartLine, skeletonData.end());
|
skeletonSubData = vector<string>(skeletonData.begin() + driverStartLine, skeletonData.end());
|
||||||
@@ -536,12 +535,11 @@ namespace vb01{
|
|||||||
getLineData(meshData[3].substr(meshData[3].find_first_of(':') + 2), data, 3);
|
getLineData(meshData[3].substr(meshData[3].find_first_of(':') + 2), data, 3);
|
||||||
Vector3 scale = Vector3(atof(data[0].c_str()), atof(data[1].c_str()), atof(data[2].c_str()));
|
Vector3 scale = Vector3(atof(data[0].c_str()), atof(data[1].c_str()), atof(data[2].c_str()));
|
||||||
|
|
||||||
AnimationController *controller = new AnimationController();
|
Node *node = new Node(pos, rot, scale, name);
|
||||||
Node *node = new Node(pos, rot, scale, name, controller);
|
|
||||||
nodes.push_back(node);
|
nodes.push_back(node);
|
||||||
|
|
||||||
meshSubData = vector<string>(meshData.begin() + animationStartLine, meshData.begin() + driverStartLine);
|
meshSubData = vector<string>(meshData.begin() + animationStartLine, meshData.begin() + driverStartLine);
|
||||||
readAnimations(node, controller, meshSubData);
|
readAnimations(node, meshSubData);
|
||||||
meshSubData.clear();
|
meshSubData.clear();
|
||||||
|
|
||||||
meshSubData = vector<string>(meshData.begin() + driverStartLine, meshData.end());
|
meshSubData = vector<string>(meshData.begin() + driverStartLine, meshData.end());
|
||||||
@@ -604,15 +602,14 @@ namespace vb01{
|
|||||||
light->setInnerAngle(innerAngle);
|
light->setInnerAngle(innerAngle);
|
||||||
currentLight = light;
|
currentLight = light;
|
||||||
|
|
||||||
AnimationController *controller = new AnimationController();
|
Node *node = new Node(pos, rot, scale, name);
|
||||||
Node *node = new Node(pos, rot, scale, name, controller);
|
|
||||||
node->addLight(light);
|
node->addLight(light);
|
||||||
nodes.push_back(node);
|
nodes.push_back(node);
|
||||||
|
|
||||||
int animationStartLine = 9;
|
int animationStartLine = 9;
|
||||||
int driverStartLine = findDriverStartLine(lightData, animationStartLine);
|
int driverStartLine = findDriverStartLine(lightData, animationStartLine);
|
||||||
vector<string> lightSubData = vector<string>(lightData.begin() + animationStartLine, lightData.begin() + driverStartLine);
|
vector<string> lightSubData = vector<string>(lightData.begin() + animationStartLine, lightData.begin() + driverStartLine);
|
||||||
readAnimations(node, controller, lightSubData);
|
readAnimations(node, lightSubData);
|
||||||
lightSubData.clear();
|
lightSubData.clear();
|
||||||
|
|
||||||
lightSubData = vector<string>(lightData.begin() + driverStartLine, lightData.end());
|
lightSubData = vector<string>(lightData.begin() + driverStartLine, lightData.end());
|
||||||
|
|||||||
+1
-1
@@ -27,7 +27,7 @@ namespace vb01{
|
|||||||
int findDriverStartLine(std::vector<std::string>&, int);
|
int findDriverStartLine(std::vector<std::string>&, int);
|
||||||
void createBones(Skeleton*, std::vector<std::string>&);
|
void createBones(Skeleton*, std::vector<std::string>&);
|
||||||
KeyframeChannel readKeyframeChannel(Animatable*, std::vector<std::string>&, int&);
|
KeyframeChannel readKeyframeChannel(Animatable*, std::vector<std::string>&, int&);
|
||||||
void readAnimations(Animatable*, AnimationController*, std::vector<std::string>&);
|
void readAnimations(Animatable*, std::vector<std::string>&);
|
||||||
Skeleton* readSkeleton(std::vector<std::string>&);
|
Skeleton* readSkeleton(std::vector<std::string>&);
|
||||||
void readVertices(std::vector<Vector3>&, std::vector<Vector3>&, std::vector<float>&, std::vector<std::string>&, int);
|
void readVertices(std::vector<Vector3>&, std::vector<Vector3>&, std::vector<float>&, std::vector<std::string>&, int);
|
||||||
void readFaces(std::vector<Vector3>&, std::vector<Vector3>&, std::vector<u32>&, std::vector<float>&, std::vector<std::string>&, int, Mesh::Vertex*, u32*);
|
void readFaces(std::vector<Vector3>&, std::vector<Vector3>&, std::vector<u32>&, std::vector<float>&, std::vector<std::string>&, int, Mesh::Vertex*, u32*);
|
||||||
|
|||||||
@@ -176,7 +176,7 @@ namespace vb01{
|
|||||||
else
|
else
|
||||||
CPPUNIT_ASSERT(bones[i].parent == "-");
|
CPPUNIT_ASSERT(bones[i].parent == "-");
|
||||||
}
|
}
|
||||||
AnimationController *controller = skeleton->getAnimationController();
|
AnimationController *controller = AnimationController::getSingleton();
|
||||||
string animNames[]{"Action", "open"};
|
string animNames[]{"Action", "open"};
|
||||||
CPPUNIT_ASSERT(controller->getAnimation(animNames[0]));
|
CPPUNIT_ASSERT(controller->getAnimation(animNames[0]));
|
||||||
CPPUNIT_ASSERT(controller->getAnimation(animNames[1]));
|
CPPUNIT_ASSERT(controller->getAnimation(animNames[1]));
|
||||||
|
|||||||
Reference in New Issue
Block a user