Brian Schott wrote:
>       Can anyone suggest a correction for this script?

Here's how I'd approach it with the m beta.

I did not understand some of your script, so I grabbed
a copy of Oleg's code from the jwiki and pounded on it
until it seemed right.

Here's a summary of these steps:

[1] Created a wd wrapper class
[2] Incorporated Oleg's code
[3] Split his paint method into size and paint event handlers.
[3a] put initialization code into the size event handler,
with initial rendering into a list
[3b] use draw_keep instead of draw
[4] Hacked the size event handler so it would work on resize.
[5] clear the stuff I need to be cleared in the paint event
[6] pulled the positioning code out of gsinit into the paint event 

-- 
Raul

coclass'lorenzdemo'
(coinsert[require)'jzopengl jzopenglutil'

P=: 0 : 0
pc p;
xywh 0 0 200 150;cc c isigraph rightmove bottommove;
pas 0 0;
rem form end;
pshow;
)

create=: 3 : 0
 create_jzopengl_ f.y
 wd P
 ogl=:coname''
 p_c_size''
)

destroy=: 3 : 0
 wd'pclose'
 destroy_jzopengl_ f.''
)

p_close=: destroy


NB. =========================================================
NB. Lorenz Attractor - for OpenGL demo, j601
NB. 04/29/06 by Oleg Kobchenko
NB. http://www.jsoftware.com/jwiki/Essays/Lorenz_Attractor

'`X Y Z'=: (0&{)`(1&{)`(2&{)
' s r b'=: 10 , 28 , 8%3

dx=: s*(Y - X)
dy=: (X * r - Z) - Y
dz=: (X*Y) - b*Z

dt=: 0.01
I=: + dt * dx,dy,dz

NB. =========================================================
COUNT=: 4000
L=: 0.07*I^:(<COUNT) 0 1 0
T=: -([:-:>./+<./)"1|:L

NB. =========================================================
SPHERESIZE=: 0.03
SPHERE=: 2041
GS_ROTXYZ=: 355.519 359.069 321.959
GS_TRNXYZ=: 0.025 0.325 0

NB. =========================================================
list_at=: 4 : 0 "1
  glPushMatrix ''
  glTranslate y
  glCallList x
  glPopMatrix ''
)
NB.__________________________________________________________

p_c_char=: gschar
paint=: p_c_paint

LORENZ=:2345

WH=:_1
p_c_paint=: 3 : 0
 NB. size event handler did not work for me
 wh=.glqwh''
 if.-.wh-:WH do.
  p_c_size_hack ''
  WH=:wh
 else.
  glLoadIdentity''
  gluLookAt GS_VIEWXYZ,0 0 0,GS_VIEWUP
  glTranslate GS_TRNXYZ
  glRotate GS_ROTNDX { GS_ROTXYZ ,. GS_ID3
 end.
 glClear GL_COLOR_BUFFER_BIT+GL_DEPTH_BUFFER_BIT
 glCallList LORENZ
 draw_keep''
)

p_c_size_hack=: 3 : 0
 gsinit GS_LIGHT
 quad=. {.>gluNewQuadric''
  
  gsnewlist SPHERE
   gluSphere quad,SPHERESIZE,10 10
  gsendlist''

  glPushMatrix''
  gscolor GRAY
  gsnewlist LORENZ
   glTranslate T
   SPHERE list_at L
  gsendlist''
  glPopMatrix''
   
 gluDeleteQuadric quad
)


0 !: 101 (0 : 0)
 ''conew'lorenzdemo'
)


----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to