Hello

I want to code a sphere with points (not with triangle),
and I'll display them with the fonction API "SetPixelA".
I want to code an algo,if somebody can help me with a tut/source/url.

PS: I'll code it only in Win32, not in DirectX, D3D,OpenGL,...
thx
Posted on 2006-06-01 09:26:02 by tomart2005
Hi
Look into the ObjAsm32 package and search for a project called API_3D_Engine. Here you can find the code for a sphere and other simple geometries.

Regards,

Biterider
Posted on 2006-06-01 12:01:33 by Biterider
tomart2005,

loop throught the whole 360 degrees, taking sinus and cosinus of these angles...

multiply these 2 values (sin/cos) by radius, and add sphere centre, and you have the X and Y for your SetPixel

ancev

ps: the much smallers steps you use while looping from 0-360 degrees, the closer the points will appear
Posted on 2006-06-01 12:28:37 by ancev
hey ancev

you wrote:

loop throught the whole 360 degrees, taking sinus and cosinus of these angles...

multiply these 2 values (sin/cos) by radius, and add sphere centre, and you have the X and Y for your SetPixel

ancev

ps: the much smallers steps you use while looping from 0-360 degrees, the closer the points will appear


----------------------------------------------

Can you give me a formula, coz I don't understand with my  bad english, plz

thx


Posted on 2006-07-12 09:29:03 by tomart2005
Here's the pseudocode for drawing a full circle:

for radius = 0 to radius_max
for degree=0 to 359
  x = x_center + radius * cos(degree)
  y = y_center + radius * sin(degree)
  plot ( x, y )
endfor
endfor

But realy... you should be able to find yourself the formula of circle/sphere..

For higher resolution.. you could increment you angle with values smaller than 1, maybe 0.1 or other values.. it depends of the circle radius..

For 3D its more complicated.. depends of a lot of factors: projection/camera etc.

Eugen
Posted on 2006-07-12 11:48:26 by Eugen