Code: Select all
#using<....Excluded path for security reasons....Irrlicht.NET.dll>
#using<System.dll>
using namespace Irrlicht;
using namespace Irrlicht::Video;
using namespace Irrlicht::Core;
using namespace Irrlicht::Scene;
using namespace System;
int main()
{
IrrlichtDevice^ device = gcnew IrrlichtDevice(DriverType::OPENGL);
device->ResizeAble = true;
device->WindowCaption = "Irrlicht.Net using C++/CLI";
ITexture^ texSydney = device->VideoDriver->GetTexture("..\\..\\media\\sydney.bmp");
ITexture^ texWall = device->VideoDriver->GetTexture("..\\..\\media\\wall.bmp");
ITexture^ texLogo = device->VideoDriver->GetTexture("..\\..\\media\\irrlichtlogoaligned.jpg");
Irrlicht::Scene::IAnimatedMesh^ mesh = device->SceneManager->GetMesh("..\\..\\media\\sydney.md2");
if(mesh == nullptr)
{
Console::WriteLine("Could not load mesh");
return 1;
}
ICameraSceneNode^ cam = device->SceneManager->AddCameraSceneNode(nullptr, 100, 100, -1);
cam->Position = gcnew Vector3D(20,0,-50);
ISceneNode^ node = device->SceneManager->AddTestSceneNode(15,
nullptr, -1, gcnew Vector3D(30,-15,0));
node->SetMaterialTexture(0, texWall);
node = device->SceneManager->AddAnimatedMeshSceneNode(mesh, nullptr, -1);
node->SetMaterialTexture(0, texSydney);
node->SetMaterialFlag(MaterialFlag->LIGHTING, false);
device->CursorControl->Visible = false;
int fps = 0;
while(device->Run())
{
if (device->WindowActive)
{
device->VideoDriver->BeginScene(true, true, gcnew Color(0,100,100,100));
device->SceneManager->DrawAll();
// draw the logo
device->VideoDriver->Draw2DImage(
texLogo, gcnew Position2D(10,10),
gcnew Rect(0,0,88,31),
gcnew Rect(gcnew Position2D(0,0),device->VideoDriver->ScreenSize),
gcnew Color(0xffffff), false);
device->VideoDriver->EndScene();
if (fps != device->VideoDriver->FPS)
{
fps = device->VideoDriver->FPS;
device->WindowCaption = "Irrlicht.NET C++/CLI example 01 - Hello World ["+
device->VideoDriver->Name + "] fps:" + fps;
}
}
}
}