[Solved] 1) 3D lines 2) About meshes

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
Piter
Posts: 11
Joined: Thu Dec 05, 2013 12:13 am

[Solved] 1) 3D lines 2) About meshes

Post by Piter »

Hello all,

I have a couple of problems:

1) 3D lines don't seem to be drawn properly. At the beginning they are, but when I move the camera their positions aren't correct. I think it's not something I've done wrong, because the positions where the lines should be drawn in are static.

2) I have a problem with meshes. I need to have a lot of small meshes for a map, but the perfomance is really poor. I've taken a look to the MeshCombiner, but I can't use it for my project. Therefore, the question is: can I have multiple meshes with the same mesh data (so the perfomance is good)? If so, if I wanted to change the color of a node, could I do the following?

Code: Select all

smgr->getMeshManipulator()->setVertexColors(...)
I've tried using that, but every node gets painted, not only the one I specified.

Thank you for any help you can provide.
Last edited by Piter on Fri Dec 20, 2013 11:06 pm, edited 1 time in total.
CuteAlien
Admin
Posts: 9734
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Re: 1) 3D lines 2) About meshes

Post by CuteAlien »

1. Do you reset the transformation before you start to draw? (See: http://irrlicht.sourceforge.net/docu/cl ... 3a4eebb5e6)
2. Scenenodes can share the mesh and overwrite materials. But vertex-colors are part of the mesh - so if you want to modify those you have to copy the mesh. At least when using the fixed function pipeline. Depending on what exactly you try to do you might be able to use shaders instead and change certain colors from there.
IRC: #irrlicht on irc.libera.chat
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
jiangcaiyang
Posts: 9
Joined: Tue Nov 12, 2013 3:24 pm

Re: 1) 3D lines 2) About meshes

Post by jiangcaiyang »

The first question seems like what I posted in another thread:
http://irrlicht.sourceforge.net/forum/v ... =4&t=49330
I've resolved in this way: the problem is when drawing 3D line as a scene node, you probably forget to set material, or set material count to zero. This is not the correct behaviour, the result is somthing that z-order get messed up. So let getMaterialCount() method returns 1 and getMaterial() method returns a dummy material.
Piter
Posts: 11
Joined: Thu Dec 05, 2013 12:13 am

Re: 1) 3D lines 2) About meshes

Post by Piter »

CuteAlien wrote:1. Do you reset the transformation before you start to draw? (See: http://irrlicht.sourceforge.net/docu/cl ... 3a4eebb5e6)
That was exactly what I was missing. Many thanks. Thank you jiangcaiyang too for your response.
CuteAlien wrote:2. Scenenodes can share the mesh and overwrite materials.
Could you explain how can two nodes share a mesh?
CuteAlien
Admin
Posts: 9734
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Re: 1) 3D lines 2) About meshes

Post by CuteAlien »

SceneNodes share the mesh by default when they are using the same one (you pass it as a parameter when creating scenenodes).
IRC: #irrlicht on irc.libera.chat
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
Piter
Posts: 11
Joined: Thu Dec 05, 2013 12:13 am

Re: 1) 3D lines 2) About meshes

Post by Piter »

If when I painted the mesh of a node, all of them got painted, then that means they were sharing the mesh, right? In that case, I don't know why I am getting bad FPS (like 10-16) with a 14*10 map. In the future, it should be something like 1000*1000 or even bigger. Isn't Irrlicht using some kind of clipping/culling automatically? I really need a fix for this.
CuteAlien
Admin
Posts: 9734
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Re: 1) 3D lines 2) About meshes

Post by CuteAlien »

You can use clipping, but if it's a static mesh then the better optimization is making the mesh static (http://irrlicht.sourceforge.net/docu/cl ... 8599043dfe).
And if you have lots of nodes it will certainly get slower. Depends certainly also on the polygon numbers. One way to optimize is to merge meshes into a single mesh. CMeshCombiner and CBatchingMesh from here are good for something like that for example: http://sourceforge.net/p/irrext/code/HE ... ene/IMesh/
IRC: #irrlicht on irc.libera.chat
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
hendu
Posts: 2600
Joined: Sat Dec 18, 2010 12:53 pm

Re: 1) 3D lines 2) About meshes

Post by hendu »

Another minecraft clone? 1 million draw calls is simply not possible, you will need to batch in some way. One node = at least one draw call, even if mesh data is shared.

Sharing the mesh data only saves memory.
Piter
Posts: 11
Joined: Thu Dec 05, 2013 12:13 am

Re: 1) 3D lines 2) About meshes

Post by Piter »

It's not a minecraft clone, but the maps are made of cubes.
Thanks for the provided solutions, I really appreciate your help. I didn't want to use external tools, but now I'll consider it.
kklouzal
Posts: 343
Joined: Sun Mar 28, 2010 8:14 pm
Location: USA - Arizona

Re: 1) 3D lines 2) About meshes

Post by kklouzal »

Dream Big Or Go Home.
Help Me Help You.
Piter
Posts: 11
Joined: Thu Dec 05, 2013 12:13 am

Re: 1) 3D lines 2) About meshes

Post by Piter »

Thanks for your input, kklouzal.

By the way, I've found this thread (http://irrlicht.sourceforge.net/forum/v ... hp?t=42065) and the user seemed to find a way to do it. But I can't figure out the code he could have written. Any idea is welcome...
mongoose7
Posts: 1227
Joined: Wed Apr 06, 2011 12:13 pm

Re: 1) 3D lines 2) About meshes

Post by mongoose7 »

He said he removes inner vertices and uses one draw call. The code would write itself.
Piter
Posts: 11
Joined: Thu Dec 05, 2013 12:13 am

Re: 1) 3D lines 2) About meshes

Post by Piter »

I've ended up using the CMeshCombiner, which works really really well. Congratulations to the author.

And thank you all. Problems solved :)
Post Reply