Re: Facial animation
Posted: Mon Jul 25, 2011 12:50 pm
Note that fixing your normals is the better solution.
Official forum of the Irrlicht Engine
https://irrlicht.sourceforge.io/forum/
Code: Select all
#include "stdafx.h"
#include <irrlicht.h>
using namespace irr;
using namespace core;
using namespace scene;
using namespace video;
using namespace io;
using namespace gui;
#ifdef _IRR_WINDOWS_
#pragma comment(lib, "Irrlicht.lib")
#pragma comment(linker, "/subsystem:windows /ENTRY:mainCRTStartup")
#endif
int main()
{
IrrlichtDevice *device =
createDevice( video::EDT_SOFTWARE, dimension2d<u32>(640, 480), 16,
false, false, false, 0);
if (!device)
return 1;
device->setWindowCaption(L"test!");
IVideoDriver* driver = device->getVideoDriver();
ISceneManager* smgr = device->getSceneManager();
IGUIEnvironment* guienv = device->getGUIEnvironment();
IAnimatedMesh* mesh = smgr->getMesh("../../media/model.X");
if (!mesh)
{
device->drop();
return 1;
}
IAnimatedMeshSceneNode* node = smgr->addAnimatedMeshSceneNode( mesh );
if (node)
{
node->setMaterialTexture( 0, driver->getTexture("../../media/texture.jpg") );
node->setMaterialFlag(EMF_LIGHTING, false);
node->setFrameLoop(0, 100);
node->setAnimationSpeed(15);
node->setPosition(core::vector3df(0,-2,4));
node->setMaterialFlag(irr::video::EMF_BACK_FACE_CULLING, false);
}
smgr->addCameraSceneNode(0, vector3df(80,80,0), vector3df(50,1000,0));
smgr->addCameraSceneNodeFPS();
device->getCursorControl()->setVisible(false);
int lastFPS = -1;
u32 then = device->getTimer()->getTime();
const f32 MOVEMENT_SPEED = 5.f;
while(device->run())
{
const u32 now = device->getTimer()->getTime();
const f32 frameDeltaTime = (f32)(now - then) / 1000.f; // Time in seconds
then = now;
driver->beginScene(true, true, SColor(255,100,101,140));
core::vector3df nodePosition = node->getPosition();
node->setPosition(nodePosition);
driver->beginScene(true, true, video::SColor(255,113,113,133));
smgr->drawAll();
device->getGUIEnvironment()->drawAll();
driver->endScene();
int fps = driver->getFPS();
}
device->drop();
return 0;
}