Page 1 of 1

Showing boundaries on Cube Scene Node

Posted: Sun Mar 27, 2011 1:24 pm
by newbie8787
Is it possible to draw boundaries on the cubeSceneNode's I am using a chain of them to form a playing field and need one to be distinguished from the other.

Posted: Sun Mar 27, 2011 3:05 pm
by Acki
maybe show it's bounding box ??? ;)

Code: Select all

theCube->setDebugDataVisible(EDS_BBOX);

Boundig box : Doesnt show boundaries

Posted: Sun Mar 27, 2011 4:12 pm
by newbie8787
Thanks for the suggestion Acki :)
But the bounding box does not seem to have the effect I need. I need the whole cube, and all its edges to be outlined with black , the bounding box just kinda shows some squiggly white areas outside of the mesh.

Posted: Sun Mar 27, 2011 4:55 pm
by nespa

Code: Select all

void OutlineMesh(IAnimatedMeshSceneNode* mesh,float Width,unsigned int R,unsigned int G,unsigned int B)
	{
		SMaterial tmat[MATERIAL_MAX_TEXTURES],lmat;

		lmat.DiffuseColor = SColor(255,R,G,B);
		lmat.SpecularColor = SColor(255,R,G,B);
		lmat.AmbientColor = SColor(255,R,G,B);
		lmat.EmissiveColor = SColor(255,R,G,B);
		lmat.BackfaceCulling = false;
		lmat.FrontfaceCulling = true;
		lmat.Lighting = true;
		lmat.Thickness = Width;
		lmat.Wireframe = true;
		
		for(unsigned int i = 0;i<mesh->getMaterialCount();i++)
		{
			tmat[i] = mesh->getMaterial(i);
			mesh->getMaterial(i) = lmat;
		}

		mesh->render();

		for(unsigned int j = 0;j<mesh->getMaterialCount();j++)
			mesh->getMaterial(j) = tmat[j];
	}

Whoa !!

Posted: Sun Mar 27, 2011 4:58 pm
by newbie8787
Whoa !! That much just to get a simple boundary on a cube :P

Still , thanks a lot :) I'll try it out !

Posted: Sun Mar 27, 2011 7:27 pm
by nespa
take care, call the function inside the main loop before drawAll

Posted: Sun Mar 27, 2011 8:56 pm
by hybrid
You can use the OverrideMaterial to avoid copying all those materials. Also move the material definition to a place before the render loop. Then it's just a few calls.

Posted: Sun Mar 27, 2011 9:01 pm
by nespa
yes, is faster this way