PDA

View Full Version : User-Interface


Johannes
02-08-2005, 07:52 AM
Hi,
while developing a user interface with sliders and labels I encountered the following problem:

1. Sometimes Slider and labels are not that good visible if the background of the scene is about the same color.
So I tried to play with draworder and a Texquad (as a background image for the user-interface) which worked for the labels but not for the sliders


labelGraph = viz.add(viz.TEXT3D,'velocity vs. time',viz.SCREEN)
labelGraph.font('times.ttf')
labelGraph.scale(0.4,0.4)
labelGraph.translate(0,0.9)
labelGraph.visible(viz.ON)
labelGraph.draworder(100)
labelGraph.disable(viz.DEPTH_TEST)


tex1 = viz.add('../resources/joNew/grainy.jpg')
tex2 = viz.add('image2.jpg')
quad = viz.add(viz.TEXQUAD,viz.SCREEN)
quad.translate(0.1,0.9)
quad.scale(5,18)
#label.alignment(viz.TEXT_CENTER_CENTER)
#label.translate(0.5,0.5)
quad.texture(tex1)

quad.draworder(0)
quad.disable(viz.DEPTH_TEST)
quad.visible(viz.ON)

Any ideas?

2. Is it possible to program menu-bars and stuff like that inside vizard?

I guess you told me in an earlier post that it is not possible to use textboxes etc..

Johannes

farshizzo
02-08-2005, 10:06 AM
Hi,

Try setting the draw order of the quad to -1.

Vizard doesn't have any menu bars, but you might want to take a look at the vizinfo class. Most of the examples that come with Vizard use this class to display a menu in the upper right corner of the screen. You can place text, buttons, sliders, and other gui items in this menu. The Vizard command reference has more information on how to use this class.

Johannes
02-08-2005, 12:31 PM
Hi,

Originally posted by farshizzo

Try setting the draw order of the quad to -1.

Tried this before, but then the background-Image is behind the room, so this will not help.

Vizard doesn't have any menu bars, but you might want to take a look at the vizinfo class. Most of the examples that come with Vizard use this class to display a menu in the upper right corner of the screen. You can place text, buttons, sliders, and other gui items in this menu. The Vizard command reference has more information on how to use this class.


Yes, it helps. Is there a way to make these objects invisible (the *.visible did not work).

To be flexible I might also try tkinter or (as I found recommendation in the web) wxPython and boa constructor to built my user interface?!

What would you recommend?
Johannes

farshizzo
02-08-2005, 12:49 PM
Hi,

The visible command should work. Can you provide some sample code?

I can only recommend wxPython because that is the only one I have used. I already have a few examples of Vizard running within a wxPython application. wxPython is very simple and straightforward to use, and from what I have heard, tkinter is also very easy to use.

Johannes
02-08-2005, 01:50 PM
@background-image: posted the quote wrong so you might not have seen my reply:
You wrote: Try setting the draw order of the quad to -1.

I wrote:
Tried this before, but then the background-Image is behind the room, so this will not help.


@Visible of info-class: Sample Code



info1 = vizinfo.add('Options33')
#Add some GUI items to the info box
slider2 = info1.add(viz.SLIDER,'A slider:')
button2 = info1.add(viz.BUTTON,'A button:')
checkbox2 = info1.add(viz.CHECKBOX,'A checkbox')
radio2 = info1.add(viz.RADIO,0,'A radio button:')
radio3 = info1.add(viz.RADIO,0,'A radio button:')
#Make the label for the slider red
slider2.label.color(viz.GREEN)

#info1.visible(viz.OFF)
info1.visible(False)




Both visible-commands did not work...

Johannes

farshizzo
02-08-2005, 03:01 PM
I didn't realize you were referring to the vizinfo class. You can manually shrink the info box by clicking on the logo in the corner or you can issue the shrink command.

Johannes
02-08-2005, 03:49 PM
@ info-class, thank you. But there is no way to hide the logo I guess.


@background-image (in the back of graphs etc.). Here I was referring to my texquad that I mentioned at the beginning.
Did I miss an answer?

you said: Try setting the draw order of the quad to -1.

I said, this does not work because the Background is then behind my building.

Do I have to set all my objects (that have to be behind the quad) to object.draworder(-2)

Only because the sliders cannot be set to slider.draworder(1)

I can try a different approach.

Johannes

farshizzo
02-08-2005, 04:22 PM
Are you manually adding the slider or is the slider being added through the info box? Have you tried switching the order in which you add the background and the slider?

Johannes
02-08-2005, 04:31 PM
Hi,
I think I tried this, but it did not work.
I try to work without it (as I now the info class now), if it is still a problem I will come back to it again,
thank you for your help,
Johannes

Johannes
02-10-2005, 11:29 AM
Hi,
1. I want to add an "menu" with the info-class.

For example the users should be able to select certain properties for the ball (size, material ...)

As I don't want to lose too much time getting worked in wxpython (if it's not necessary) I would like to use the vizinfo class.


Is it possible to change the vizard icon that "produces" the info-class "box"? Because for the ball properties I want a ball, for the glider a glider logo, so users can easy discriminate...


2. As collidemesh has problems with scaled objects, do

collidesphere(radius) and collidebox(width,height,depth)

with the params of the new (scaled) object, do also have problems?

3. Right now I'm having problems importing a coil into vizard with a reflection-texture from 3D-Studio. In 3DStudio it looks fine, in vizard it does not show the reflection-texture. (I get no error telling me the jpg-file is missing...). I tried the formats 3ds and wrl.

Johannes

farshizzo
02-10-2005, 11:41 AM
Hi,

1) Try doing the following:info._checkbox.uppicture('image.jpg')
info._checkbox.downpicture('image.jpg')
2) None of the collide functions account for the objects scale. So you will have to call collidebox or collidesphere with the new size.

3) The 3ds and wrl formats don't support reflection textures. You will have to manually apply the texture to the object within your script. You could also export your object to the .osg format, which supports reflection textures. The exporter is called OSGExp. The following page shows where you can download it:http://www.worldviz.com/products/vizard/tools.html

Johannes
02-10-2005, 12:57 PM
Hi,
1) worked great, thank you.

2.) Ok, I think we can work well with that.

3) "You will have to manually apply the texture to the object within your script"

Does not look good.

"You could also export your object to the .osg format, which supports reflection textures. The exporter is called OSGExp "

Tried it, but it is not compiled for 3ds Max 6 yet and compiling it myself seems too much of work right now.
I'll try to find another way...

Johannes

farshizzo
02-10-2005, 01:00 PM
Hi,

How are you applying the reflection texture? Take a look at the minicooper example, it uses a reflection texture on the car.

Johannes
02-10-2005, 01:57 PM
Thank you, it works fine now!


coil = viz.add('../resources/joNew/coil.wrl')

#innerCoil=coil.getchild('innerCoil')
texGold=viz.add('../resources/joNew/Lakerem2.jpg')

coil.texture(texGold,'innerCoil',1)
coil.appearance(viz.TEXGEN,'innerCoil',1)
coil.translate(0,0.85,0)

Johannes

Johannes
02-14-2005, 08:25 AM
Hi,

while working on my user-interface I encountered the following problem:

Picking objects form screen (as in the soccer-example) works fine to apply certain textures to objects (e.g. assigning materials to projectiles...)

But as I want to use them in the user interface I thought about putting them into the screen, which also works fine, but now the picking and assigning is not possible any more.

There maybe two solutions:
1. There is a command to pick objects from the screen...

2. When the user hits the "select material button' I translate the objects to a certain position in the real world that is e.g. 1 m in front of the user and disable mouse-movement until the user selected the material and than hide the objects again (object.visible(False)) and enable mouse-movement again.

To get the position of the user I guess I need something like viz.get(HEAD_POS)

Thank you,
Johannes

P.S. Code-Example for picking off the screen (which does not seem to work)






import viz
viz.go()


soccerball1 = viz.add('../resources/soccerball.ive',viz.SCREEN)
soccerball2 = viz.add('../resources/soccerball.ive',viz.SCREEN)
soccerball3 = viz.add('../resources/soccerball.ive',viz.SCREEN)
soccerball4 = viz.add('../resources/soccerball.ive',viz.SCREEN)
soccerball1.translate(0.8,0.1)

soccerball2.translate(0.8,0.3)
soccerball3.translate(0.8,0.5)
soccerball4.translate(0.8,0.7)



arrow = viz.add('../resources/arrow.wrl')
arrow.disable(viz.PICKING)

arrow.scale(.1, .1, .1)
#arrow.visible(viz.OFF)
viz.clearcolor(0.5,0.5,1)

tex1 = viz.add('../resources/joNew/Oak1.tga')
tex2 = viz.add('../resources/joNew/STUCCO.JPG')
texSoccer2=viz.add('../resources/joNew/ball.jpg')
#soccerball3.texture(soccerball4.texture)
soccerball2.texture(texSoccer2)
soccerball1.texture(tex1)
soccerball4.texture(tex2)


objectOld=soccerball3

def mouseclick(button):
global objectOld
if button == viz.MOUSEBUTTON_LEFT:
object = viz.pick()
#if object.valid() and object != arrow:
if (object.valid() and object !=soccerball2):
#print 'obj',object
objectOld=object
print objectOld.getpos()
pos = object.get(viz.POSITION)
pos[1] += 1
print pos
arrow.translate(pos)
arrow.visible(viz.ON)
if (object.valid()and object ==soccerball2):
soccerball3.texture(texSoccer2)
if (object.valid()and object ==soccerball1):
soccerball3.texture(tex1)
if (object.valid()and object ==soccerball4):
soccerball3.texture(tex2)

viz.callback(viz.MOUSEDOWN_EVENT,mouseclick)
viz.mouse(viz.OFF)

farshizzo
02-14-2005, 10:59 AM
1) The following code will pick an object from the screen:object = viz.pick(0,viz.SCREEN)

2) The following code will get the current head position:pos = viz.get(viz.HEAD_POS)

Johannes
02-14-2005, 05:02 PM
Hi,
this
object = viz.pick(0,viz.SCREEN)
did not seem to work, but maybe I made something wrong.
Did not want to ask too much, so I choose the other way, if I don't get along I will ask again.

Thank you and have a great evening,

Johannes

farshizzo
02-14-2005, 05:12 PM
Make sure you are using Vizard 2.5

I've included a sample script. It adds a quad to the lower left of the SCREEN and a quad to the center of the WORLD. Clicking the left mouse button will perform a pick on the WORLD and clicking the right mouse button will perform a pick on the SCREEN. When the screen quad is picked it will print out "Picked screen quad". When the world quad is picked it will print out "Picked world quad". If it doesn't work can you check if any errors are being printed out.import viz
viz.go()

ScreenQuad = viz.add(viz.TEXQUAD,viz.SCREEN)
ScreenQuad.translate(0.2,0.2)

WorldQuad = viz.add(viz.TEXQUAD)
WorldQuad.translate(0,1.8,4)

viz.mouse(0)

def onmousedown(button):
object = 0
if button == viz.MOUSEBUTTON_LEFT:
object = viz.pick()
elif button == viz.MOUSEBUTTON_RIGHT:
object = viz.pick(0,viz.SCREEN)
if object and object.valid():
if object == ScreenQuad:
print 'Picked screen quad'
elif object == WorldQuad:
print 'Picked world quad'

viz.callback(viz.MOUSEDOWN_EVENT,onmousedown)

Johannes
02-14-2005, 06:49 PM
OK, I will check it tomorrow. But as I said, I decided already for another way...


Is there a possibility to implement something like tooltips (with mouse-over etc.). If not, I will do it with the picking-possibility, so that objects reveal their properties e.g. size, density...

Thanks, have a great evening,
Johannes

Johannes
02-15-2005, 08:55 AM
Hi,
your sample-Script works fine. No errors and the picking works. Maybe my soccerballs were to little. If I need it, I try it again with them...

2. Tooltipps (previous message): possible?

3. Is it possible to put a pure label-line in vizinfo object?

(e.g. to show the exact value of a slider, below the slider)

Help says only ... is possible.


<vizinfo>.add(
what
label = ''

)



what

An item to add to the info box. Can be one of the following values:

viz.SLIDER
viz.BUTTON
viz.CHECKBOX
viz.RADIO
viz.TEXQUAD


So I might have to use a Textquad-object or change the label of the very top message (e.g. info.message(showSizeAsLabel))


Johannes

Johannes
02-15-2005, 09:08 AM
More questions:

4. In the help-file you describe how to add a label to the screen with the stage of vizard.

But as it works it seems also to be possible to add text to the screen with

text = viz.add(viz.TEXT3D, 'World Text',viz.SCREEN)

Is this correct or is it not recommended to do this (it is faster than going through the stage...)

5. Is it possible to change the label of for example radio buttons in the vizinfo-Objects?

radio.message(showSizeAsLabel) did not work.

Johannes
02-15-2005, 09:22 AM
Originally posted by Johannes


5. Is it possible to change the label of for example radio buttons in the vizinfo-Objects?

radio.message(showSizeAsLabel) did not work. [/B]

Found the answer to question 5 by playing around...

radioPine = info.add(viz.RADIO,0,'Pine 350 kg/m3')
radioPine.label.color(viz.GREEN)
radioPine.label.message('hallo')

farshizzo
02-15-2005, 10:20 AM
2) Tooltips are not built-in, but it should be possible. Perhaps you could use the vizinfo library.

3) Not in the version you have. The current version allows this and will be available in the next update

4) Either way is fine. They both do the same thing.

Johannes
02-15-2005, 10:35 AM
Originally posted by farshizzo
2) Tooltips are not built-in, but it should be possible. Perhaps you could use the vizinfo library.


Don't understand this. What did you think here?

I originally wanted to use the tooltipps for objects in the world (if you move with the mouse above them, a tooltip popps up and shows some of the properties of the objects)...

I know that originally tooltipps are used for menues etc. in the user interface... Maybe that's because you wrote vizinfo...
But other than in the help I don't find docu to the vizinfo class. So what were you referencing to when you mentiond 'use the vizinfo library'?


All the other questions are resloved, thank's for your answer.

Johannes

farshizzo
02-15-2005, 10:50 AM
I've attached a script that implements tooltips using the vizinfo class. Place the mouse over one of the balls for it to display a tooltip.

Johannes
02-15-2005, 11:14 AM
Wow, thank you!

Works fine.

Johannes

farshizzo
02-15-2005, 11:17 AM
I'm thinking of making it an addon to Vizard. Let me know if there are any bugs or other features that would be useful with it.

Johannes
02-15-2005, 12:27 PM
OK. Looking at it I was thinking if it does not take too much 'ressources' running in complex applications?!


New question: I'm having trouble with the checkbox-feature. This does not seem to work?!

Help says:
<node2d:button>.get
This action will return the current state of the Button or Checkbox



<node2d:button>.get(

)

Remarks

This action will return whether the Button or Checkbox is down or up.



Return Value

viz.DOWN or viz.UP



Example

button = viz.add(viz.BUTTON)
.
.
.
if button.get() == viz.DOWN:
print ‘The button is currently down’
else:
print ‘The button is currently up’
-----------------------------------------------------------------


this neither:





balltraceCheckbox = viz.add(viz.CHECKBOX,viz.SCREEN)
print 'balltraceCheckboxState',balltraceCheckbox.get()
if (balltraceCheckbox.get() == viz.DOWN):
print 'halloIsNotDownasdfasf'
balltraceCheckbox.translate(0.3,0.3)
showBalltraceCheckbox=0




def mybutton(obj,pos):
print 'halloMyButton',obj,pos
print balltraceCheckbox.get()
global ballMaterialDensity,showBalltraceCheckbox
if obj == radioPine:
ballMaterialDensity=350
if obj == radioPlastic:
ballMaterialDensity=700
if obj == radioSilver:
ballMaterialDensity=10490
if obj == radioIron:
ballMaterialDensity=2100
if obj == radioGranite:
ballMaterialDensity=2691
if obj == radioGold:
ballMaterialDensity=19320
if obj == balltraceCheckbox:
#showBalltraceCheckbox=pos
print 'shoabadf:',showBalltraceCheckbox

viz.callback(viz.BUTTON_EVENT,mybutton)

farshizzo
02-15-2005, 12:38 PM
I'm not clear on what the problem is. Are you saying that the get command is returning the wrong value? Keep in mind that DOWN means the checkbox is checked and UP means it is unchecked. Also, when manually adding a checkbox, or other GUI items, you don't have to specify viz.SCREEN.

Johannes
02-15-2005, 01:07 PM
Sorry, was a mistake with the viz.SCREEN. Works now, thank you!

Johannes
02-21-2005, 08:08 AM
Hi,
when I looked at my little simulation with the VR-Glasses last Friday I wanted to change some variables with my menues and on screen sliders.

So I had to stop the tracker to gain mouse control again. The on-screen slider worked (also not quite accurate, I had to drag it with an offset) but it was not possible to open the vizinfo menues and to change the sliders or values hidden in there...
Any ideas?
Johannes

P.S. at the beginning I use the following to start the tracker:

viz.go(viz.PROMPT)
ppt = viz.add('vizppt.dls')
v = viz.add('intersense.dls')
ppt.command(6,'',1,1,1)
viz.tracker()
#ppt.reset()

viz.eyeheight(-0.3)


P. P.S. I stop and start the tracker like this:


if key == 'x':
viz.tracker(viz.STOP)
#global vX
#vX = viz.input('Please type velocity x (e.g. 1.2 for 1.2 m/s)')
if key == 'y':
viz.tracker(viz.START)

farshizzo
02-22-2005, 10:37 AM
Are you viewing your simulation in Stereo mode? If so, then this is your problem. The GUI interaction will work as if Stereo mode is off, this is probably why you noticed an offset with the slider.

Johannes
02-22-2005, 10:44 AM
So if I would do something like this with a key command I could open my vizinfo
classes (and set the slider without offset)



#Change stereo to Anaglyphic
viz.stereo(viz.STEREO_RIGHT)

Or which command can I type to end and then restart the stereo-mode while running the simulation?

Johannes

farshizzo
02-22-2005, 10:49 AM
Correct, you could temporarily turn off stereo.You would use the following to disable stereo:viz.stereo(viz.STEREO_LEFT)And the following will enable stereo:viz.stereo(viz.STEREO) #Or whatever stereo mode you initially used

Johannes
02-22-2005, 11:32 AM
For right now this is fine, thank you for your help.



And what would you recommend, if people are in the VR (Head mounted display on their head) and don't have access to keyboard to change the values of variables?

We were thinking about a remote mouse control (and then sliders) but they still would have to open the vizinfo-menues first....

Johannes

farshizzo
02-22-2005, 12:02 PM
Usually the person observing the user would be in control of changing values. If you have a remote control mouse then you could use that to access the GUI, but it would still be difficult to use it while wearing an HMD.

Johannes
02-28-2005, 09:41 AM
How can I end a callback-function?

def mymousemove(horz, vert):
print 'My mouse moved to: ', horz, vert

viz.callback(viz.MOUSEMOVE_EVENT, mymousemove)

Not important, just to tell you why I need this:
The new idea to add User interaction is to put some sliders in the scene e.g. on the table.
I was thinking about something like this: as soon as the user clicks on his/her mouse (with a tracker-light taped to it) in a certain area of the scene, a UserInterfaceFunction to change a certain slider is called (identification by position).
When he drags the mouse now to a certain position and releases the mouse it changes something in the room, e.g. the light...

When he releases the mouse button the callback-function for mousemoved should exit (performance...), how do I do that?

Johannes

farshizzo
02-28-2005, 10:30 AM
To end a callback event simply pass 0 as the second argument:viz.callback(viz.MOUSEMOVE_EVENT,0)

Johannes
02-28-2005, 11:02 AM
Works fine, thank you!
Johannes

Johannes
03-02-2005, 01:24 PM
Hi,
how do I find out if an object is visible?

(I need this for something like:
if object == resetStartSwitch.switchOFF and resetStartSwitch.switchOFF.isvisible??:)

If it is difficult I will work with counter-variables that tell me if it is visible or not..
Johannes

farshizzo
03-02-2005, 01:30 PM
There is no command to get the visibility of an object. You can keep track of it manually by setting a variable everytime you change the visiblity of an object.object.visible(0)
object.isVisible = 0
.
.
.
if object.isVisible:
print 'object is visible'

Johannes
03-04-2005, 02:48 PM
thank you, that is what I tried to say somehow complicated with countervariable... :)

How do I match the normal rgb-color scheme with the vizard colors?

As I read in the help-file vizard uses something like

<node3d>.color(
[r,g,b]
subchild = '' )

and ball.color(1,0,0) #Turn the ball red

But as I "know" it is normally 255,0,0 for red...
So how could I translate a color 0,61,136 to vizard-colors?

I tried: pointGraphColor=(0,61/255,136/255) but it did not work...


Johannes

farshizzo
03-04-2005, 03:14 PM
Since you are dividing an integer with another integer, the result will be an interger. You need to use floating point numbers instead:pointGraphColor=(0,61/255.0,136/255.0)

Johannes
03-07-2005, 06:05 AM
Thank you,
Johannes

Johannes
06-03-2005, 03:18 PM
A while ago we discussed:


3) The 3ds and wrl formats don't support reflection textures. You will have to manually apply the texture to the object within your script. You could also export your object to the .osg format, which supports reflection textures. The exporter is called OSGExp. The following page shows where you can download it:http://www.worldviz.com/products/vizard/tools.html


I did the workaround looking at the minicooper example
innerCoil=coil.getchild('innerCoil')
texGold=viz.add('../resources/joNew/Lakerem2.jpg')
innerCoil.texture(texGold,'',1)
innerCoil.appearance(viz.TEXGEN,'',1)

Looks fine on the screen but when I look at it with the HMD I only see the golden reflecting innercoil as black?!

If this will solve itself when I use the open scene Graph exporter for 3DS do not worry much if it is too much work to descripe that...

Johannes

farshizzo
06-03-2005, 03:27 PM
Hi,

Are you using the same computer when viewing on screen and through the HMD?

Johannes
06-03-2005, 03:29 PM
Yes

farshizzo
06-03-2005, 04:47 PM
Wow, that is really weird. So if you turn on stereo and just view it on screen the texture is black also?

Johannes
06-06-2005, 06:19 AM
Hi,
no when I'm using stereo on the normal screen it is fine (golden and reflecting), only in the HMD it appears black.

So I guess it has to do with the quality of the HMD?!

Johannes

mspusch
06-06-2005, 07:40 AM
hi,

A) HMD settings
the HMD (you use the Virtual Research V8 from what I know) needs 480 by 640 resolution and 60Hz.

B) GRAPHICS DRIVER
If this is the case, then I would suspect that output on one eye different than the other eye might have something to do with your graphics card / driver. please make sure you use the latest driver for your graphics hardware and (in case you use nVidia hardware) that you use horizontal span mode, NOT dualview.
See also

http://www.worldviz.com/support/hardware_faqs.html

for more details on this driver issue.

C) if nothing helps and one eye continues to look different from the other, run the HMD in mono mode (i.e. only provide input for the left eye) and see if one eye still shows funcky stuff. if yes, there is a problem with your HMD and you need to get in touch with Virtual research.

Please let us know if any of above helps.

betancourtb82
06-05-2006, 03:34 PM
I'm trying to figure out a way to write a scenario where a word (scrambled) would be placed on screen and the user would have to type out the word (unscrambled). Is there anyway to have the user be able to type in some text in vizard?

Thanks

halley
06-06-2006, 07:42 AM
betancourt, looks like you wanted to start a new thread with that question.

In brief, I would just have a global string variable hold the letters typed so far; whenever you get a keyboard event that's a letter, add it to the string, and whenever you get a keyboard event that's a backspace, remove the last character from the string. If you want to discuss this or other options, consider starting a new thread so it's not confused with this thread's topic.