To make a long story short, I think I have solved my
second Question which I called Rotxyz, and I fixed some bugs
in another eye movement facility I reported earlier. I have
also updated the revised version of tgsj3ogl.ijs to the
jwiki.

        The Rotxyz question became easier to think about
when I realized rotating objects around any axis is the same
as but in the opposite direction as rotating the Eye around
the origin if the Eye moves only in the axes planes and this
is exactly the purpose of the arrow key and PageUp/Dn
actions of gldemo.

        I have not yet worked on Raul's suggestion about
detecting F4 in the other question.

        Below I give some more details about updates and
revisions applied by the summary above.

On Fri, 22 Dec 2006, Brian Schott wrote:

        [snip]


+
+       The challenge for me of late has been to translate
+ (gldemo) keystroke control results into (tgsj) program
+ control results and vice versa. I though I had a way of
+ doing this when I asked the forum about finding an
+ inverse to gluLookAt that Raul created and named gluAtLook,
+ but that did not work for me as I had hoped. Raul's solution
+ was correct, my question was wrong.
+
+       Instead I have needed to (conditionally) pass
+ changes in various keystroke globals like GS_TRNXYZ and
+ GS_VIEWXYZ from gldemo to tgsj;  and in the reverse
+ direction, programming globals like (Eye&{) Position and
+ Heading and (Eye&{) State from tgsj to gldemo. When the
+ passing of globals is conditioned upon whether a keystroke
+ has been made by the user, a global flag noun, EyeQ, is set
+ to 1. The 'paint' verb checks for the status of EyeQ and
+ always resets EyeQ =: 0 on exit.

        The revised verb 'paint' is below the old one.
+
+ paint =: monad define
+   wd'psel opengl;pactive'
+   if. gsinit GS_LIGHT do. tgsj_run'' end.
+
+       NB. lots snipped out here *******************
+
+   if. EyeQ
+   do.
+     Heading =:  DEGREE (<Eye,DIR)}Heading
+     heading =. ,ROT gsmp 3 3$eye state 'Heading'
+     State =: heading (;/Eye,. SN aindex 'Heading')}State
+     position =. VIEWXYZ- TRNXYZ
+     Position =: position Eye}Position
+     State =: position(;/Eye,.SN aindex'Position')}State
+   end.
+   gsfini''
+     VIEWXYZ =: TRNXYZ =: 3#0
+     DEGREE =: 0
+     ROT =: GS_ID3
+ )

paint =: monad define
  wd'psel opengl;pactive'
  if. gsinit GS_LIGHT do. tgsj_run'' end.

      NB. lots snipped out here *******************

  if. EyeQ
  do.
    DEGREE =: DEGREE+(<Eye,2-DIR){Heading
    Heading =:  (dfd DEGREE) (<Eye,2-DIR)}Heading
    heading =. ,ROT gsmp 3 3$eye state 'Heading'
    State =: heading (;/Eye,. SN aindex 'Heading')}State
    position =. GS_VIEWXYZ- GS_TRNXYZ
    Position =: position Eye}Position
    State =: position(;/Eye,.SN aindex'Position')}State
  end.
  gsfini''
    DEGREE =: 0
    ROT =: GS_ID3
)

+
+       In addition to the 'paint' verb in tgsj, the adverbs
+ 'turn' and 'advance' which are the bases for all
+ turtle rotations and translations in tgsj, set eponymous
+ global nouns such as
+
+ TRNXYZ  for GS_TRNXYZ  via a revised gstranslate in advance,
+ and
+ VIEWXYZ for GS_VIEWXYZ via a revised gsfly         in turn.
+

        It turns out that the extra nouns above TRNXYZ and
VIEWXYZ were not necessary, so a couple of verbs were
symplified as shown below.

+       The adverb 'advance' contains the following extra
+ code to supply information to gldemo.
+
+   if. eye y
+   do.
+     gstranslate -(eye y)* eye state OneHeading
+   end.
+

        gstranslate is no longer revised from its original
definition in jzopenglutil.ijs .

+       Where gstranslate is revised as follows.
+
+ gstranslate_jzopenglutil_=: 3 :'TRNXYZ=:GS_TRNXYZ=:GS_TRNXYZ+y'
+
+       The adverb 'turn' contains the following extra code
+ to supply information to gldemo.
+
+   if. eye y
+   do.
+     H =. +/&.:*: GS_VIEWXYZ
+     S =.   sin rfd -: eye D
+     C =. - cos rfd -: eye D
+     dsh =. +:H*S
+     select. type
+     case. 0 do.
+       (-eye D) gsfly GS_VIEWXYZ
+     case. 1 do.
+       (eye D) gsfly GS_VIEWUP
+       gstranslate dsh*C,0,S
+     case. 2 do.
+       (eye D) gsfly GS_VIEWXYZ gscross GS_VIEWUP
+       gstranslate dsh*S,C,0
+     end.
+   end.
+
+       Where gstranslate is revised as above and gszoom and
+ gsfly are revised as below.
+
        gszoom is no longer revised from its original
definition in jzopenglutil.ijs .

+ gszoom_jzopenglutil_=: 3 :'VIEWXYZ=:GS_VIEWXYZ=:GS_VIEWXYZ*y'
+ gsfly_jzopenglutil_=: 4 : 0
+   DEGREE =: x
+   ROT =: rot=. (rfd x) gsrotxyz y

        VIEWXYZ =: in the next line is not needed

+   VIEWXYZ=: GS_VIEWXYZ=: rot gsmp GS_VIEWXYZ
+   GS_VIEWUP=: rot gsmp GS_VIEWUP
+ )
+
+       I have two major questions, call them Char and
+ Rotxyz.
+
+ Question: Char
+
+       The key F4 is used in gldemo to snap the eye view
+ back to the previously initialized position set by pressing
+ F3. This works fine in opengl, but I have not found a way to
+ detect the press of the F4 key so that I can trigger the
+ EyeQ=:1 flag necessary for 'paint' to do its thing. At
+ present I have revised the gldemo verb gscharJAVA as
+ follows, but it does not recognize F4.
+
+ gscharJAVA_jzopenglutil_=: 3 : 0
+   key=. Jout {~ Jin i. {. sysdata
+   ('1' = {.sysmodifiers) gskey key
+   EyeQ =: 1   NB. Flag for programmed eye movement
+   gspaint''
+ )
+
+       The problem in gscharJAVA_jzopenglutil_ above may
+ originate in the anonymous verb below that does not
+ recognize F4 in its Jin and Jout nouns. I have attempted to
+ detect the F4 key using wd'q' and wdq, but without success.
+
+ 3 : 0''
+ if. IFJAVA do.
+   Jin=: (16 17 20 22 21 23 { a.), '123456789iojklxyz',a.
+   Jout=: 33 34 37 39 38 40, a.i.'123456789IOJKLXYZ',a.
+   gschar=: gscharJAVA f.
+ else.
+   Wkey=: 33 34 37 39 38 40, a.i.'123456789IOJKLXYZ'
+   Wkeystate=: 'qkeystate *',Wkey{a.
+   Wshiftstate=: 'qkeystate *',16{a.
+   gschar=: gscharWDW f.
+ end.
+ i.0 0
+ )
+
+ Question: Rotxyz
+
+       gldemo keystrokes x,X,y,Y,z, and Z produce rotations
+ of all the objects around the corresponding axis, either
+ clockwise or anticlockwise. No such programmable turtle (or
+ eye) commands exist in tgsj, so there is no need to send
+ information from tgsj to gldemo, but for now I do not know
+ what information to send nor how to send such information
+ from gldemo to tgsj. The gldemo verb gsrotate is built
+ around the global nouns GS_ROTXYZ and GS_ROTNDX and by a
+ slew of verbs with names prefixed by gsrot... and gsflip...
+ which manage and use the global nouns.
+
+       At present the user of tgsj should be warned not to
+ use the gldemo axis-rotation keystrokes x,X,y,Y,z, and Z,
+ because they are not integrated with tgsj. I am not yet
+ convinced that a translation from gldemo to tgsj can be
+ created even though the corresponding gldemo
+ axis-translation keystrokes j,J,k,K,l and L have been
+ incorporated.
+
+       Another minor question involves the *different*
+ scale used in tgsj for eye translations and turtle
+ translations. All eye translations use the gldemo scale of
+ small numbers, say between _3 and 3.  All turtle
+ translations use larger numbers, of absolute value between
+ about 5 and 100. This is no major problem, and I like the
+ separate scales, but it is not so nice in the same system.
+
+       Well this has been quite a long message. At least it
+ has helped *me* to take the time to write it. If anyone has
+ the time to look into it further, I have put the script
+ tgsj3ogl.ijs on the jwiki at
+
+ http://www.jsoftware.com/jwiki/BrianSchott/code/turtleGraphics/3Dogl
+
+       I have not been able to work on any nonJava
+ version because I have access only to a Mac. Also, note
+ that the other script dancersogl.ijs at this link is not
+ needed.
+
+ (B=) <----------my "sig"
+

(B=) <----------my "sig"

Brian Schott
Atlanta, GA, USA
schott DOT bee are eye eh en AT gee em ae eye el DOT com
http://schott.selfip.net/~brian/
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to