Ive been tinkering with my first program using irrlicht and i realize that im dropping the node before my main loop
any help is greatly appreciated, thanks
here is the main loop in my program:
Code: Select all
#include <irrlicht.h>
#include <stdio.h>
#include <conio.h>
#include <string.h>
#include <stdlib.h>
#include <iostream>
using namespace std;
//#include <string.h>
//#include <string>
using namespace irr;
using namespace core;
using namespace scene;
using namespace video;
using namespace io;
using namespace gui;
#pragma comment(lib, "Irrlicht.lib")
IAnimatedMeshSceneNode* addMesh(ISceneManager *,IVideoDriver*, char[], char[], f32[], f32[]);
int main()
{
IrrlichtDevice *device =
createDevice(EDT_DIRECTX9, dimension2d<s32>(640, 480), 16,
false, false, false, 0);
IVideoDriver* driver = device->getVideoDriver();
ISceneManager* smgr = device->getSceneManager();
IGUIEnvironment* guienv = device->getGUIEnvironment();
// make my node
f32 position[] = {0,0,0};
f32 rotation[] = {0,0.3f,.3f};
IAnimatedMeshSceneNode * myNode = addMesh(smgr,driver,"test.3DS","brkweat.jpg",position,rotation);
myNode->drop();
smgr->addCameraSceneNode(0, vector3df(0,30,-40), vector3df(0,5,0));
while(device->run())
{
driver->beginScene(true, true, SColor(255,100,101,140));
smgr->drawAll();
guienv->drawAll();
driver->endScene();
}
device->drop();
return 0;
};
IAnimatedMeshSceneNode* addMesh(ISceneManager* smgr, IVideoDriver* driver, char MeshFileName[], char textureFileName[], f32 position[], f32 rotation[])
{
IAnimatedMesh* mesh = smgr->getMesh( MeshFileName );
IAnimatedMeshSceneNode* node = smgr->addAnimatedMeshSceneNode( mesh,0,-1,core::vector3df(position[0],position[1],position[2]),core::vector3df(rotation[0],rotation[1],rotation[2]),core::vector3df(1,1,1) );
if (node)
{
node->setMaterialFlag(EMF_LIGHTING, false);
//add the texture file
if (textureFileName != "")
node->setMaterialTexture( 0, driver->getTexture( textureFileName ) );
// add rotation animator
scene::ISceneNodeAnimator* anim =
smgr->createRotationAnimator(core::vector3df(rotation[0],rotation[1],rotation[2]));
node->addAnimator(anim);
anim->drop();
return node;
}
return false;
}