instantreality forum
news: Welcome to the instantreality forums!
 
*
Welcome, Guest. Please login or register.
Did you miss your activation email?
April 24, 2018, 01:28:01 pm


Login with username, password and session length


Pages: [1] 2
  Print  
Author Topic: UITexture Example or Tutorial?  (Read 10817 times)
wedge
Newbie
*
Posts: 7


View Profile
« on: April 20, 2010, 09:12:14 am »

I want to use UITexture fur GUI. But the dokumantation is very short. Is there a tutorial or example somewere, how to interact with the GUI elements?
Logged
yjung
Administrator
Sr. Member
*****
Posts: 260


View Profile
« Reply #1 on: April 20, 2010, 11:39:28 am »

Not yet, but we are currently working on a tutorial. Nevertheless, below you will find a little usage example. But keep in mind that you need Qt installed for first creating an UI file with your GUI.

Code:
DEF GUI Shape {
  appearance Appearance {
    texture DEF colorUi UITexture {
      ...
      exposedField SFInt32 reddial   0
      exposedField SFInt32 greendial 0
      exposedField SFInt32 bluedial  0
      url "color.ui"
    }
  }
  ...
}
Shape {
  appearance Appearance {
    material DEF mat Material {}
    geometry Box { size 3 4 2 }
}

ROUTE colorUi.reddial   TO script.red
ROUTE colorUi.greendial TO script.green
ROUTE colorUi.bluedial  TO script.blue
ROUTE script.color TO mat.diffuseColor

As can be seen in the code fragment, the UITexture can be applied onto a 3D Shape the usual way. Whereas "color.ui" denotes the pre-designed Qt UI file, the texture additionally supports dynamic fields, which denote certain signals and slots (the Qt concept for event propagation) as defined in the UI file. In this example, the exposedField "reddial" references the Qt-specific QDial widget element for changing the amount of red in the material of the colored box behind the UI.

Because the widget can be used as input and output (slot and signal) respectively, in this case we are using an exposed field instead of an in- or out-slot. Finally, when a value was changed, the current state of all QDial widgets is routed to a Script node for assembling an SFColor value that is routed to the 'diffuseColor' field  of the Material of the Box node. If the types match, the last step certainly can be skipped.

Bye
Yvonne
Logged
wedge
Newbie
*
Posts: 7


View Profile
« Reply #2 on: April 22, 2010, 02:08:53 pm »

thx that helps
Logged
mcx
Newbie
*
Posts: 18


View Profile
« Reply #3 on: August 13, 2010, 01:23:37 pm »

Is this still usual to make kind of inputfields?

I want to create some textfields where I can input text, which then will affect the x3d scene.

I simply don't know how to create such an example Sad

I have created a widget ui with a textfield in it, but I don't know how to route the value from that textfield to a textfield in my X3D file.

Is there a better way to create some kind of UI ? I also tested the Stringsensor, but that leads to some extend where I have to simulate all textfield properties like highlighting when you edit a field etc.

Also, is there a way to keep a applied UI topmost?

(I simply added a widget.ui via UITexture without using it as a actual texture, just wanted to create some kind of UI with it)


THX
MCX
Logged
yjung
Administrator
Sr. Member
*****
Posts: 260


View Profile
« Reply #4 on: August 14, 2010, 07:10:20 pm »

Hi,

I'm not quite sure I understood your question correctly.

You can use a QLineEdit Element that is defined as SFString slot. With a KeySensor you can route values to it. Analogously, other events are defined, e.g. for a radio button the syntax is like in this example:

eventOut SFBool radioButton0/toggled(bool)

The previously shown example is a short form for this full syntax for default Qt signals/slots for the respective elements.

Bye
Yvonne
Logged
mcx
Newbie
*
Posts: 18


View Profile
« Reply #5 on: August 15, 2010, 05:00:05 pm »

Thanks Smiley

What I mean is, where can I find some information about creating a route from a qt.ui element to my x3d scene?

And with the topmost part I mean if it is possible to keep the Qwidget on top of my x3d, so when I click a box in my scene, the qwidget stays on top of the x3d (doesn't hide).
Logged
yjung
Administrator
Sr. Member
*****
Posts: 260


View Profile
« Reply #6 on: August 15, 2010, 05:35:41 pm »

More information can be found in the Qt documentation (http://doc.qt.nokia.com/4.6/classes.html). There possible signals and slots (which map to input/ output slots in X3D) are described in more detail. E.g. in the aforementioned radio button example you'll learn from the documentation that the following Qt signal exists:

void    toggled ( bool checked )

This maps in the UITexture interface to:

eventOut SFBool radioButton0/toggled(bool)

This event then can e.g. routed to a Script with an assumed radioButton0 inslot like this:

ROUTE radioUI.radioButton0/toggled(bool) TO radioScript.radioButton0

Regarding your second question, keeping the UI on top, you can apply the same concepts as for all other 3D elements. For instance you can use a Screengroup with a Viewspace (see the related posts).
Logged
mcx
Newbie
*
Posts: 18


View Profile
« Reply #7 on: August 15, 2010, 06:24:59 pm »

thanks thanks thanks Cheesy

That is what I really like about coding for X3D and instant.. you add sometimes some lines where you think "that can't work that simple" and it does. Cheesy

for the hud part, i will try some things out
Logged
mcx
Newbie
*
Posts: 18


View Profile
« Reply #8 on: August 19, 2010, 10:59:21 pm »

Is it possible that I can't touch an element on that ui directly? I've tested something with touchsensors but i can't select any element on that ui.
Logged
yjung
Administrator
Sr. Member
*****
Posts: 260


View Profile
« Reply #9 on: August 20, 2010, 09:00:12 am »

Hi,

if you can't touch the elements, they would be rather useless  Wink

However, an object's texture coordinates sometimes don't fit with the UI's window coordinates. Attached you find a little example with which you can play around to get started.

Hope this helps
Yvonne
« Last Edit: August 20, 2010, 11:19:25 am by yjung » Logged
mcx
Newbie
*
Posts: 18


View Profile
« Reply #10 on: August 20, 2010, 03:36:13 pm »

thanks for making this much effort.

For some reason the box is only black if i start the wrl. I converted it to X3D but it stays black. I've got version 2.0.0beta7
Logged
yjung
Administrator
Sr. Member
*****
Posts: 260


View Profile
« Reply #11 on: August 20, 2010, 04:11:07 pm »

Yes, the box is black on startup. But there should be a floating rectangle with a color chooser in front of it (i.e. the UITexture that refers to the Qt Designer file that is also in the zip).
This example should work with all recent versions. Have you had a look at the log output? Perhaps a Qt version conflict or something like this.
Logged
mcx
Newbie
*
Posts: 18


View Profile
« Reply #12 on: August 21, 2010, 01:02:55 pm »

Hmm I only get some of these:

WARNING   Avalon    TimerJob/defaultTimerJob.exec: processValueChange() && _isChangingMask set

nothing more. the box stays black without a rectangle in front of it.
Logged
yjung
Administrator
Sr. Member
*****
Posts: 260


View Profile
« Reply #13 on: August 21, 2010, 02:39:03 pm »

Very strange. Can you open the ui file with the Qt designer tool?

Or perhaps you're using a broken build (e.g. with missing Qt dll's). In this case you might like to try another one. Here is the link to the dev builds:

ftp://ftp.igd.fraunhofer.de/irbuild/
Logged
mcx
Newbie
*
Posts: 18


View Profile
« Reply #14 on: August 21, 2010, 04:31:12 pm »

Ok I found something out:

1. it doesn't work with a 64bit build
2. it only shows the ui every 4-5th time i open the file (while the previous are still open!, otherwise won't show the ui)
3. it only works with a devbuild

I also tested this on a 32bit vista machine, same results. If it opens, it works perfectly nice! But as i mentioned only every 4 or 5th time i open the file.


So maybe this is related to a special build version. Which one do you use? I'll try something a bit older, maybe it works every time with that one (16.08.2010)
« Last Edit: August 21, 2010, 04:46:08 pm by mcx » Logged
Pages: [1] 2
  Print  
 
Jump to:  

Powered by SMF 1.1.15 | SMF © 2011, Simple Machines