Commit a7b73dbf authored by hybrid's avatar hybrid

New test for orthogonal Cameras.

git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@3205 dfc29bdd-3216-0410-991c-e03cc46cb475
parent 303e5c16
// Copyright (C) 2008-2009 Christian Stehno, Colin MacDonald // Copyright (C) 2008-2010 Christian Stehno, Colin MacDonald
// No rights reserved: this software is in the public domain. // No rights reserved: this software is in the public domain.
#include "testUtils.h" #include "testUtils.h"
...@@ -11,7 +11,7 @@ static bool testLightTypes(video::E_DRIVER_TYPE driverType) ...@@ -11,7 +11,7 @@ static bool testLightTypes(video::E_DRIVER_TYPE driverType)
if (!device) if (!device)
return true; // No error if device does not exist return true; // No error if device does not exist
// device->getSceneManager()->setAmbientLight(video::SColorf(0.3f,0.3f,0.3f)); // device->getSceneManager()->setAmbientLight(video::SColorf(0.3f,0.3f,0.3f));
scene::ICameraSceneNode* cam = device->getSceneManager()->addCameraSceneNodeFPS(); scene::ICameraSceneNode* cam = device->getSceneManager()->addCameraSceneNode();
cam->setPosition(core::vector3df(0,200,0)); cam->setPosition(core::vector3df(0,200,0));
cam->setTarget(core::vector3df()); cam->setTarget(core::vector3df());
device->getSceneManager()->addAnimatedMeshSceneNode(device->getSceneManager()->addHillPlaneMesh("plane", core::dimension2df(4,4), core::dimension2du(128,128))); device->getSceneManager()->addAnimatedMeshSceneNode(device->getSceneManager()->addHillPlaneMesh("plane", core::dimension2df(4,4), core::dimension2du(128,128)));
......
...@@ -106,6 +106,7 @@ int main(int argumentCount, char * arguments[]) ...@@ -106,6 +106,7 @@ int main(int argumentCount, char * arguments[])
TEST(antiAliasing); TEST(antiAliasing);
TEST(draw2DImage); TEST(draw2DImage);
TEST(lights); TEST(lights);
TEST(orthoCam);
// TODO: Needs to be fixed first. // TODO: Needs to be fixed first.
// TEST(projectionMatrix); // TEST(projectionMatrix);
// large scenes // large scenes
......
// Copyright (C) 2008-2010 Christian Stehno, Colin MacDonald
// No rights reserved: this software is in the public domain.
#include "testUtils.h"
using namespace irr;
static bool testOrthoCam(video::E_DRIVER_TYPE driverType)
{
IrrlichtDevice *device = createDevice (driverType, core::dimension2d<u32>(160,120));
if (!device)
return true; // No error if device does not exist
scene::ICameraSceneNode* cam = device->getSceneManager()->addCameraSceneNode();
cam->setPosition(core::vector3df(500,200,-500));
cam->setTarget(core::vector3df());
cam->setProjectionMatrix(core::matrix4().buildProjectionMatrixOrthoLH(240,180,0.9f,2000.f), true);
device->getSceneManager()->addAnimatedMeshSceneNode(device->getSceneManager()->addHillPlaneMesh("plane", core::dimension2df(32,32), core::dimension2du(16,16)));//->setMaterialFlag(video::EMF_WIREFRAME, true);
device->getSceneManager()->addCubeSceneNode(20.f)->setPosition(core::vector3df(50,20,50));
device->getSceneManager()->addCubeSceneNode(20.f)->setPosition(core::vector3df(50,20,-50));
device->getSceneManager()->addCubeSceneNode(20.f)->setPosition(core::vector3df(50,50,0));
device->getSceneManager()->addCubeSceneNode(20.f)->setPosition(core::vector3df(-50,10,0));
device->getSceneManager()->addCubeSceneNode(20.f)->setPosition(core::vector3df(100,10,-100));
device->getSceneManager()->addCubeSceneNode(20.f)->setPosition(core::vector3df(150,10,0));
scene::IAnimatedMeshSceneNode* node = device->getSceneManager()->addAnimatedMeshSceneNode(device->getSceneManager()->getMesh("../media/ninja.b3d"), 0, -1, core::vector3df(-50,2,-50), core::vector3df(),core::vector3df(5,5,5));
node->setAnimationSpeed(0.f);
scene::ILightSceneNode* light = device->getSceneManager()->addLightSceneNode(0, core::vector3df(0,100,0));
light->setLightType(video::ELT_POINT);
light->setRadius(500.f);
light->getLightData().DiffuseColor.set(0,1,1);
device->getVideoDriver()->beginScene (true, true, 0);
device->getSceneManager()->drawAll();
device->getVideoDriver()->endScene();
const bool result = takeScreenshotAndCompareAgainstReference(device->getVideoDriver(), "-orthoCam.png", 99.91f);
device->drop();
return result;
}
static bool testOrthoStencil(video::E_DRIVER_TYPE driverType)
{
IrrlichtDevice *device = createDevice (driverType, core::dimension2d<u32>(160,120), 16, false, true);
if (!device)
return true; // No error if device does not exist
scene::ICameraSceneNode* cam = device->getSceneManager()->addCameraSceneNodeFPS();
cam->setPosition(core::vector3df(300,250,-300));
cam->setTarget(core::vector3df(0,20,0));
cam->setProjectionMatrix(core::matrix4().buildProjectionMatrixOrthoLH(120,90,0.9f,2000.f), true);
device->getSceneManager()->addAnimatedMeshSceneNode(device->getSceneManager()->addHillPlaneMesh("plane", core::dimension2df(32,32), core::dimension2du(16,16)));//->setMaterialFlag(video::EMF_WIREFRAME, true);
scene::IAnimatedMeshSceneNode* node = device->getSceneManager()->addAnimatedMeshSceneNode(device->getSceneManager()->getMesh("../media/ninja.b3d"), 0, -1, core::vector3df(0,2,0), core::vector3df(),core::vector3df(5,5,5));
node->addShadowVolumeSceneNode();
node->setAnimationSpeed(0.f);
scene::ILightSceneNode* light = device->getSceneManager()->addLightSceneNode(0, core::vector3df(100,150,100));
light->setLightType(video::ELT_POINT);
light->setRadius(500.f);
light->getLightData().DiffuseColor.set(0,1,1);
device->getVideoDriver()->beginScene (true, true, 0);
device->getSceneManager()->drawAll();
device->getVideoDriver()->endScene();
const bool result = takeScreenshotAndCompareAgainstReference(device->getVideoDriver(), "-orthoStencil.png", 99.91f);
device->drop();
return result;
}
bool orthoCam(void)
{
bool passed = true;
passed &= testOrthoCam(video::EDT_OPENGL);
// no lights in sw renderer
// passed &= testOrthoCam(video::EDT_SOFTWARE);
passed &= testOrthoCam(video::EDT_BURNINGSVIDEO);
passed &= testOrthoCam(video::EDT_DIRECT3D9);
passed &= testOrthoCam(video::EDT_DIRECT3D8);
passed &= testOrthoStencil(video::EDT_OPENGL);
passed &= testOrthoStencil(video::EDT_DIRECT3D9);
return passed;
}
Tests finished. 52 tests of 52 passed. Tests finished. 53 tests of 53 passed.
Compiled as DEBUG Compiled as DEBUG
Test suite pass at GMT Sat Feb 06 16:38:57 2010 Test suite pass at GMT Sat Feb 06 23:27:05 2010
...@@ -295,6 +295,10 @@ ...@@ -295,6 +295,10 @@
RelativePath=".\meshTransform.cpp" RelativePath=".\meshTransform.cpp"
> >
</File> </File>
<File
RelativePath=".\orthoCam.cpp"
>
</File>
<File <File
RelativePath=".\planeMatrix.cpp" RelativePath=".\planeMatrix.cpp"
> >
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment