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.
Render Individual SceneNode
Render Individual SceneNode
Dream Big Or Go Home.
Help Me Help You.
Help Me Help You.
Re: Render Individual SceneNode
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?
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?
Re: Render Individual SceneNode
After lots of trial and error here it is, complete render code, well mostly ;)
Big thanks to Foaly for telling me to render the camera. :P
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();
Dream Big Or Go Home.
Help Me Help You.
Help Me Help You.