Link to home
Start Free TrialLog in
Avatar of garyennis
garyennis

asked on

VRML anchor problem

I have a VRML file with specific viewpoints.  Is it possible to be able to link one of these viewpoints to display a *.html file in another target frame.  That is - I want a picture to appear in a different frame, WHEN I click to move on to my next viewpoint.

I had tried simply to wrap an anchor round my Perspective camera node, and although i got no errors, I got no results either!!

I would much appreciate any suggestions.....
Avatar of julio011597
julio011597

When you activate a Viewpoint, as far as i've understood it, the Viewpoint sends an isBound eventOut TRUE.

So you could simply trap this event in a Javascript script to open the desired page.
Avatar of garyennis

ASKER

Appreciate the response julio, but any chance of giving an axample of the script.....  I've never come across this isBound eventOut stuff before, nor have I used Javascript and VRML together (seperate yes, but together no!).

Thanks!
 Hello back.

Well i had some troubles because _everything_is_case_sensitive!, and the specs are not very stable.

Anyway here is a template, asuuming there's an existing "FRAME_0" frame as target:

--//--
#VRML V2.0 utf8

Group {
  children [

    DEF OpenUrl Script {
      eventIn SFBool isBound
      field MFString AUrl "http://some.site.com"
      field MFString AParameter "target=FRAME_0"
      url "javascript:
        function isBound(val) {
          if(val) {
            Browser.loadURL(AUrl, AParameter);
          }
        }
      "
    }

    Viewpoint {
      description "V0"
    }
    DEF V1 Viewpoint {
      description "V1"
    }

  ]
}

ROUTE V1.isBound TO OpenUrl.isBound
--//--

Now, each time you select the "V1" Viewpoint, an AUrl is loaded in frame "FRAME_0".

Hope this is what you're looking for.
Quick question to Julio before i give you the points....

I see your code is for VRML ver2.  Will it also work in ver1, if not, any work-arounds?

Cheers!
ASKER CERTIFIED SOLUTION
Avatar of julio011597
julio011597

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Julio, if I had any more points to give I would!!

Thanks for the time and patience...!  Although I'm only developing in VRML 1 at the mo., your comments will help greatly when we eventually do decide to upgrade!!

Thanks again!
Julio, tried your code now that we're working with VRML2.

Looks like it would work, but am getting an arror after I've clicked the viewpoint - "Script node OpenUrl: No supported script format specified"

Any comments, please advise....Thanks, Gary
Really, don't know.

I have CosmoPlayer2.0 on Communicator4.0.

May the problem have to do with your configuration?
(because that sample works for me!)
Julio......

Looking for another way around this....(for 100 points!)

Is it possible to do it using a technique like the one you gave me for displaying both a htm and wrl file from a anchor in the vrml file. (using    

Anchor { url
"javascript:top.jump('htm file','wrl file')"    etc.etc...


The reason is that i still get the above error when implementing your code above AND i will be setting up a number of views which i want to automatically display pictures, - dont want to write to much code, so using some sort of function might speed things up....

Any ideas???

Please, try this one first:

--//--
#VRML V2.0 utf8

DEF V0 Viewpoint {
  description "V0"
}
DEF V1 Viewpoint {
  description "V1"
}

Group {
  children [
  ]
}

DEF SC Script {
  eventIn SFBool V0_isBound
  eventIn SFBool V1_isBound

  field MFString V0_URL "V0.gif"
  field MFString V1_URL "V1.gif"

  field MFString VPar "target=AFrame"

  url "javascript:
    function V0_isBound(val) {
      if(val) Browser.loadURL(V0_URL, VPar);
    }
    function V1_isBound(val) {
      if(val) Browser.loadURL(V1_URL, VPar);
    }
  "
}

ROUTE V0.isBound TO SC.V0_isBound
ROUTE V1.isBound TO SC.V1_isBound
--//--

The bad news is that there's no easy way to avoid a lot of code typing.

Let me know, julio
heres the deal....

The code works fine for CP2 on the PC, but most of my development is done on the unix with an older version of cosmo which apparently doesnt like any javascript script (only vrml script) and therefore doesnt like the browser.LoadURL command!!!!

(gives the same error as before!)

Ant possible ideas using older specifications, which would work on all systems????
First a doubt: Javascript is case-sensitive, so

 browser.LoadURL()

if fact *is* wrong, because it should look like:

  Browser.loadURL()

Anyway, you are probably right about your browser handling VRMLScript only, but, then, i have no idea of how to work out the problem. An Anchor would work, but - AFAIK - there's no way to ROUTE a Viewpoint isBound to an Anchor...

Have you got a reference to a VRMLScript tutorial on-line, for me to have a look at it, given that i couldn't find any with search engines?

-julio
Julio..... problem solved...

I upgraded our version of cosmoplayer to 1.02 for the unix, and unlike the last one, this does support Browser.loadURL() with Vrmlscript!!!

Thanks anyway for the help...., I'll post 100 points for you in the "lounge" ok...

Cheers again!!!