Page 1 of 1

Draw whole scene with wireframe overlay

Posted: Tue Feb 28, 2006 6:23 pm
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

Posted: Wed Mar 01, 2006 11:14 am
by bearSoft
hmm try to make a general parent for all and do it that way?? -Would serius doubt any other way is posible

Posted: Wed Mar 01, 2006 3:45 pm
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.

Posted: Wed Mar 01, 2006 4:15 pm
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:

Posted: Wed Mar 01, 2006 4:27 pm
by Isometric God
that sounds reasonable. thanks !

Posted: Wed Mar 01, 2006 6:06 pm
by sdi2000
oups
dont forget to scale the wired scenenode a little bit bigger,
otherwise you could not see the wire :D

Posted: Wed Mar 01, 2006 6:08 pm
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);
}

Posted: Thu Mar 02, 2006 8:00 am
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

Posted: Thu Mar 02, 2006 8:49 am
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