Overlays between viewports (see picture)
-
- Gnome
- Posts: 336
- Joined: Sat Dec 08, 2007 4:28 am
- Location: Canada
- x 7
Overlays between viewports (see picture)
Hi,
I was just wondering if it would be easy to implement? Has anybody had ever done this? I would aprecciate any help, hint (or snippet )
Thanks!
I was just wondering if it would be easy to implement? Has anybody had ever done this? I would aprecciate any help, hint (or snippet )
Thanks!
-
- Greenskin
- Posts: 127
- Joined: Tue Feb 14, 2006 1:34 am
- Location: Orlando, FL
- x 1
Re: Overlays between viewports (see picture)
I think you could use a RenderTargetListener to position the overlay in each viewport befores it is updated. Move it to left edge of one viewport before it's updated, and move it to the right edge of the other before it's updated, would make it appear to be in between the two.
hope it helps
hope it helps
-
- Gnome
- Posts: 312
- Joined: Sat Nov 26, 2005 4:03 pm
Re: Overlays between viewports (see picture)
Its simple just use half of the star as first overlay, and another half of the star as second overlay.
if the star shape are generated at runtime, you can also split it.
if the star shape are generated at runtime, you can also split it.
_________________________________
Best regards
Ahmadi
Best regards
Ahmadi
-
- Goblin
- Posts: 213
- Joined: Mon Jan 26, 2009 11:51 pm
- x 15
Re: Overlays between viewports (see picture)
ok, so I know nothing about viewports or overlays, but I thought I would toss this in since it might be a different direction, and I think it would work? is it possible to have viewports inside other viewports? how are things like rearview mirrors done for racing games? I think you could do something like that, have the two side panels inside one, and the overlay is above those two in that same viewport
-
- Gnome
- Posts: 372
- Joined: Thu Dec 20, 2007 1:00 am
- Location: Florida
- x 3
Re: Overlays between viewports (see picture)
Why don't you just put the star in a different viewport that covers the entire screen? Just make it's zorder higher than the other 2 and it will render after them.
EDIT: sorry I didn't see shadowfeign's response. Yes that works, consider what he said (and what I said).
EDIT: sorry I didn't see shadowfeign's response. Yes that works, consider what he said (and what I said).
-
- OGRE Expert User
- Posts: 1671
- Joined: Mon Jan 21, 2008 10:26 pm
- x 50
Re: Overlays between viewports (see picture)
I'll say the same as the other : just put it in another viewport, it's very easy.
But I'll add some snippet :
at the creation level
edit : overlay creation:
and then when using it:
OT : how do you attach a picture in your post on ogres forum (you can pm me)?
But I'll add some snippet :
at the creation level
Code: Select all
Ogre::SceneManager* lSceneManager = mRoot->createSceneManager(Ogre::ST_GENERIC,"monPremierSceneManager");
Ogre::Camera* lCamera = lSceneManager->createCamera("maPremiereCamera");
Ogre::SceneNode * lNodeCamera = lSceneManager->getRootSceneNode()->createChildSceneNode("nodeDeMaPremiereCamera");
lNodeCamera->attachObject(lCamera);
// first viewport
Ogre::Viewport * vp = mWindow->addViewport(lCamera,100, 0.1, 0.1, 0.4, 0.8);
// second viewport
Ogre::Viewport * vp2 = mWindow->addViewport(lCamera,80, 0.5, 0.1, 0.4, 0.8);
// overlay viewport on top of everything
Ogre::SceneManager *scMagrOverlay = mRoot->createSceneManager(Ogre::ST_GENERIC,"OverlayOnly_SceneManager");
Ogre::Camera* lCamOverlay = scMagrOverlay->createCamera("maCam");
Ogre::Viewport * vpOverlay = mWindow->addViewport(lCamOverlay,50, 0.1, 0.1, 0.8, 0.8);
vpOverlay->setBackgroundColour(Ogre::ColourValue(0,0,0));
vpOverlay->setClearEveryFrame(false);// you 'll need it in order not to overwrite everything.
vpOverlay->setOverlaysEnabled(true);
vpOverlay->setSkiesEnabled(false); // you don't want skies /scene to pollute your rendering.
vp->setOverlaysEnabled(false);
vp2->setOverlaysEnabled(false);
mWindow->setActive(true);
mWindow->setAutoUpdated(false); // I prefer manual updating.
Code: Select all
{
Ogre::Overlay * lOverlay = Ogre::OverlayManager::getSingleton().create("Overlay/RttSceneTete");
Ogre::OverlayContainer * lOverlaySuperContainer = dynamic_cast<Ogre::OverlayContainer*> (Ogre::OverlayManager::getSingleton().createOverlayElement("Panel","Overlay/RttSceneTete/SuperContainer",false));
lOverlaySuperContainer->setParameter("transparent","true"); // il est invisible (pas de material).
lOverlaySuperContainer->show();// si on veut voir ses "enfants", il faut que lui meme soit 'visible'.
lOverlay->add2D(lOverlaySuperContainer);
{
Ogre::TextAreaOverlayElement * lTextOverlay = dynamic_cast<Ogre::TextAreaOverlayElement*>(Ogre::OverlayManager::getSingleton().createOverlayElement("TextArea","Overlay/RttSceneTete/legende",false));
lTextOverlay->setLeft(0.40);
lTextOverlay->setWidth(0.3);
lTextOverlay->setTop(0.3);
lTextOverlay->setHeight(0.08);
lTextOverlay->setColour(Ogre::ColourValue(1,0,0,1)); // la couleur de font
lTextOverlay->setFontName("BlueHighway"); // la font
lTextOverlay->setCaption("THIS OVERLAY IS IN A THIRD VIEWPORT"); // le texte dans cette area
lTextOverlay->setCharHeight(0.08); // hauteur des lettres par rapport a l'overlay parent
lTextOverlay->show();
lOverlaySuperContainer->addChild(lTextOverlay);
}
lOverlay->show();
}
and then when using it:
Code: Select all
// time to render!
vp->update();
vp2->update();
vpOverlay->update();
// just swapping the buffers.
mWindow->swapBuffers(true);
// call frame listeners etc...
mRoot->renderOneFrame();
Tutorials + Ogre searchable API + more for Ogre1.7 : http://sourceforge.net/projects/so3dtools/
Corresponding thread : http://www.ogre3d.org/forums/viewtopic. ... 93&start=0
Corresponding thread : http://www.ogre3d.org/forums/viewtopic. ... 93&start=0
-
- Gnome
- Posts: 336
- Joined: Sat Dec 08, 2007 4:28 am
- Location: Canada
- x 7
Re: Overlays between viewports (see picture)
Ok, thanks for all the replies. The star was just an example, the thing is that I see very common on games with split screen to use overlays that don't seem to be bothered by the viewports limits.
Right now I can't try your solution cause I'm at work, but I remember some time ago trying to overlap viewports with different z orders and what I never could do was to transparent the background of them, if I assigned a black background with 0 alpha, that didn't seem to blend them...
I even posted a new topic trying to look for a way to do transparent viewports and didn't recieve much replies...
http://www.ogre3d.org/forums/viewtopic.php?p=286341
Right now I can't try your solution cause I'm at work, but I remember some time ago trying to overlap viewports with different z orders and what I never could do was to transparent the background of them, if I assigned a black background with 0 alpha, that didn't seem to blend them...
I even posted a new topic trying to look for a way to do transparent viewports and didn't recieve much replies...
http://www.ogre3d.org/forums/viewtopic.php?p=286341
-
- OGRE Expert User
- Posts: 1671
- Joined: Mon Jan 21, 2008 10:26 pm
- x 50
Re: Overlays between viewports (see picture)
My solution (just above) is using 'transparent' viewport on top of 2 others.
I posted full code, I don't see want you want more?!
I wanted to post a picture where you can see clearly the text of the overlay in red, and the background that is from the 2 other viewports... but I don't know how to share images on the internet.
I posted full code, I don't see want you want more?!
I wanted to post a picture where you can see clearly the text of the overlay in red, and the background that is from the 2 other viewports... but I don't know how to share images on the internet.
Tutorials + Ogre searchable API + more for Ogre1.7 : http://sourceforge.net/projects/so3dtools/
Corresponding thread : http://www.ogre3d.org/forums/viewtopic. ... 93&start=0
Corresponding thread : http://www.ogre3d.org/forums/viewtopic. ... 93&start=0
-
- Gnome
- Posts: 336
- Joined: Sat Dec 08, 2007 4:28 am
- Location: Canada
- x 7
Re: Overlays between viewports (see picture)
Lol! I didn´t look the code thoroughly. I see you change some parameters. I was looking for that like a couple months ago!!! Awesome.
Check this free Image hosting:
http://www.imageshack.us/
Have never used it, but it's on googles top list.
Check this free Image hosting:
http://www.imageshack.us/
Have never used it, but it's on googles top list.
-
- Gnome
- Posts: 336
- Joined: Sat Dec 08, 2007 4:28 am
- Location: Canada
- x 7
Re: Overlays between viewports (see picture)
Ok, so basically to make the viewport transparent the most important command is:
I was setting it to true...
Code: Select all
setClearEveryFrame(false);
-
- OGRE Expert User
- Posts: 1671
- Joined: Mon Jan 21, 2008 10:26 pm
- x 50
Re: Overlays between viewports (see picture)
Not exactly,
what you want is :
which means that the depth buffer is cleaned but not the color buffer.
In your case, setClearEveryFrame(false); was quickier to execute because you don't have more 3D.
But if you want to merge viewport with 3D content , you need
And if you also happen to use stencil buffer ( from stencil shadows/volumetric shadows):
Hope this helps!
what you want is :
Code: Select all
viewport->setClearEveryFrame(true, FBT_DEPTH);
In your case, setClearEveryFrame(false); was quickier to execute because you don't have more 3D.
But if you want to merge viewport with 3D content , you need
Code: Select all
viewport->setClearEveryFrame(true, FBT_DEPTH);
Code: Select all
viewport->setClearEveryFrame(true, FBT_DEPTH|FBT_STENCIL);
Tutorials + Ogre searchable API + more for Ogre1.7 : http://sourceforge.net/projects/so3dtools/
Corresponding thread : http://www.ogre3d.org/forums/viewtopic. ... 93&start=0
Corresponding thread : http://www.ogre3d.org/forums/viewtopic. ... 93&start=0
-
- OGRE Expert User
- Posts: 1119
- Joined: Sat Jan 01, 2011 7:57 pm
- x 217
Re: Overlays between viewports (see picture)
Sorry to dig up the old thread, but I've used this solution fine in Ogre 1.7, but in Ogre 1.8 trunk it doesn't work anymore. I can't see the 3d scene anymore, just the background color of viewport.
Has anyone successfully used this with ogre 1.8?
Has anyone successfully used this with ogre 1.8?