First of all sorry for my poor english. Any one know a good thecnic to inflate a non selfintersecting polygon in 3D space (like the well know windows function InflateRect(rect,cx,cy))? Thanks in advance…
You mean scale?
Or extrude each point along its surface normal?
glScalef() should do it just fine.
Scaling is not correct because the amount of inflating is not equal for each side of the polygon. My target is to obtain a inflated polygon in wich each side is parallel to the original and translated of the prescribed (de)inflating value delta. Sorry for my poor english chief
then you probably want to displace the vertex along the surface normal like knackered said. But if you want to do that for a mesh of polygons then you will need to displace the along the vertex normal or else you will get cracks in the mesh.
if you are looking for pseudo code…
V’ = V + delta*N
V,V’ the vectors pointing the vertex before and after inflating, N is the normal.
I’ve just read the spec for the win32 InflateRect function. I’m still unsure what the difference between that method and a simple scale is…
InflateRect does just a scale. However, the original question also wants a solution to the problem for concave polygons (a rectangle is convex).
One algorithm is to split your concave polygon into convex pieces, inflate them all, and then merge them back.
Another algorithm is to describe the polygon as a series of planes; the translate the planes, and rediscover the polygon (a la BSP rendering).
Actually, thinking about it, inflaterect does not do a scale. It adds values to the points rather than multiply the points by a scalar.
It seems to find the rough center of the polygon and, depending on each points position in relation to the center, add or subtract the constant ‘inflation’ value you supply it with.
The algorithm would then be this, for a 3d poly:

Add up all vertices, and divide by number of vertices to find the mean center vertex(and call it ‘C’)

for each vertex in polygon
— if (vert.x < C.x)
 vert.x = inflateval
— else if (vert.x > C.x)
 vert.x += inflateval
— if (vert.y < C.y)
 vert.y = inflateval
— else if (vert.y > C.y)
 vert.y += inflateval
— if (vert.z < C.z)
 vert.z = inflateval
— else if (vert.z > C.z)
 vert.z += inflateval
That should do it.
[This message has been edited by knackered (edited 10032002).]
Hey, you can use this technique to make clowns inflate 3d baloons in a circus game! heh heh
EDIT: Hehe, forgot the 2nd ‘c’ in circus.
SirKnight
[This message has been edited by SirKnight (edited 10032002).]