Author Topic: Plot UFO (Opengl)  (Read 6142 times)

0 Members and 1 Guest are viewing this topic.

Charles Pegge

  • Guest
Plot UFO (Opengl)
« on: February 16, 2014, 05:39:26 AM »



Code: [Select]
  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

JRS

  • Guest
Re: Plot UFO (Opengl)
« Reply #1 on: February 17, 2014, 12:35:50 AM »
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.

 

Charles Pegge

  • Guest
Re: Plot UFO (Opengl)
« Reply #2 on: February 17, 2014, 02:24:34 AM »
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! :)

Code: [Select]
 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
« Last Edit: February 17, 2014, 02:40:50 AM by Charles Pegge »

JRS

  • Guest
Re: Plot UFO (Opengl)
« Reply #3 on: February 17, 2014, 07:43:25 AM »
Quote
Using an all-float system now. Perfection!

Looks GREAT!

Quote from: BaCon Forum
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


.
« Last Edit: February 17, 2014, 07:57:04 AM by John »

Aurel

  • Guest
Re: Plot UFO (Opengl)
« Reply #4 on: February 17, 2014, 08:34:41 AM »
He-he this ba-con forum looks like complete F*G-s show with all this *dear
sufixes. ;D 

Charles Pegge

  • Guest
Re: Plot UFO (Opengl)
« Reply #5 on: February 17, 2014, 10:14:45 AM »
Okay, how about a 3D moving UFO :)

JRS

  • Guest
Re: Plot UFO (Opengl)
« Reply #6 on: February 17, 2014, 10:24:28 AM »
Quote
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)

.
« Last Edit: February 17, 2014, 05:04:31 PM by John »

Charles Pegge

  • Guest
Re: Plot UFO (Opengl)
« Reply #7 on: February 19, 2014, 05:03:09 AM »
Saucer Studio: :)

.

JRS

  • Guest
Re: Plot UFO (Opengl)
« Reply #8 on: February 19, 2014, 09:14:43 AM »
I'm thinking this may be how intelligent life began in America. Or the beginning of the big/little endian debate.



« Last Edit: February 19, 2014, 11:21:39 AM by John »