using Viewpoint Node in prototype definition 
Author Message
 using Viewpoint Node in prototype definition

I'm a vrml newbie trying to hand-code a Sign object. I want to be able to
stamp these objects around my world, so that the user can click on them and
go to the appropriate place.

I want to pass the object some text, and a viewpoint node to which the user
will move when the sign is clicked. So far, so good: In my test.wrl I've got

EXTERNPROTO Sign

 exposedField MFString text
 exposedField SFNode view
 ] "Sign.wrl"

and it's used in a context such as

 Sign

  text "Reactor"
  view USE VPReactor
 }
 where VPReactor is a previously DEF'ed Viewpoint.

In the prototype file "Sign.wrl",  the prototype is declared as
PROTO Sign [
 exposedField MFString text []
 exposedField SFNode view NULL
 ]

and that's all cool, until I try to actually use the viewpoint which gets
passed in. And this is the problem. Although I can use 'text' OK, I can't
find a syntax to use 'view' in the prototype body. I've tried

DEF VP IS view
DEF VP Viewpoint IS view
DEF VP Viewpoint{} IS view

but they all give "Syntax error" in Worldview

Any ideas?



Tue, 03 Jul 2001 03:00:00 GMT  
 using Viewpoint Node in prototype definition

Quote:

> I'm a VRML newbie trying to hand-code a Sign object. I want to be able to
> stamp these objects around my world, so that the user can click on them and
> go to the appropriate place.

> I want to pass the object some text, and a viewpoint node to which the user
> will move when the sign is clicked. So far, so good: In my test.wrl I've got

> EXTERNPROTO Sign

>  exposedField MFString text
>  exposedField SFNode view
>  ] "Sign.wrl"

> and it's used in a context such as

>  Sign

>   text "Reactor"
>   view USE VPReactor
>  }
>  where VPReactor is a previously DEF'ed Viewpoint.

> In the prototype file "Sign.wrl",  the prototype is declared as
> PROTO Sign [
>  exposedField MFString text []
>  exposedField SFNode view NULL
>  ]

> and that's all cool, until I try to actually use the viewpoint which gets
> passed in. And this is the problem. Although I can use 'text' OK, I can't
> find a syntax to use 'view' in the prototype body. I've tried

> DEF VP IS view
> DEF VP Viewpoint IS view
> DEF VP Viewpoint{} IS view

> but they all give "Syntax error" in Worldview

> Any ideas?

IS statements can only be used with fields. You could change the data
type for "view" to MFNode and do something like this:

        Group {
                children IS view
        }

However, it sounds like Sign is going to function as a sort of extended
Viewpoint node. In that case, you are better off making Viewpoint the
node type for your PROTO (be using a Viewpoint node as the first node in
your PROTO definition). I suggest you match the fields of Viewpoint in
your PROTO interface, and IS them to the fields of a Viewpoint node in
your PROTO definition:

        PROTO Sign [
          exposedField MFString   text           []
          eventIn      SFBool     set_bind
          exposedField SFFloat    fieldOfView    0.785398
          exposedField SFBool     jump           TRUE
          exposedField SFRotation orientation    0 0 1 0
          exposedField SFVec3f    position       0 0 10
          field        SFString   description    ""
          eventOut     SFTime     bindTime
          eventOut     SFBool     isBound
        ] {
          Viewpoint {
            set_bind    IS set_bind
            fieldOfView IS fieldOfView
            jump        IS jump
            orientation IS orientation
            position    IS position
            description IS description
            bindTime    IS bindTime
            isBound     IS isBound
          }

          # rest of PROTO definition

        }

If you really wanted to stick with the interface using an SFNode as the
parameter, you could write a simple script to add the node to a grouping
node in your PROTO definition.

--
Braden N. McDaniel

<URI:http://www.endoframe.com>



Tue, 03 Jul 2001 03:00:00 GMT  
 using Viewpoint Node in prototype definition

Quote:
>I'm a VRML newbie trying to hand-code a Sign object. I want to be able to
>stamp these objects around my world, so that the user can click on them and
>go to the appropriate place.

Just a thought, but maybe you could put an Anchor in the PROTO, and pass it the
url string (containing a viewpoint name). Something like:

DEF Initial Viewpoint {...}
DEF reactorView Viewpoint {...}
...
PROTO Sign [
 field MFString viewLink "#Initial"
 field SFString viewDesc ""
 field MFString text ""
]
{
  Anchor {
   url IS viewLink
   description IS viewDesc
   children [ ... ]
  }

Quote:
}

...
Sign {
 viewLink "#reactorView"
 viewDesc "Click to go to reactor view"
 text "To Reactor"
Quote:
}

...

This should cause some viewers (like CosmoPlayer) to smoothly animate to the
selected viewpoint.

Cheers,
Roving Gambler



Tue, 03 Jul 2001 03:00:00 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. Creating a prototype node instance within another prototype.

2. using a Node within a prototype

3. discrepancies between prototypes and definitions?

4. question about Viewpoint Node

5. Viewpoint Node

6. Multiple rotations in Viewpoint nodes?

7. Viewpoint Node Documentation

8. Viewpoint Node Field Parameters

9. Viewpoint Node

10. Smooth transitions when binding a Viewpoint node?

11. Viewpoint node

12. Much Ado about the Viewpoint::orientation Node

 

 
Powered by phpBB® Forum Software