hi,
we are making a game with an airship and we are going to to have a cockpit view but so far usin code in the tutorials i cant get the HUD texture to load along with my irredit level, could you please advise on what i am doing wrong, as i am new to this. i can get my hud texture into the example program.
my code as follows:
IrrlichtDevice* device = createDevice( EDT_DIRECT3D9, dimension2d<s32>(640,480), 32, false, false, false, &receiver );
device->setWindowCaption(L"NAVIGATOR");
video::IVideoDriver* driver = device->getVideoDriver();
scene::ISceneManager* smgr = device->getSceneManager();
IGUIEnvironment* env = device->getGUIEnvironment();
env->addImage(driver->getTexture("../media/HUD.jpg"),position2d<int>(10,10));
any help will be mcuh appreciated
regards
Head Up Display (HUD)
right, not sure how to do this, quite new to this engine, this is my camera code it fixes to my ship which moves through the level, help please:
int lastFPS = -1;
while(device->run())
if (device->isWindowActive())
{
driver->beginScene(true, true, video::SColor(0,200,200,200));
smgr->drawAll();
driver->endScene();
core::vector3df v = Munch->getPosition();
v.Z += 1.0f;
Munch->setPosition(v);
//==========================================CAMERA SYSTEM==========================================
vector3df MunchRot = Munch->getRotation();
vector3df MunchPos = Munch->getPosition();
float DirY = ((MunchRot.Y + 90) * 3.14) / 180; //original 3.14
int CamX = (MunchPos.X - cos(DirY)*45);
int CamY = (MunchPos.Z - sin(DirY)*35);
int CamZ = (MunchPos.Y + 4);
camera = smgr->addCameraSceneNode();
camera->setTarget(MunchPos);
camera->setPosition( vector3df( CamX, CamZ, CamY ) );
//============================================CAM END==============================================
int fps = driver->getFPS();
if (lastFPS != fps)
{
core::stringw str = L"Load Irrlicht File example - Irrlicht Engine [";
str += driver->getName();
str += "] FPS:";
str += fps;
device->setWindowCaption(str.c_str());
lastFPS = fps;
}
eventReceiver.startEventProcess();
}
regards
int lastFPS = -1;
while(device->run())
if (device->isWindowActive())
{
driver->beginScene(true, true, video::SColor(0,200,200,200));
smgr->drawAll();
driver->endScene();
core::vector3df v = Munch->getPosition();
v.Z += 1.0f;
Munch->setPosition(v);
//==========================================CAMERA SYSTEM==========================================
vector3df MunchRot = Munch->getRotation();
vector3df MunchPos = Munch->getPosition();
float DirY = ((MunchRot.Y + 90) * 3.14) / 180; //original 3.14
int CamX = (MunchPos.X - cos(DirY)*45);
int CamY = (MunchPos.Z - sin(DirY)*35);
int CamZ = (MunchPos.Y + 4);
camera = smgr->addCameraSceneNode();
camera->setTarget(MunchPos);
camera->setPosition( vector3df( CamX, CamZ, CamY ) );
//============================================CAM END==============================================
int fps = driver->getFPS();
if (lastFPS != fps)
{
core::stringw str = L"Load Irrlicht File example - Irrlicht Engine [";
str += driver->getName();
str += "] FPS:";
str += fps;
device->setWindowCaption(str.c_str());
lastFPS = fps;
}
eventReceiver.startEventProcess();
}
regards
The idea of war is not to die for your country, but to make the other bastard die for his!
You need to draw the gui. That means you need to put a call to env->drawAll() between driver->beginScene() and driver->endScene() [usually after the call to smgr->drawAll()]. This would have been very easy to answer for yourself by looking at one of the tutorials that use the gui.
One other note... You might want to use code tags around source code when you post. They preserve formatting and make your posts much easier to read.
Travis
One other note... You might want to use code tags around source code when you post. They preserve formatting and make your posts much easier to read.
Travis
Code: Select all
int main()
{
eventReceiver.init();
MyEventReceiver receiver;
IrrlichtDevice* device = createDevice( EDT_DIRECT3D9, dimension2d<s32>(640,480), 32, false, false, false, &receiver );
device->setWindowCaption(L"NAVIGATOR");
video::IVideoDriver* driver = device->getVideoDriver();
scene::ISceneManager* smgr = device->getSceneManager();
IGUIEnvironment* env = device->getGUIEnvironment();
smgr->loadScene("../media/Level(st).irr");
//=====================================================MESHES===================================================
IAnimatedMesh *MunchMesh = smgr->getMesh("../media/virus4.obj");
Munch = smgr->addAnimatedMeshSceneNode(MunchMesh, 0, 999, vector3df(0,0,0), vector3df(0,0,0), vector3df(1,1,1), false);
Munch->setPosition(core::vector3df(0,0,30));
Munch->setMaterialTexture(0, driver->getTexture("../media/XF_1_HULL.jpg"));
Munch->setMaterialFlag(video::EMF_LIGHTING, false);
//=============================================MESHES END=======================================================
eventReceiver.endEventProcess();
//==========================================HUD=================================================================
env->addImage(driver->getTexture("../media/HUD.jpg"),position2d<int>(10,10));
env->addImage(driver->getTexture("../media/Health.jpg"),position2d<int>(10,240));
env->addImage(driver->getTexture("../media/Health.jpg"),position2d<int>(10,250));
env->addImage(driver->getTexture("../media/Health.jpg"),position2d<int>(10,260));
env->addImage(driver->getTexture("../media/Health.jpg"),position2d<int>(10,270));
env->addImage(driver->getTexture("../media/Health.jpg"),position2d<int>(10,280));
env->addImage(driver->getTexture("../media/Health.jpg"),position2d<int>(10,290));
env->addImage(driver->getTexture("../media/Health.jpg"),position2d<int>(10,300));
//==========================================HUD END=============================================================
int lastFPS = -1;
while(device->run())
if (device->isWindowActive())
{
if(receiver.KeyIsDown[KEY_KEY_A])
{
Xpos ++;
camera->setPosition(vector3df(Xpos, Ypos, Zpos));
}
driver->beginScene(true, true, video::SColor(0,200,200,200));
smgr->drawAll();
env->drawAll();
driver->endScene();
Zpos = Zpos + 2;
Munch->setPosition(vector3df(Xpos, Ypos, Zpos));
//==========================================CAMERA SYSTEM==========================================
vector3df MunchRot = Munch->getRotation();
vector3df MunchPos = Munch->getPosition();
float DirY = ((MunchRot.Y + 90) * 3.14) / 180; //original 3.14
int CamX = (MunchPos.X - cos(DirY)*45);
int CamY = (MunchPos.Z - sin(DirY)*35);
int CamZ = (MunchPos.Y + 5);
camera = smgr->addCameraSceneNode();
//camera->setTarget(MunchPos);
//camera->setPosition( vector3df( CamX, CamZ, CamY ) );
//============================================CAM END==============================================
int fps = driver->getFPS();
if (lastFPS != fps)
{
core::stringw str = L"Load Irrlicht File example - Irrlicht Engine [";
str += driver->getName();
str += "] FPS:";
str += fps;
device->setWindowCaption(str.c_str());
lastFPS = fps;
}
eventReceiver.startEventProcess();
}
device->drop();
return 0;
}
regards
The idea of war is not to die for your country, but to make the other bastard die for his!