Code: Select all
#include <irrlicht.h>
using namespace irr;
using namespace core;
using namespace scene;
using namespace video;
SColor const WHITE(255, 255, 255, 255);
int main() {
IrrlichtDevice* irrDevice = createDevice(EDT_OPENGL, dimension2d<u32>(1600, 900), 32, false, false, false, 0); if (irrDevice == 0) return 1;
ISceneManager* irrScene = irrDevice->getSceneManager();
IVideoDriver* irrDriver = irrDevice->getVideoDriver();
ICameraSceneNode* Camera = irrScene->addCameraSceneNodeFPS(0, 100.0f, 0.001f);
Camera->setPosition(vector3df(1.1f, 1.0f, -0.6f)); /// When turning right from this position the mesh dissappears
Camera->setTarget(vector3df(3, 0, 1));
SMesh* Mesh = new SMesh;
SMeshBuffer* TempBuff = new SMeshBuffer();
Mesh->addMeshBuffer(TempBuff);
TempBuff->drop();
TempBuff->Vertices.push_back(S3DVertex(vector3df(2, 0, 0), vector3df(0, 0, 0), WHITE, vector2df(0, 1)));
TempBuff->Vertices.push_back(S3DVertex(vector3df(2, 1, 0), vector3df(0, 0, 0), WHITE, vector2df(0, 0)));
TempBuff->Vertices.push_back(S3DVertex(vector3df(3, 0, 0), vector3df(0, 0, 0), WHITE, vector2df(1, 1)));
TempBuff->Vertices.push_back(S3DVertex(vector3df(3, 1, 0), vector3df(0, 0, 0), WHITE, vector2df(1, 0)));
TempBuff->Indices.push_back(0); //┐
TempBuff->Indices.push_back(1); //├ 1st triangle
TempBuff->Indices.push_back(2); //┘ 1----3
TempBuff->Indices.push_back(3); //┐ | |
TempBuff->Indices.push_back(2); //├ 2nd triangle | |
TempBuff->Indices.push_back(1); //┘ 0----2
TempBuff->setDirty(EBT_VERTEX_AND_INDEX);
IMeshSceneNode* Meshnode = irrScene->addMeshSceneNode(Mesh);
while(irrDevice->run()) {
irrDriver->beginScene(true, true, SColor(255, 128, 128, 128));
irrScene->drawAll();
irrDriver->endScene();
}
Mesh->drop();
irrDevice->drop();
return 0;
}