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 Discussion / how to make a "sphere" out of plains

Author
Message
That1Smart Guy
16
Years of Service
User Offline
Joined: 26th Feb 2009
Location: Somewhere...... yep
Posted: 15th Jun 2009 02:46
how would i adapt the manual circle equation (cx+cos(angle)*rad,cy+sin(angle)*rad) into one for a sphere?

There are only 10 kinds of people in the world, those who understand binary and those who dont
qwe
21
Years of Service
User Offline
Joined: 3rd Sep 2003
Location: place
Posted: 15th Jun 2009 14:21 Edited at: 15th Jun 2009 14:23
you don't want the circle equation, you want the sphere equation

for any particular angle THETA and PHI (lets say theta (ill say T) goes from 0 to 360 on the Y axis (XZ plane) and PHI goes from -90 to 90 degrees. that's longitude and latitude basically. you could have a function that gets each point on a sphere, eg, get a point for each angle pair where THETA = 0 to 360 step (sphere_resolution_longitude) and PHI = -90 to 90 step (sphere_resolution_latitude). so, if you want a point every 15 degrees, you step 15 degrees in the for-next statement

so now we use spherical coordinates to get an XYZ point for a particular pair of angles (THETA, PHI) and a distance (R)... sound familiar? it's the spherical coordinate system taught in second and/or third semester calculus (integrals and multivar) and prob precalc

wikipedia has the equations to get cartesian (XYZ) from spherical (THETA, PHI, R): http://en.wikipedia.org/wiki/Spherical_coordinates

X = R * cos(PHI) * sin(THETA)
Y = R * sin(PHI) * sin(THETA)
Z = R * cos(THETA)

be sure to make rotational adjustments if required, eg, if your coordinate system on paper doesn't match the coordinate system in gamespace. dbpro starts, as 0 degrees on y axis, well idk... in the positive z direction? that'd make sense, but i don't know. maybe someone can answer that

so, with all these points XYZ for each point on the sphere,

simply make triangles or plains connecting adjacent ones in the correct sequence!

texturing something made, in dbpro commands, from a bunch of plains; that is a tough thing to do i would think. though i suppose they could each be individually textured, it'd take some working to get it seamless

---

just curious, why not make a pre-texture-uv-mapped sphere? are different plains going to roll into defined places, like a broken spherical marble constructing itself, sort of like an animation? or what?
That1Smart Guy
16
Years of Service
User Offline
Joined: 26th Feb 2009
Location: Somewhere...... yep
Posted: 15th Jun 2009 14:33
ok that sorta worked, if somewhat strangely

but now i have a question, why arent the plains all pointed at 0,0,0?



There are only 10 kinds of people in the world, those who understand binary and those who dont
pictionaryjr
16
Years of Service
User Offline
Joined: 12th Mar 2009
Location:
Posted: 15th Jun 2009 16:36 Edited at: 15th Jun 2009 16:39
edit:
woops didn't read the code all the way
That1Smart Guy
16
Years of Service
User Offline
Joined: 26th Feb 2009
Location: Somewhere...... yep
Posted: 15th Jun 2009 18:11
and as for what im doing with it, im not actually making a sphere, picture a sphere with the vertices adjusted enough to where you can see between them, so it looks like a bunch of plains floating, only they're all pointe towards the center of the circle

im making this for my entry in the current challenge, shoot the plains (textured with targets) and they disappear, see how many you can hit in a certain amount of time

There are only 10 kinds of people in the world, those who understand binary and those who dont

Login to post a reply

Server time is: 2025-06-08 10:43:31
Your offset time is: 2025-06-08 10:43:31