Part of the Khronos Group
OpenGL.org

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Results 1 to 9 of 9

Thread: Expanding 3D Objects!

  1. #1
    Junior Member Newbie
    Join Date
    Sep 2002
    Posts
    18

    Expanding 3D Objects!

    I need to clone and expand a mesh... building a "shell" around the object so to speak. Anyone who knows how to do this with complex objects? C++ source is prefered, a plugin or script for 3ds max also works.

  2. #2
    Super Moderator OpenGL Guru dorbie's Avatar
    Join Date
    Jul 2000
    Location
    Bay Area, CA, USA
    Posts
    3,971

    Re: Expanding 3D Objects!

    Extruding verts along their surface normals would be one simple way. Average the normals first ofcourse.

  3. #3
    Member Regular Contributor
    Join Date
    Feb 2002
    Location
    Hamburg, Germany
    Posts
    413

    Re: Expanding 3D Objects!

    dorbie's solution will only work with fully closed meshes. If there are any duplicated vertices on the same geometrical position (ie. adjacent edges of two polygons with different mapping) you'll get holes or - in the mostly worse case - a bunch of free floating triangles.
    So you also need to fix this problem by searching for this "wrong" edges ("wrong" means: edges with the same position but not the same vertices) and create new polygons between them.

  4. #4
    Intern Contributor
    Join Date
    Apr 2001
    Location
    Sofia, Bulgaria
    Posts
    65

    Re: Expanding 3D Objects!

    Here's one correct way to do this.
    1. Break the mesh into convex volumes by using a BSP tree.
    2. Get the set of planes for each volume. "Expand" the planes by adding some value to plane.D
    3. Bevel the sharp edges by adding bevel planes (don't forget to "expand" them too) to the plane set.
    4. Generate a mesh from each plane set.
    5. CSG all expanded convex volume meshes.

    This is a bit of overkill for complex meshes and also not very easy to implement unless you have a good BSP library at hand.

  5. #5
    Super Moderator OpenGL Guru
    Join Date
    Feb 2000
    Location
    Montreal, Canada
    Posts
    4,256

    Re: Expanding 3D Objects!

    Originally posted by AdrianD:
    dorbie's solution will only work with fully closed meshes. If there are any duplicated vertices on the same geometrical position (ie. adjacent edges of two polygons with different mapping) you'll get holes or - in the mostly worse case - a bunch of free floating triangles.
    So you also need to fix this problem by searching for this "wrong" edges ("wrong" means: edges with the same position but not the same vertices) and create new polygons between them.

    As long as the duplicate vertices have identical normals, no holes will occur. So all you need is a good normal computing algorithm that searches for these duplicates in your entire object.

    The only problem is over expanding. The expansion could penetrate an oposing face on the same object and worst, could exit on the other side.

    V-man
    ------------------------------
    Sig: http://glhlib.sourceforge.net
    an open source GLU replacement library. Much more modern than GLU.
    float matrix[16], inverse_matrix[16];
    glhLoadIdentityf2(matrix);
    glhTranslatef2(matrix, 0.0, 0.0, 5.0);
    glhRotateAboutXf2(matrix, angleInRadians);
    glhScalef2(matrix, 1.0, 1.0, -1.0);
    glhQuickInvertMatrixf2(matrix, inverse_matrix);
    glUniformMatrix4fv(uniformLocation1, 1, FALSE, matrix);
    glUniformMatrix4fv(uniformLocation2, 1, FALSE, inverse_matrix);

  6. #6
    Intern Contributor
    Join Date
    Jul 2001
    Location
    Chennai, TN, India
    Posts
    50

    Re: Expanding 3D Objects!

    Tried Scaling the Mesh?

    -Sundar

  7. #7
    Senior Member OpenGL Guru
    Join Date
    Mar 2001
    Posts
    2,411

    Re: Expanding 3D Objects!

    Scaling the mesh won't work right. Think about a donut. If you expand it, the inner hole will actually get bigger in the scaled version, instead of SMALLER which is what you want an "inflated" donut to look like.

    Here's a solution that's usually sufficient:

    1) generate the "fully welded" mesh of position verts. I e, collapse all verts whose position are (nearly) the same to one vert, ignoring normal and texture information

    2) calculate the fully smoothed normal for each vert: add the face normal of all faces that share this vert, then normalize the result

    3) move all vert positions in the direction of the thus-calculated vert normal, by your inflation distance

    4) un-collapse the mesh, tieing all the "welded" verts back to all their ancestors (that you had to remember back in step 1)
    "If you can't afford to do something right,
    you'd better make sure you can afford to do it wrong!"

  8. #8
    Super Moderator OpenGL Guru dorbie's Avatar
    Join Date
    Jul 2000
    Location
    Bay Area, CA, USA
    Posts
    3,971

    Re: Expanding 3D Objects!

    Other parameters don't count for this calculation of shared normals, texcoords etc. Just the cross products, it will work. If there are degenerate tris and you don't delete (nasty you really should deal with that) the verts would be shared and they'd remain degenerate. The real problems occur with concave regions where geometry extrudes into eachother but that's another story.

    [This message has been edited by dorbie (edited 10-19-2002).]

  9. #9
    Senior Member OpenGL Guru
    Join Date
    Mar 2001
    Posts
    2,411

    Re: Expanding 3D Objects!

    dorbie,

    The algorithm I describe does reasonably well even for concave geometry and "reasonable" amounts of inflate. The reason is that the inner ("bottom") vertices will get normals that point "out" of hollowness. I e, for a "V", the normal for the vert at the bottom of the "V" would point straight up.

    Of course, if you have a "U" and the two sides of the U contains verts with normals pointing straight at each other, if you inflate by more than the width of the "U" you'll get geometry interpenetration. Luckily, the rendered object will still look as you would expect it to (!) -- modulo Z fighting at the interpenetration, of course :-)
    "If you can't afford to do something right,
    you'd better make sure you can afford to do it wrong!"

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •