getVertexCount() Is Not Returning the amount of vertexes

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
trollger
Posts: 84
Joined: Tue Jun 01, 2010 2:17 am
Location: At my computer

getVertexCount() Is Not Returning the amount of vertexes

Post by trollger »

I have tried to get the amount of vertexes in a mesh but I am having a problem with it. This is the code that I am using:

Code: Select all

 std::cout << "The Mesh Has: " << CUBE->getMesh()->getMeshBuffer(0)->getVertexCount() << " Vertices";
I have a cube and obviously a cube has 8 vertexes but this function keeps returning 12 :shock:

I'm stumped.
Radikalizm
Posts: 1215
Joined: Tue Jan 09, 2007 7:03 pm
Location: Leuven, Belgium

Re: getVertexCount() Is Not Returning the amount of vertexes

Post by Radikalizm »

A cube doesn't necessarily have to have 8 vertices; to be able to do correct UVW-mapping for the cube it needs 12 vertices, otherwise not all faces would display their textures correctly ;)
trollger
Posts: 84
Joined: Tue Jun 01, 2010 2:17 am
Location: At my computer

Re: getVertexCount() Is Not Returning the amount of vertexes

Post by trollger »

hmm... Thats Interesting. So How Would I count the vertexes so as to arrive at 8?
Radikalizm
Posts: 1215
Joined: Tue Jan 09, 2007 7:03 pm
Location: Leuven, Belgium

Re: getVertexCount() Is Not Returning the amount of vertexes

Post by Radikalizm »

trollger wrote:hmm... Thats Interesting. So How Would I count the vertexes so as to arrive at 8?
You could always create a mesh scenenode which holds a cube with only 8 vertices (you'd need to write an implementation to generate such a cube yourself, but this isn't hard) as long as you keep in mind that your textures won't display correctly

Otherwise there's no way around the fact that your vertex count will be higher than 8
HerrAlmanack
Posts: 52
Joined: Mon Jun 13, 2011 3:50 pm

Re: getVertexCount() Is Not Returning the amount of vertexes

Post by HerrAlmanack »

trollger wrote:hmm... Thats Interesting. So How Would I count the vertexes so as to arrive at 8?

I suggest you read up on some general 3d graphics tutorials. you need to understand the concepts of unwrapped vertices, their normals, etc etc. it's not a simple matter of the "apparent" number of vertices.
Radikalizm
Posts: 1215
Joined: Tue Jan 09, 2007 7:03 pm
Location: Leuven, Belgium

Re: getVertexCount() Is Not Returning the amount of vertexes

Post by Radikalizm »

HerrAlmanack wrote:I suggest you read up on some general 3d graphics tutorials. you need to understand the concepts of unwrapped vertices, their normals, etc etc. it's not a simple matter of the "apparent" number of vertices.
I can understand his confusion about the subject, in computer graphics the word vertex has a slightly different meaning than in standard geometry

In geometry a vertex is just a point which represents a corner or intersection of geometric shapes, this means that 2 vertices should never be in the same location since this would make absolutely no sense
In CG a vertex is an element which describes certain properties of a mesh at a certain position, and since a single point can have multiples of the same property (like UV-coordinates), 2 vertices can be placed at the same position
trollger
Posts: 84
Joined: Tue Jun 01, 2010 2:17 am
Location: At my computer

Re: getVertexCount() Is Not Returning the amount of vertexes

Post by trollger »

HerrAlmanack wrote:
trollger wrote:hmm... Thats Interesting. So How Would I count the vertexes so as to arrive at 8?

I suggest you read up on some general 3d graphics tutorials. you need to understand the concepts of unwrapped vertices, their normals, etc etc. it's not a simple matter of the "apparent" number of vertices.

I Would be willing to do some reading on the subject if you have any suggestions.

By the way I have used blender a lot and I have unwrapped UV coordinates but the idea of 2 (or more) vertexes in one position is new to me.
HerrAlmanack
Posts: 52
Joined: Mon Jun 13, 2011 3:50 pm

Re: getVertexCount() Is Not Returning the amount of vertexes

Post by HerrAlmanack »

blender sets more than one vertex per position when unwrapping, it's just that blender makes it more user friendly by providing a nice graphical interface; it does all the back-end stuff for you.

btw I use blender too :) I started out with game programming with python and the blender game engine.
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Re: getVertexCount() Is Not Returning the amount of vertexes

Post by hybrid »

If your question in your first reply was how to find the really distinct vertices, you have to go through all vertices and sort out those which are quite close to each other. Definition of 'quite close' is up to you, and can differ from mesh to mesh. That's the only thing you can do. If you can lend Irrlicht some memory temporarily, you can also create a mesh with distinct vertices with the geometry manipulator. Calling getVertexCount would result in the correct number then.
Post Reply