2010-11-22 8 views
5

Ho il seguente codice:Perché i triangoli vengono ritagliati in questa mesh?

#include <irrlicht.h> 

using namespace irr; 

using namespace core; 
using namespace scene; 
using namespace video; 
using namespace io; 
using namespace gui; 

int main(int argc, char** argv) 
{ 
    IrrlichtDevice *device = 
     createDevice(EDT_SOFTWARE, dimension2d<unsigned int>(640, 480), 16, 
      false, false, false, 0); 

    device->setWindowCaption(L"Train Simulator Demo"); 

    IVideoDriver* driver = device->getVideoDriver(); 
    ISceneManager* smgr = device->getSceneManager(); 
    IGUIEnvironment* guienv = device->getGUIEnvironment(); 

    IAnimatedMesh* mesh1 = smgr->getMesh("media/simple_engine.b3d"); 
    IAnimatedMesh* mesh2 = smgr->getMesh("media/simple_track.b3d"); 

    IAnimatedMeshSceneNode* node1 = smgr->addAnimatedMeshSceneNode(mesh1); 
    IAnimatedMeshSceneNode* node2 = smgr->addAnimatedMeshSceneNode(mesh2); 

    if (node1) 
     node1->setMaterialFlag(EMF_LIGHTING, false); 

    if (node2) 
    { 
     node2->setMaterialFlag(EMF_LIGHTING, false); 
     node2->setMaterialTexture(0, driver->getTexture("media/grass.jpg")); 
    } 

    ICameraSceneNode * pCamera = smgr->addCameraSceneNode(0, vector3df(5,0,5), vector3df(0,0,0)); 

    pCamera->setNearValue(0.5f); 
    pCamera->setFarValue(40.0f); 

    while(device->run()) 
    { 
     driver->beginScene(true, true, SColor(0,0,0,0)); 

     u32 cur_time = device->getTimer()->getTime(); 
     float f_time = (float)cur_time/1000.0f; 

     // Change the camera 
     pCamera->setPosition(vector3df(sinf(f_time) * 8.0f ,3.0f ,cosf(f_time) * 8.0f)); 

     smgr->drawAll(); 
     guienv->drawAll(); 

     driver->endScene(); 
    } 

    device->drop(); 

    return 0; 
} 

... che quando viene eseguito produce il seguente:

alt text

... che va bene, tranne che l'erba dovrebbe essere una griglia di 16x16 quadrati e sembra che alcuni dei triangoli vengano tagliati per qualche motivo. Sembra anche che questo abbia qualcosa a che fare con i triangoli che vengono visualizzati solo parzialmente sullo schermo in quanto vengono visualizzati solo i triangoli che sono completamente nella finestra della finestra. Come posso risolvere questo?

aggiuntive:

OS: Ubuntu 10.04 a 64 bit
Irrlicht versione: 1.7 beta

risposta

3

scopre che il problema era che stavo usando il programma di rendering software al posto del Renderer OpenGL.

Così la linea 13:

IrrlichtDevice *device = 
    createDevice(EDT_SOFTWARE, dimension2d<unsigned int>(640, 480), 16, 
     false, false, false, 0); 

diventa:

IrrlichtDevice *device = 
    createDevice(EDT_OPENGL, dimension2d<unsigned int>(640, 480), 16, 
     false, false, false, 0); 
+1

hmm cosa buona da ricordare. – RolandiXor