[solved]How to manual rendering without drawAll.

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
moriwo
Posts: 40
Joined: Fri Jul 04, 2008 9:29 pm

[solved]How to manual rendering without drawAll.

Post by moriwo »

I try this code.
but, the node was not rendering.

Is it possible?

Code: Select all


	IAnimatedMesh* mesh = Scene->getMesh("test.x");
	IAnimatedMeshSceneNode* node = Scene->addAnimatedMeshSceneNode(mesh);


	stringw str;
	while(Device->run()) 
	{  
		Driver->beginScene(true, true, SColor(0,0,100,100)); 
	
		node->render();
	//	Scene->drawAll();

		Driver->endScene();
	} 
Last edited by moriwo on Sat Aug 30, 2008 2:25 am, edited 1 time in total.
rogerborg
Admin
Posts: 3590
Joined: Mon Oct 09, 2006 9:36 am
Location: Scotland - gonnae no slag aff mah Engleesh
Contact:

Post by rogerborg »

drawAll() does a lot more than just calling render() on your animated mesh scene nodes.

In your case, this is probably the minimum that you can get away with doing:

Code: Select all

    while(device->run())
    {
        driver->beginScene(true, true, SColor(255,100,101,140));

        smgr->getActiveCamera()->OnRegisterSceneNode();

        node->OnAnimate(device->getTimer()->getTime());

        smgr->getActiveCamera()->render();
        node->render();

        driver->endScene();
    }
If you have further questions, then I suggest that you look at CSceneManager::drawAll() to see what it's doing.
Please upload candidate patches to the tracker.
Need help now? IRC to #irrlicht on irc.freenode.net
How To Ask Questions The Smart Way
moriwo
Posts: 40
Joined: Fri Jul 04, 2008 9:29 pm

Post by moriwo »

thanks rogerborg.

I succeeded the rendering by your code in case of solid node.

but, rendering was not done for the transparency node.

Code: Select all

IAnimatedMesh* mesh = Scene->getMesh("shadow_alp.x");
IAnimatedMeshSceneNode* node = Scene->addAnimatedMeshSceneNode(mesh);
node->setMaterialType(EMT_TRANSPARENT_ALPHA_CHANNEL);
node->getMaterial(0).MaterialTypeParam = 0.01f;
I read the drawAll function of CSceneManager.cpp.
but, I do not understand what mistake I am doing.
Can I ask your advice on something?
JP
Posts: 4526
Joined: Tue Sep 13, 2005 2:56 pm
Location: UK
Contact:

Post by JP »

I would imagine it would work the same whether the node is transparent or solid...

Within the smgr there are 2 lists (at least). One for solid objects and one for transparent ones. The solid objects are rendered first in an arbitrary order as the order doesn't matter but the transparent objects must be rendered back to front (i.e. farthest from camera first) in order to get the correct alpha blending.

But that shouldn't affect you if you're rendering a node manually...

Incidentally why do you not want to use smgr->drawAll()?
Image Image Image
rogerborg
Admin
Posts: 3590
Joined: Mon Oct 09, 2006 9:36 am
Location: Scotland - gonnae no slag aff mah Engleesh
Contact:

Post by rogerborg »

moriwo wrote:thanks rogerborg.

I succeeded the rendering by your code in case of solid node.

but, rendering was not done for the transparency node.

Code: Select all

void CAnimatedMeshSceneNode::render()
{
	video::IVideoDriver* driver = SceneManager->getVideoDriver();

	if (!Mesh || !driver)
		return;

	bool isTransparentPass =
		SceneManager->getSceneNodeRenderPass() == scene::ESNRP_TRANSPARENT;

//... and only render transparent materials during the transparent render pass
However, there's no public method to set the scene manager's render pass, so the test never passes, and mesh buffers with transparent materials don't get rendered.

I don't see a solution to that other than modifying Irrlicht and recompiling. Trivially, you could just add an ISceneManager::setSceneNodeRenderPass() method, and tell the scene manager that it's in the ESNRP_TRANSPARENT pass before calling your node's render() method.

Is this really a route you want to take? I'd echo JP's question about what requirement has led you to do the rendering yourself.
Please upload candidate patches to the tracker.
Need help now? IRC to #irrlicht on irc.freenode.net
How To Ask Questions The Smart Way
moriwo
Posts: 40
Joined: Fri Jul 04, 2008 9:29 pm

Post by moriwo »

thanks guys.

Please look at this post about the reason why I do the manual rendering.
http://irrlicht.sourceforge.net/phpBB2/ ... hp?t=30021

I know a transparent node is sorted by the distance from the camera.

but, the function seems to have trouble. just like my former post.

Therefore, I should render the node of ground first.(manually)
Or, I should render the node of the shadow end.

It is a reason why I do the manual rendering.

(Please teach me if you have good ideas other than manual rendering.)
dlangdev
Posts: 1324
Joined: Tue Aug 07, 2007 7:28 pm
Location: Beaverton OR
Contact:

Post by dlangdev »

I think if you get the transparent materials spread out to its own material, it would get automatically sorted. That's what I did in one my of my test program.

But your case could be unique, though.
Image
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Post by hybrid »

Another solution could be to duplicate the node, put it into a second scene manager, and disable the solid (resp. transparent) meshbuffers. It might already work with one scene manager, but you cannot change the order among the same type of materials.
BlindSide
Admin
Posts: 2821
Joined: Thu Dec 08, 2005 9:09 am
Location: NZ!

Post by BlindSide »

For transparent scene nodes (static mesh),

Code: Select all

driver->setTransform(ETS_WORLD, node->getAbsoluteTransformation());

for(u32 i = 0;i < node->getMesh()->getMesh(0)->getMeshBufferCount();++i)
{
    driver->setMaterial(node->getMaterial(i));
    driver->drawMeshBuffer(node->getMesh()->getMesh(0)->getMeshBuffer(i));
}
works for me.
ShadowMapping for Irrlicht!: Get it here
Need help? Come on the IRC!: #irrlicht on irc://irc.freenode.net
moriwo
Posts: 40
Joined: Fri Jul 04, 2008 9:29 pm

Post by moriwo »

I solved problem by adding the setSceneNodeRenderPass function.

It seems enough for now.

Thank you for teaching some methods.

thanks all.
Post Reply