Sorting Polygons on CustomSceneNode

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
pwierz
Posts: 59
Joined: Sun Aug 20, 2006 3:32 pm

Sorting Polygons on CustomSceneNode

Post by pwierz »

I created my own custom scene node and it works properly but the problem with it is that it always draws the polygons in the same order and disregards the z-buffer. Is there a way I can fix this? Obviously I could just do an algorithm to sort per frame based on distance to the camera but my node can have several thousand polys and sorting every frame seems horribly inefficient. Is there a better way of handling this? Thanks for any help.
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Post by hybrid »

Well, sounds like your registration of the scene node is wrong, or the material setup. Maybe show the code for those two methods, or the whole scene node code.
What's the actual purpose on having a custom scene node btw?
pwierz
Posts: 59
Joined: Sun Aug 20, 2006 3:32 pm

Post by pwierz »

Thanks, hybrid. Here is where I set up the materials:

Code: Select all

	Material.Wireframe = false;
	Material.Lighting = false;   
	Material.MaterialType = video::EMT_TRANSPARENT_ALPHA_CHANNEL;

	setMaterialFlag(video::EMF_BILINEAR_FILTER,false);
	setMaterialFlag(video::EMF_ANISOTROPIC_FILTER,true);
	setMaterialFlag(video::EMF_ZBUFFER,true);
	setMaterialFlag(video::EMF_ZWRITE_ENABLE,true);
	setMaterialFlag(video::EMF_BACK_FACE_CULLING,true);

	AutomaticCullingState = scene::EAC_OFF;
And

Code: Select all

void CCustomNode::OnRegisterSceneNode()
{
	if (IsVisible)
		SceneManager->registerNodeForRendering(this);

	ISceneNode::OnRegisterSceneNode();
}
The reason I have a custom node is because I created a class that turns a point cloud into a surface, which none of the existing nodes could do for me.
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Post by hybrid »

You need to enable the scene paramater ZWRITE_ON_TRANSPARENT (or very near to this). As a default, all transparent materials have zwrite forcedly turned off. This is usually ok for transparent materials, because the blending will take care of overlaps.
pwierz
Posts: 59
Joined: Sun Aug 20, 2006 3:32 pm

Post by pwierz »

That was it. Thanks, hybrid.
Post Reply