• Announcements

    • khawk

      Download the Game Design and Indie Game Marketing Freebook   07/19/17

      GameDev.net and CRC Press have teamed up to bring a free ebook of content curated from top titles published by CRC Press. The freebook, Practices of Game Design & Indie Game Marketing, includes chapters from The Art of Game Design: A Book of Lenses, A Practical Guide to Indie Game Marketing, and An Architectural Approach to Level Design. The GameDev.net FreeBook is relevant to game designers, developers, and those interested in learning more about the challenges in game development. We know game development can be a tough discipline and business, so we picked several chapters from CRC Press titles that we thought would be of interest to you, the GameDev.net audience, in your journey to design, develop, and market your next game. The free ebook is available through CRC Press by clicking here. The Curated Books The Art of Game Design: A Book of Lenses, Second Edition, by Jesse Schell Presents 100+ sets of questions, or different lenses, for viewing a game’s design, encompassing diverse fields such as psychology, architecture, music, film, software engineering, theme park design, mathematics, anthropology, and more. Written by one of the world's top game designers, this book describes the deepest and most fundamental principles of game design, demonstrating how tactics used in board, card, and athletic games also work in video games. It provides practical instruction on creating world-class games that will be played again and again. View it here. A Practical Guide to Indie Game Marketing, by Joel Dreskin Marketing is an essential but too frequently overlooked or minimized component of the release plan for indie games. A Practical Guide to Indie Game Marketing provides you with the tools needed to build visibility and sell your indie games. With special focus on those developers with small budgets and limited staff and resources, this book is packed with tangible recommendations and techniques that you can put to use immediately. As a seasoned professional of the indie game arena, author Joel Dreskin gives you insight into practical, real-world experiences of marketing numerous successful games and also provides stories of the failures. View it here. An Architectural Approach to Level Design This is one of the first books to integrate architectural and spatial design theory with the field of level design. The book presents architectural techniques and theories for level designers to use in their own work. It connects architecture and level design in different ways that address the practical elements of how designers construct space and the experiential elements of how and why humans interact with this space. Throughout the text, readers learn skills for spatial layout, evoking emotion through gamespaces, and creating better levels through architectural theory. View it here. Learn more and download the ebook by clicking here. Did you know? GameDev.net and CRC Press also recently teamed up to bring GDNet+ Members up to a 20% discount on all CRC Press books. Learn more about this and other benefits here.
Sign in to follow this  
Followers 0
JoryRFerrell

Determine if vert normal moves into or out of geometry by finding if verts cw/ccw?

9 posts in this topic

<p>How do I determine if a the normal for a vertex has been created by ccw ordered verts or cw wound verts? I assign each vert's neighbors to a list in the order they wind around, but it doesn't assign them in a secific clockwise/ccw order consistently. I have just decided to calculate the normal then determine whether the verts are cw, or ccw, and then change the signs of the normal vector components accordingly.</p>
<p>&nbsp;</p>
<p>Some suggested using a secondary vector to compare the angle between the secondary and the generated normal. If greater than 90, or less than, that would tell me if the normal vector is facing the direction I need. But I don't think this works for concave (NOTE: I originally wrote &quot;CONVEX&quot;. I meant &quot;CONCAVE&quot;. :\) shapes (normals can face toward origin, allowing for angles less than 90 degrees when compared with a vector drawn from the origin of object.</p> Edited by JoryRFerrell
0

Share this post


Link to post
Share on other sites

Is the object guaranteed to be closed? Convex or not.

Yes. Objects are guaranteed to be closed (for now) and must account for both convex and concave geometry. Is their an algorithm which will do this for both with a single equation? Or would it require different equations/logic-branches for each?

 

Also, I want it to handle weird geometry with verts forming concave shapes which bow in past the objects local origin. Say you take a unit cube a split two opposite faces, along the z axis, into four faces each. then you take the center vertices of those four faces and translate them both -1.5 along the z axis. You'd have one vert which went inwards (forming a concave surface) past its own origin, so I can't rely on a vector from the origin to each vert, that compares with the generated normal to check the total angle between the two or something.

Edited by JoryRFerrell
0

Share this post


Link to post
Share on other sites
note:
usually figuring out the vertex normals is done (in the simple case) via a cross product.

say, we have 3 points (A, B, C) along the edge of a polygon, and want to find the normal for point B:
X=B-A
Y=C-B
Z=normalize(X % Y)

then basically, similar is done for each vertex, to generate starting normals.

note that depending on the winding of the vertices, the normals will either point into or out-of the object.


while this works, the normals generated tend to point directly out of the face, and ignore adjacent faces. for some tasks, we might want weighted normals.

the trick is basically for each vertex, finding any other vertices at the same coordinates.
then, one can do a "weighted average" of all the normals, with the weight being the dot-product between the normals.
this will smooth out soft curves while also preserving sharp edges.


dunno if this helps...
0

Share this post


Link to post
Share on other sites

I've been giving this problem some thought over the past day or so and here's what has been on my mind.

 

Let's take the simplest example, a cube.

 

First you need to determine a point that is outside the object. You need to have some sort of reference/view point.The easiest way would be to pick a point that is some large distance away from the object so that it pretty much guarantees the point is outside.

 

Next calculate the normal for a triangle/face of the cube and calculate the dot product of this normal vector with the one formed by the view point and a point on the face of the cube to determine which way the triangle/face is facing.

 

The problem is that the winding order matters in that you could be comparing a back face of the cube and the dot product result would indicate that its a front facing surface.

 

I guess you would need to calculate the closest intersection point between the way-off-in-the-distance point and the faces of the cube. The closest intersection point would indicate that you have found a surface that is facing "outward" towards the view point. (You could only do this for objects that are closed)

 

From here you could use the result of the dot product to make a determination as to the winding order of the verts.

 

Thoughts?

0

Share this post


Link to post
Share on other sites

note:
usually figuring out the vertex normals is done (in the simple case) via a cross product.

say, we have 3 points (A, B, C) along the edge of a polygon, and want to find the normal for point B:
X=B-A
Y=C-B
Z=normalize(X % Y)

then basically, similar is done for each vertex, to generate starting normals.

note that depending on the winding of the vertices, the normals will either point into or out-of the object.


while this works, the normals generated tend to point directly out of the face, and ignore adjacent faces. for some tasks, we might want weighted normals.

the trick is basically for each vertex, finding any other vertices at the same coordinates.
then, one can do a "weighted average" of all the normals, with the weight being the dot-product between the normals.
this will smooth out soft curves while also preserving sharp edges.


dunno if this helps...

Yea, I already know about cross-product method. I have made one, but Newell's Method is more accurate.

 

Like I was saying, my method grabs all neighboring verts, and forms a projected face from them on each axis. For each created face, I find the normal of the face via the cross product method. Then with all those calculated face normals, I take the average and I end up with the more accurate per-vertex normal.

My problem was correctly finding the neighbor vertices in a consistent clockwise/counter-clockwise order. They often get reversed with my current algorithm. But, if I could find a way to correctly determine the order of the verts after finding them, I could simply reverse the per-vertex normal whenever it was facing the wrong direction. However I found a way to ensure the normal is facing the correct direction no matter what, and I don't need to determine the handedness of the neighbor verts order to do it. Look at explanation below.

0

Share this post


Link to post
Share on other sites

the trick is basically for each vertex, finding any other vertices at the same coordinates.
then, one can do a "weighted average" of all the normals, with the weight being the dot-product between the normals.
this will smooth out soft curves while also preserving sharp edges.

Wouldnt it be better if the dot product is just used to divide those vertices at the same coordinate into groups with not too high angle in between the surface normals and then use weights that get higher for wider angles between adjacent edges of each vertex?

0

Share this post


Link to post
Share on other sites

Given a possibly concave (or even self-intersecting) polygon as a vertex list, you can compute whether it's sorted clockwise or counterclockwise by looking at the sign of its area, which you can compute as the sum of the signed area of each triangle formed by two consecutive vertices of the polygon and a chosen point outside it. You need neither normals nor angles.

0

Share this post


Link to post
Share on other sites


the trick is basically for each vertex, finding any other vertices at the same coordinates.
then, one can do a "weighted average" of all the normals, with the weight being the dot-product between the normals.
this will smooth out soft curves while also preserving sharp edges.

Wouldnt it be better if the dot product is just used to divide those vertices at the same coordinate into groups with not too high angle in between the surface normals and then use weights that get higher for wider angles between adjacent edges of each vertex?


well, typically there will only be 3 or 4 faces sharing each vertex, so grouping wouldn't seem to make much sense.

a weighted average for each vertex seems to work pretty well, since the only times the different normals will effect each other is when they are already similar.

say, if it is at the corner of a box, for each vertex, the dot-products of the other vertices' normals will be 0, so they have no real effect (each vertex will retain its own normal), and on a pointy corner they will be negative (which is clamped to 0).

whereas, on a curve, the faces may have much closer normals, so this will tend to average them out a lot more.
0

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0