WorldViz User Forum  

Go Back   WorldViz User Forum > Vizard

Reply
 
Thread Tools Rating: Thread Rating: 3 votes, 2.67 average. Display Modes
  #1  
Old 02-08-2005, 07:52 AM
Johannes Johannes is offline
Member
 
Join Date: Jan 2005
Posts: 143
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
Reply With Quote
  #2  
Old 02-08-2005, 10:06 AM
farshizzo farshizzo is offline
WorldViz Team Member
 
Join Date: Mar 2003
Posts: 2,849
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.
Reply With Quote
  #3  
Old 02-08-2005, 12:31 PM
Johannes Johannes is offline
Member
 
Join Date: Jan 2005
Posts: 143
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
Reply With Quote
  #4  
Old 02-08-2005, 12:49 PM
farshizzo farshizzo is offline
WorldViz Team Member
 
Join Date: Mar 2003
Posts: 2,849
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.
Reply With Quote
  #5  
Old 02-08-2005, 01:50 PM
Johannes Johannes is offline
Member
 
Join Date: Jan 2005
Posts: 143
@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
Reply With Quote
  #6  
Old 02-08-2005, 03:01 PM
farshizzo farshizzo is offline
WorldViz Team Member
 
Join Date: Mar 2003
Posts: 2,849
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.
Reply With Quote
  #7  
Old 02-08-2005, 03:49 PM
Johannes Johannes is offline
Member
 
Join Date: Jan 2005
Posts: 143
@ 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
Reply With Quote
  #8  
Old 02-08-2005, 04:22 PM
farshizzo farshizzo is offline
WorldViz Team Member
 
Join Date: Mar 2003
Posts: 2,849
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?
Reply With Quote
  #9  
Old 02-08-2005, 04:31 PM
Johannes Johannes is offline
Member
 
Join Date: Jan 2005
Posts: 143
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
Reply With Quote
  #10  
Old 02-10-2005, 11:29 AM
Johannes Johannes is offline
Member
 
Join Date: Jan 2005
Posts: 143
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
Reply With Quote
  #11  
Old 02-10-2005, 11:41 AM
farshizzo farshizzo is offline
WorldViz Team Member
 
Join Date: Mar 2003
Posts: 2,849
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
Reply With Quote
  #12  
Old 02-10-2005, 12:57 PM
Johannes Johannes is offline
Member
 
Join Date: Jan 2005
Posts: 143
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
Reply With Quote
  #13  
Old 02-10-2005, 01:00 PM
farshizzo farshizzo is offline
WorldViz Team Member
 
Join Date: Mar 2003
Posts: 2,849
Hi,

How are you applying the reflection texture? Take a look at the minicooper example, it uses a reflection texture on the car.
Reply With Quote
  #14  
Old 02-10-2005, 01:57 PM
Johannes Johannes is offline
Member
 
Join Date: Jan 2005
Posts: 143
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
Reply With Quote
  #15  
Old 02-14-2005, 08:25 AM
Johannes Johannes is offline
Member
 
Join Date: Jan 2005
Posts: 143
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)
Reply With Quote
  #16  
Old 02-14-2005, 10:59 AM
farshizzo farshizzo is offline
WorldViz Team Member
 
Join Date: Mar 2003
Posts: 2,849
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)
Reply With Quote
  #17  
Old 02-14-2005, 05:02 PM
Johannes Johannes is offline
Member
 
Join Date: Jan 2005
Posts: 143
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
Reply With Quote
  #18  
Old 02-14-2005, 05:12 PM
farshizzo farshizzo is offline
WorldViz Team Member
 
Join Date: Mar 2003
Posts: 2,849
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)
Reply With Quote
  #19  
Old 02-14-2005, 06:49 PM
Johannes Johannes is offline
Member
 
Join Date: Jan 2005
Posts: 143
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
Reply With Quote
  #20  
Old 02-15-2005, 08:55 AM
Johannes Johannes is offline
Member
 
Join Date: Jan 2005
Posts: 143
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
Reply With Quote
  #21  
Old 02-15-2005, 09:08 AM
Johannes Johannes is offline
Member
 
Join Date: Jan 2005
Posts: 143
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.
Reply With Quote
  #22  
Old 02-15-2005, 09:22 AM
Johannes Johannes is offline
Member
 
Join Date: Jan 2005
Posts: 143
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')
Reply With Quote
  #23  
Old 02-15-2005, 10:20 AM
farshizzo farshizzo is offline
WorldViz Team Member
 
Join Date: Mar 2003
Posts: 2,849
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.
Reply With Quote
  #24  
Old 02-15-2005, 10:35 AM
Johannes Johannes is offline
Member
 
Join Date: Jan 2005
Posts: 143
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
Reply With Quote
  #25  
Old 02-15-2005, 10:50 AM
farshizzo farshizzo is offline
WorldViz Team Member
 
Join Date: Mar 2003
Posts: 2,849
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.
Attached Files
File Type: zip testtooltip.zip (1.2 KB, 757 views)
Reply With Quote
  #26  
Old 02-15-2005, 11:14 AM
Johannes Johannes is offline
Member
 
Join Date: Jan 2005
Posts: 143
Wow, thank you!

Works fine.

Johannes
Reply With Quote
  #27  
Old 02-15-2005, 11:17 AM
farshizzo farshizzo is offline
WorldViz Team Member
 
Join Date: Mar 2003
Posts: 2,849
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.
Reply With Quote
  #28  
Old 02-15-2005, 12:27 PM
Johannes Johannes is offline
Member
 
Join Date: Jan 2005
Posts: 143
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:



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)
Reply With Quote
  #29  
Old 02-15-2005, 12:38 PM
farshizzo farshizzo is offline
WorldViz Team Member
 
Join Date: Mar 2003
Posts: 2,849
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.
Reply With Quote
  #30  
Old 02-15-2005, 01:07 PM
Johannes Johannes is offline
Member
 
Join Date: Jan 2005
Posts: 143
Sorry, was a mistake with the viz.SCREEN. Works now, thank you!
Reply With Quote
Reply

Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -7. The time now is 01:11 PM.


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