# Order points to build mesh

Hello all,

How do you order 4 points counter-clockwise?

What is the referential since this only makes sense in 2D as if you turn around in 3D the points get inverted.

The method of finding the normal to the surface shouldn’t work for me in theory because according to this guy different triangles in a strip can get conflicting demands from different neighbors.

I get the feeling this is a very basic question that should be somewhere on the web but I can’t put my finger on it.

@kotoko said:
How do you order 4 points counter-clockwise?
What is the referential since this only makes sense in 2D as if you turn around in 3D the points get inverted.

You order 3 points, then you order the other 1 with some other 2 points. In the end all 4 points are now ordered.
For referential, I guess its the plane where all 4 points are.

@kotoko said:
The method of finding the normal to the surface shouldn't work for me in theory because according to this guy different triangles in a strip can get conflicting demands from different neighbors.

The normals are blended among all neighbors.
@Momoko_fan For referential, I guess its the plane where all 4 points are.

I can't guarantee that all 4 points will be in the same plane. In fact they probably won't.
Like if the points are: (3.5, 0.0, 3.5), (-3.5, 0.0, -3.5), (5.0, 1.0, 15.0), (5.0, 1.0, 5.0)

@Momoko_fan The normals are blended among all neighbors.

Sorry for the dumb question but what is going on to get that effect?
Just having 2 vertices in common achieves this? What about if you're drawing a Moebius strip?
@kotoko said:
I can't guarantee that all 4 points will be in the same plane. In fact they probably won't.
Like if the points are: (3.5, 0.0, 3.5), (-3.5, 0.0, -3.5), (5.0, 1.0, 15.0), (5.0, 1.0, 5.0)

Then you need some reference plane to project the points on. You cannot check it otherwise, it just doesn't make sense.

@kotoko said:
Sorry for the dumb question but what is going on to get that effect?
Just having 2 vertices in common achieves this? What about if you're drawing a Moebius strip?

You're the one who tells us what the normals are, this isn't our problem, its your problem.

All the stuff I’ve found is either very theoretical and I don’t understand how to apply it or very specific so I can’t translate to my problem.

I have looked at all the tutorials on meshes here, information on how to order in 2D and on how to make permutations.

Here’s info on how to create custom meshes:

The section about normals is fairly small, but the rest illustrates on how to create meshes with jME3. You should be able to apply your theoretical knowledge about normals by using that tutorial.

Yeah, I read that at least ten times, but I’m still not getting the whole ordering thing.

All the examples there are pretty basic, I still don’t see how do you pass from that to “take 3 arbitrary points and order them”

@kotoko said:
Yeah, I read that at least ten times, but I'm still not getting the whole ordering thing.
All the examples there are pretty basic, I still don't see how do you pass from that to "take 3 arbitrary points and order them"

I'm not even really sure what you are asking. How are you getting the points if they aren't already ordered.

Or do you mean you have three points and don't know whether they should be clockwise or counterclockwise? Or what "clockwise" or "counterclockwise" is relative to?

If you were to draw a triangle on a piece of paper. The corners should be ordered counterclockwise in OpenGL.... relative to your looking at it. There is no "back side" by default... so you won't even see it from the other side.

If you have a bunch of arbitrary points then it's a more difficult problem. You probably need to explain more about what you are trying to do in that case.
1 Like

I think I understand the question.

@kotoko: The thing that’s confusing you is also the thing that is the key to understanding it.

You are absolutely right. The points are only clockwise/anticlockwise from a certain direction. That is exactly what the ordering is used for. If the points in a triangle run clockwise on the screen then you are looking at the back of the triangle. If they run anticlockwise you are looking at the front of the triangle.

It’s a simple as that.

By default (this can be changed) openGL only draws the front of a triangle, so you build a mesh out of outward-facing triangles by putting the vertex indices in the correct order so that when viewed from outside the object you see the face. This saves a lot of un-needed rendering of faces that are pointing away from the screen and (usually) hidden behind the other side of the object.

1 Like

What I have is a 4 arbitrary points, at least I can’t extract any useful information from the preconditions.

What I know about the points is:

• they are 2 pairs of points equidistant to a central point. Example, I get point A(0,0,0) and B(5, 1, 10); the points will be one pair (wing points) the point to the right and to the left of (0, 0, 0) - considering the line AB, the wing points are in a line normal to AB. I have a nice pic to show you but the upload things is overcapacity.

I do not know what plane should I use to “draw them in a piece of paper” since I can look at them from every angle.

I hope I don’t need to calculate every time I move.

I know I should order them counterclockwise from where I see them.
@zarch If the points in a triangle run clockwise on the screen then you are looking at the back of the triangle. If they run anticlockwise you are looking at the front of the triangle.

From this it sounds to me as if there is some kind of universal reference that can be used to check if they are clockwise or counter clock wise.
Is this the view point?
If so, does this mean I need to re-check my ordering every time the camera moves?
@kotoko said:
From this it sounds to me as if there is some kind of universal reference that can be used to check if they are clockwise or counter clock wise.
Is this the view point?
If so, does this mean I need to re-check my ordering every time the camera moves?

No, the reference point is the other points.

If you have three points then there are only two ways to order them. One way makes the face point one way the other makes the face point the other way.
1 Like

You don’t check your ordering. The rendering (graphics card) does…

Imagine a cube, made of 6 faces, each face is 2 triangles - so you have 12 triangles.

1 2

3 4

That’s one side of the cube. The triangles are 1,2,3 and 2,4,3.

Now if you are looking at the square the way its drawn in this post you can see that 1,2,3 go around clockwise - that means we are looking at the back of the triangle. On the other hand if I had done it as 1,3,2 then we would be looking at the front of the triangle.

OpenGL will draw the front but not the back - since there is no point drawing the inside of the cube.

If you want both sides you can either turn off rear face culling or you can define the triangle twice - once in each direction.

1 Like

I think I’m starting to get it…

Ok, so the thing I need to do is to draw it counter clockwise using one of the normal vectors as reference.

(right?)

I’ll try from the 3 points:

• get the plane equation
• compute the normal opposite to the origin of the coordinate axis
• draw counter clockwise from that

“normal opposite to the origin of the coordinate axis”?

What does that mean, exactly?

Are you trying to surface a point cloud or something?