mirror of
https://github.com/ApfelTeeSaft/vb01.git
synced 2026-08-26 19:33:45 +00:00
particle emitter test
This commit is contained in:
+1
-1
@@ -26,7 +26,7 @@ target_link_libraries(vb01 glad)
|
|||||||
target_link_libraries(vb01 assimp)
|
target_link_libraries(vb01 assimp)
|
||||||
target_link_libraries(vb01 freetype)
|
target_link_libraries(vb01 freetype)
|
||||||
|
|
||||||
set(renderTest nodeTest.cpp cameraTest.cpp shaderTest.cpp)
|
set(renderTest nodeTest.cpp cameraTest.cpp shaderTest.cpp particleEmitterTest.cpp)
|
||||||
set(armatureTest boneTest.cpp)
|
set(armatureTest boneTest.cpp)
|
||||||
set(modelTest vbModelReaderTest.cpp)
|
set(modelTest vbModelReaderTest.cpp)
|
||||||
set(animationTest animationChannelTest.cpp)
|
set(animationTest animationChannelTest.cpp)
|
||||||
|
|||||||
@@ -9,6 +9,7 @@
|
|||||||
#include "vbModelReaderTest.h"
|
#include "vbModelReaderTest.h"
|
||||||
#include "animationChannelTest.h"
|
#include "animationChannelTest.h"
|
||||||
#include "shaderTest.h"
|
#include "shaderTest.h"
|
||||||
|
#include "particleEmitterTest.h"
|
||||||
|
|
||||||
using namespace CppUnit;
|
using namespace CppUnit;
|
||||||
using namespace vb01;
|
using namespace vb01;
|
||||||
@@ -21,6 +22,7 @@ int main(){
|
|||||||
runner.addTest(VbModelReaderTest::suite());
|
runner.addTest(VbModelReaderTest::suite());
|
||||||
runner.addTest(AnimationChannelTest::suite());
|
runner.addTest(AnimationChannelTest::suite());
|
||||||
runner.addTest(ShaderTest::suite());
|
runner.addTest(ShaderTest::suite());
|
||||||
|
runner.addTest(ParticleEmitterTest::suite());
|
||||||
runner.run();
|
runner.run();
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|||||||
+4
-1
@@ -12,7 +12,8 @@ namespace vb01{
|
|||||||
|
|
||||||
class ParticleEmitter{
|
class ParticleEmitter{
|
||||||
public:
|
public:
|
||||||
ParticleEmitter(int = 1);
|
ParticleEmitter(){}
|
||||||
|
ParticleEmitter(int);
|
||||||
~ParticleEmitter();
|
~ParticleEmitter();
|
||||||
void update();
|
void update();
|
||||||
inline void setMaterial(Material *mat){this->material = mat;}
|
inline void setMaterial(Material *mat){this->material = mat;}
|
||||||
@@ -59,6 +60,8 @@ namespace vb01{
|
|||||||
Vector3 direction = Vector3(0, .1, 0), gravity = Vector3::VEC_ZERO;
|
Vector3 direction = Vector3(0, .1, 0), gravity = Vector3::VEC_ZERO;
|
||||||
Vector4 startColor, endColor;
|
Vector4 startColor, endColor;
|
||||||
float spread = 1, lowLife = 1, highLife = 2;
|
float spread = 1, lowLife = 1, highLife = 2;
|
||||||
|
|
||||||
|
friend class ParticleEmitterTest;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,31 @@
|
|||||||
|
#include "particleEmitterTest.h"
|
||||||
|
#include "particleEmitter.h"
|
||||||
|
|
||||||
|
#include <algorithm>
|
||||||
|
|
||||||
|
using namespace std;
|
||||||
|
|
||||||
|
namespace vb01{
|
||||||
|
void ParticleEmitterTest::setUp(){
|
||||||
|
particleEmitter = new ParticleEmitter();
|
||||||
|
particleEmitter->numParticles = numParticles;
|
||||||
|
particleEmitter->particles = new ParticleEmitter::Particle*[numParticles];
|
||||||
|
for(int i = 0; i < numParticles; i++){
|
||||||
|
ParticleEmitter::Particle *particle = new ParticleEmitter::Particle;
|
||||||
|
particle->d = rand() % 1000;
|
||||||
|
particleEmitter->particles[i] = particle;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void ParticleEmitterTest::tearDown(){
|
||||||
|
}
|
||||||
|
|
||||||
|
void ParticleEmitterTest::testHeapSort(){
|
||||||
|
particleEmitter->heapSort();
|
||||||
|
for(int i = 1; i < numParticles; i++){
|
||||||
|
ParticleEmitter::Particle *prevPart = particleEmitter->particles[i - 1];
|
||||||
|
ParticleEmitter::Particle *currPart = particleEmitter->particles[i];
|
||||||
|
CPPUNIT_ASSERT(prevPart->d >= currPart->d);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,28 @@
|
|||||||
|
#ifndef PARTICLE_EMIITER_TEST_H
|
||||||
|
#define PARTICLE_EMIITER_TEST_H
|
||||||
|
|
||||||
|
#include <cppunit/TestFixture.h>
|
||||||
|
#include <cppunit/extensions/HelperMacros.h>
|
||||||
|
|
||||||
|
namespace vb01{
|
||||||
|
class ParticleEmitter;
|
||||||
|
|
||||||
|
class ParticleEmitterTest : public CppUnit::TestFixture{
|
||||||
|
CPPUNIT_TEST_SUITE(ParticleEmitterTest);
|
||||||
|
CPPUNIT_TEST(testHeapSort);
|
||||||
|
CPPUNIT_TEST_SUITE_END();
|
||||||
|
|
||||||
|
public:
|
||||||
|
ParticleEmitterTest(){}
|
||||||
|
~ParticleEmitterTest(){}
|
||||||
|
void setUp();
|
||||||
|
void tearDown();
|
||||||
|
private:
|
||||||
|
int numParticles = 100;
|
||||||
|
ParticleEmitter *particleEmitter = nullptr;
|
||||||
|
|
||||||
|
void testHeapSort();
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
Reference in New Issue
Block a user