Render Individual SceneNode

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
kklouzal
Posts: 343
Joined: Sun Mar 28, 2010 8:14 pm
Location: USA - Arizona

Render Individual SceneNode

Post by kklouzal »

I need to render an individual scene node so it can be rendered-to-texture. I've been searching through the forums and can't figure it out.
Basically what I've learned is, you need to hide all scene nodes but the one you want to render then call drawAll() but I can't find a way to actually get an array of all scene nodes. I would rather not have to loop through each node, hide them, drawAll(), loop again, then unhide. There must be a way to just individually render a node without all this fuss?

I actually have no need to even use a scene node here if I could just draw an IMesh.
Dream Big Or Go Home.
Help Me Help You.
Foaly
Posts: 142
Joined: Tue Apr 15, 2014 8:45 am
Location: Germany

Re: Render Individual SceneNode

Post by Foaly »

You can always render your nodes or meshes using the video driver or simply calling render() on a scene node.
But you have to take care of the lights and the camera. To set the camera's projection matrix, you can call render() on the camera node before rendering you stuff.

Just try it?
kklouzal
Posts: 343
Joined: Sun Mar 28, 2010 8:14 pm
Location: USA - Arizona

Re: Render Individual SceneNode

Post by kklouzal »

After lots of trial and error here it is, complete render code, well mostly ;)

Code: Select all

                m_Driver->beginScene();
                //  Set Render-Target
                m_Driver->setRenderTarget(RTT, true, true, irr::video::SColor(0, 0, 0, 0));
 
                //  Get the mesh and draw it
                irr::scene::IMesh* ModelMesh = m_SceneManager->getMesh(ModelPath.c_str());
                ModelMesh->setMaterialFlag(irr::video::EMF_LIGHTING, false);
                const irr::core::vector3df Extent = ModelMesh->getBoundingBox().getExtent();
 
                ActiveCamera->render();
                irr::core::matrix4 Transformation;
                Transformation.setTranslation(irr::core::vector3df(Extent.X, 0, Extent.Z));
                Transformation.setRotationDegrees(irr::core::vector3df(-33, 17, 0));
                m_Driver->setTransform(irr::video::ETS_WORLD, Transformation);
                const irr::u32 mb_Count = ModelMesh->getMeshBufferCount();
                for (irr::u32 i = 0; i < mb_Count; i++)
                {
                    m_Driver->setMaterial(ModelMesh->getMeshBuffer(i)->getMaterial());
                    m_Driver->drawMeshBuffer(ModelMesh->getMeshBuffer(i));
                }
 
                //  Reset Render-Target
                m_Driver->setRenderTarget(NULL, false, false);
                m_Driver->endScene();
Big thanks to Foaly for telling me to render the camera. :P
Dream Big Or Go Home.
Help Me Help You.
Post Reply