Draw whole scene with wireframe overlay

If you are a new Irrlicht Engine user, and have a newbie-question, this is the forum for you. You may also post general programming questions here.
Post Reply
Isometric God
Posts: 69
Joined: Sun Oct 12, 2003 3:42 pm
Location: Germany

Draw whole scene with wireframe overlay

Post by Isometric God »

Is it possible to draw the whole scene with a wireframe overlay without duplicating every single scenenode with material set to wireframe?
thanks
bearSoft
Posts: 165
Joined: Fri Apr 01, 2005 9:55 pm
Location: Denmark

Post by bearSoft »

hmm try to make a general parent for all and do it that way?? -Would serius doubt any other way is posible
Regards.
Tech: win98se| 320mb ram| abitbe6| 433mhzceleron| atiRadeon7000.64mb| soundblaster125| dx9.0b | devCPP | IRR 0.12.0 |
Alien

Post by Alien »

I haven't tried this...but i do know u can render the scene manager more than once. Loop through all nodes and turn their materials to wireframe, and then call the render function. The only problem is, this is effectively creating 2 scenes and putting them together so instead of having one scene 'overlay' the other...the two become part of each other, and the 3d objects overlay in 3d space...so the result is the wireframe can be hidden both other things in the foreground ( often a desired effect ). You can of course fix this by using the setmaterialflag command and turning off the zbuffer for the materials...just remember to turn the option back on afterwards.
sdi2000
Posts: 129
Joined: Thu Aug 25, 2005 12:19 pm
Location: Berlin, DE
Contact:

Post by sdi2000 »

hmm like cell shading...

a way to draw outlines is to hold your nodes in a container
or they names or any identifier to get a scene node
and switch all them to wired or not before u call the draw() function

Code: Select all

//i assume u use an array with scene nodes
switchToWired(bool _wired)
{
   size_t idx;
   for(idx=0; idx < array.size(); ++idx)
   {
      ISceneNode *l_node = (ISceneNode *)array[idx];
      l_node->setMaterialFlag(video:EMF_WIREFRAME, _wired);
   }
}

loopCall()
{
   driver->beginScene(true, true, video::SColor(255,0,0,255));
   manager->draw();
   switchToWired(true);
   manager->draw();
   driver->endScene();
   switchToWired(false);
}
or code a shader :D
but there i cant help :shock:
Isometric God
Posts: 69
Joined: Sun Oct 12, 2003 3:42 pm
Location: Germany

Post by Isometric God »

that sounds reasonable. thanks !
sdi2000
Posts: 129
Joined: Thu Aug 25, 2005 12:19 pm
Location: Berlin, DE
Contact:

Post by sdi2000 »

oups
dont forget to scale the wired scenenode a little bit bigger,
otherwise you could not see the wire :D
vitek
Bug Slayer
Posts: 3919
Joined: Mon Jan 16, 2006 10:52 am
Location: Corvallis, OR

Post by vitek »

If you want the entire scene to be rendered wireframe, it seems wasteful [and error prone] to hold a copy of all node pointers. You could easily traverse the scene graph enabling/disabling wireframe...

Code: Select all

void enableWireframeMode(bool enable, scene::ISceneNode* node, bool recurse)
{
   node->setMaterialFlag(video::EMF_WIREFRAME, enable);

   if (recurse)
   {
      core::list<scene::ISceneNode*>::Iterator head = node->getChildren().begin();
      core::list<scene::ISceneNode*>::Iterator tail = node->getChildren().end();

      for (; head != tail; ++head)
         enableWireframeMode(enable, (*head), true);
   }
}

void enableWireframeMode(scene::ISceneManager* scene, bool enable)
{
   enableWireframeMode(enable, scene->getRootSceneNode(), true);
}
But at that point, maybe it is better to just add an override flag to the video driver...

Code: Select all

// declare new interface in IVideoDriver.h
virtual void enableOverrideWire(bool enable) = 0;

//! implement in each driver
void COpenGLDriver::enableOverrideWire(bool enable)
{
   OverrideWireframeEnabled = enable;
}

// use override flag in derived drivers
void COpenGLDriver::setMaterial(const SMaterial& material)
{
   Material = material;

   if (OverrideWireframeEnabled)
      Material.Wireframe = true;

   setTexture(0, Material.Texture1);
   setTexture(1, Material.Texture2);
}
sdi2000
Posts: 129
Joined: Thu Aug 25, 2005 12:19 pm
Location: Berlin, DE
Contact:

Post by sdi2000 »

hey vitek whats up...
for the second solution im not with u because if we change the source of irrlicht we must rebuild the engine. and i think a wireframe mode is not necessary/important for everyone so let it as flag

remember your words:
Again, as I mentioned in another topic post, my solution does the same thing as yours. The advantages are that it does not require rebuilding the library, and it makes it possible for the user to change the rotation on the fly.
:D

and to the first solution
linear access against recursion
whats the better solution a reference to all nodes to access there linear or a recursion with a slow app stack? ...
time is money or a frame =)
for 10 nodes no prob, but for 1000

i think many people holds an extra array with infos/properties about there nodes (id´s or names or what ever) why not a reference to the scenenode ?

now i shut up thats better for me :D
vitek
Bug Slayer
Posts: 3919
Joined: Mon Jan 16, 2006 10:52 am
Location: Corvallis, OR

Post by vitek »

Yeah, I agree. I don't like changing the engine either. Unfortunately I found a few bugs and ended up making changes against my will. :) If you are going to be turning wireframe on/off every render, then it is a bad idea to be iterating through a deep tree to toggle the flag. I don't imagine that the scene graphs are extremely deep. If they are not there would be little recursion and just iterating over the scene node lists.

My thought was that it would be used for debugging purposes only and you would only want to render with wireframe on or off for all nodes [press F12 to toggle wireframe mode].

Travis
Post Reply