1
// Copyright (C) 2008-2011 Colin MacDonald
2
// No rights reserved: this software is in the public domain.
13
// Tests MD2 animations.
14
/** At the moment, this just verifies that the last frame of the animation produces the expected bitmap. */
15
bool md2Animation(void)
17
// Use EDT_BURNINGSVIDEO since it is not dependent on (e.g.) OpenGL driver versions.
18
IrrlichtDevice *device = createDevice( EDT_BURNINGSVIDEO, dimension2d<u32>(160, 120), 32);
23
IVideoDriver* driver = device->getVideoDriver();
24
ISceneManager * smgr = device->getSceneManager();
26
IAnimatedMesh* mesh = smgr->getMesh("../media/sydney.md2");
27
IAnimatedMeshSceneNode* node;
30
bool result = (mesh != 0);
33
node = smgr->addAnimatedMeshSceneNode(mesh);
38
node->setPosition(vector3df(20, 0, 30));
39
node->setMaterialFlag(EMF_LIGHTING, false);
40
node->setMaterialTexture(0, driver->getTexture("../media/sydney.bmp"));
41
node->setLoopMode(false);
43
(void)smgr->addCameraSceneNode();
45
// Just jump to the last frame since that's all we're interested in.
46
node->setMD2Animation(EMAT_DEATH_FALLBACK);
47
node->setCurrentFrame((f32)(node->getEndFrame()));
48
node->setAnimationSpeed(0);
50
driver->beginScene(true, true, SColor(255, 255, 255, 0));
53
if (mesh->getBoundingBox() != mesh->getMesh(node->getEndFrame())->getBoundingBox())
55
logTestString("bbox of md2 mesh not updated.\n");
58
//TODO: Does not yet work, not sure if this is correct or not
60
if (node->getBoundingBox() != mesh->getMesh(node->getFrameNr())->getBoundingBox())
62
logTestString("bbox of md2 scene node not updated.\n");
66
if (node->getTransformedBoundingBox() == core::aabbox3df())
68
logTestString("md2 node returns empty bbox.\n");
74
result &= takeScreenshotAndCompareAgainstReference(driver, "-md2Animation.png");
75
device->closeDevice();