Block rotation
Posted: Tue May 25, 2010 5:23 pm
I want to do a block rotation. I have model of triangle and i rotate it. But i don't get that i want. I want something like this:
i get this:
Why irrlicht rotate it that?
There is a code:
i get this:
Why irrlicht rotate it that?
There is a code:
Code: Select all
#include <irrlicht.h>
using namespace irr;
using namespace core;
using namespace scene;
using namespace video;
using namespace io;
using namespace gui;
int i=0;
class MyEventReceiver : public IEventReceiver
{
public:
virtual bool OnEvent(const SEvent& event)
{
if (event.EventType == irr::EET_KEY_INPUT_EVENT)
KeyIsDown[event.KeyInput.Key] = event.KeyInput.PressedDown;
return false;
}
virtual bool IsKeyDown(EKEY_CODE keyCode) const
{
return KeyIsDown[keyCode];
}
MyEventReceiver()
{
for (u32 i=0; i<KEY_KEY_CODES_COUNT; ++i)
KeyIsDown[i] = false;
}
private:
bool KeyIsDown[KEY_KEY_CODES_COUNT];
};
int main()
{
IrrlichtDevice* device = createDevice( EDT_OPENGL, dimension2d<u32>(840, 580),
32, false, true, false, 0);
MyEventReceiver receiver;
device->setEventReceiver(&receiver);
IVideoDriver* video = device->getVideoDriver();
IGUIEnvironment* env = device->getGUIEnvironment();
ISceneManager* smgr = device->getSceneManager();
device ->getCursorControl()->setVisible(false);
ICameraSceneNode *kam = smgr->addCameraSceneNodeFPS();
kam->setFarValue(90000);
kam->setPosition(core::vector3df(0,0,0));
env->addStaticText(L"Naciscnij ESC by wyjsc\nNaciscnij A by zmienic animacje\nNaciscnij S by rozpoczacz animacje\nNaciscnij D by zatrzymac animacje\nNaciscnij Z by wyzerowac animacje\n",
rect<s32>(700,510,840,580), true, true, 0);
IAnimatedMeshSceneNode* pud = 0;
IAnimatedMesh* pudlo = smgr->getMesh("triangle.b3d");
pud = smgr->addAnimatedMeshSceneNode(pudlo);
pud -> setScale (core::vector3df(100,100,100));
pud -> setPosition(core::vector3df(0,0,0));
pud ->setMaterialFlag(video::EMF_LIGHTING, false);
pud ->setMaterialFlag(video::EMF_BACK_FACE_CULLING, false);
while(i<=180){
i++;
pud = smgr->addAnimatedMeshSceneNode(pudlo);
pud -> setScale (core::vector3df(100,100,100));
pud -> setPosition(core::vector3df(0,0,0));
pud -> setRotation(core::vector3df(0,i,0));
pud ->setMaterialFlag(video::EMF_LIGHTING, false);
pud ->setMaterialFlag(video::EMF_BACK_FACE_CULLING, false);
}
int lastFPS = -1; //dla fps
while(device->run())
{
if(receiver.IsKeyDown(KEY_ESCAPE))break;
video->beginScene(true, true, video::SColor(255,113,113,133));
env->drawAll();
smgr->drawAll();
video->endScene();
int fps = video->getFPS(); //oblicznie i wyświetlanie fps
if (lastFPS != fps)
{
core::stringw tmp(L"Animacje ");
tmp += L"fps: ";
tmp += fps;
device->setWindowCaption(tmp.c_str());
lastFPS = fps;
}
}
device->drop();
return 0;
}