Hello all hi Charles...
Made an example how to combine Panel Slider overlap example with triangle vector Data I have Managed 95 per Cent :)
But the sliders dont fit in complete Size perhaps the dozyframe command prevent this.. If I activate this one only the sliders appears..
I have scaled the sliders to get them bigger but thats not perfect
There are two different Setup OpenGL gui's I have noticed but IT must Work together
Help is Welcome again thx Frank
Example oxygen
'-------- experiment to combine triangle data with slider overlapped
'-------- oxygenbasic, by frank brübach, 27-11-2023
'
#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
'Keys: Esc, arrow-keys, n,m, F4
'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
BeginScript
procedure main() 'triangle-data example
================
static single ra,ri,angi1=.5
static sys initscene
sys hwnd
'
'
'--------------------------------------------------- //
'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
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 .8,.0,.8
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 procedure 'main
'-------------------- //
static single ra,ri,angi1=.5
static sys initscene
'---------- //
'DozyFrame 'causes overlapped sliders
'---------- //
glscalef 18,18,18
'------------------------------
'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=3
static ControlPanelA cb[ordn]
static int ord[16]
static int idb[16]
'
if closing
int i
for i=1 to 3
cb[i].destructor
next
exit sub
endif
'
'INITIAL PLACEMENT ETC
'
if initscene=0
ord={1,2,3}
idb={0,100,200}
cb[1].x=.0 : cb[1].y=.0
cb[2].x=.1 : cb[2].y=.05
cb[3].x=.2 : cb[3].y=.10
int i
for i=1 to ordn : cb[i].sc=1 : 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
'
'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
glpopmatrix
'
'
EndPick
'
' ang1+=angi1
' if ang1>=360 then ang1-=360
end procedure 'main
EndScript
This example Works however with Basis of overlapped sliders and I have included a simple gl_triangle
PS my Idea was to manipulate the vector Data of the First example above by sliders ;)
'-- two different guis opengl with sliders
'-- 27/11/2023 by frank brübach, oxygen
'
#compact
$ FileName "co.exe"
'uses RTL64
'uses console
'
% ExplicitMain
$ title "Panels Overlap"
$ 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
===================
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 .10,.20,.40,.9
'glColor4f .99,.99,.99,.99
'glEnable GL_TEXTURE_2D
'
'RENDERED LOWEST FIRST (FOR TRANSPARENCY BLENDING)
'
static ControlPanelA cb[4] '[3]
% ordn=4 '3
static int ord[16]
static int idb[16]
static single ang1,angi1=1
'---------------------------------------- //
'
''glClearColor 0.3, 0.3, 0.5, 0
''glClear GL_COLOR_BUFFER_BIT or GL_DEPTH_BUFFER_BIT
'
'
'INITIAL PLACEMENT ETC
'
if initscene=0
ord={1,2,3,4} '1,2,3
idb={0,100,200,300} '200}
cb[1].x=.0 : cb[1].y=.0
cb[2].x=.1 : cb[2].y=.05
cb[3].x=.2 : cb[3].y=.10
cb[4].x=.4 : cb[4].y=.15
int i
for i=1 to ordn : cb[i].sc=1/2 : next 'kleiner machen
initscene=1
end if
'
'ORDER OF BUILD (SUPPORTING TRANSPARENCY)
'
if picked and bleft
int a=1+trunc(picked/100)
PlaceTop(a,ord,ordn)/2
end if
'
'BUILD
'
glpushmatrix
static float layr=.001
static float f = -1 - layr*ordn
gltranslatef .0, .0, f
'glscalef 0.5,0.5,0.5
int i,j
glcolor4f .10,.20,.40,.9
for i=1 to ordn
j=ord[i]
cb[j].act idb[j]
gltranslatef .0, .0, layr 'next micro-layer in front
next
glpopmatrix
'
glpushmatrix
gltranslatef 0.0, 0.0, -4.0
glrotatef ang1, 0.0, 0.0, 1.0
'
glBegin GL_TRIANGLES
glColor3f 1.0, 0.0, 0.0 : glVertex3f 0.0, 1.0, 0.0
glColor3f 0.0, 1.0, 0.0 : glVertex3f -1.0, -1.0, 0.0
glColor3f 0.0, 0.0, 1.0 : glVertex3f 1.0, -1.0, 0.0
glEnd
glpopmatrix
'
EndPick
'
'ang1+=angi1
'if ang1>=360 then ang1-=360 '
end sub
'
MainWindow 200+width,200+height,WS_OVERLAPPEDWINDOW 'WS_POPUP
Hi Frank, This fixes your slider scaling problem on the first example:
A small alteration in the PanelA object, which is now included in the source.
drag(dx,dy,1.0/sc)
Then you can set the scale here:
'set scale
for i=1 to ordn : cb[i].sc=2.5 : next
'-------- experiment to combine triangle data with slider overlapped
'-------- oxygenbasic, by frank brübach, 27-11-2023
'
#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
=================
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
'
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
'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
BeginScript
procedure main() 'triangle-data example
================
static single ra,ri,angi1=.5
static sys initscene
sys hwnd
'
'
'--------------------------------------------------- //
'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
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 .8,.0,.8
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 procedure 'main
'-------------------- //
static single ra,ri,angi1=.5
static sys initscene
'---------- //
'DozyFrame 'causes overlapped sliders
'---------- //
glscalef 18,18,18
'------------------------------
'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=3
static ControlPanelA cb[ordn]
static int ord[16]
static int idb[16]
'
if closing
int i
for i=1 to 3
cb[i].destructor
next
exit sub
endif
'
'INITIAL PLACEMENT ETC
'
if initscene=0
ord={1,2,3}
idb={0,100,200}
cb[1].x=.0 : cb[1].y=.0
cb[2].x=.1 : cb[2].y=.05
cb[3].x=.2 : cb[3].y=.10
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
'
'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
glpopmatrix
'
'
EndPick
'
' ang1+=angi1
' if ang1>=360 then ang1-=360
end procedure 'main
EndScript
The sliders touch zone is it bit low, so I will need to adjust it in controls.inc
Very good many thanks Charles :)
I have scaled the sliders in my Second example without Problems with
for i=1 to ordn : cb[i].sc=1/2 : next '
Its possible to make a String Label for the sliderboxes? Can I do IT with GetWordArea or simple gprint?
Best regards Frank
You can add labels to each panel as follows:
Add lbl string to the panel class.
===================
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]
===================
then add label display code to the act method, just after drawing the panel
'DISPLAY PANEL LABEL
if lbl
glpushmatrix
gltranslatef -.43,-.18,.0005
glcolor4f .9,.9,.0,.8
glscalef .04,.04,.04
gprint lbl
glpopmatrix
endif
then give each panel a name, when the panels are initialized:
'INITIAL PLACEMENT ETC
'
if initscene=0
ord={1,2,3}
idb={0,100,200}
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"
int i
'set scale
for i=1 to ordn : cb[i].sc=2.5 : next
initscene=1
end if
full code:
'-------- experiment to combine triangle data with slider overlapped
'-------- oxygenbasic, by frank brübach, 27-11-2023
'
#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 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 "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
'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
BeginScript
procedure main() 'triangle-data example
================
static single ra,ri,angi1=.5
static sys initscene
sys hwnd
'
'
'--------------------------------------------------- //
'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
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 .8,.0,.8
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 procedure 'main
'-------------------- //
static single ra,ri,angi1=.5
static sys initscene
'---------- //
'DozyFrame 'causes overlapped sliders
'---------- //
glscalef 18,18,18
'------------------------------
'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=3
static ControlPanelA cb[ordn]
static int ord[16]
static int idb[16]
'
if closing
int i
for i=1 to 3
cb[i].destructor
next
exit sub
endif
'
'INITIAL PLACEMENT ETC
'
if initscene=0
ord={1,2,3}
idb={0,100,200}
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"
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
'
'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
glpopmatrix
'
'
EndPick
'
' ang1+=angi1
' if ang1>=360 then ang1-=360
end procedure 'main
EndScript
Many thanks Charles :) saw your example Just some minutes ago