3D scene and GUI in the same view

You are an experienced programmer and have a problem with the engine, shaders, or advanced effects? Here you'll get answers.
No questions about C++ programming or topics which are answered in the tutorials!
Post Reply
RLam
Posts: 9
Joined: Sat Oct 08, 2005 5:59 am

3D scene and GUI in the same view

Post by RLam »

I decide to divide the screen into several part. One part is to draw a GUI. Another part is to draw the camera view.

Usually, if I want to add the GUI to on top on the camera view, I can add a small window (like the one in tutorial "MeshViewer").

Howerver, I don't want to do so since I don't want the window frame appear in my game. Therefore, I would like to add a panel and put all the menu or items on top of the panel.

How can I do so?
Pr3t3nd3r
Posts: 186
Joined: Tue Feb 08, 2005 6:02 pm
Location: Romania
Contact:

Post by Pr3t3nd3r »

create one panel.
make all objects of the gui child of panel ... and that is all ..
RLam
Posts: 9
Joined: Sat Oct 08, 2005 5:59 am

Post by RLam »

Pr3t3nd3r wrote:create one panel.
make all objects of the gui child of panel ... and that is all ..
To create a panel....
Do you mean that I need to use the Window.form?
But actually, I would prefer writing the coding in C++.
If I use C++, are there any other way to implement such kind of panel?
JP
Posts: 4526
Joined: Tue Sep 13, 2005 2:56 pm
Location: UK
Contact:

Post by JP »

Look in the IGUIEnvironment class, or some of the tutorials have some use of the GUI stuff, such as Hello World or the Mesh Viewer. You can create a window which can then have items added to it, or you dont even need to use a window in fact, just add items to the root GUI node and they'll appear on the screen.
Image Image Image
RLam
Posts: 9
Joined: Sat Oct 08, 2005 5:59 am

Post by RLam »

JP wrote:Look in the IGUIEnvironment class, or some of the tutorials have some use of the GUI stuff, such as Hello World or the Mesh Viewer. You can create a window which can then have items added to it, or you dont even need to use a window in fact, just add items to the root GUI node and they'll appear on the screen.
Actually, I have read through all the tutorials related to the GUI already.
But it seems that they can't help me solve my problem.
The main point is that I hope 3D scence and GUI(2D) needs to be drawn in the same view/panel.

(It seems that MeshViewer tutorial is similar to that. However, I don't want to GUI like a window which have window frame and cover upon the 3D scene.What I need is the panel is divided to 2 parts. One is 3D scene and one is GUI. The area GUI occpies and area the 3D sciene ocupies have certain ratio.)

I would like to ask if I want to do such thing, do I really need to change the source code myself or are there any functions which can give me helping hand?
JP
Posts: 4526
Joined: Tue Sep 13, 2005 2:56 pm
Location: UK
Contact:

Post by JP »

I think someone else has asked for a similar thing, to have the 3D scene take up only part of the screen, so look through the beginners and advanced forums for something like that, i think one of the threads was called something about having a second camera view overlaid onto the main scene.
Image Image Image
Guest

Post by Guest »

viewports! they are in the docs.
RLam
Posts: 9
Joined: Sat Oct 08, 2005 5:59 am

Post by RLam »

JP wrote:I think someone else has asked for a similar thing, to have the 3D scene take up only part of the screen, so look through the beginners and advanced forums for something like that, i think one of the threads was called something about having a second camera view overlaid onto the main scene.
Yes, I know the SplitScreen Tutorial has talked about that.
Nonetheless, I seems doesn't give any help to my problem.
In the tutorial, it saids
"After Render all objects (view of 4 cameras)
If you have a GUI:
Set the viewport the whole screen
Display the GUI
End scene "

But it doesn't work.
In my case, I try to set there is one camera only and use viewport to set the area that display the 3D scene in the panel. After render the objects in 3d scene, I disply the GUI. But don't know why only the 3D scence can be shown but no GUI I have added.
Have I done something wrong?

Code: Select all

gui::IGUITabControl* tabctrl = 0;
gui::IGUITab* optTab = 0;
gui::IGUITab* aboutTab = 0;
while(device->run()) {
    //Set the viewpoint the the whole screen and begin scene
    driver->setViewPort(rect<s32>(0,0,ResX,ResY));
    driver->beginScene(true,true,SColor(0,100,100,100));
    driver->setViewPort(rect<s32>(0,0,ResX/2,ResY/2));
    //Activate camera
    smgr->setActiveCamera(camera);
    //Draw scene
    smgr->drawAll();
    if (!(tabctrl) && !(optTab) && !(aboutTab) ){
	tabctrl = env->addTabControl(core::rect<int>(ResX/2,0,ResX,ResY/2), 0, true, true); 
	optTab = tabctrl->addTab(L"Demo");
	aboutTab = tabctrl->addTab(L"About");
	driver->setViewPort(rect<s32>(0,0,ResX,ResY));
	env->drawAll ();
       }
	 
    driver->endScene(); 

     //Get and show fps
    if (driver->getFPS() != lastFPS) {
      lastFPS = driver->getFPS();
      wchar_t tmp[1024];
      swprintf(
          tmp,
          1024,
          L"Irrlicht SplitScreen-Example (FPS: %d)",
          lastFPS);
      device->setWindowCaption(tmp);
    }
  }
bitplane
Admin
Posts: 3204
Joined: Mon Mar 28, 2005 3:45 am
Location: England
Contact:

Post by bitplane »

env->drawAll() is inside your if statement, so it will only call on the first frame. if you tab your code in properly you'll be able to read it better.
RLam
Posts: 9
Joined: Sat Oct 08, 2005 5:59 am

Post by RLam »

Oh..I know what I have done wrong.

I have put
driver->setViewPort(rect<s32>(0,0,ResX,ResY));
env->drawAll ();

to the wrong place.

sorry to ask such silly question
Post Reply