Author Topic: Rob's Fibonacci Pine Cone  (Read 2955 times)

0 Members and 1 Guest are viewing this topic.

Charles Pegge

  • Guest
Rob's Fibonacci Pine Cone
« on: February 14, 2015, 03:59:15 AM »
Hi Rob,

Your pine-cone ported to OxygenBasic. F1 will reveal the navigation controls.

Code: [Select]
  #compact
  % Title "PineCone"
 '% Animated
  % ScaleUp
 '% PlaceCentral
 '% AnchorCentral
 '% NoEscape
  % ColorCodedPick
  % MultiSamples 4

  includepath "$\inc\"
  include "ConsoleG.inc"


  function makelist() as sys
  ==========================

  type coor float x,y,z

  static coor z
  static float golden_angle = 137.508 
  static float golden       = golden_angle*Pi/180
                                     
  sub floret (sys n) 'inner procedure
  ------------------
  float r , ang , xc , yc
  r =(5.3 * Sqr(n*golden))
  ang = (n*golden)
  xc = r*Cos(ang)/100
  yc = r*Sin(ang)/100
  z.x=xc : z.y=yc
  end Sub   

  sys i
  seeds=CompileList 0
  for i=1 to 140
    floret(i)
    glPushMatrix
    glTranslatef z.x , z.y , i/100
    scale 0.11+i/900
    go sphere
    glPopMatrix   
  next 
  for i=144 To 1 step -1
    floret(i) 
    glPushMatrix
    glTranslatef -z.x , -z.y , 2.2-i/200
    Scale  0.11+i/1000
    go sphere
    glPopMatrix   
  next
  glEndList
  return seeds
  end function


 function main()
  ===============
  sys i,p
  string s
  float  a
  cls 0,0.1,0.2
  '
   shading
  '
  pushstate
  move 15,-15,-20
  static MoveableObject seeds
  static sys            seedform
  static sys            id=100
  if not seeds.id 
    seeds.snap=.5
    seeds.set id,0,0.,0.0,-0.0
    seeds.mode=0x101
    SeedForm=MakeList()
  end if
  picked=100 'always selected
  seeds.act
  scale 10
  move 0,0,-1
  SilverMaterial.act
  go SeedForm
  popstate
  '
  'F1 HELP
  '
  if key[0x70]
    flat
    pushstate
    move 20,0
    color .9,.9,.9
    scale  1.5,1.0
    printl "Active Keys:"
    printl
    scale  1/1.5,1.0
    printl "Esc"    tab "Exit"
    printl "Ctrl-P" tab "Take snapshot"
    printl "F1 This help panel"
    printl "Arrow keys PgUp PgDn to move"
    printl "Ctrl Arrow keys PgUp PgDn to rotate"
    printl "+ - keys to scale up and scale down"
    printl "Ctrl Home to reset rotation"
    printl "Shift for faster movement"
    printl
    scale 1.5,1.0
    printl "Mouse:"
    printl
    scale 1/1.5,1.0
    printl "Point to Object, then"
    printl "Left button to move"
    printl "Middle button to scale"
    printl "Right button to rotate"
    printl "Wheel to move in Z direction"
    popstate
  end if
  picklabel 0
  lastkey=0
  lastchar=0
  end function

  EndScript

http://www.thinbasic.com/community/showthread.php?12534-Natural-things-TBGL-geometry&p=91844#post91844

.
« Last Edit: February 14, 2015, 05:14:00 PM by Charles Pegge »