mirror of https://github.com/mosra/magnum.git
Browse Source
* The light didn't catch camera transformation changes, so it was
returning wrong position for most of the time.
* The multiplication was in wrong order, it should be multiplied with
camera matrix from the left.
I need to find an solution for this, because now it is one redundant
matrix*vector multiplication per object per frame again.
This reverts commit 0443bbe286.
Conflicts:
src/Light.cpp
src/Test/LightTest.cpp
vectorfields
5 changed files with 8 additions and 118 deletions
@ -1,4 +1,3 @@
|
||||
corrade_add_test(ObjectTest ObjectTest.h ObjectTest.cpp MagnumTestLib) |
||||
corrade_add_test(CameraTest CameraTest.h CameraTest.cpp Magnum) |
||||
corrade_add_test(LightTest LightTest.h LightTest.cpp MagnumTestLib) |
||||
corrade_add_test(SceneTest SceneTest.h SceneTest.cpp Magnum) |
||||
|
||||
@ -1,63 +0,0 @@
|
||||
/*
|
||||
Copyright © 2010, 2011, 2012 Vladimír Vondruš <mosra@centrum.cz> |
||||
|
||||
This file is part of Magnum. |
||||
|
||||
Magnum is free software: you can redistribute it and/or modify |
||||
it under the terms of the GNU Lesser General Public License version 3 |
||||
only, as published by the Free Software Foundation. |
||||
|
||||
Magnum is distributed in the hope that it will be useful, |
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of |
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||||
GNU Lesser General Public License version 3 for more details. |
||||
*/ |
||||
|
||||
#include "LightTest.h" |
||||
|
||||
#include <sstream> |
||||
#include <QtTest/QTest> |
||||
|
||||
#include "Camera.h" |
||||
#include "Light.h" |
||||
#include "Scene.h" |
||||
|
||||
QTEST_APPLESS_MAIN(Magnum::Test::LightTest) |
||||
|
||||
using namespace std; |
||||
using namespace Corrade::Utility; |
||||
|
||||
namespace Magnum { namespace Test { |
||||
|
||||
void LightTest::positionWrongCamera() { |
||||
stringstream ss; |
||||
Error::setOutput(&ss); |
||||
|
||||
Camera c; |
||||
Light l; |
||||
QVERIFY(l.position(&c) == Vector3()); |
||||
QVERIFY(ss.str() == "Light: camera and light aren't in the same scene!\n"); |
||||
} |
||||
|
||||
void LightTest::position() { |
||||
Scene s; |
||||
|
||||
Object lightParent(&s); |
||||
lightParent.translate(Vector3::zAxis(3)); |
||||
Light light(&lightParent); |
||||
|
||||
Object cameraParent(&s); |
||||
cameraParent.rotate(deg(90.0f), Vector3::xAxis()); |
||||
Camera camera(&cameraParent); |
||||
|
||||
QVERIFY(light.position(&camera) == (Matrix4::translation(Vector3::zAxis(3))* |
||||
Matrix4::rotation(deg(90.0f), Vector3::xAxis()).inverted())[3].xyz()); |
||||
|
||||
/* Set another camera */ |
||||
Camera another(&cameraParent); |
||||
another.scale(Vector3(3.0f)); |
||||
QVERIFY(light.position(&another) == (Matrix4::translation(Vector3::zAxis(3))* |
||||
(Matrix4::scaling(Vector3(3.0f))*Matrix4::rotation(deg(90.0f), Vector3::xAxis())).inverted())[3].xyz()); |
||||
} |
||||
|
||||
}} |
||||
@ -1,32 +0,0 @@
|
||||
#ifndef Magnum_Test_LightTest_h |
||||
#define Magnum_Test_LightTest_h |
||||
/*
|
||||
Copyright © 2010, 2011, 2012 Vladimír Vondruš <mosra@centrum.cz> |
||||
|
||||
This file is part of Magnum. |
||||
|
||||
Magnum is free software: you can redistribute it and/or modify |
||||
it under the terms of the GNU Lesser General Public License version 3 |
||||
only, as published by the Free Software Foundation. |
||||
|
||||
Magnum is distributed in the hope that it will be useful, |
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of |
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||||
GNU Lesser General Public License version 3 for more details. |
||||
*/ |
||||
|
||||
#include <QtCore/QObject> |
||||
|
||||
namespace Magnum { namespace Test { |
||||
|
||||
class LightTest: public QObject { |
||||
Q_OBJECT |
||||
|
||||
private slots: |
||||
void positionWrongCamera(); |
||||
void position(); |
||||
}; |
||||
|
||||
}} |
||||
|
||||
#endif |
||||
Loading…
Reference in new issue