Render Entity in Widget

Kukanani

15-10-2010 17:46:14

Hey, I'm trying to show a "preview window" of an Ogre Entity as a MyGUI widget. The widget isn't part of the 3D world, it's part of the interface, but I want to render an entity on it.

I've searched the forums and everything about RTTLayers and stuff is confusing me. Also there are like 10 different classes that seem to be related to render-to-texture. Where should I start?

Thanks

Altren

16-10-2010 03:32:36

Look at Demo_RenderBox, I guess this is what you need.
For one or several meshes there is wraps::RenderBoxScene class, that can be used next way:
wraps::RenderBoxScene gRenderBoxScene;

MyGUI::Canvas* canvas2 = window2->createWidget<MyGUI::Canvas>("Canvas", MyGUI::IntCoord(0, 0, window2->getClientCoord().width, window2->getClientCoord().height), MyGUI::Align::Stretch);

gRenderBoxScene.setCanvas(canvas2);
gRenderBoxScene.injectObject("Robot.mesh");

cafeole

05-11-2010 09:51:16

Hi, I have used the same code that you put and I get a runtime error in mygui_renderitem.cpp in line 96:

"MYGUI_EXCEPT("texture pointer is not valid, texture name '" << mTextureName << "'");".

It seems like mTexture pointer is not initialized correctly...how could I fix that??

Thanks!

Altren

05-11-2010 10:07:08

I guess my example is not clear. Actually gRenderBoxScene is global variable. Use next code if you don't like global variables:
Declaration: wraps::RenderBoxScene* renderBoxScene;
Initialisation: renderBoxScene = new wraps::RenderBoxScene();
MyGUI::Canvas* canvas2 = window2->createWidget<MyGUI::Canvas>("Canvas", MyGUI::IntCoord(0, 0, window2->getClientCoord().width, window2->getClientCoord().height), MyGUI::Align::Stretch);

renderBoxScene->setCanvas(canvas2);
renderBoxScene->injectObject("Robot.mesh");

Destruction: delete renderBoxScene;

cafeole

05-11-2010 10:43:31

You are so fast!! Thanks for the answer! it works!! :D