Slider Box changes triangle Size

Started by Frank Brübach, November 29, 2023, 07:31:10 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Frank Brübach

Good evening
Overlap Panel sliders

Made an OpenGL example for moving better: changing the Size of triangle by Slider boxes and IT Works but... By moving whole sliderbox thats a funny effect

If you move sliderbox 1 (Control 1)  Up or down or left the triangle moves Changes Size  in y Direction
Move Control 101 or 201 sliderboxes triangle Size Changes moves to x y Direction

My Intention was however to Change triangle size by every Slider panel movements ;)

Little Help is Welcome again thx Frank

PS Code will be updated soon :)

Frank Brübach

#1
Hi charles... sorry No choice...
I have No Idea how to implement correct separately every Slider Panel movements to Change the triangle Size

In my example the whole sliderbox Change triangle Size thats OK but Not wished ;)

What's one single Slider Panel AS function?

Any Help is Welcome :


  #compact
  '-------- slider controls with labels and influences to triangle size
  '-------- 27-31.11.2023 by frank brübach, oxygen basic
  '-------- openGL, ControlPanelsOverlap try 3c, 02.12.2023
  '--------
  $ FileName  "co.exe"
  'uses RTL64
  'uses console
  '
  % ExplicitMain
  $ title        "Panels Overlap with triangle"
  $ fontA        "Arial",FW_SEMIBOLD

  'macro keydown
  'case 27 : 'no action
  'case 32 : 'no action
  'end macro
  '
  uses OpenglSceneFrame
  uses ControlPanels

  indexbase 1
  sys       texn[16]
  sys       GdiplusToken
  float     ang1
  sys       cube,pent


  sub initialize(sys hWnd)
  ========================
  '
  GDIplus 1
  '
  cube=CompileList : CubeForm    : glEndList
  end sub


  sub Release(sys hwnd)
  =====================
  glDeleteLists    cube,1
  glDeleteLists    pent,1
  Gdiplus 0
  end sub



  uses controls
  ===================
  class ControlPanelA
  ===================
  float  x,y,z
  int    id
  float  xx,yy,zz
  float  dx,dy,dz
  float  sc
  int    lock
  int    t1,t2
  int    f1,f2
  string lbl
  ===================
  sliders      c[4]
  lightbuttons l[4]
  ===================

  method act(optional int n)
  indexbase 1
  if id=0
    f1=0 'cube
    f2=0 'pent
    --------------------------------------------------------------------------
    'ctrl   x    y   z     sc    shm shb tex id  lk  lbl
    --------------------------------------------------------------------------
    c[1]=>-.40,-.00, .00,  0.10, f1, 00, t1, 10, 1, "slider"
    c[2]=>-.30,-.00, .00 , 0.10, f2, 00, t1, 20, 1, "slider"
    c[3]=>-.20,-.00, .00 , 0.10, f2, 00, t1, 30, 1, "slider"
    c[4]=>-.10,-.00, .00 , 0.10, f2, 00, t1, 40, 1, "slider"
    -------------------------------------------------------------------------
    l[1]=>-.40, .15, .00,  0.02, f1, 00, t1, 50, 1, "light button"
    l[2]=>-.30, .15, .00 , 0.02, f2, 00, t1, 60, 1, "light button"
    l[3]=>-.20, .15, .00 , 0.02, f2, 00, t1, 70, 1, "light button"
    l[4]=>-.10, .15, .00 , 0.02, f2, 00, t1, 80, 1, "light button"
    --------------------------------------------------------------------------
    id=1+n
    int i
    for i=1 to 4
      c[i].id+=n
      l[i].id+=n
    next
  end if
  '
  glpushmatrix
  gltranslatef  x,y,z
  '
  gltranslatef -.25,.0,-.0005
  if sc then glscalef sc,sc,1.0
  if pick
    PickLabel id
  else
    QuadShadow .20,.20,.005,.5
    glcolor3f     .60,.50,.60 'fix alpha bug
    glcolor4f     .60,.50,.60,0.50 'box
  endif
  QuadTex       .20,.20,.0.01
  gltranslatef  .25,.0,-.0
  '
  'DISPLAY PANEL LABEL
  if lbl
    glpushmatrix
    gltranslatef -.43,-.18,.0005
    glcolor4f .9,.9,.0,.8
    glscalef  .04,.04,.04
    gprint lbl
    glpopmatrix
  endif
  '
  '
  if bleft
    if picked=id
      if not lock
        drag(dx,dy,1.0/sc)
        x=xx+dx : y=yy+dy
      end if
    end if
  else
    xx=x : yy=y : zz=z 'ANCHOR
  end if
  '
  'render
  '
  int i,oi1,oi2
  for i=1 to 4
    c[i].act(1,i,oi1)
    l[i].act(1,i,oi2)
  next
  glpopmatrix
  '
  'show data
  '
  'glDisable GL_TEXTURE_2D
  glDisable GL_LIGHTING
  '
  glPushMatrix
  glLoadIdentity
  if pick
    PickLabel 0
  endif
  gltranslatef -.5,.35,-1.0
  float w,h
  glscalef     .05,.05,.01
  GetWordArea  "Control:",w,h
  if pick
    PutBoxArea   w,h
  else
    glColor3f    .99,.99,.00
    gprint       "Controls: "
    glColor3f    .99,.99,.99
    gprint    str(picked)
    if oi1+oi2
      gprint "   "
      if oi1 then gprint str((1.0+c[oi1].vy)*50 , 0)
      if oi2 then gprint str (l[oi2].lit)
    end if
  end if
  glPopMatrix
  end method
  '
  method destructor()
  ===================
  'del this.label
  'sliders      c[4]
  'lightbuttons l[4]
  int i
  for i=1 to 4
    c[i].destructor
  next
  for i=1 to 4
    l[i].destructor
  next
  end method
  '
  end class

  '#recordof ControlPanelA

  ===================
  sub scene(sys hWnd)
  ===================
  '
  static single ra,ri,angi1=.5
  static sys    initscene
  '
  DozyFrame
 'glClearColor 0.5, 0.5, 0.7, 0
  glClearColor 0.1, 0.2, 0.1, 0
  BeginPick
  '
  glColor4f .99,.99,.99,.99
  'glEnable GL_TEXTURE_2D
  '
  'RENDERED LOWEST FIRST (FOR TRANSPARENCY BLENDING)
  '
  %                    ordn=4 '3
  static ControlPanelA cb[ordn]
  static int           ord[16]
  static int           idb[16]
  '
  if closing
    int i
    for i=1 to 4' 3
      cb[i].destructor
    next
    exit sub
  endif
  string lbl
  'DISPLAY PANEL LABEL
  if lbl
    glpushmatrix
    gltranslatef -.43,-.18,.0005
    glcolor4f .9,.9,.0,.8
    glscalef  .04,.04,.04
    gprint lbl
    glpopmatrix
  endif
 
  'INITIAL PLACEMENT ETC
  '
  if initscene=0
    ord={1,2,3,4}
    idb={0,100,200,300}
    cb[1].x=.0 : cb[1].y=.00 : cb[1].lbl="Panel X"
    cb[2].x=.1 : cb[2].y=.05 : cb[2].lbl="Panel Y"
    cb[3].x=.2 : cb[3].y=.10 : cb[3].lbl="Panel Z"
    cb[4].x=.4 : cb[4].y=.15 : cb[4].lbl="master"
    int i
    'set scale
    for i=1 to ordn : cb[i].sc=0.5 : next 'cb[i].sc=2.5
    initscene=1
  end if
 
  '
  'ORDER OF BUILD (SUPPORTING TRANSPARENCY)
  '
  if picked and bleft
    int a=1+trunc(picked/100)
    PlaceTop(a,ord,ordn)
  end if
  '
  'BUILD
  '
  ''glpushmatrix
  static float layr=.001
  static float f = -1 - layr*ordn
  gltranslatef .0, .0, f
  int i,j
  for i=1 to ordn
    j=ord[i]
    cb[j].act idb[j]
    gltranslatef .0, .0, layr 'next micro-layer in front
  next

'-------------Triangle transformations but not with every slider ;)
'
glPushMatrix
glTranslatef 0.0, 0.0, -1.15
'glRotatef ang1, 0.0, 0.0, 1.0

// Triangle drawing code
glBegin GL_TRIANGLES
  glColor3f   1.0, 0.0, 0.0
  glVertex3f 0.0, cb[1].y, 0.0 ''good 90 per cent
 
  glColor3f   0.0, 1.0, 0.0
  glVertex3f -cb[2].x, -cb[2].y, 0.0 ''good 90 per cent
 
  glColor3f   0.0, 0.0, 1.0
  glVertex3f cb[3].x, -cb[3].y, 0.0  ''good 90 per cent

glEnd
glPopMatrix
EndPick
  '
  'ang1+=angi1
  if ang1>=360 then ang1-=360
  '
  end sub
  '
  MainWindow 200+width,200+height,WS_OVERLAPPEDWINDOW 'WS_POPUP



PS Or its a complete Other way of going by Translation the glVertex3f ,?  More Here?
Gltranslatef 0,0,0 for Slider effects?

Charles Pegge

#2
Hi Frank,
I've cleaned up the previous and linked color/transparency to one slider panel. I hope this answers your questions and resolves the issues you were having.

'-------- experiment to combine triangle data with slider overlapped
  '-------- oxygenbasic, by frank brübach, 27-11-2023
  '
  '17:29 03/12/2023 CP
  #compact
 '%filename "t.exe"
 'uses RTL64
  % Title "Triangle Data:  Move points with mouse and arrow keys etc"

 '% WindowStyle WS_OVERLAPPEDWINDOW
 '% Animated
 '% ScaleUp
  % PlaceCentral
  % AnchorCentral

  '% shaders

  uses consoleG
 'uses glo2/geoplanar
  'uses ControlPanels


  uses controls
  ===================
  class ControlPanelA
  ===================
  float  x,y,z
  int    id
  float  xx,yy,zz
  float  dx,dy,dz
  float  sc
  int    lock
  int    t1,t2
  int    f1,f2
  string lbl
  ===================
  sliders      c[4]
  lightbuttons l[4]
  ===================

  method act(optional int n)
  indexbase 1
  if id=0
    f1=0 'cube
    f2=0 'pent
    ==========================================================================
    'ctrl   x    y   z     sc    shm shb tex id  lk  lbl
    --------------------------------------------------------------------------
    c[1]=>-.40,-.00, .00,  0.10, f1, 00, t1, 10, 1, "slider"
    c[2]=>-.30,-.00, .00 , 0.10, f2, 00, t1, 20, 1, "slider"
    c[3]=>-.20,-.00, .00 , 0.10, f2, 00, t1, 30, 1, "slider"
    c[4]=>-.10,-.00, .00 , 0.10, f2, 00, t1, 40, 1, "slider"
    -------------------------------------------------------------------------
    l[1]=>-.40, .15, .00,  0.02, f1, 00, t1, 50, 1, "light button"
    l[2]=>-.30, .15, .00 , 0.02, f2, 00, t1, 60, 1, "light button"
    l[3]=>-.20, .15, .00 , 0.02, f2, 00, t1, 70, 1, "light button"
    l[4]=>-.10, .15, .00 , 0.02, f2, 00, t1, 80, 1, "light button"
    ==========================================================================
    id=1+n
    int i
    for i=1 to 4
      c[i].id+=n
      l[i].id+=n
    next
  end if
  '
  glpushmatrix
  gltranslatef  x,y,z
  '
  gltranslatef -.25,.0,-.0005
  if sc then glscalef sc,sc,1.0
  if pick
    PickLabel id
  else
    QuadShadow .20,.20,.005,.5
    glcolor3f     .60,.50,.60 'fix alpha bug
    glcolor4f     .60,.50,.60,0.50 'box
  endif
  QuadTex       .20,.20,.0.01
  gltranslatef  .25,.0,-.0
  '
  'DISPLAY LABELS
  if lbl
    glpushmatrix
    gltranslatef -.43,-.13,.0005
    glcolor4f .9,.9,.4,.9
    float j=0.015
    'DISPLAY EACH SLIDER VALUE
    for i=1 to 4
      glpushmatrix
      gltranslatef j,0,0
      glscalef  .035,.035,.035
      if pick
        gltranslatef -.1,-.18,.0
        picklabel id+i
        PutBoxArea 2,1
        gltranslatef .1,.18,.0
      else
        if picked=id+i 'edit
          ------------
          'DATA EDITING
          color 0.9,0.9,0.9
          'box-around
          gltranslatef -.1,-.18,.0
          glBegin GL_LINE_STRIP
          glVertex2f 0,0
          glVertex2f 2,0
          glVertex2f 2,1
          glVertex2f 0,1
          glVertex2f 0,0
          glEnd
          gltranslatef .1,.18,.0
          '
          static string ss
          ss= str(50+c[i].vy*50,0) '0..100
          input ss
          c[i].vy=(val(ss)-50) *0.02
          '
          static int cpick,cy,cx
          if cpick<>picked
            cp=le+1 'place cursor at end of string
            cy=y
            cx=x
            cpick=picked
          endif
          '
          select lastkey
          case VK_UP
            c[i].vy+=0.01
          case VK_DOWN
            c[i].vy-=0.01
          case VK_PRIOR 'PGUP
            c[i].vy+=0.01
          case VK_NEXT 'PGDN
            c[i].vy-=0.01
          case 9 'tab
            if GetAsyncKeyState(VK_SHIFT)=0
              picked++
              if picked>id+4
                picked=id+4
              end if
            else 'left
              picked--
              if picked<id+1
                picked=id+1
              endif
            endif
          end select
          lastkey=0
          lastchar=0
        else 'display
          gprint str(50+c[i].vy*50,0) '0..100
          'gprint str((c[i].vy)*100 , 0) -100..100
        endif
      endif
      glpopmatrix
      j+=0.1
    next
    'DISPLAY MAIN PANEL LABEL
    gltranslatef 0,-.05,0
    glscalef  .04,.04,.04
    glcolor4f .9,.9,.0,.9
    gprint lbl
    glpopmatrix
  endif
  '
  '
  if bleft
    if picked=id
      if not lock
        drag(dx,dy,1.0/sc)
        x=xx+dx : y=yy+dy
      end if
    end if
  else
    xx=x : yy=y : zz=z 'ANCHOR
  end if
  '
  'render
  '
  int i,oi1,oi2
  for i=1 to 4
    c[i].act(1,i,oi1)
    l[i].act(1,i,oi2)
  next
  glpopmatrix
  '
  'show data
  '
  'glDisable GL_TEXTURE_2D
  glDisable GL_LIGHTING
  '
  glPushMatrix
  glLoadIdentity
  if pick
    PickLabel 0
  endif
  gltranslatef -.5,.35,-1.0
  float w,h
  glscalef     .05,.05,.01
  GetWordArea  "Control:",w,h
  if pick
    PutBoxArea   w,h
  else
    /*
    glColor3f    .99,.99,.00
    gprint       "Control: "
    glColor3f    .99,.99,.99
    gprint    str(picked)
    if oi1+oi2
      gprint "   "
      if oi1 then gprint str((1.0+c[oi1].vy)*50 , 0)
      if oi2 then gprint str (l[oi2].lit)
    end if
    */
  end if
  glPopMatrix
  end method
  '
  method destructor()
  ===================
  'del this.label
  'sliders      c[4]
  'lightbuttons l[4]
  int i
  for i=1 to 4
    c[i].destructor
  next
  for i=1 to 4
    l[i].destructor
  next
  end method
  '
  end class

  '#recordof ControlPanelA



  'Keys: Esc, arrow-keys, n,m, F4

  indexbase 1
  sys       texn[16]
  sys       GdiplusToken
  float     ang1
  sys       cube,pent



  BeginScript

  procedure main() 'triangle-data example
  ================

  static single ra,ri,angi1=.5
  static sys    initscene
  sys hwnd
  static float rr=.5,gg=.5,bb=.5,aa=.8 'object color
  '
  '
'--------------------------------------------------- //
  'WaitForEvent '0 off 1 on (default on)
  static quad t1,t2

  if opening 'FIRST CALL ONLY
    timemark t1
    'picked=100
    'mbox "helo"
  end if
  '
  if closing 'FINAL CALL BEFORE SHUTDOWN
    'mbox "Bye!"
    exit sub
  end if
  cls

  subroutine ShowPolygon
  ======================
  move 0,0,-1
  shading
  UserMovement mu,1100,3 'symbol identity, count
  if opening
    mu[1].x= 0
    mu[1].y= 5
    mu[2].x=-5
    mu[2].y=-5
    mu[3].x= 5
    mu[3].y=-5
  endif
  scale 1
  picklabel 0
  int i
  for i=1 to 3
    pushstate
    mu[i].act
    color 1,.9,0,1
    scale 0.4
    go sphere
    popstate
  next
  float xa,xb,xc,ya,yb,yc
  xa=mu[1].x : ya=mu[1].y
  xb=mu[2].x : yb=mu[2].y
  xc=mu[3].x : yc=mu[3].y
  '
  'MOUSE DRAG ADJUSTMENT
  select picked
    case 1100 : xa+=mu[1].d.x : ya+=mu[1].d.y
    case 1200 : xb+=mu[2].d.x : yb+=mu[2].d.y
    case 1300 : xc+=mu[3].d.x : yc+=mu[3].d.y
  end select
  flat
  thickness 2
  '
  color 1,1,0,1
  pushstate
  move xa-.5,ya-1
  gprint "A"
  popstate
  pushstate
  move xb+1,yb+1
  gprint "B"
  popstate
  pushstate
  move xc-1,yc+1
  gprint "C"
  popstate
  '
  color rr,gg,bb,aa 'linked to slider panel 1
  float zp=-1.001
  glBegin GL_TRIANGLES
  glVertex3f xa,ya,zp
  glVertex3f xb,yb,zp
  glVertex3f xc,yc,zp
  glEnd
  '
  color 0,.9,.9
  glBegin GL_LINES
  glVertex2f xa,ya
  glVertex2f xb,yb
  glVertex2f xb,yb
  glVertex2f xc,yc
  glVertex2f xc,yc
  glVertex2f xa,ya
  glEnd

  move 5

  'if not pick then
    if key[49] then picked=100 'keypress '1'
    if key[50] then picked=200 'keypress  '2'
    pushstate
    move -20,12
    static sys tally
    timemark t2
    scale 1.0
    '
    int dp=3
    '
    macro pr1(a) 'PRINTING LIST
    -----------------------------
      pushstate : color .5,1,1 : print a : popstate
      printl ""
    end macro
    '
    macro pr2(a,b) 'PRINTING LIST
    -----------------------------
      pushstate : color .5,1,1 : print a : popstate
      pushstate : color 1,1,.5 : move 4 : print str(b,dp) : popstate
      printl ""
    end macro
    '
    macro pr3(a,b,c) 'PRINTING LIST
    ------------------------------
      pushstate : color .5,1,1 : print a : popstate
      pushstate : color 1,1,.5 : move 4 : print str(b,dp) : popstate
      pushstate : color 1,1,.5 : move 8 : print str(c,dp) : popstate
      printl ""
    end macro
    '
    '
    'DISPLAY INFO
    -------------
    picklabel 0

    pushstate
    scale 2
    color 1,1,1
    print "Triangle Data"
    popstate
    pr1 ""
    pr1 ""
   'pr2 "Action Code:   ", act
   'pr2 "indexbase      ", indexbase
   'pr2 "Keyboard Code: ", keyd
    pr2 "Picked ID:     ", picked
    '
    pr3 "Point A: ", str(xa,3), ya
    pr3 "Point B: ", str(xb,3), yb
    pr3 "Point C: ", str(xc,3), yc
    '
    float ab,ac,bc,ar,ht,hb
    '
    ab=hypot(xa-xb, ya-yb)
    ac=hypot(xa-xc, ya-yc)
    bc=hypot(xb-xc, yb-yc)
    '
    hb=0.5* ( ab*ab - ac*ac + bc*bc ) / bc
    ht=sqr(ab*ab-hb*hb)
    ar=0.5*bc*ht

    'ANGLES
    float na,nb,nc
    nb=deg(asin(ht/ab))
    nc=deg(asin(ht/ac))
    na=180-nb-nc

    pr1 ""
    pr2 "Angle A:",na
    pr2 "Angle B:",nb
    pr2 "Angle C:",nc
  
    pr1 ""
    pr2 "Line AB:",ab
    pr2 "Line AC:",ac
    pr2 "Line BC:",bc
    pr2 "Left base:",hb
    pr2 "Height:",ht
    pr2 "Area:", ar
    pr1 ""
    '
    picklabel 0
    popstate
  'end if
  end subroutine

  '--------------------
  'end polygon display
  '--------------------

  'PANEL DISPLAY
  ==============

  static single ra,ri,angi1=.5
  static sys    initscene
 
  '------------------------------
 'glClearColor 0.5, 0.5, 0.7, 0
 'glClearColor 0.1, 0.2, 0.1, 0
  '
  glColor4f .99,.99,.99,.99
  'glEnable GL_TEXTURE_2D
  '
  'RENDERED LOWEST FIRST (FOR TRANSPARENCY BLENDING)
  '
  %                    ordn=1
  static ControlPanelA cb[ordn]
  static int           ord[16]
  static int           idb[16]
  '
  if closing
    int i
    for i=1 to ordn
      cb[i].destructor
    next
    exit sub
  endif
 
  '
  'INITIAL PLACEMENT ETC
  '
  if initscene=0
    ord={1,2,3}
    idb={0,100,200}
    cb[1].x=.8 : cb[1].y=.6 : cb[1].lbl="Color"
    int i
    'set scale
    for i=1 to ordn : cb[i].sc=2.5 : next
    initscene=1
  end if
  '
  'ORDER OF BUILD (SUPPORTING TRANSPARENCY)
  '
  if picked and bleft
    int a=1+trunc(picked/100)
    PlaceTop(a,ord,ordn)
  end if
  '
  'RENDER SCENE
  '
  move 0,0,-1
  gosub ShowPolygon
  move 0,0,1
  '
  glpushmatrix
  static float layr=.001
  static float f = -1 - layr*ordn
  glscalef 15,15,1
  gltranslatef .0, .0, f
  int i,j
  for i=1 to ordn
    j=ord[i]
    cb[j].act idb[j]
    gltranslatef .0, .0, layr 'next micro-layer in front
  next
  '
  'LINK TO SLIDERS
  'COLOR
  rr=0.5+cb[1].c[1].vy*.5
  gg=0.5+cb[1].c[2].vy*.5
  bb=0.5+cb[1].c[3].vy*.5
  aa=0.5+cb[1].c[4].vy*.5
  glpopmatrix
  '
  '
  '
  '
 
'  ang1+=angi1
'  if ang1>=360 then ang1-=360
 
  end procedure 'main
  EndScript

Frank Brübach

#3
First of all thank you Charles :) Looks good!

It's Not quite clear for me to Setup a Second sliderbox with Size Manipulation of the triangle..

Look at my Code example more to the end If I need the Link to Slider Go through a separately Slider function Like cb(I).act idb(j) can modified by cb(I).act mu(j).x ?

Code example:


'
'-------- experiment to combine triangle data with slider overlapped
'-------- oxygenbasic, by frank brübach, 27-11-2023, 04-12-23
  '
  #compact
 '%filename "t.exe"
 'uses RTL64
  % Title "Triangle Data:  Move points with mouse and arrow keys etc"

 '% WindowStyle WS_OVERLAPPEDWINDOW
 '% Animated
 '% ScaleUp
  % PlaceCentral
  % AnchorCentral

  '% shaders

  uses consoleG
 'uses glo2/geoplanar
  'uses ControlPanels


  uses controls
  ===================
  class ControlPanelA
  ===================
  float  x,y,z
  int    id
  float  xx,yy,zz
  float  dx,dy,dz
  float  sc
  int    lock
  int    t1,t2
  int    f1,f2
  string lbl
  float  sizer 'for sizing the triangle by sliders
  ===================
  sliders      c[4]
  lightbuttons l[4]
  ===================

  method act(optional int n)
  indexbase 1
  if id=0
    f1=0 'cube
    f2=0 'pent
    ==========================================================================
    'ctrl  x    y  z    sc    shm shb tex id  lk  lbl
    --------------------------------------------------------------------------
    c[1]=>-.40,-.00, .00,  0.10, f1, 00, t1, 10, 1, "slider"
    c[2]=>-.30,-.00, .00 , 0.10, f2, 00, t1, 20, 1, "slider"
    c[3]=>-.20,-.00, .00 , 0.10, f2, 00, t1, 30, 1, "slider"
    c[4]=>-.10,-.00, .00 , 0.10, f2, 00, t1, 40, 1, "slider"
    -------------------------------------------------------------------------
    l[1]=>-.40, .15, .00,  0.02, f1, 00, t1, 50, 1, "light button"
    l[2]=>-.30, .15, .00 , 0.02, f2, 00, t1, 60, 1, "light button"
    l[3]=>-.20, .15, .00 , 0.02, f2, 00, t1, 70, 1, "light button"
    l[4]=>-.10, .15, .00 , 0.02, f2, 00, t1, 80, 1, "light button"
    ==========================================================================
    id=1+n
    int i
    for i=1 to 4
      c[i].id+=n 'slider
      l[i].id+=n 'light button
    next
  end if
  '
  glpushmatrix
  gltranslatef  x,y,z
  '
  gltranslatef -.25,.0,-.0005
  if sc then glscalef sc,sc,1.0
  if pick
    PickLabel id
  else
    QuadShadow .20,.20,.005,.5
    glcolor3f    .60,.50,.60 'fix alpha bug
    glcolor4f    .60,.50,.60,0.50 'box
  endif
  QuadTex      .20,.20,.0.01
  gltranslatef  .25,.0,-.0
  '
  'DISPLAY LABELS
  if lbl
    glpushmatrix
    gltranslatef -.43,-.13,.0005
    glcolor4f .9,.9,.4,.9
    float j=0.015
    'DISPLAY EACH SLIDER VALUE
    for i=1 to 4
      glpushmatrix
      gltranslatef j,0,0
      glscalef  .035,.035,.035
      if pick
        gltranslatef -.1,-.18,.0
        picklabel id+i
        PutBoxArea 2,1
        gltranslatef .1,.18,.0
      else
        if picked=id+i 'edit
          ------------
          'DATA EDITING
          color 0.9,0.9,0.9
          'box-around
          gltranslatef -.1,-.18,.0
          glBegin GL_LINE_STRIP
          glVertex2f 0,0
          glVertex2f 2,0
          glVertex2f 2,1
          glVertex2f 0,1
          glVertex2f 0,0
          glEnd
          gltranslatef .1,.18,.0
          '
          static string ss
          ss= str(50+c[i].vy*50,0) '0..100
          input ss
          c[i].vy=(val(ss)-50) *0.02
          '
          static int cpick,cy,cx
          if cpick<>picked
            cp=le+1 'place cursor at end of string
            cy=y
            cx=x
            cpick=picked
          endif
          '
          select lastkey
          case VK_UP
            c[i].vy+=0.01
          case VK_DOWN
            c[i].vy-=0.01
          case VK_PRIOR 'PGUP
            c[i].vy+=0.01
          case VK_NEXT 'PGDN
            c[i].vy-=0.01
          case 9 'tab
            if GetAsyncKeyState(VK_SHIFT)=0
              picked++
              if picked>id+4
                picked=id+4
              end if
            else 'left
              picked--
              if picked<id+1
                picked=id+1
              endif
            endif
          end select
          lastkey=0
          lastchar=0
        else 'display
          gprint str(50+c[i].vy*50,0) '0..100
          'gprint str((c[i].vy)*100 , 0) -100..100
        endif
      endif
      glpopmatrix
      j+=0.1
    next
    'DISPLAY MAIN PANEL LABEL
    gltranslatef 0,-.05,0
    glscalef  .04,.04,.04
    glcolor4f .9,.9,.0,.9
    gprint lbl
    glpopmatrix
  endif
  '
  '
  if bleft
    if picked=id
      if not lock
        drag(dx,dy,1.0/sc)
        x=xx+dx : y=yy+dy
      end if
    end if
  else
    xx=x : yy=y : zz=z 'ANCHOR
  end if
  '
  'render
  '
  int i,oi1,oi2
  for i=1 to 4
    c[i].act(1,i,oi1) 'slider
    l[i].act(1,i,oi2) 'lightbutton
  next
  glpopmatrix
  '
  'show data
  '
  'glDisable GL_TEXTURE_2D
  glDisable GL_LIGHTING
  '
  glPushMatrix
  glLoadIdentity
  if pick
    PickLabel 0
  endif
  gltranslatef -.5,.35,-1.0
  float w,h
  glscalef    .05,.05,.01
  GetWordArea  "Control:",w,h
  if pick
    PutBoxArea  w,h
  else
    /*
    glColor3f    .99,.99,.00
    gprint      "Control: "
    glColor3f    .99,.99,.99
    gprint    str(picked)
    if oi1+oi2
      gprint "  "
      if oi1 then gprint str((1.0+c[oi1].vy)*50 , 0)
      if oi2 then gprint str (l[oi2].lit)
    end if
    */
  end if
  glPopMatrix
  end method
  '
  method destructor()
  ===================
  'del this.label
  'sliders      c[4]
  'lightbuttons l[4]
  int i
  for i=1 to 4
    c[i].destructor
  next
  for i=1 to 4
    l[i].destructor
  next
  end method
  '
  end class

  '#recordof ControlPanelA
  'Keys: Esc, arrow-keys, n,m, F4

  indexbase 1
  sys      texn[16]
  sys      GdiplusToken
  float    ang1
  sys      cube,pent

  '--------------------------------------- //
  BeginScript

  procedure main() 'triangle-data example
  ================

  static single ra,ri,angi1=.5
  static sys    initscene
  sys hwnd
  static float rr=.5,gg=.5,bb=.5,aa=.8 'object color
  static float sx,sy,sz
  '
  '
'--------------------------------------------------- //
  'WaitForEvent '0 off 1 on (default on)
  static quad t1,t2

  if opening 'FIRST CALL ONLY
    timemark t1
    'picked=100
    'mbox "helo"
  end if
  '
  if closing 'FINAL CALL BEFORE SHUTDOWN
    'mbox "Bye!"
    exit sub
  end if
  cls

  subroutine ShowPolygon
  ======================
  move 0,0,-1
  shading
  UserMovement mu,1100,3 'symbol identity, count
  if opening
    mu[1].x= 0
    mu[1].y= 5
    mu[2].x=-5
    mu[2].y=-5
    mu[3].x= 5
    mu[3].y=-5
  endif
  scale 1
  picklabel 0
  int i
  for i=1 to 3
    pushstate
    mu[i].act
    color 1,.9,0,1
    scale 0.4
    go sphere
    popstate
  next
  float xa,xb,xc,ya,yb,yc 'mu[i].act
  xa=mu[1].x : ya=mu[1].y
  xb=mu[2].x : yb=mu[2].y
  xc=mu[3].x : yc=mu[3].y
  '
  static float sx,sy,sz

  'MOUSE DRAG ADJUSTMENT
  select picked
    case 1100 : xa+=mu[1].d.x : ya+=mu[1].d.y
    'print "1100"
    case 1200 : xb+=mu[2].d.x : yb+=mu[2].d.y
    case 1300 : xc+=mu[3].d.x : yc+=mu[3].d.y
  end select
  flat
  thickness 2
  '
  color 1,1,0,1
  pushstate
  move xa-.5,ya-1
  gprint "A"
  popstate
  pushstate
  move xb+1,yb+1
  gprint "B"
  popstate
  pushstate
  move xc-1,yc+1
  gprint "C"
  popstate
  '
  color rr,gg,bb,aa 'linked to slider panel 1
  'sizer sx,sy,sz

  float zp=-1.001
  glBegin GL_TRIANGLES
  glVertex3f xa,ya,zp
  glVertex3f xb,yb,zp
  glVertex3f xc,yc,zp
  glEnd
  '
  color 0,.9,.9
  glBegin GL_LINES
  glVertex2f xa,ya
  glVertex2f xb,yb
  glVertex2f xb,yb
  glVertex2f xc,yc
  glVertex2f xc,yc
  glVertex2f xa,ya
  glEnd

  move 5

  'if not pick then
    if key[49] then picked=100 'keypress '1'
    if key[50] then picked=200 'keypress  '2'
    pushstate
    move -20,12
    static sys tally
    timemark t2
    scale 1.0
    '
    int dp=3
    '
    macro pr1(a) 'PRINTING LIST
    -----------------------------
      pushstate : color .5,1,1 : print a : popstate
      printl ""
    end macro
    '
    macro pr2(a,b) 'PRINTING LIST
    -----------------------------
      pushstate : color .5,1,1 : print a : popstate
      pushstate : color 1,1,.5 : move 4 : print str(b,dp) : popstate
      printl ""
    end macro
    '
    macro pr3(a,b,c) 'PRINTING LIST
    ------------------------------
      pushstate : color .5,1,1 : print a : popstate
      pushstate : color 1,1,.5 : move 4 : print str(b,dp) : popstate
      pushstate : color 1,1,.5 : move 8 : print str(c,dp) : popstate
      printl ""
    end macro
    '
    '
    'DISPLAY INFO
    -------------
    picklabel 0

    pushstate
    scale 2
    color 1,1,1
    print "Triangle Data"
    popstate
    pr1 ""
    pr1 ""
  'pr2 "Action Code:  ", act
  'pr2 "indexbase      ", indexbase
  'pr2 "Keyboard Code: ", keyd
    pr2 "Picked ID:    ", picked
    '
    pr3 "Point A: ", str(xa,3), ya
    pr3 "Point B: ", str(xb,3), yb
    pr3 "Point C: ", str(xc,3), yc
    '
    float ab,ac,bc,ar,ht,hb
    '
    ab=hypot(xa-xb, ya-yb)
    ac=hypot(xa-xc, ya-yc)
    bc=hypot(xb-xc, yb-yc)
    '
    hb=0.5* ( ab*ab - ac*ac + bc*bc ) / bc
    ht=sqr(ab*ab-hb*hb)
    ar=0.5*bc*ht

    'ANGLES
    float na,nb,nc
    nb=deg(asin(ht/ab))
    nc=deg(asin(ht/ac))
    na=180-nb-nc

    pr1 ""
    pr2 "Angle A:",na
    pr2 "Angle B:",nb
    pr2 "Angle C:",nc
 
    pr1 ""
    pr2 "Line AB:",ab
    pr2 "Line AC:",ac
    pr2 "Line BC:",bc
    pr2 "Left base:",hb
    pr2 "Height:",ht
    pr2 "Area:", ar
    pr1 ""
    '
    picklabel 0
    popstate
  'end if
  end subroutine

  '--------------------
  'end polygon display
  '--------------------

  'PANEL DISPLAY
  ==============

  static single ra,ri,angi1=.5
  static sys    initscene
 
  '------------------------------
 'glClearColor 0.5, 0.5, 0.7, 0
 'glClearColor 0.1, 0.2, 0.1, 0
  '
  glColor4f .99,.99,.99,.99
  'glEnable GL_TEXTURE_2D
  '
  'RENDERED LOWEST FIRST (FOR TRANSPARENCY BLENDING)
  '
  %                    ordn=2'1
  static ControlPanelA cb[ordn]
  static int          ord[16]
  static int          idb[16]
  '
  if closing
    int i
    for i=1 to ordn
      cb[i].destructor
    next
    exit sub
  endif
 
  '
  'INITIAL PLACEMENT ETC
  '
  if initscene=0
    ord={1,2,3,4}
    idb={0,100,200,300}
    cb[1].x=.8 : cb[1].y=.6 : cb[1].lbl="Color"
    cb[2].x=.8 : cb[2].y=.6 : cb[2].lbl="size"
    int i
    'set scale
    for i=1 to ordn : cb[i].sc=2.5 : next
    initscene=1
  end if
  '
  'ORDER OF BUILD (SUPPORTING TRANSPARENCY)
  '
  if picked and bleft
    int a=1+trunc(picked/100)
    PlaceTop(a,ord,ordn)
  end if
  '
  'RENDER SCENE
  '
  move 0,0,-1
  gosub ShowPolygon
  move 0,0,1
  '
  UserMovement mu,1100,3

  glpushmatrix
  static float layr=.001
  static float f = -1 - layr*ordn
  glscalef 15,15,1
  gltranslatef .0, .0, f
  int i,j
  for i=1 to ordn
    j=ord[i]
    cb[j].act idb[j] 'original
    'cb[2].act mu[1].x
    'cb[j].act mu[j].x
    cb[i].act mu[j].x
    gltranslatef .0, .0, layr 'next micro-layer in front
  next
  '
  'LINK TO SLIDERS
  'COLOR
  rr=0.5+cb[1].c[1].vy*.5 'c[1] slider
  gg=0.5+cb[1].c[2].vy*.5
  bb=0.5+cb[1].c[3].vy*.5
  aa=0.5+cb[1].c[4].vy*.5
  'glpopmatrix
  '----------------------------------- // slider to triangle size how?
  '---------- problem zone here ------ //
  float xa,xb,xc,ya,yb,yc ''mu[i].act
  xa=mu[1].x : cb[1].c[1].vy : ya=mu[1].y
  xb=mu[2].x : cb[1].c[1].vy : yb=mu[2].y
  xc=mu[3].x : cb[1].c[1].vy : yc=mu[3].y
  glpopmatrix
 
  '  ang1+=angi1
  '  if ang1>=360 then ang1-=360
 
  end procedure 'main
  EndScript



Charles Pegge

#4
Hi Frank,

The logistics are too complex when you can already drag the nodes to change the shape of the triangle. Perhaps at a later stage we can do this with a bounding box and resizer.

I have added a grid and made the information panel mobile. All the components of the scene are arranged in micro-layers so they do not conflict.

'-------- experiment to combine triangle data with slider overlapped
  '-------- oxygenbasic, by frank brübach, 27-11-2023
  '
  '17:29 04/12/2023 CP
  #compact
 '%filename "t.exe"
 'uses RTL64
  % Title "Triangle Data:  Move points with mouse and arrow keys etc"

 '% WindowStyle WS_OVERLAPPEDWINDOW
 '% Animated
 '% ScaleUp
  % PlaceCentral
  % AnchorCentral

  '% shaders

  uses consoleG
 'uses glo2/geoplanar
  'uses ControlPanels


  uses controls
  ===================
  class ControlPanelA
  ===================
  float  x,y,z
  int    id
  float  xx,yy,zz
  float  dx,dy,dz
  float  sc
  int    lock
  int    t1,t2
  int    f1,f2
  string lbl
  ===================
  sliders      c[4]
  lightbuttons l[4]
  ===================

  method act(optional int n)
  indexbase 1
  if id=0
    f1=0 'cube
    f2=0 'pent
    ==========================================================================
    'ctrl   x    y   z     sc    shm shb tex id  lk  lbl
    --------------------------------------------------------------------------
    c[1]=>-.40,-.00, .00,  0.10, f1, 00, t1, 10, 1, "slider"
    c[2]=>-.30,-.00, .00 , 0.10, f2, 00, t1, 20, 1, "slider"
    c[3]=>-.20,-.00, .00 , 0.10, f2, 00, t1, 30, 1, "slider"
    c[4]=>-.10,-.00, .00 , 0.10, f2, 00, t1, 40, 1, "slider"
    -------------------------------------------------------------------------
    l[1]=>-.40, .15, .00,  0.02, f1, 00, t1, 50, 1, "light button"
    l[2]=>-.30, .15, .00 , 0.02, f2, 00, t1, 60, 1, "light button"
    l[3]=>-.20, .15, .00 , 0.02, f2, 00, t1, 70, 1, "light button"
    l[4]=>-.10, .15, .00 , 0.02, f2, 00, t1, 80, 1, "light button"
    ==========================================================================
    id=1+n
    int i
    for i=1 to 4
      c[i].id+=n
      l[i].id+=n
    next
  end if
  '
  glpushmatrix
  gltranslatef  x,y,z
  '
  gltranslatef -.25,.0,-.0005
  if sc then glscalef sc,sc,1.0
  if pick
    PickLabel id
  else
    QuadShadow .20,.20,.005,.5
    glcolor3f     .60,.50,.60 'fix alpha bug
    glcolor4f     .60,.50,.60,0.50 'box
  endif
  QuadTex       .20,.20,.0.01
  gltranslatef  .25,.0,-.0
  '
  'DISPLAY LABELS
  if lbl
    glpushmatrix
    gltranslatef -.43,-.13,.0005
    glcolor4f .9,.9,.4,.9
    float j=0.015
    'DISPLAY EACH SLIDER VALUE
    for i=1 to 4
      glpushmatrix
      gltranslatef j,0,0
      glscalef  .035,.035,.035
      if pick
        gltranslatef -.1,-.18,.0
        picklabel id+i
        PutBoxArea 2,1
        gltranslatef .1,.18,.0
      else
        if picked=id+i 'edit
          ------------
          'DATA EDITING
          color 0.9,0.9,0.9
          'box-around
          gltranslatef -.1,-.18,.0
          glBegin GL_LINE_STRIP
          glVertex2f 0,0
          glVertex2f 2,0
          glVertex2f 2,1
          glVertex2f 0,1
          glVertex2f 0,0
          glEnd
          gltranslatef .1,.18,.0
          '
          static string ss
          ss= str(50+c[i].vy*50,0) '0..100
          input ss
          c[i].vy=(val(ss)-50) *0.02
          '
          static int cpick,cy,cx
          if cpick<>picked
            cp=le+1 'place cursor at end of string
            cy=y
            cx=x
            cpick=picked
          endif
          '
          select lastkey
          case VK_UP
            c[i].vy+=0.01
          case VK_DOWN
            c[i].vy-=0.01
          case VK_PRIOR 'PGUP
            c[i].vy+=0.01
          case VK_NEXT 'PGDN
            c[i].vy-=0.01
          case 9 'tab
            if GetAsyncKeyState(VK_SHIFT)=0
              picked++
              if picked>id+4
                picked=id+4
              end if
            else 'left
              picked--
              if picked<id+1
                picked=id+1
              endif
            endif
          end select
          lastkey=0
          lastchar=0
        else 'display
          gprint str(50+c[i].vy*50,0) '0..100
          'gprint str((c[i].vy)*100 , 0) -100..100
        endif
      endif
      glpopmatrix
      j+=0.1
    next
    'DISPLAY MAIN PANEL LABEL
    gltranslatef 0,-.05,0
    glscalef  .04,.04,.04
    glcolor4f .9,.9,.0,.9
    gprint lbl
    glpopmatrix
  endif
  '
  '
  if bleft
    if picked=id
      if not lock
        drag(dx,dy,1.0/sc)
        x=xx+dx : y=yy+dy
      end if
    end if
  else
    xx=x : yy=y : zz=z 'ANCHOR
  end if
  '
  'render
  '
  int i,oi1,oi2
  for i=1 to 4
    c[i].act(1,i,oi1)
    l[i].act(1,i,oi2)
  next
  glpopmatrix
  '
  'show data
  '
  'glDisable GL_TEXTURE_2D
  glDisable GL_LIGHTING
  '
  glPushMatrix
  glLoadIdentity
  if pick
    PickLabel 0
  endif
  gltranslatef -.5,.35,-1.0
  float w,h
  glscalef     .05,.05,.01
  GetWordArea  "Control:",w,h
  if pick
    PutBoxArea   w,h
  else
    /*
    glColor3f    .99,.99,.00
    gprint       "Control: "
    glColor3f    .99,.99,.99
    gprint    str(picked)
    if oi1+oi2
      gprint "   "
      if oi1 then gprint str((1.0+c[oi1].vy)*50 , 0)
      if oi2 then gprint str (l[oi2].lit)
    end if
    */
  end if
  glPopMatrix
  end method
  '
  method destructor()
  ===================
  'del this.label
  'sliders      c[4]
  'lightbuttons l[4]
  int i
  for i=1 to 4
    c[i].destructor
  next
  for i=1 to 4
    l[i].destructor
  next
  end method
  '
  end class

  '#recordof ControlPanelA



  'Keys: Esc, arrow-keys, n,m, F4

  indexbase 1
  sys       texn[16]
  sys       GdiplusToken
  float     ang1
  sys       cube,pent



  BeginScript

  procedure main() 'triangle-data example
  ================

  static single ra,ri,angi1=.5
  static sys    initscene
  static float rr=.5,gg=.5,bb=.5,aa=.8 'object color
  '
  '
'--------------------------------------------------- //
  'WaitForEvent '0 off 1 on (default on)
  static quad t1,t2

  if opening 'FIRST CALL ONLY
    timemark t1
    'picked=100
    'mbox "helo"
  end if
  '
  if closing 'FINAL CALL BEFORE SHUTDOWN
    'mbox "Bye!"
    exit sub
  end if
  '
  cls
  '
  'LAYERS
  =======
  'background    'z=-inf
  'grid          'z=-2.002
  'object        'z=-2
  'info panel    'z=-1.01
  'tool panels   'z=-1 +.001 each layer
  'tool controls '+ .0001 each layer


  'IDENTITIES
  ===========
  '.id
  'control panels
  '100..199
  'controls
  '111 slider1
  '121 slider2
  '131 slider3
  '141 slider4
  '151 light button1
  '161 light button2
  '171 light button3
  '181 light button4
  '200..299 unused
  '300..399 unused
  'data area---------
  'md       400
  'colored area------
  'mpol     900..999
  'polygon nodes-----
  'mu[1]   2100..2199
  'mu[2]   2200..2299
  'mu[3]   2300..2399



  'BACKGROUND GRID
  ================
  if not pick
    pushstate
    color .2,.4,.6,1.0
    thickness 1
    move -50,-30, -2.002
    grid 1,100,60
    popstate
  endif



  subroutine ShowPolygon
  ======================
  '
  pushstate 'polygon
  pushstate 'mpol
  static moveableobject mpol
  mpol.id=900
  mpol.mode=1
  mpol.act
  float zp=-0.001
  '
  'move 0,0,-1
  shading
  UserMovement mu,2100,3 'symbol identity, count
  if opening
    mu[1].x= 0
    mu[1].y= 5
    mu[2].x=-5
    mu[2].y=-5
    mu[3].x= 5
    mu[3].y=-5
  endif
  scale 1
  picklabel 0
  int i
  for i=1 to 3
    pushstate
    mu[i].act
    color 1,.9,0,1
    scale 0.4
    go sphere
    popstate
  next
  '
  picklabel 0
  '
  float xa,xb,xc,ya,yb,yc
  xa=mu[1].x : ya=mu[1].y
  xb=mu[2].x : yb=mu[2].y
  xc=mu[3].x : yc=mu[3].y
  '
  'MOUSE DRAG ADJUSTMENT
  select picked
    'mu.id ...
    case 2100 : xa+=mu[1].d.x : ya+=mu[1].d.y
    case 2200 : xb+=mu[2].d.x : yb+=mu[2].d.y
    case 2300 : xc+=mu[3].d.x : yc+=mu[3].d.y
  end select
  flat
  thickness 2
  '
  color 1,1,0,1
  '
  pushstate
  move xa-.5,ya-1
  gprint "A"
  popstate
  '
  pushstate
  move xb+1,yb+1
  gprint "B"
  popstate
  '
  pushstate
  move xc-1,yc+1
  gprint "C"
  popstate
  '
  color rr,gg,bb,aa 'linked to slider panel 1
  picklabel mpol.id
  float zp=-0.001
  glBegin GL_TRIANGLES
  glVertex3f xa,ya,zp
  glVertex3f xb,yb,zp
  glVertex3f xc,yc,zp
  glEnd
  picklabel 0
  '
  color 0,.9,.9
  glBegin GL_LINES
  glVertex2f xa,ya
  glVertex2f xb,yb
  glVertex2f xb,yb
  glVertex2f xc,yc
  glVertex2f xc,yc
  glVertex2f xa,ya
  glEnd

  popstate 'mpol

  move 5

    move -20,12
    static sys tally
    timemark t2
    scale 1.0
    '
    int dp=3
    '
    '
    pushstate 'md
    move 0,0,0.99
    color .5,.5,.7,.7
    static moveableobject md
    md.id=400
    md.mode=1
    md.act
    float zp=-0.001
    glBegin GL_QUADS
      glVertex3f -.1,-17,zp
      glVertex3f 11,-17,zp
      glVertex3f 11,2,zp
      glVertex3f -.10,2,zp
    glEnd
    if pick
      goto nDataPanel
    endif
    '
    macro pr1(a) 'PRINTING LIST
    -----------------------------
      pushstate : color .5,1,1 : print a : popstate
      printl ""
    end macro
    '
    macro pr2(a,b) 'PRINTING LIST
    -----------------------------
      pushstate : color .5,1,1 : print a : popstate
      pushstate : color 1,1,.5 : move 4 : print str(b,dp) : popstate
      printl ""
    end macro
    '
    macro pr3(a,b,c) 'PRINTING LIST
    ------------------------------
      pushstate : color .5,1,1 : print a : popstate
      pushstate : color 1,1,.5 : move 4 : print str(b,dp) : popstate
      pushstate : color 1,1,.5 : move 8 : print str(c,dp) : popstate
      printl ""
    end macro
    '
    '
    'DISPLAY INFO
    -------------
    picklabel 0

    pushstate
    scale 2
    color 1,1,1
    print "Triangle Data"
    popstate
    pr1 ""
    pr1 ""
   'pr2 "Action Code:   ", act
   'pr2 "indexbase      ", indexbase
   'pr2 "Keyboard Code: ", keyd
    pr2 "Picked ID:     ", picked
    '
    pr3 "Point A: ", str(xa,3), ya
    pr3 "Point B: ", str(xb,3), yb
    pr3 "Point C: ", str(xc,3), yc
    '
    float ab,ac,bc,ar,ht,hb
    '
    ab=hypot(xa-xb, ya-yb)
    ac=hypot(xa-xc, ya-yc)
    bc=hypot(xb-xc, yb-yc)
    '
    hb=0.5* ( ab*ab - ac*ac + bc*bc ) / bc
    ht=sqr(ab*ab-hb*hb)
    ar=0.5*bc*ht

    'ANGLES
    float na,nb,nc
    nb=deg(asin(ht/ab))
    nc=deg(asin(ht/ac))
    na=180-nb-nc

    pr1 ""
    pr2 "Angle A:",na
    pr2 "Angle B:",nb
    pr2 "Angle C:",nc
   
    pr1 ""
    pr2 "Line AB:",ab
    pr2 "Line AC:",ac
    pr2 "Line BC:",bc
    pr2 "Left base:",hb
    pr2 "Height:",ht
    pr2 "Area:", ar
    pr1 ""
    '
    nDataPanel:
    ===========
    popstate 'md
    picklabel 0
    '
    'end polygon display
    '--------------------
    '
    popstate 'polygon
  end subroutine

  'PANEL DISPLAY
  ==============

  static single ra,ri,angi1=.5
  static sys    initscene
 
  '------------------------------
 'glClearColor 0.5, 0.5, 0.7, 0
 'glClearColor 0.1, 0.2, 0.1, 0
  '
  glColor4f .99,.99,.99,.99
  'glEnable GL_TEXTURE_2D
  '
  'RENDERED LOWEST FIRST (FOR TRANSPARENCY BLENDING)
  '
  %                    ordn=1
  static ControlPanelA cb[ordn]
  static int           ord[16]
  static int           idb[16]
  '
  if closing
    int i
    for i=1 to ordn
      cb[i].destructor
    next
    exit sub
  endif
 
  '
  'INITIAL PLACEMENT ETC
  '
  if initscene=0
    ord={1,2,3}
    idb={100,200,300} 'panel identities
    cb[1].x=.8 : cb[1].y=.6 : cb[1].lbl="Color"
    int i
    'set scale
    for i=1 to ordn : cb[i].sc=2.5 : next
    initscene=1
  end if
  '
  'ORDER OF BUILD (SUPPORTING TRANSPARENCY)
  '
  if picked and bleft
    int a=1+trunc(picked/100)
    PlaceTop(a,ord,ordn)
  end if
  '
  'RENDER SCENE
  '
  move 0,0,-2
  gosub ShowPolygon
  move 0,0,2
  '
  glpushmatrix
  static float layr=.001
  static float f = -1 - layr*ordn
  glscalef 15,15,1
  gltranslatef .0, .0, f
  int i,j
  for i=1 to ordn
    j=ord[i]
    cb[j].act idb[j] 'set identity
    gltranslatef .0, .0, layr 'next micro-layer in front
  next
  '
  'LINK TO SLIDERS
  'COLOR
  rr=0.5+cb[1].c[1].vy*.5
  gg=0.5+cb[1].c[2].vy*.5
  bb=0.5+cb[1].c[3].vy*.5
  aa=0.5+cb[1].c[4].vy*.5
  glpopmatrix
  '
  '
 
'  ang1+=angi1
'  if ang1>=360 then ang1-=360
 
  end procedure 'main
  EndScript


Frank Brübach

#5
Hi Charles I was ill have a hard cold No time to make any Progress Here or House building Project

One little question about Mouse Position of triangle Data example with Slider Panel Box

How to Insert a Mouse Position below Display Info Box? A little Code snippets I have found already

'string stmouse
   
opengl: how to insert a mouse position
below the display info box?
'string stmouse
 
'pr2 "mouse: ",stmouse
   
  '----------------
  ''case WM_MOUSEMOVE
  '================

  ''  bselect=bselect or 1
  ''  mPosX = LOword(lParam)
  ''  mPosY = HIword(lParam)
    '
   '' if bleft=1
      '
    ''  x=mPosX : y=mPosY

Thanks in advance  Bye Frank
 

Frank Brübach

Found a simple solution
string s
s= "xPos: "+STR(LOWORD(LPARAM)) + " yPos: , " + STR(HIWORD(LPARAM))
        SetWindowText hWnd, s
SetFocus hwnd
Works with winGui now I will include in triangle example

Frank Brübach

#7
' mouse position x,y
Although IT Works with Powerbasic OpenGL  IT doesn't Run with oxygen Basic consoleG

string stmouse,s
s= "xPos: "+str(loword(lparam)) + " yPos: , " + str(hiword(lparam))
setWindowText hwnd,s
pr2 "mouse: ",s ''stmouse

'doesnt work in openGL consoleG mode

regards frank

Charles Pegge

Hi Frank,

Hope you are feeling better. ConsoleG uses global variables:

gWnd for the main window. mposx and mposy for the current mouse position. Also bLeft, bMid and bRight for the mouse buttons.

These state variables are defined in inc\winutil.inc

  macro MouseMessages
  ===================
  case WM_MOUSEMOVE
    mposx=LoWord(lparam)
    mposy=HiWord(lparam)
    mmove=1
    if act=0 then act=1
    static POINT sp,mp
  case WM_LBUTTONDOWN : bleft=1  : LogMousePos
  case WM_LBUTTONUP   : bleft=0  : eposx=mposx
  case WM_RBUTTONDOWN : bright=1 : LogMousePos
  case WM_RBUTTONUP   : bright=0 : eposx=mposx
  case WM_MBUTTONDOWN : bMid=1   : LogMousePos
  case WM_MBUTTONUP   : bMid=0   : eposx=mposx
  case WM_MOUSEWHEEL  : bWheel=wParam : sar bWheel,16
  end macro


  macro KeyboardMessages
  ======================
  case WM_CHAR    : lastchar=wparam
  case WM_KEYUP   : key[wparam]=0 : keyd=0 : if wparam>30 then bkey=0
  case WM_KEYDOWN
    wparam and= 255
    select wparam
    keydown 'macro intercept
    'DEFAULT CASES
    case 27 : SendMessage hwnd, WM_CLOSE, 0, 0
    case 32 : if key[32]=0 then pause=1-pause 'toggle
    end select
    key[wparam]=1
    lastkey=wparam
    bkey=lastkey
    keyd=lastkey
    #ifdef opengl
    act=1
    #endif
  end macro


Frank Brübach

#9
Yes thanks... Feeling much better Charles everybody Here at Work Had a cold now

  'mouse Position added by Frank bruebach 27/12/23, oxygen
  '% Title "Rotating Cuboid 1x3x4"
  string Title="Rotating Cuboid 1x3x4"
  % Animated
  % PlaceCentral
  uses ConsoleG

  sys lparam,wparam,wMsg,hwnd
  string stmouse,s

  sub main
  ========
  cls 0.0, 0.2, 0.7
  '-- mouse position works --- :-)
  pushstate
  's= "xPos: "+str(loword(lparam)) + " yPos:  " + str(hiword(lparam))
  s= "xPos: " + mposx+str(loword(lparam)) + " yPos:  " +mposy+ str(hiword(lparam))
  SetWindowText gWnd,s 'hWnd
  popstate

  shading
  scale 3
  pushstate
    Material Gold
    static float ang
    rotateX ang
    rotateY ang
    scale 1,3,4
    go cube
  popstate
  ang+=.5 : if ang>=360 then ang-=360
 

  end sub
  EndScript

Good hint with gwnd instead of hwnd.
Now Mouse Position is working fine.

PS triangle Data Slider example Works with new Mouse Position too See Pic 2