Well, this time i'm trying to render a Cegui window on an Ogre Texture (the end result should be of three different menus, each on a different surface - basically, i will have each one on a page and passing to the next menu makes the page turn). I'm still using Cegui 0.7.9, as now - waiting for a stable release of Ogre 1.9 so that i can recompile all of them just a single time, hopefully.
As now i'm trying to render the first window in the first page. I'm already having some result - even if not exactly how i wanted it. I still haven't found a way to render it to the texture without having the window itself visibile on the screen. And i can't see the mouse. Basically, there are problems i will have to solve. Eventually.
Because here come the question. By searching in regard to similar issues, i've also read about a support for multiple roots that would be used in such situations (even if i'm not exactly sure about its use). That support was mentioned to be implemented in the 0.8 versions, that are now out. That also means that while i may search for complex workarounds, part of my problems may be solved by simply upgrading the CEGUI version i'm using - something that i would have done anyway in due time - and using the instruments there contained.
Am i correct?
Render CEGUI to Ogre texture - a question
Moderators: CEGUI MVP, CEGUI Team
Re: Render CEGUI to Ogre texture - a question
Yes, see the GUIContext class in CEGUI 0.8.x
Re: Render CEGUI to Ogre texture - a question
And indeed i was able to do so, even if there is some graphical issue i've still to solve (as the texture involved has the aspect ratio of an A4 page, the fonts get shrinked).
The code involved is quite simple (here is rearranged a bit, cause i've moved some parts to a different function for better readability in my code; also, i have two other windows in separate "pages", as they are accessed in sequence, akin to a book).
The texture is then applied to a cloned material that substitutes the default one.
It seems to work, i don't see anymore the normal window, i see just it rendered on the object.
The issue is ...how do i pass the inputs now? Neither one of the rendered window seems to be receiving anything. I supposed i just had to activate the window i wanted to use at a time, but that doesn't seem to work. Guess i missed some other function, then?
The code involved is quite simple (here is rearranged a bit, cause i've moved some parts to a different function for better readability in my code; also, i have two other windows in separate "pages", as they are accessed in sequence, akin to a book).
Code: Select all
m_guiRoot[0] = CEGUI::WindowManager::getSingleton().loadLayoutFromFile((CEGUI::utf8*)"Test_1.layout");
//subscribe the various events
m_guiRoot[0]->setUsingAutoRenderingSurface( true );
CEGUI::OgreTextureTarget &aTarget = dynamic_cast<CEGUI::OgreTextureTarget&>(m_guiRoot[0]->getRenderingSurface()->getRenderTarget());
CEGUI::Texture& ceTex = aTarget.getTexture();
CEGUI::OgreTexture& ogreTex = static_cast<CEGUI::OgreTexture&>(ceTex);
pageTex[0]=ogreTex.getOgreTexture();
OgreFramework::getSingletonPtr()->m_pGUISystem->createGUIContext(aTarget).setRootWindow(m_guiRoot[0]);
The texture is then applied to a cloned material that substitutes the default one.
It seems to work, i don't see anymore the normal window, i see just it rendered on the object.
The issue is ...how do i pass the inputs now? Neither one of the rendered window seems to be receiving anything. I supposed i just had to activate the window i wanted to use at a time, but that doesn't seem to work. Guess i missed some other function, then?
Re: Render CEGUI to Ogre texture - a question
Mh, any help about this? I mean, i did search the forums...but i've found no example of this feature with the changes introduced with the 0.8 version.
Edit: albeit, maybe the problem is also due of how i input the commands; as in, i input them to the default gui context, by default. Got to see how to input them to a non-default one, but i cannot see any function to do so.
Edit: albeit, maybe the problem is also due of how i input the commands; as in, i input them to the default gui context, by default. Got to see how to input them to a non-default one, but i cannot see any function to do so.
Re: Render CEGUI to Ogre texture - a question
Update on the situation. I've seen some progress after i've set the inputs using the correct gui context. Still, a problem mentioned above is still there biting me (and probably my major concern right now).
Basically, the window i've got in the texture is treated as if it was of the same dimension of the screen. That is reflected in both the layout (as i said before it gets shrinked, due of the different ratio between a normal screen and a texture and because it is being obviously smaller than the screen) and in the inputs (as the mouse position there doesn't reflect the real position in the screen; beside that, i shouldn't even see the mouse in the rendered window, and neither it should do those graphical glitches).
Guess i'll have to examine further the properties, cause probably i just forgot to set something, or i have set it incorrectly.
Edit: by the way, is it even possible to render just the window and not the whole screen (as it happens as now in my case)?
Basically, the window i've got in the texture is treated as if it was of the same dimension of the screen. That is reflected in both the layout (as i said before it gets shrinked, due of the different ratio between a normal screen and a texture and because it is being obviously smaller than the screen) and in the inputs (as the mouse position there doesn't reflect the real position in the screen; beside that, i shouldn't even see the mouse in the rendered window, and neither it should do those graphical glitches).
Guess i'll have to examine further the properties, cause probably i just forgot to set something, or i have set it incorrectly.
Edit: by the way, is it even possible to render just the window and not the whole screen (as it happens as now in my case)?
Re: Render CEGUI to Ogre texture - a question
Guess i'll have to ask if what i want to do is even feasible with the instruments provided with cegui.
What i want to do would be having a situation like the one in the screen, with a mouse cursor displayed like usual and the cegui window rendered into a page (only the window - as now i've just been able to render the whole screen shrinked into that page). And the commands should be passed when i hover and click like i would do on a normal cegui window. Basically having just the window in a 3d space.
I've seen some other people rendering both the mouse and windows on a surface with old versions, but this is a bit different after all. And i'm beginning to think i'll have to use some raycasting as well (after i've found a way to render just what i need, and not the whole).
What i want to do would be having a situation like the one in the screen, with a mouse cursor displayed like usual and the cegui window rendered into a page (only the window - as now i've just been able to render the whole screen shrinked into that page). And the commands should be passed when i hover and click like i would do on a normal cegui window. Basically having just the window in a 3d space.
I've seen some other people rendering both the mouse and windows on a surface with old versions, but this is a bit different after all. And i'm beginning to think i'll have to use some raycasting as well (after i've found a way to render just what i need, and not the whole).
Re: Render CEGUI to Ogre texture - a question
I dunno about the glitches which is why I haven't replied.
Regarding CEGUI window in 3D space: yes, this is possible. Keep in mind though that CEGUI does not do the mouse cursor projection into the GUI context. As far as CEGUI is concerned it has no idea the GUI context is in 3D space and it has no idea where it is related to the cursor. So you have to do the linear algebra yourself and inject projected cursor coords into the context.
We wanted to have some sort of a demo of this for 0.8 (a room with computer displays or something) but we are lacking art and time
Regarding CEGUI window in 3D space: yes, this is possible. Keep in mind though that CEGUI does not do the mouse cursor projection into the GUI context. As far as CEGUI is concerned it has no idea the GUI context is in 3D space and it has no idea where it is related to the cursor. So you have to do the linear algebra yourself and inject projected cursor coords into the context.
We wanted to have some sort of a demo of this for 0.8 (a room with computer displays or something) but we are lacking art and time
Re: Render CEGUI to Ogre texture - a question
Well, i had already done something like that, for another game state, via raycasting. Being as it is just an image with some text applied at runtime and a glow effect when hovering, i hadn't used CEGUI for that.
Still, it would seem that it applies exactly what we were talking about - get the position in the 3d space and calculate the position relative to the 2d space of the texture.
I could even recycle the code rather easily.
Well, after solving the other problems.
Edit: seems like i remembered wrong; i wasn't calculating the 2d space in that example, i used a workaround. As now i have only the point in the 3d space where the mouse ray hits the mesh. I may try to approximate the page as a flat surface (as it is mostly flat, aside from the borders, where there aren't clickable objects anyway) but if that doesn't works well, guess i'll have to find some other way (i've got a bunch of ideas, but i have doubts about their performance).
Still, it would seem that it applies exactly what we were talking about - get the position in the 3d space and calculate the position relative to the 2d space of the texture.
I could even recycle the code rather easily.
Well, after solving the other problems.
Edit: seems like i remembered wrong; i wasn't calculating the 2d space in that example, i used a workaround. As now i have only the point in the 3d space where the mouse ray hits the mesh. I may try to approximate the page as a flat surface (as it is mostly flat, aside from the borders, where there aren't clickable objects anyway) but if that doesn't works well, guess i'll have to find some other way (i've got a bunch of ideas, but i have doubts about their performance).
Last edited by Jefferian on Sun Sep 01, 2013 11:10, edited 1 time in total.
Re: Render CEGUI to Ogre texture - a question
Regarding the "shrinked" text, i've found a solution. I had to also slightly change my layout.
Instead of having a layout structured like "baseWindow/otherContent" i had to change it into something like "root/baseWindow/otherContent", with root as an empty DefaultWindow.
In the first case i had
while in the second one
and despite both cases referring to the same window, the first one textured the whole screen. While the second correctly textured only the window.
Instead of having a layout structured like "baseWindow/otherContent" i had to change it into something like "root/baseWindow/otherContent", with root as an empty DefaultWindow.
In the first case i had
Code: Select all
m_guiRoot[0]->setUsingAutoRenderingSurface( true );
CEGUI::OgreTextureTarget &aTarget = dynamic_cast<CEGUI::OgreTextureTarget&>(m_guiRoot[0]->getRenderingSurface()->getRenderTarget());
CEGUI::Texture& ceTex = aTarget.getTexture();
while in the second one
Code: Select all
CEGUI::Window* bWindow = m_guiRoot[0]->getChild("baseWindow");
bWindow->setUsingAutoRenderingSurface( true );
CEGUI::OgreTextureTarget &aTarget = dynamic_cast<CEGUI::OgreTextureTarget&>(bWindow->getRenderingSurface()->getRenderTarget());
CEGUI::Texture& ceTex = aTarget.getTexture();
and despite both cases referring to the same window, the first one textured the whole screen. While the second correctly textured only the window.
Re: Render CEGUI to Ogre texture - a question
I'm still working on it.
Like i mentioned above, i've used a plane onto whom i raycasted to in order to get the coordinates relative to that plane. Thus i've got a vector2 with those relative, normalized coordinates.
I can then inject the proper mouse position by multiplying it for the screen dimensions and a factor that is, basically, the relative width and height of the window in the cegui layout (basically giving cegui the coordinates relative to his normal visualization).
I could probably take those same informations about the factor directly from the layout, and i'll probably do so later.
So, the result is basically this, when the page is flipping. At least with a single page, i'll add the other two ones later (and i'll have to change the code a bit).
So, all fine and well? Not exactly, sadly.
I've still some issues related to ogre, and one relative to cegui. Basically, when i move the mouse along the page, parts of the texture have some nasty graphical glitches in the form of black flashes. And i've got no idea about either what causes them, or to solve it.
(instead, relative to ogre, the problem lies with not having found a way yet to use a manual plane for the raycast; as now i'm using a previously created, saved and exported one as mesh for that purpose, and i can't even move it - something that will hamper the precision when i'll work on the other pages, since they're obviously in a different position, and it would seem moving the related scenenode has no effect, or i'm doing something wrong in that regard; i will probably have to ask about raycasts on manual planes and some other technical questions about meshes and the movement of related scenenodes on the ogre forums).
Edit: indeed, i missed some parameter regarding the derived position; i just need to do something about those weird black flashes now...
Like i mentioned above, i've used a plane onto whom i raycasted to in order to get the coordinates relative to that plane. Thus i've got a vector2 with those relative, normalized coordinates.
I can then inject the proper mouse position by multiplying it for the screen dimensions and a factor that is, basically, the relative width and height of the window in the cegui layout (basically giving cegui the coordinates relative to his normal visualization).
Code: Select all
m_gContext->injectMousePosition(int(menuRelPos.x*evt.state.width*0.5f), int(menuRelPos.y*evt.state.height*0.8f));
I could probably take those same informations about the factor directly from the layout, and i'll probably do so later.
So, the result is basically this, when the page is flipping. At least with a single page, i'll add the other two ones later (and i'll have to change the code a bit).
So, all fine and well? Not exactly, sadly.
I've still some issues related to ogre, and one relative to cegui. Basically, when i move the mouse along the page, parts of the texture have some nasty graphical glitches in the form of black flashes. And i've got no idea about either what causes them, or to solve it.
(instead, relative to ogre, the problem lies with not having found a way yet to use a manual plane for the raycast; as now i'm using a previously created, saved and exported one as mesh for that purpose, and i can't even move it - something that will hamper the precision when i'll work on the other pages, since they're obviously in a different position, and it would seem moving the related scenenode has no effect, or i'm doing something wrong in that regard; i will probably have to ask about raycasts on manual planes and some other technical questions about meshes and the movement of related scenenodes on the ogre forums).
Edit: indeed, i missed some parameter regarding the derived position; i just need to do something about those weird black flashes now...
Re: Render CEGUI to Ogre texture - a question
Hi
May I ask for a brief example of how this was done? My own attempts so far (rendering a second CEGUI GUIContext on an Ogre Texture) haven't rendered anything visible... I have a main GUI context that handles my "main" CEGUI root+windows. My 3D scene shows many Ogre objects, and on ONE of these objects I want to render a separate CEGUI window (that isn't part of my main window hierarchy).
What I've got
How do I get ceWin to draw on ogTex? And do I need to setup the Ogre texture in any specific way?
My approach is basically to create a second GUIContext and let its root window be my ceWin. Could it be that I am giving createGUIContext the wrong render target?
Please help!
BR,
mmixLinus
May I ask for a brief example of how this was done? My own attempts so far (rendering a second CEGUI GUIContext on an Ogre Texture) haven't rendered anything visible... I have a main GUI context that handles my "main" CEGUI root+windows. My 3D scene shows many Ogre objects, and on ONE of these objects I want to render a separate CEGUI window (that isn't part of my main window hierarchy).
What I've got
- A CEGUI window, created as *ceWin = WindowManager::loadLayoutFromFile("special.layout")
- An Ogre::TexturePtr ogTex = Ogre::TextureManager::getByName("myImageName") (assigned to a material, used on a Mesh in an Entity)
- I am using CEGUI::OgreRenderTarget
- My GUIContexts are all receiving TimePulses.
I have used some of the code posted above, in various permutations, but still don't see anythingJefferian wrote:Code: Select all
CEGUI::Window* bWindow = m_guiRoot[0]->getChild("baseWindow");
bWindow->setUsingAutoRenderingSurface( true );
CEGUI::OgreTextureTarget &aTarget = dynamic_cast<CEGUI::OgreTextureTarget&>(bWindow->getRenderingSurface()->getRenderTarget());
CEGUI::Texture& ceTex = aTarget.getTexture();
How do I get ceWin to draw on ogTex? And do I need to setup the Ogre texture in any specific way?
My approach is basically to create a second GUIContext and let its root window be my ceWin. Could it be that I am giving createGUIContext the wrong render target?
Please help!
BR,
mmixLinus
MMiX.Me 3D Music Player
Galaxy Navigator 3D - 2 million stars (ESA's Gaia satellite)
(YouTube|Facebook)
Galaxy Navigator 3D - 2 million stars (ESA's Gaia satellite)
(YouTube|Facebook)
Re: Render CEGUI to Ogre texture - a question
Hi, what you said is correct. However there is more code involved than you posted, see here:
http://cegui.org.uk/wiki/Rendering_to_a ... GUIContext
Also you can look into the SampleBrowser to see how we do it internally, successfuly, with Ogre.
Feel free to edit the article with any information that might be wrong/missing or generally helpful.
http://cegui.org.uk/wiki/Rendering_to_a ... GUIContext
Also you can look into the SampleBrowser to see how we do it internally, successfuly, with Ogre.
Feel free to edit the article with any information that might be wrong/missing or generally helpful.
CrazyEddie: "I don't like GUIs"
Who is online
Users browsing this forum: Bing [Bot] and 17 guests