• 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
noatom

Question regarding dot product of polygon normal and poligon vertex

9 posts in this topic

I know that you can find it a polygon is facing the camera using that method.You need the polygon normal and the position of a vertex on that polygon.I don't remember more.

 

Can someone explain with details,and maybe some drawings?

 

Thanks

0

Share this post


Link to post
Share on other sites

You take the dot product of the normal and the vector between the viewpoint and one of the vertices. A negative dot product means the side of the polygon in the direction of the normal is visible from the view point.

Edited by Brother Bob
0

Share this post


Link to post
Share on other sites

If you do the dot product of the normal and the vector from the camera to a point on the polygon it will be negative if they are facing in opposite directions, which means the polygon is facing the camera.

 

Dot product positive -> vectors are facing same direction (within 90 degrees each way)

Dot product negative -> vectors facing different directions

Dot product 0 -> vectors are perpendicular

 

You can also use the z-component of the cross product of polygon edge directions in screen space to check if the polygon is back facing.

 

EDIT: My first answer was incorrect, edited now.

Edited by Paradigm Shifter
0

Share this post


Link to post
Share on other sites

I know that you can find it a polygon is facing the camera using that method.  Can someone explain with details,and maybe some drawings?

There are several formulas to define a dot product, just like there are several formulas that can define a line.

 

One of those formulas is:

 

DotProduct = |A| * |B| * cos(AngleBetweenAB)

 

The dot product equals the magnitude (length) of the first vector, times the magnitude of the second vector, times the cosine of the angle between the two vectors.

 

If both vectors are normalized (length = 1) they drop out of the equation.

 

So if we have normalized vectors A and B: DotProduct = cos(AngleBetweenAB).

 

If you remember from the definition of a cosine, angles between -90 degrees and 90 degrees are all positive, with 90 and -90 being exactly zero.

 

 

So if one vector is pointing forward and the dot product is positive, the second vector is also pointing forward.  It might only be a tiny bit forward, but it is still at least partially forward.

 

The opposite is also true: if one vector is pointing forward and the dot product is negative, the second vector is pointing backwards.  It might only be a tiny bit backward, but it is still at least partially backward.

 

 

And since for the normalized angles DotProduct = cos(AngleBetweenAB), that means you can undo the cosine:  AngleBetweenAB = arccos(DotProduct)

 

Sorry no pictures, but I hope that clears it up.

Edited by frob
0

Share this post


Link to post
Share on other sites

If you are just testing relative facing (towards/away from/perpendicular) you don't need to normalise, all that matters is the sign (+ve -> facing same way, -ve -> facing opposite way, 0 -> perp).

0

Share this post


Link to post
Share on other sites

Ok,got it:

If you are just testing relative facing (towards/away from/perpendicular) you don't need to normalise, all that matters is the sign (+ve -> facing same way, -ve -> facing opposite way, 0 -> perp)

 

But I still have problems visualizing the test.For example:

 

x4irmg.png

 

 

 

 

What I think happens is:

 

2v86ez4.png

 

 

 

Obviously,my thoughts are wrong,but can someone say where and why? Thanks

0

Share this post


Link to post
Share on other sites

The angles you measure in for the two polygons have different references. Notice how on the left side the angle is measured between the normal and the red line, while on the right hand side the angle is measured between the inverse of the normal and the red line.

0

Share this post


Link to post
Share on other sites

The angle is between the blue line and the red line. I thought the blue line was the extended normal from the origin since that is what you measured the angle from and not the black line itself. What are the red and blue lines then in your picture, just to make sure we're talking about the same thing.

0

Share this post


Link to post
Share on other sites

Your angle measurement is a misinterpretation. Think of the vectors as free vectors, not localized.Now imagine both vectors(the normal and the camera to vertex vector) with their tails attached. The polygon on the left has a normal pointing away from the blue vector. If you do the same on the right, you can see they point the same direction.

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