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.
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.
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.
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.
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.
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.