If you're determined to do this, then you could:
Move your calls to render()
after smgr->drawAll(); and it will work, after a fashion. However, if you're rendering an opaque object, it will crap all over any translucent nodes since it's rendered out of order.
Alternatively, create a custom scene node type that encapsulates whatever node you want to render, and render the node multiple times in the desired render pass.
Code: Select all
#include <irrlicht.h>
#include <assert.h>
#pragma comment(lib, "Irrlicht.lib")
using namespace irr;
using namespace core;
using namespace scene;
using namespace video;
using namespace io;
using namespace gui;
struct NodeInstancer : public ISceneNode
{
NodeInstancer(ISceneNode * parent, ISceneManager * smgr,
IAnimatedMeshSceneNode * meshNode, E_SCENE_NODE_RENDER_PASS renderPass)
: ISceneNode(parent, smgr)
{
MyNode = meshNode;
MyNode->grab();
RenderPass = renderPass;
}
~NodeInstancer()
{
MyNode->drop();
}
const core::aabbox3d<f32>& getBoundingBox() const { return MyNode->getBoundingBox(); }
void OnRegisterSceneNode()
{
SceneManager->registerNodeForRendering(this, RenderPass);
ISceneNode::OnRegisterSceneNode();
}
void render()
{
for(f32 x = -50.f; x <= 50.f; x += 50.f)
{
MyNode->setPosition(vector3df(x, 0, 0));
MyNode->updateAbsolutePosition();
MyNode->render();
}
}
IAnimatedMeshSceneNode * MyNode;
E_SCENE_NODE_RENDER_PASS RenderPass;
};
int main()
{
IrrlichtDevice *device =
createDevice( video::EDT_OPENGL, dimension2d<s32>(640, 480), 16,
false, false, false, 0);
IVideoDriver* driver = device->getVideoDriver();
ISceneManager* smgr = device->getSceneManager();
IAnimatedMeshSceneNode* dwarf = smgr->addAnimatedMeshSceneNode(smgr->getMesh("../../media/dwarf.x"));
NodeInstancer myNode(smgr->getRootSceneNode(), smgr, dwarf, ESNRP_SOLID);
dwarf->remove();
smgr->addCameraSceneNode(0, vector3df(0, 40, -80));
while(device->run())
{
driver->beginScene(true, true, SColor(255,100,101,140));
smgr->drawAll();
driver->endScene();
}
device->drop();
return 0;
}