WorldViz User Forum

WorldViz User Forum (https://forum.worldviz.com/index.php)
-   Vizard (https://forum.worldviz.com/forumdisplay.php?f=17)
-   -   User-Interface (https://forum.worldviz.com/showthread.php?t=285)

Johannes 02-08-2005 07:52 AM

User-Interface
 
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

Code:

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,

Quote:

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

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:
Code:

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)






Code:

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:
Code:

object = viz.pick(0,viz.SCREEN)
2) The following code will get the current head position:
Code:

pos = viz.get(viz.HEAD_POS)

Johannes 02-14-2005 05:02 PM

Hi,
this
Code:

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.
Code:

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.


.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

Quote:

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

Quote:

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

1 Attachment(s)
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:
.get
This action will return the current state of the Button or Checkbox



.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:



Code:


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!


All times are GMT -7. The time now is 07:47 AM.

Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2019, vBulletin Solutions, Inc.
Copyright 2002-2018 WorldViz LLC