Solved

VRML Variables

Posted on 1998-04-29
7
657 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
Comment Utility
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
Comment Utility
Huh, forgot... hello again! :)
0
 
LVL 1

Author Comment

by:garyennis
Comment Utility
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
Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

 
LVL 5

Accepted Solution

by:
julio011597 earned 110 total points
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

Envision that you are chipping away at another e-business site with a team of pundit developers and designers. Everything seems, by all accounts, to be going easily.
Boost your ability to deliver ambitious and competitive web apps by choosing the right JavaScript framework to best suit your project’s needs.
This tutorial demonstrates how to identify and create boundary or building outlines in Google Maps. In this example, I outline the boundaries of an enclosed skatepark within a community park.  Login to your Google Account, then  Google for "Google M…
This video teaches users how to migrate an existing Wordpress website to a new domain.

763 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

12 Experts available now in Live!

Get 1:1 Help Now