Browse Source

SceneGraph: split object transformations test into more functions.

pull/7/head
Vladimír Vondruš 14 years ago
parent
commit
b86f107396
  1. 19
      src/SceneGraph/Test/ObjectTest.cpp

19
src/SceneGraph/Test/ObjectTest.cpp

@ -30,6 +30,8 @@ class ObjectTest: public Corrade::TestSuite::Tester {
void scene(); void scene();
void absoluteTransformation(); void absoluteTransformation();
void transformations(); void transformations();
void transformationsRelative();
void transformationsOrphan();
void setClean(); void setClean();
void bulkSetClean(); void bulkSetClean();
}; };
@ -56,6 +58,8 @@ ObjectTest::ObjectTest() {
&ObjectTest::scene, &ObjectTest::scene,
&ObjectTest::absoluteTransformation, &ObjectTest::absoluteTransformation,
&ObjectTest::transformations, &ObjectTest::transformations,
&ObjectTest::transformationsRelative,
&ObjectTest::transformationsOrphan,
&ObjectTest::setClean, &ObjectTest::setClean,
&ObjectTest::bulkSetClean); &ObjectTest::bulkSetClean);
} }
@ -164,10 +168,19 @@ void ObjectTest::transformations() {
initial*Matrix4::rotationZ(deg(30.0f))*Matrix4::translation(Vector3::xAxis(5.0f)), initial*Matrix4::rotationZ(deg(30.0f))*Matrix4::translation(Vector3::xAxis(5.0f)),
initial*Matrix4::rotationZ(deg(30.0f)), initial*Matrix4::rotationZ(deg(30.0f)),
})); }));
}
{ void ObjectTest::transformationsRelative() {
CORRADE_EXPECT_FAIL("Transformations not relative to scene are not yet implemented."); CORRADE_EXPECT_FAIL("Transformations not relative to scene are not yet implemented.");
Scene3D s;
Object3D first(&s);
first.rotateZ(deg(30.0f));
Object3D second(&first);
second.scale(Vector3(0.5f));
Object3D third(&first);
third.translate(Vector3::xAxis(5.0f));
/* Transformation relative to another object */ /* Transformation relative to another object */
CORRADE_COMPARE(second.transformations({&third}), std::vector<Matrix4>{ CORRADE_COMPARE(second.transformations({&third}), std::vector<Matrix4>{
Matrix4::scaling(Vector3(0.5f)).inverted()*Matrix4::translation(Vector3::xAxis(5.0f)) Matrix4::scaling(Vector3(0.5f)).inverted()*Matrix4::translation(Vector3::xAxis(5.0f))
@ -184,12 +197,14 @@ void ObjectTest::transformations() {
CORRADE_COMPARE(orphan1.transformations({&orphan2}), std::vector<Matrix4>{ CORRADE_COMPARE(orphan1.transformations({&orphan2}), std::vector<Matrix4>{
Matrix4::scaling(Vector3::xScale(3.0f)).inverted()*Matrix4::translation(Vector3::zAxis(5.0f)) Matrix4::scaling(Vector3::xScale(3.0f)).inverted()*Matrix4::translation(Vector3::zAxis(5.0f))
}); });
} }
void ObjectTest::transformationsOrphan() {
std::ostringstream o; std::ostringstream o;
Error::setOutput(&o); Error::setOutput(&o);
/* Transformation of objects not part of the same scene */ /* Transformation of objects not part of the same scene */
Scene3D s;
Object3D orphan; Object3D orphan;
CORRADE_COMPARE(s.transformations({&orphan}), std::vector<Matrix4>()); CORRADE_COMPARE(s.transformations({&orphan}), std::vector<Matrix4>());
CORRADE_COMPARE(o.str(), "SceneGraph::Object::transformations(): the objects are not part of the same tree\n"); CORRADE_COMPARE(o.str(), "SceneGraph::Object::transformations(): the objects are not part of the same tree\n");

Loading…
Cancel
Save