~baltix/+junk/irrlicht-test

« back to all changes in this revision

Viewing changes to tests/orthoCam.cpp

  • Committer: Mantas Kriaučiūnas
  • Date: 2011-07-18 13:06:25 UTC
  • Revision ID: mantas@akl.lt-20110718130625-c5pvifp61e7kj1ol
Included whole irrlicht SVN libraries to work around launchpad recipe issue with quilt, see https://answers.launchpad.net/launchpad/+question/165193

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
// Copyright (C) 2008-2011 Christian Stehno, Colin MacDonald
 
2
// No rights reserved: this software is in the public domain.
 
3
 
 
4
#include "testUtils.h"
 
5
 
 
6
using namespace irr;
 
7
 
 
8
static bool testOrthoCam(video::E_DRIVER_TYPE driverType)
 
9
{
 
10
        IrrlichtDevice *device = createDevice (driverType, core::dimension2d<u32>(160,120));
 
11
        if (!device)
 
12
                return true; // No error if device does not exist
 
13
 
 
14
        scene::ICameraSceneNode* cam = device->getSceneManager()->addCameraSceneNode();
 
15
        cam->setPosition(core::vector3df(500,200,-500));
 
16
        cam->setTarget(core::vector3df());
 
17
        cam->setProjectionMatrix(core::matrix4().buildProjectionMatrixOrthoLH(240,180,0.9f,2000.f), true);
 
18
 
 
19
        device->getSceneManager()->addAnimatedMeshSceneNode(device->getSceneManager()->addHillPlaneMesh("plane", core::dimension2df(32,32), core::dimension2du(16,16)));//->setMaterialFlag(video::EMF_WIREFRAME, true);
 
20
        device->getSceneManager()->addCubeSceneNode(20.f)->setPosition(core::vector3df(50,20,50));
 
21
        device->getSceneManager()->addCubeSceneNode(20.f)->setPosition(core::vector3df(50,20,-50));
 
22
        device->getSceneManager()->addCubeSceneNode(20.f)->setPosition(core::vector3df(50,50,0));
 
23
 
 
24
        device->getSceneManager()->addCubeSceneNode(20.f)->setPosition(core::vector3df(-50,10,0));
 
25
        device->getSceneManager()->addCubeSceneNode(20.f)->setPosition(core::vector3df(100,10,-100));
 
26
        device->getSceneManager()->addCubeSceneNode(20.f)->setPosition(core::vector3df(150,10,0));
 
27
 
 
28
        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));
 
29
        node->setMaterialFlag(video::EMF_NORMALIZE_NORMALS, true);
 
30
        node->setAnimationSpeed(0.f);
 
31
 
 
32
        scene::ILightSceneNode* light = device->getSceneManager()->addLightSceneNode(0, core::vector3df(0,100,0));
 
33
        light->setLightType(video::ELT_POINT);
 
34
        light->setRadius(500.f);
 
35
        light->getLightData().DiffuseColor.set(0,1,1);
 
36
 
 
37
        device->getVideoDriver()->beginScene (true, true, 0);
 
38
        device->getSceneManager()->drawAll();
 
39
        device->getVideoDriver()->endScene();
 
40
 
 
41
        const bool result = takeScreenshotAndCompareAgainstReference(device->getVideoDriver(), "-orthoCam.png", 99.91f);
 
42
 
 
43
        device->closeDevice();
 
44
        device->run();
 
45
        device->drop();
 
46
 
 
47
        return result;
 
48
}
 
49
 
 
50
static bool testOrthoStencil(video::E_DRIVER_TYPE driverType)
 
51
{
 
52
        IrrlichtDevice *device = createDevice (driverType, core::dimension2d<u32>(160,120), 16, false, true);
 
53
        if (!device)
 
54
                return true; // No error if device does not exist
 
55
 
 
56
        scene::ICameraSceneNode* cam = device->getSceneManager()->addCameraSceneNode();
 
57
        cam->setPosition(core::vector3df(300,250,-300));
 
58
        cam->setTarget(core::vector3df(0,20,0));
 
59
        cam->setProjectionMatrix(core::matrix4().buildProjectionMatrixOrthoLH(120,90,0.9f,2000.f), true);
 
60
 
 
61
        device->getSceneManager()->addAnimatedMeshSceneNode(device->getSceneManager()->addHillPlaneMesh("plane", core::dimension2df(32,32), core::dimension2du(16,16)));//->setMaterialFlag(video::EMF_WIREFRAME, true);
 
62
 
 
63
        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));
 
64
        node->setMaterialFlag(video::EMF_NORMALIZE_NORMALS, true);
 
65
        node->addShadowVolumeSceneNode();
 
66
        node->setAnimationSpeed(0.f);
 
67
 
 
68
        scene::ILightSceneNode* light = device->getSceneManager()->addLightSceneNode(0, core::vector3df(100,150,100));
 
69
        light->setLightType(video::ELT_POINT);
 
70
        light->setRadius(500.f);
 
71
        light->getLightData().DiffuseColor.set(0,1,1);
 
72
 
 
73
        device->getVideoDriver()->beginScene (true, true, 0);
 
74
        device->getSceneManager()->drawAll();
 
75
        device->getVideoDriver()->endScene();
 
76
 
 
77
        const bool result = takeScreenshotAndCompareAgainstReference(device->getVideoDriver(), "-orthoStencil.png", 99.91f);
 
78
 
 
79
        device->closeDevice();
 
80
        device->run();
 
81
        device->drop();
 
82
 
 
83
        return result;
 
84
}
 
85
 
 
86
bool orthoCam(void)
 
87
{
 
88
        bool passed = true;
 
89
 
 
90
        passed &= testOrthoCam(video::EDT_OPENGL);
 
91
        // no lights in sw renderer
 
92
//      passed &= testOrthoCam(video::EDT_SOFTWARE);
 
93
        passed &= testOrthoCam(video::EDT_BURNINGSVIDEO);
 
94
        passed &= testOrthoCam(video::EDT_DIRECT3D9);
 
95
        passed &= testOrthoCam(video::EDT_DIRECT3D8);
 
96
 
 
97
        passed &= testOrthoStencil(video::EDT_OPENGL);
 
98
        passed &= testOrthoStencil(video::EDT_DIRECT3D9);
 
99
 
 
100
        return passed;
 
101
}