bone test

This commit is contained in:
devZoGok
2021-10-19 19:06:41 +03:00
parent 532b1f6363
commit bae1b7a9cc
5 changed files with 80 additions and 3 deletions
+1 -1
View File
@@ -20,7 +20,7 @@ set(anim animationController.cpp animationChannel.cpp animation.cpp)
set(armature skeleton.cpp bone.cpp)
set(library ${render} ${math} ${model} ${utils} ${gui} ${armature} ${anim})
set(test cameraTest.cpp nodeTest.cpp)
set(test cameraTest.cpp nodeTest.cpp boneTest.cpp)
add_library(vb01 SHARED ${library})
target_link_libraries(vb01 glfw)
+47
View File
@@ -0,0 +1,47 @@
#include "boneTest.h"
#include "model.h"
#include "root.h"
#include "skeleton.h"
#include "mesh.h"
#include <string>
using namespace std;
namespace vb01{
BoneTest::BoneTest(){
}
void BoneTest::setUp(){
string PATH="/home/dominykas/c++/v/";
Root *root = Root::getSingleton();
root->setBasePath("../");
rootNode = root->getRootNode();
model = new Model(PATH + "../vb01/test.vb");
Material *glMat=new Material();
glMat->setTexturingEnabled(true);
glMat->setLightingEnabled(false);
glMat->addDiffuseMap(PATH+"defaultTexture.jpg");
//model->setMaterial(glMat);
rootNode->attachChild(model);
}
void BoneTest::tearDown(){
rootNode->dettachChild(model);
delete model;
}
void BoneTest::testGetModelSpacePos(){
float eps = .0001;
int numChildren = model->getNumChildren();
Skeleton *skeleton = model->getChild(numChildren - 1)->getMesh(0)->getSkeleton();
Bone *bone = skeleton->getBone("ik");
Vector3 initModelPos = bone->getModelSpacePos();
model->setPosition(Vector3(1, 2, 3));
Vector3 deltaModelPos = bone->getModelSpacePos();
CPPUNIT_ASSERT(initModelPos.getDistanceFrom(deltaModelPos) <= eps);
}
}
+28
View File
@@ -0,0 +1,28 @@
#ifndef BONE_TEST_H
#define BONE_TEST_H
#include <cppunit/TestFixture.h>
#include <cppunit/extensions/HelperMacros.h>
namespace vb01{
class Model;
class Node;
class BoneTest : public CppUnit::TestFixture{
CPPUNIT_TEST_SUITE(BoneTest);
CPPUNIT_TEST(testGetModelSpacePos);
CPPUNIT_TEST_SUITE_END();
public:
BoneTest();
void setUp();
void tearDown();
private:
void testGetModelSpacePos();
Model *model = nullptr;
Node *rootNode = nullptr;
};
}
#endif
+2
View File
@@ -5,6 +5,7 @@
#include "cameraTest.h"
#include "nodeTest.h"
#include "boneTest.h"
using namespace CppUnit;
using namespace vb01;
@@ -13,6 +14,7 @@ int main(){
TextUi::TestRunner runner;
runner.addTest(CameraTest::suite());
runner.addTest(NodeTest::suite());
runner.addTest(BoneTest::suite());
runner.run();
return 0;
}
+2 -2
View File
@@ -52,6 +52,8 @@ namespace vb01{
void Mesh::initFramebuffer(){
int width = Root::getSingleton()->getWidth();
/*
*/
u32 RBO;
string basePath = "../../vb01/depthMap.";
environmentShader = new Shader(basePath + "vert", basePath + "frag", basePath + "geo");
@@ -61,12 +63,10 @@ namespace vb01{
glBindFramebuffer(GL_FRAMEBUFFER, environmentBuffer);
glFramebufferTexture(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, *(environmentMap->getTexture()), 0);
/*
glGenRenderbuffers(1,&RBO);
glBindRenderbuffer(GL_RENDERBUFFER,RBO);
glRenderbufferStorage(GL_RENDERBUFFER,GL_DEPTH24_STENCIL8,width,width);
glFramebufferRenderbuffer(GL_FRAMEBUFFER,GL_DEPTH_STENCIL_ATTACHMENT,GL_RENDERBUFFER,RBO);
*/
if(glCheckFramebufferStatus(GL_FRAMEBUFFER) != GL_FRAMEBUFFER_COMPLETE)
cout<<"Not complete\n";