I have a problem.I created a billboard node and added scene::ISceneNodeAnimator* texture animation.Even if i set timePerFrame to 1 on
ISceneNodeAnimator*,it is too fast.What can i do?
Best regards.
My codes:
Code: Select all
#include <irrlicht.h>
#include <string>
using namespace irr;
using namespace core;
using namespace scene;
using namespace video;
using namespace io;
using namespace gui;
#ifdef _MSC_VER
#pragma comment(lib, "Irrlicht.lib")
#pragma comment(linker, "/subsystem:windows /ENTRY:mainCRTStartup")
#endif
int main()
{
// create device
IrrlichtDevice *device = createDevice( video::EDT_DIRECT3D9, dimension2d<u32>(1024, 768), 32,
false, false, true, 0);
if (device == 0)
return 1; // could not create selected driver.
// create engine and camera
device->setWindowCaption(L"Irrlicht Engine Demo");
video::IVideoDriver* driver = device->getVideoDriver();
scene::ISceneManager* smgr = device->getSceneManager();
int posx=50;
int posy=0;
ICameraSceneNode* camera = smgr->addCameraSceneNode(0, core::vector3df(posx,posy,-100), core::vector3df(posx,posy,0) );
IBillboardSceneNode* billboard=smgr->addBillboardSceneNode(0,dimension2d<f32>(20,20),vector3df(50,20,-0));
billboard->setMaterialFlag(EMF_LIGHTING, false);
billboard->setMaterialType(video::EMT_TRANSPARENT_ALPHA_CHANNEL);
array<ITexture*,irrAllocator<ITexture*>> textures;
for (int i=0;i<9;i++)
{
video::ITexture* texture ;
char textureFileName[90];
strcpy(textureFileName, "Data/character/frame");
strcat(textureFileName, (std::to_string((long double)i)).c_str());
strcat(textureFileName, ".png");
texture = smgr->getVideoDriver()->getTexture((char*)textureFileName);
if(!texture)
{
device->drop();
return 1;
}
textures.push_back(texture);
}
scene::ISceneNodeAnimator* anim =
smgr->createTextureAnimator(textures,1,true);//<-----------too fast :(
if(anim)
{
billboard->addAnimator(anim);
anim->drop();
anim = 0;
}
u32 frames=0;
while(device->run())
{
driver->beginScene(true, true, video::SColor(0,100,100,100));
smgr->drawAll();
driver->endScene();
if (++frames==100)
{
core::stringw str = L"Irrlicht Engine [";
str += driver->getName();
str += L"] FPS: ";
str += (s32)driver->getFPS();
device->setWindowCaption(str.c_str());
frames=0;
}
}
device->drop();
return 0;
}
http://www.mediafire.com/?0lk0x2cnqmm1273
Thanks.