Oxygen Basic
Programming => Example Code => Graphics => Topic started by: Charles Pegge on February 16, 2014, 05:39:26 AM
-
(http://www.oxygenbasic.org/o2pics/opengl/PlotUFO.jpg)
includepath "$\inc\"
$ title "UFO Plot"
include "OpenglSceneFrame.inc"
sys UFO
sub scene(sys hWnd)
===================
'
SnapShots(hwnd) 'Ctrl-P take snapshot
'
glLoadIdentity
glClear GL_COLOR_BUFFER_BIT or GL_DEPTH_BUFFER_BIT
glClearColor 0.3, 0, 0, 0
gltranslatef 0,0,-1
glscalef 0.0007,0.0007,1
'
int xs = 1
int ys = 1
int a = 700
int b = a * a
int c = 600
float q,r,y
int i,m,n,p,x,st
float ia = 1/a
'
glColor3f .5, 1.0, 1.0 ' color 14
glPointSize 1.0
if UFO then
glCallList UFO
goto ExitScene
end if
UFO=CompileList
glBegin GL_POINTS
for x = 0 to a step xs
s = x * x
p = sqr(b - s)
st=6*ys
for i = -p to p step st
r = sqr(s + i * i) /a
q = (r -1.0) * sin(24 * r)
y = round(i/3 + q * c)
if i=-p then
m=y
n=y
end if
if y > m then m = y 'top half
if y < n then n = y 'bottom half
if m = y or n = y then
glVertex2i -x, y
glVertex2i x, y
end if
next
next
glEnd
glEndList
'
ExitScene:
'
sleep 20
'
end sub
sub initialize(sys hWnd)
========================
SetTimer hWnd,1,10,NULL
end sub
sub Release(sys hwnd)
=====================
glDeleteLists UFO,1
killTimer hwnd, 1
end sub
-
Nice Charles.
There seems to be a math error in the center. There is a vertical band that is offset lower than it should. It seems to get noisy in the center region.
-
Yes there is significant line jitter, but I could not pinpoint the cause. Maybe it's the float / integer mix.
PS
Using an all-float system now. Perfection! :)
includepath "$\inc\"
$ title "UFO Plot"
include "OpenglSceneFrame.inc"
sys UFO
sub scene(sys hWnd)
===================
'
SnapShots(hwnd) 'Ctrl-P take snapshot
NewFrame
glClearColor 0.3, 0, 0, 0
gltranslatef 0,0,-1
glscalef 0.0007,0.0007,1
'
float xs = 1
float ys = 1
float a = 700
float b = a * a
float c = 600
float q,r,y
float i,m,n,p,x,st
float ia = 1/a
'
glColor3f .5, 1.0, 1.0 ' color 14
glPointSize 1.0
if UFO then
glCallList UFO
goto ExitScene
end if
UFO=CompileList
glBegin GL_POINTS
for x = 0 to a step xs
s = x * x
p = sqr(b - s)
st=6*ys
for i = -p to p step st
r = sqr(s + i * i) *ia
q = (r -1.0) * sin(24 * r)
y = i*.33333 + q * c
if i=-p then
m=y
n=y
end if
if y > m then m = y 'top half
if y < n then n = y 'bottom half
if m = y or n = y then
glVertex2f -x, y
glVertex2f x, y
end if
next
next
glEnd
glEndList
'
ExitScene:
'
sleep 20
'
end sub
sub initialize(sys hWnd)
========================
SetTimer hWnd,1,10,NULL
end sub
sub Release(sys hwnd)
=====================
glDeleteLists UFO,1
killTimer hwnd, 1
end sub
-
Using an all-float system now. Perfection!
Looks GREAT!
Dear Alex and Joe,
I looked at that Oxygen Basic ufo image. Yes, it looks pretty ugly, but, then, some GL smoothing tricks are not used (and could be) and the colour depth is low (I think). But the Alex cairo version speaks for itself. :) This is the link to the Oxygen Basic image: h2o_ufo.
With kind regards,
vovchik
.
-
He-he this ba-con forum looks like complete F*G-s show with all this *dear
sufixes. ;D
-
Okay, how about a 3D moving UFO :)
-
Okay, how about a 3D moving UFO
Moving the image with the arrow keys would be cool. I was thinking of adding a sequence of flashing small circles around the edge of the UFO. Hey, this is turning out to be a better code challenge than the bible word count challenge of yesteryear.
The BaCon boys are gaining on us. :D
I'm not committing to this challenge yet until I get the SB-gfx extension module completed. That should level the playing field a bit. (zoom, rotate, alpha, ...)
I'm visualizing a star filled sky as a background and the UFO zooms in shifting rapidly on multiple planes and using the alpha channel to make the UFO pulsate from near invisible to full brightness. A few pulsating 'lights' might be a nice effect. Well, that's what I have planned if this gets serious. 8)
.
-
Saucer Studio: :)
.
-
I'm thinking this may be how intelligent life began in America. Or the beginning of the big/little endian debate.
(http://images.fineartamerica.com/images-medium-large/flying-saucer-murphy-elliott.jpg)