Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Code Snippets / Create a convex hull from an array of points [DBP]

Author
Message
lower logic
18
Years of Service
User Offline
Joined: 15th Jun 2006
Location:
Posted: 28th Sep 2006 08:49 Edited at: 28th Sep 2006 08:52
This code snippet makes an object in the shape of a convex hull that contains all points in the points() array. The hull creation code is all in 1 function, making it easy to use and add to existing projects.



Bugs:
It does not work well when 4 or more points lie on the same plane.
Zotoaster
19
Years of Service
User Offline
Joined: 20th Dec 2004
Location: Scotland
Posted: 28th Sep 2006 18:42
That's pretty damn cool.

Alquerian
18
Years of Service
User Offline
Joined: 29th Mar 2006
Location: Reno Nevada
Posted: 28th Sep 2006 21:26
Dude thats awesome

"We are what we repeatedly do. Excellence, therefore, is not an act, but a habit." - Aristotle
Sixty Squares
18
Years of Service
User Offline
Joined: 7th Jun 2006
Location: Somewhere in the world
Posted: 29th Sep 2006 05:11
nice

Ummm...
lower logic
18
Years of Service
User Offline
Joined: 15th Jun 2006
Location:
Posted: 29th Sep 2006 08:13 Edited at: 29th Sep 2006 08:15
Thanks, here's a demo that uses the convex hull to make boxes, spheres, cylinders, pyramids, tetrahedrons, octahedrons, capsules, cones, and chamfer boxes.

I also worked on the convex hull algorithm. While it still wants the first 4 points to be non coplanar, it can add points that are coplanar to the existing points in the convex hull. If the first 4 points are coplanar, for the time being it wiggles them slightly until they're not, though the proper way to do it would be to search the array of points for 4 non-coplanar points and start with those.

Syncaidius
19
Years of Service
User Offline
Joined: 22nd Mar 2005
Location: United Kingdom
Posted: 29th Sep 2006 22:51 Edited at: 29th Sep 2006 22:52
Thats some impressive work you've done there Lower Logic.

Is it ok to use your code as part of my world builder?

If its okay to do so, i'll add you to the credits in the readme.

Mr Kohlenstoff
18
Years of Service
User Offline
Joined: 7th Jun 2006
Location: Germany
Posted: 29th Sep 2006 22:54
That's great!

Very good work, especially the "advanced" objects.

Visit the DBPro - Speed up your game-Thread. http://forum.thegamecreators.com/?m=forum_view&t=88661&b=1
lower logic
18
Years of Service
User Offline
Joined: 15th Jun 2006
Location:
Posted: 30th Sep 2006 05:20 Edited at: 30th Sep 2006 05:23
@DBking, sure, I posted the code for others to use, and your world builder looks great. You'll need to find a way to uv map the convex hulls if you plan on texturing them.

Btw, anyone have any other ideas of algorithms that I could try to code? Right now I'm thinking of attempting a smoothing function that takes a 3d object and returns a new version of it with rounded corners.
Sven B
19
Years of Service
User Offline
Joined: 5th Jan 2005
Location: Belgium
Posted: 30th Sep 2006 10:10 Edited at: 30th Sep 2006 10:10
Try to make a subdivide function.

I don't know if a smooth function would be possible. Especially since you'll need extra verteces to make the rounded corners.

But if you made a convex hull function... Maybe it might work out for you after all.

It's the programmer's life:
Have a problem, solve the problem, and have a new problem to solve.
Syncaidius
19
Years of Service
User Offline
Joined: 22nd Mar 2005
Location: United Kingdom
Posted: 30th Sep 2006 12:14
@lower Logic:
Thanks. I'll use memblocks or DK's Advanced Vertex manipulation commands to set the UV co-ordinates.

I've added you to the credits list in V1.00 now, so I dont for get later.

Login to post a reply

Server time is: 2024-11-23 03:43:33
Your offset time is: 2024-11-23 03:43:33