Solved

VRML Variables

Posted on 1998-04-29
7
666 Views
Last Modified: 2013-12-25
I'm having real problems when trying to assign variables in VRML.

Heres what im trying to do - I want to inline an object relating to the number of times object a is clicked AND object b is clicked.

For example - if i click on object a 3 times, and object b 4 times then the object inlined will be object 7 (3+4).

At present i can inline the object relating to one of the objects, using a simple switch node (which , depending on the number of clicks, inlines that specific object)

But am finding it very difficult to then add a second variable into the puzzle????

Hope all this makes sense.... Any ideas as to the code please help..
0
Comment
Question by:garyennis
  • 4
  • 3
7 Comments
 
LVL 5

Expert Comment

by:julio011597
ID: 1854400
The general answer is: have a global variable in your script node, and increment it each time object "a" or object "b" are clicked.

In order to give you some code, would you show your code so far? (Script node and ROUTEs is enough)

-julio
0
 
LVL 5

Expert Comment

by:julio011597
ID: 1854401
Huh, forgot... hello again! :)
0
 
LVL 1

Author Comment

by:garyennis
ID: 1854402
DEF SIGN Switch {
                      whichChoice 0
                      choice [
                        Inline {
                            url      "sign0.wrl"
                        },
                        Inline {
                            url      "sign1.wrl"
                        },
                        Inline {
                            url      "sign2.wrl"  
                        },
                        Inline {
                            url      "sign3.wrl"  
                        },
                        Inline {
                            url      "sign4.wrl"  
                        },
                        Inline {
                            url      "sign5.wrl"  
                        },
                        Inline {
                            url      "sign6.wrl"  
                        },
                        Inline {
                            url      "sign7.wrl"  
                        },
                        Inline {
                            url      "sign8.wrl"  
                        },
                        Inline {
                            url      "sign9.wrl"  
                        },
                        Inline {
                            url      "sign10.wrl"  
                        },
                        Inline {
                            url      "sign11.wrl"  
                        },
                      ]
                  }


                ]
            }
          ]
      }
    ]
}

                    
##################### SCRIPTS

DEF SIGNScript Script {
    eventIn SFTime clicked
    eventOut SFInt32 nextActive

    field SFInt32 whichActive 0

    url "vrmlscript:
function clicked(t) {
    whichActive = whichActive + 1;
    if (whichActive > 11) {
        whichActive = 11;
    }
    nextActive = whichActive;
}
"
}


ROUTE CITYCOLLIDE.collideTime TO Source.set_startTime
ROUTE CITYCOLLIDE.collideTime TO SIGNScript.clicked
ROUTE SIGNScript.nextActive TO SIGN.set_whichChoice




This is about it so far......  what this does is detect the collision of the avatar into the walls of my 'maze' and add one to the choice of inline.  This works fine, but what i really want to do is also have a map icon, (bit of geometry) that when clicked, increases the inline by, lets say 3.

So, to confirm.... the user walks round my maze, collides with the wall 4 times (4 x 1) and clicks on the map 1 time (1 x 3), so the object i ultimately want to inline is object 7.

Hope this makes it somewhat clearer as to what im trying to achieve...

Thanks for the time!
0
DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

 
LVL 5

Accepted Solution

by:
julio011597 earned 110 total points
ID: 1854403
Hello back,

sorry for this long silence, i've been a bit busy.

Your scheme so far is fine and can be easily extended.

You should associate a TouchSensor to your map object - let's DEF it "TOUCHSensor". Then you Script and ROUTEs could look like:

--//--
DEF SIGNScript Script {
  eventIn SFTime clicked
  eventIn SFTime touchTime
  eventOut SFInt32 nextActive

  field SFInt32 whichActive 0

  url "vrmlscript:
    function clicked(t) {
      whichActive = whichActive + 1;
      if (whichActive > 11) {
        whichActive = 11;
      }
      nextActive = whichActive;
    }
    function touchTime(t) {
      whichActive = whichActive + 3;
      if(whichActive > 11) {
        whichActive = 11;
      }
      nextActive = whichActive
    }
  "
}

ROUTE CITYCOLLIDE.collideTime TO SIGNScript.clicked
ROUTE TOUCHSensor.touchTime TO SIGNScript.touchTime
ROUTE SIGNScript.nextActive TO SIGN.set_whichChoice
--//--

HTH, julio
0
 
LVL 1

Author Comment

by:garyennis
ID: 1854404
Julio..... bit weird....

On the SGI (Running cosmoplayer) i get an error when i click on the map or collide with the wall...
>
VrmlScript Parse Error: Script node:syntax error: line"}"



Any ideas????

I've put the whole thing on the Internet for you to look at :

http://iris.abacus.strath.ac.uk/gary/Public/maze/maze_new.wrl
0
 
LVL 5

Expert Comment

by:julio011597
ID: 1854405
Your page works as expected for me, on Cosmo Player 2.0, NN4.04, WinNT4.0...??

BTW, why are you using vrmlscript? javascript is almost a standard now.

-julio
0
 
LVL 1

Author Comment

by:garyennis
ID: 1854406
Thanks Julio...... probably just a problem with the SGI.

I think I've tried javascript before (instead of vrmlscript) but because we mainly use unix on the SGI here... Im sure it gave us some problems....

Thanks again!!
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Link to post behind image slider 1 52
Finding a free PC on campus 6 64
increase words that display in widget 6 59
get multiple images to align right 5 44
Deprecated and Headed for the Dustbin By now, you have probably heard that some PHP features, while convenient, can also cause PHP security problems.  This article discusses one of those, called register_globals.  It is a thing you do not want.  …
Although it can be difficult to imagine, someday your child will have a career of his or her own. He or she will likely start a family, buy a home and start having their own children. So, while being a kid is still extremely important, it’s also …
The viewer will learn how to dynamically set the form action using jQuery.
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.

896 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now