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.

DarkBASIC Professional Discussion / 3D - Asteriod Models???

Author
Message
ScottyB
19
Years of Service
User Offline
Joined: 26th Jul 2007
Location:
Posted: 24th Feb 2010 21:55
I know how to make 3d asteroids with a modeller program but...

I was wondering if anyone knew some algorythms to construct the 3d shapes?

In 2D I uese...

for asteroids = 1 to 10
for angles = 1 to 360 step 10

rads = rnd(10) + 40

x = xcntr + rads * cos(angles)
y = xcntr + rads * sin(angles)

next angles
next asteroids

then I just connect the points.

but how to come up with a 3D algorythm based on this I have no clue.

Any suggestions or ideas are welcome
Some short source code with an implacation would be the best to learn from.

Thanks!
And
Happy Computing!
Serial Velocity
17
Years of Service
User Offline
Joined: 24th Aug 2008
Location:
Posted: 24th Feb 2010 22:12 Edited at: 24th Feb 2010 22:16
One way to do it would be simply expanding your algorithm to 3D

Create a sphere mesh (Make Object Sphere) with a radius of the lowest point on your asteroid, then loop through each vertex and multiply the normals by a scalar (between 1 to the maximum radius) and add the result to the vertex position. Someone correct me if I got that wrong

Pseudo-code:


You could probably extend this code so that the surface is smoother by generating the scalars in an array and smoothing them out in a second pass. There is code similar to this for matrix terrains somewhere on the codebase.

Hope I helped

Madscientist
16
Years of Service
User Offline
Joined: 23rd Aug 2009
Location: Between a rock and a hard place
Posted: 25th Feb 2010 15:21
@ Serial Velocity
It looks like a crumpled piece of paper.

If it hasn't exploded yet, I haven't touched it.
Serial Velocity
17
Years of Service
User Offline
Joined: 24th Aug 2008
Location:
Posted: 25th Feb 2010 17:30 Edited at: 25th Feb 2010 17:33
It's a start

ScottyB
19
Years of Service
User Offline
Joined: 26th Jul 2007
Location:
Posted: 25th Feb 2010 17:33
It could look o.k. if...

You could skip some vertex's and somehow do an
kinda even or correct transitions up and down.

I just don't know where one ring ends and another begins?
Around or Down.

Say if you could height map it then the movement from point to point would be slightly up or down or the same giveing it the the nice look.
Serial Velocity
17
Years of Service
User Offline
Joined: 24th Aug 2008
Location:
Posted: 25th Feb 2010 18:54
By height-map do you mean something like a displacement map?

If you want the asteroid 100% procedurally generated, then I cant help here as I have no idea how to generate a map that wont distort for a sphere (it will look more ragged at the poles), but if you make one say in photoshop, just read the pixel value and use that as a scalar. Do a search for "Memblock Images" or something close to that for a code example of reading pixel data.

Login to post a reply

Server time is: 2026-07-27 21:05:12
Your offset time is: 2026-07-27 21:05:12