What do I need to display customSceneNode with texture?

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
Malgodur
Posts: 195
Joined: Sun Mar 15, 2009 8:22 pm

What do I need to display customSceneNode with texture?

Post by Malgodur »

Im trying to display TEXTURED custom mesh... but its black, either lighting is disabled or enabled. And i got one light in my scene with radius 1000 when its on 0,0,50 and mesh is at 0,0,0. Can somebody tell me what I missed? Texture's loaded properly, i chek'd in log.

Code: Select all

	Material.Lighting = false;
	Material.MaterialType= video::E_MATERIAL_TYPE::EMT_SOLID;
	Material.setTexture(0,driver->getTexture(name));

Code: Select all

	driver->setMaterial(Material);
	driver->drawIndexedTriangleList(Vertices[0], Vertices.size(), &indices[0],triangles);
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Post by hybrid »

Probably wrong normals. Lighting calculation depends on it. And of course missing texture coords as well.
Or winding order, since you're using cutsom render methods. Why not just create a mesh from your vertices and add it to a scene node?
Malgodur
Posts: 195
Joined: Sun Mar 15, 2009 8:22 pm

Post by Malgodur »

I cannot just load mesh, im working on my own scene node.
Well, I checked everything again, and im almost sure that the textures coords, normals, and textures are loaded properly.

Can you help me get it to work without lighting?


EDIT: Now I found out really strange thing!! I made lil test with vertex colors (still without lighting).
First I seted color of each vertex to blue and commented the "setTexture" line. Mesh was blue.
Then I uncommented the "setTexture" line. And mesh appeared textured?! However still blue'ed... so I setted each of colors of each vertex to 100... and it fixed it!! So now everything works, but idk why...
Last edited by Malgodur on Sat Jun 13, 2009 4:47 pm, edited 1 time in total.
sudi
Posts: 1686
Joined: Fri Aug 26, 2005 8:38 pm

Post by sudi »

Malgodur wrote:I cannot just load mesh, im working on my own scene node.
Why can't u just load a mesh?
The scenenode is only there to place the mesh animate and call the render method. Drawing itsef is done by IVideoDriver.
You can for example draw meshbuffers with IVideoDriver::drawMeshBuffer (const scene::IMeshBuffer *mb).
We're programmers. Programmers are, in their hearts, architects, and the first thing they want to do when they get to a site is to bulldoze the place flat and build something grand. We're not excited by renovation:tinkering,improving,planting flower beds.
Malgodur
Posts: 195
Joined: Sun Mar 15, 2009 8:22 pm

Post by Malgodur »

I cant just load a mesh because I need to have acces to vertices/indices every frame.
Sylence
Posts: 725
Joined: Sat Mar 03, 2007 9:01 pm
Location: Germany
Contact:

Post by Sylence »

So what?
You can load the mesh and then access the indices and vertices through the mesh buffers of the mesh. Where is the problem ?
Software documentation is like sex. If it's good you want more. If it's bad it's better than nothing.
Malgodur
Posts: 195
Joined: Sun Mar 15, 2009 8:22 pm

Post by Malgodur »

Oh yes, but its even easier to operate with them inside custom scene node class.

EDIT: Now my model works with lighting! I still dont know why, why I had to set all three colors to 255 to let it works...
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Post by hybrid »

vertx color is modulated with the texture color. You should always start with full bright vertex colors.
Post Reply