Solved

VRML Variables

Posted on 1998-04-29
7
678 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
The New “Normal” in Modern Enterprise Operations

DevOps for the modern enterprise offers many benefits — increased agility, productivity, and more, but digital transformation isn’t easy, especially if you’re not addressing the right issues. Register for the webinar to dive into the “new normal” for enterprise modern ops.

 
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

Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

Question has a verified solution.

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

Suggested Solutions

I've been asked to discuss some of the UX activities that I'm using with my team. Here I will share some details about how we approach UX projects.
An enjoyable and seamless user experience can go a long way on an eCommerce site. While a cohesive layout and engaging copy play roles in creating a positive user experience, some sites neglect aspects that seem marginal but in actuality prove very …
This video teaches users how to migrate an existing Wordpress website to a new domain.
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

856 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