Generated mesh is flipped in the z:

I am storing vector2 pts and creating a mesh. When it is rendered, it is flipped in the z.

I have tried reversing the list of vertices and using a stack, but get the same flipping. If I use the list I have to reverse it before sticking it into an arry. If I use a stack I don’t have to reverse it. If I draw the verts counter clockwise i get that CCW error. If I draw it CW…it works but it is flipped.

Any ideas?

You get what now?

Lol.

I gotta be honest, I’m not following that either. Just to be clear, Vector2 has x,y and no z, but I’ll just assume you meant to type Vector3.

But as for “ccw error” I have no idea what that means. Unity is left-hand-rule so that means wind verts clockwise to have the normal point towards you. If you go counter-clockwise, there is no error, it just faces the other way, away from you.

Try and simplify your situation, get it down to as few verts and faces that show the issue as you can, then you can display them and reason about them.

To help gain even more insight into your problem, I recommend liberally sprinkling Debug.Log() statements through your code to display information in realtime.

Doing this should help you answer these types of questions:

  • is this code even running? which parts are running? how often does it run?
  • what are the values of the variables involved? Are they initialized?

Knowing this information will help you reason about the behavior you are seeing.

1 Like

It’s the error you get when the mesh is generated and the vertices are being read counter clock wise but they’re in the array clock wise.

No it is a Vector2. I am storing the vertices (pts) in a list as a vector2 then converting it to a vector3 array to then generate the mesh.

When the mesh is rendered/generated it is like the scale is at -1 in the z. like a mirrored version or what it should be.

But I think i know what the issue is. i have to get the centroid of the mesh and make sure it is generated at that pt.

I hope.

You could always negate one of the axes… this necessarily means you would wind the triangles in the opposite way numerically, but still clockwise to see them.

The mesh is rendering properly, it’s just not positioned accurately. It has an offset because of the flip/mirror.

This…

6882974--804170--meshflip.jpg

I changed its local scale to (1, 1, -1) before rendering it and it is fixed…but that seems like a hack.

I have never seen an error from vertices being read counterclockwise and I’ve done a fair amount of mesh generation code. If you wind triangles one way you get correct results, if you wind them the other way, they’re back facing and simply invisible. There’s no error either way.

If you can post your code and paste the actual error you’re getting we might be able to give you more specific advice. We don’t have nearly enough information about what you’re trying to do to be able to be helpful.

6883025--804176--error.jpg

That’s the error.

I can’t show you the code…to much NDA stuff in it.

There are no google results for that exception, so whatever it is, it’s probably being generated from within your own project’s proprietary code. Whatever mesh-generation code you’re using, it’s nothing that any of us are going to be able to help with. I recommend getting in touch with whoever gave you that code and asking them to help you, they’re probably the only one you can. All we can recommend is to use more standard methods like accessing the Mesh API directly.

1 Like

You’re right…But he’s MIA.

My verticesOrder function must not be working. It works of course if you draw it clock wise…but throws this if CCW. And the function to check isn’t catching it…/

That is weird… never seen something like that! Perhaps that library code actually ensures your normal is going a particular direction, such as forward or backward or something like that.

Yes, it was my mistake… I was using a stack. Gotta use a list and use a bool to see which way it is and reverse it at that point if need be.

the offset is a while other issue.