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

Minkowski addition and convex hulls.

10 posts in this topic

so, I'm trying to find a paper or something for what i'm doing.

I know their's alot of papers with convex hulls represented by vertice's. but i am representing mine with a series of planes, this is fine for most intersection code, but i can't find anything for using the minkowski addition with such a representation.

does anyone know of any papers on the subject, at worse i can re-write how i represent the hulls to be vertice based, but i'd rather work with planes, since that's what it generally comes down to.
0

Share this post


Link to post
Share on other sites
Other than space considerations, what is the advantage of storing planes with plane equation over storing CH points and indices?
0

Share this post


Link to post
Share on other sites
well, that's really it, for example, if i want to represent an 3D rectangle, i only have to push 6 planes, rather than 8 points, and a number of indices. if i want to apply a transformation, i apply it directly to the plane normal, and if the matrix scales, then all i do is multiply the D component by the length of the normal upon re-normalization.

with vertices, i'd have to translate each vertices by the matrix, and potentially recalculate the planes(probably simpler than also translating them by the matrix), they defiantly arn't as intuitive as working with vertices, but their defiantly faster for doing general purpose calculations on a convex hull.


so, at the moment, i thought i had come up with an algorithm for doing the sum of two objects, but it seems i'm missing something crucial, if both shapes are the same size, but just rotated, the algorithm can handle it, just not if the object is two diffrent sizes.

this is my current code:

[code]
//Note: both hulls are already made to be around zero, so no tranlation is required.
QWConvexHull *MiniskySum(QWConvexHull *A, QWConvexHull *B){
unsigned int Len = A->GetPlaneCount()+B->GetPlaneCount();
if(!Len) return 0x0;
QWVector4 *R = new QWVector4[Len];
Len=0;
//Add the first object as the starting shape.
for(unsigned int i=0;i<A->GetPlaneCount();i++) R[Len++] = A->GetTranslatedPlane(i);
//go through each point of A:
for(unsigned int i=0;i<A->GetPlaneCount();i++){
QWVector4 AP = A->GetTranslatedPlane(i);
QWVector3 AT = QWVector3(AP.x*AP.w, AP.y*AP.w, AP.z*AP.w);
//calculate the point of the plane for the convex hull.
for(unsigned int d=0;d<B->GetPlaneCount();d++){
QWVector4 BP = B->GetTranslatedPlane(d);
QWVector3 BT = QWVector3(BP.x*BP.w, BP.y*BP.w, BP.z*BP.w);
//calculate the point for B's plane.
BT = AT+BT;
/Combine the two!
unsigned char RF=0;
for(unsigned int x=0;x<Len;x++){
//discover if this point is inside the existing convex hull.
if(QWConvexHull::PlanePointDistance(R[x], BT)>QWEPSILON){
RF=1;
break;
}
}
//If it's inside, we ignore this plane.
if(!RF) continue;
//Calculate the resulting point's plane relative to the origin.
//since BT is not in the unit sphere, but does exist on the correct plane, we translate the resulting plane's D component to be at the correct distance.
QWVector4 Z = QWVector4(BP.x, BP.y, BP.z, (BP.x*BT.x+BP.y*BT.y+BP.z*BT.z));
R[Len++] = Z;
//currently, we brute force to figure out if their are any plane points that are inside our finished hull.
for(unsigned int x=0;x<Len;x++){
QWVector3 P = QWVector3(R[x].x*R[x].w, R[x].y*R[x].w, R[x].z*R[x].w);
for(unsigned int y=0;y<Len;y++){
if(QWConvexHull::PlanePointDistance(R[y], P)>=QWEPSILON){
//We've discovered y is inside of x, so we get rid of y.
R[y--] = R[--Len];
break;
}
}
}
}
}
//Now just build the actual hull.
QWConvexHull *H = new QWConvexHull(A->GetCenter());
for(unsigned int i=0;i<Len;i++) H->PushPlane(R[i]);
//QWConvexHull *Hull
delete[] R;
return H;
}
[/code]
0

Share this post


Link to post
Share on other sites
Applying transformations directly to normals will work correctly only with orthogonal transformations. For general transforms you'll have to use the cofactor matrix.
Besides, you're not saving that much space by using the plane equation. More precisely, for zero genus, closed, triangulated surface with 'n' vertices, you'll use '8n-16' fp units to store the planes, on the other hand you'll use '3n' fp units and '6n-12' integer units to store the vertices and indices.

Also, what general purpose calculations are better be done on plane equations than on points? I ask this because all implementations that I've done so far faired far better with verts/indcs representation. For instance you want to do Minkowski sums, they're quite easy when it's just points, but working with normals makes things more complicated.
0

Share this post


Link to post
Share on other sites
[quote name='max343' timestamp='1355746085' post='5011651']
Applying transformations directly to normals will work correctly only with orthogonal transformations. For general transforms you'll have to use the cofactor matrix.
Besides, you're not saving that much space by using the plane equation. More precisely, for zero genus, closed, triangulated surface with 'n' vertices, you'll use '8n-16' fp units to store the planes, on the other hand you'll use '3n' fp units and '6n-12' integer units to store the vertices and indices.

Also, what general purpose calculations are better be done on plane equations than on points? I ask this because all implementations that I've done so far faired far better with verts/indcs representation. For instance you want to do Minkowski sums, they're quite easy when it's just points, but working with normals makes things more complicated.
[/quote]

think about what information needs to be represented from that triangle, if you want to test if a point is inside your convex hull, then you need to test that it's inside all the planes of each triangle, if you want to test ray intersection with your triangle, first you have to get the point's intersection point with the plane that the triangle resides on, then you have to test that the point is inside the triangle.

for example, i just implemented a function that can get the surface point of my convex hull from any given direction, it operates in O(n) time where n is the number of planes:

[code]
//where R is some large number.
QWVector3 QWConvexHull::GetSurfacePoint(QWVector3 Direction, float R){
QWVector3 E = Direction*R;
for(unsigned int i=m_PlaneCount;i<m_PlaneCount*2;i++){
QWVector4 P = m_PlaneList[i];
float Dot = P.x*E.x+P.y*E.y+P.z*E.z;
if(QWFCmp(Dot, 0.0f)) continue;
float D = P.w/Dot;
if(D<1.0f && D>0.0f) E*=D;
}
return m_Center+E;
}
[/code]

if we just use planes to start with, you can encode with less space, and you don't have to generate the normals from the geometry, since your providing those normals directly.

anyways, for the moment i've decided to use minkowski diffrence for collision detection, although if anyone has more information on this subject, please point me to it, as i'd like to use minkowski sum for doing sweep checks.
0

Share this post


Link to post
Share on other sites
[quote name='slicer4ever' timestamp='1355748568' post='5011664']
think about what information needs to be represented from that triangle, if you want to test if a point is inside your convex hull, then you need to test that it's inside all the planes of each triangle, if you want to test ray intersection with your triangle, first you have to get the point's intersection point with the plane that the triangle resides on, then you have to test that the point is inside the triangle.
[/quote]

Testing whether a point is inside a convex mesh takes O(log(n)) time. Why test it against all triangles?
Same thing goes for intersecting a ray with a convex mesh. Testing it against all triangles is suboptimal (can be done in O(log(n)) time). Edited by max343
0

Share this post


Link to post
Share on other sites
[quote name='max343' timestamp='1355751688' post='5011679']
[quote name='slicer4ever' timestamp='1355748568' post='5011664']
think about what information needs to be represented from that triangle, if you want to test if a point is inside your convex hull, then you need to test that it's inside all the planes of each triangle, if you want to test ray intersection with your triangle, first you have to get the point's intersection point with the plane that the triangle resides on, then you have to test that the point is inside the triangle.
[/quote]

Testing whether a point is inside a convex mesh takes O(log(n)) time. Why test it against all triangles?
Same thing goes for intersecting a ray with a convex mesh. Testing it against all triangles is suboptimal (can be done in O(log(n)) time).
[/quote]
here's an idea, link me to relevant information, you say it can be done in O(log(n)), then tell me how, instead of just making wild claims.
0

Share this post


Link to post
Share on other sites
Amazing... Wild claims? Instead of being rude (and down-voting) you can just read some textbook on computational geometry.
Lookup what is Dobkin-Kirkpatrick hierarchy.
0

Share this post


Link to post
Share on other sites
[quote name='max343' timestamp='1355754375' post='5011709']
Amazing... Wild claims? Instead of being rude (and down-voting) you can just read some textbook on computational geometry.
Lookup what is Dobkin-Kirkpatrick hierarchy.
[/quote]

uhh buddy, maybe you should actually check my rep events before making such claims, idk who down voted you,

as for the post on hand, all you had to do was throw out that name in the last post, rather than pretty much insulting the way i was doing, and telling me their's a better way to do something, without actually telling me how it's done. all i was asking is for the algorithm that you were talking about. Edited by slicer4ever
0

Share this post


Link to post
Share on other sites
Ok, sorry for being rude and not checking whether it was you who downvoted (I just assumed that, apparently wrongly).
But still, if you see something that is not familiar to you, instead of saying that it's a wild claim, you can just ask on how it's done. I didn't elaborate on it simply because it's a relatively basic topic in computational geometry, so I wasn't sure what's exactly the problem.

Now that I see what the problem is, I can give you the full answer. Using plane equations for meshes is suboptimal for this types of queries, because you want to exploit the convexity of your mesh. Multiple plane equations don't contain that information explicitly. On the other hand using verts/indcs is useful because you can construct the Dobkin-Kirkpatrick hierarchy (during pre-processing, takes linear time) and traverse only the most relevant parts of your convex mesh which results in a logarithmic time algorithm.
Implementation details can be found in almost any textbook that mentions this hierarchy.
2

Share this post


Link to post
Share on other sites
[quote name='max343' timestamp='1355756317' post='5011723']
Now that I see what the problem is, I can give you the full answer. Using plane equations for meshes is suboptimal for this types of queries, because you want to exploit the convexity of your mesh. Multiple plane equations don't contain that information explicitly. On the other hand using verts/indcs is useful because you can construct the Dobkin-Kirkpatrick hierarchy (during pre-processing, takes linear time) and traverse only the most relevant parts of your convex mesh which results in a logarithmic time algorithm.
Implementation details can be found in almost any textbook that mentions this hierarchy.
[/quote]

thank you, i'm currently reading over a pdf about Dobkin-Kirkpatric right now to get a better grasp on the subject. I've never had any formal training on computational geometry, so it's not uncommon for me to run into an new approach to a problem that essentially shines a bright light at things i've been trying to do, but didn't know proper terms for them, so usually it ends up getting done haphazardly.

I am coming to the realization that storing only planes provides only enough information for simple query's into the object, I just discovered that the implementation i created for doing minkowski diffrence has faults in the fact that drawing a straight line between two objects can cause missed collisions.
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