~baltix/+junk/irrlicht-test

« back to all changes in this revision

Viewing changes to tests/flyCircleAnimator.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 Colin MacDonald
 
2
// No rights reserved: this software is in the public domain.
 
3
 
 
4
#include "testUtils.h"
 
5
 
 
6
using namespace irr;
 
7
using namespace core;
 
8
using namespace scene;
 
9
using namespace video;
 
10
 
 
11
/** Tests the offset capability of the fly circle animator */
 
12
bool flyCircleAnimator(void)
 
13
{
 
14
        IrrlichtDevice *device = createDevice(video::EDT_BURNINGSVIDEO,
 
15
                                                                                core::dimension2du(160,120), 32);
 
16
        if (!device)
 
17
                return false;
 
18
 
 
19
        IVideoDriver* driver = device->getVideoDriver();
 
20
        ISceneManager* smgr = device->getSceneManager();
 
21
 
 
22
        const f32 offsetDegrees[] = { 0.f, 45.f, 135.f, 270.f };
 
23
 
 
24
        for(u32 i = 0; i < sizeof(offsetDegrees) / sizeof(offsetDegrees[0]); ++i)
 
25
        {
 
26
                IBillboardSceneNode * node = smgr->addBillboardSceneNode();
 
27
                // Have the animator rotate around the Z axis plane, rather than the default Y axis
 
28
                ISceneNodeAnimator * animator = smgr->createFlyCircleAnimator(
 
29
                                vector3df(0, 0, 0), 30.f, 0.001f,
 
30
                                vector3df(0, 0, 1), (offsetDegrees[i] / 360.f));
 
31
                if(!node || !animator)
 
32
                        return false;
 
33
 
 
34
                node->setMaterialType(video::EMT_TRANSPARENT_ADD_COLOR );
 
35
                node->setMaterialTexture(0, driver->getTexture("../media/particle.bmp"));
 
36
                node->setMaterialFlag(video::EMF_LIGHTING, false);
 
37
 
 
38
                node->addAnimator(animator);
 
39
                animator->drop();
 
40
        }
 
41
 
 
42
        (void)smgr->addCameraSceneNode(0, vector3df(0, 0, -50), vector3df(0, 0, 0));
 
43
 
 
44
        bool result = false;
 
45
 
 
46
        // Don't do device->run() since I need the time to remain at 0.
 
47
        if (driver->beginScene(true, true, video::SColor(0, 80, 80, 80)))
 
48
        {
 
49
                smgr->drawAll();
 
50
                driver->endScene();
 
51
                result = takeScreenshotAndCompareAgainstReference(driver, "-flyCircleAnimator.png", 100);
 
52
        }
 
53
 
 
54
        device->closeDevice();
 
55
        device->run();
 
56
        device->drop();
 
57
 
 
58
        return result;
 
59
}
 
60