martes, 7 de abril de 2015

Aplicando Textura al Mesh en Irrlicht


Descargar Assets para este proyecto


#include <irrlicht.h>

//los namespace para definir funciones de irrlicht
using namespace irr;
using namespace core;
using namespace video;
using namespace scene;

#if defined(_MSC_VER)
#pragma comment(lib, "Irrlicht.lib")
#endif

int main()
{
 //define un device para la pantalla
 IrrlichtDevice *device = createDevice(EDT_OPENGL, dimension2d<u32>(640, 480), 16, false,
  false, false, 0);

 //en caso de error
 if (!device)
  return 1;

 //Creo un driver de video
 IVideoDriver *driver = device->getVideoDriver();

 //Creo una manejador de escena
 ISceneManager *scene = device->getSceneManager();

 //creo mi mesh y le paso mi mesh de tipo obj, collada, md2 , md3
 IMesh *mesh = scene->getMesh("sydney.md2");

 //Creo un nodo
 IMeshSceneNode *node = scene->addMeshSceneNode(mesh);

 if (node)
 {
  //Agrego mi textura e iluminacion
  node->setMaterialFlag(EMF_LIGHTING, false);
  node->setMaterialTexture(0, driver->getTexture("sydney.bmp"));
 }

 //agrego una vista o camara
 scene->addCameraSceneNode(0, vector3df(0, 30, -40) , vector3df( 0 , 5 , 0));

 //Gameloop
 while (device->run())
 {
  driver->beginScene(true, true, SColor(255,255,255,255));
  scene->drawAll();
  driver->endScene();
 }

 //cerrar device
 device->drop();

 return 0;
}



No hay comentarios:

Publicar un comentario