Using field as value for another field 
Author Message
 Using field as value for another field

In the book "Rality Architecture" by McCarthy and Descartes the following
code is presented (page 142):

PROTO Wall [ field SFFloat wallPos 0.0]
{
    Transform {
        translation  wallPos 0 0
        <....>

Quote:
}

When I run this in the Cosmo-player it complaines about the use of wallPos
in translation. Is this illegal use of a field?

If I wanted to make a PROTO describing av box with fixed depth, but with
hight and width as the only parameters, how should that be done? I have
tried

geometry Box {
    size 0.5 height width

Quote:
}

but I get the same error as width the code above. I there a solution for
this?

- Roar Skullestad



Tue, 19 Feb 2002 03:00:00 GMT  
 Using field as value for another field
Using cosmo I've found no way to do what you
want other than using a script node with some
JavaScript.  

It struck me as strange that
something so simple required a script node, but
I believe it is so - ie there is no non-script way
to stick an SFFloat into SFVec3f.

[and I'll be delighted if someone out there
can convince me otherwise.]

Guy.

Quote:

> In the book "Rality Architecture" by McCarthy and Descartes the following
> code is presented (page 142):

> PROTO Wall [ field SFFloat wallPos 0.0]
> {
>     Transform {
>         translation  wallPos 0 0
>         <....>
> }



Tue, 19 Feb 2002 03:00:00 GMT  
 Using field as value for another field

you can't do that, but you can write
SFVec3df instead of SFFloat (of course default value must have 3
figures)
and then
translation IS wallPos

So 2 issues: You cannot (to my knowledge)  compose fields (e.g. just
supply
the x coordinate) like that, and you must write

somefield IS protoparam, not
somefiled protoparam.

However, by using script nodes you CAN do stuff like compose the
translation thingy from  x_coord, 0 and 0.

Quote:
>In the book "Rality Architecture" by McCarthy and Descartes the following
>code is presented (page 142):
>PROTO Wall [ field SFFloat wallPos 0.0]
>{
>    Transform {
>        translation  wallPos 0 0
>        <....>
>}
>When I run this in the Cosmo-player it complaines about the use of wallPos
>in translation. Is this illegal use of a field?
>If I wanted to make a PROTO describing av box with fixed depth, but with
>hight and width as the only parameters, how should that be done? I have
>tried
>geometry Box {
>    size 0.5 height width
>}
>but I get the same error as width the code above. I there a solution for
>this?
>- Roar Skullestad



Wed, 20 Feb 2002 03:00:00 GMT  
 Using field as value for another field


Quote:
> In the book "Rality Architecture" by McCarthy and Descartes the
following
> code is presented (page 142):

> PROTO Wall [ field SFFloat wallPos 0.0]
> {
>     Transform {
>         translation  wallPos 0 0
>         <....>
> }

The code above is wrong, and you would be justified at being purturbed
at the book's authors and editors for such sloppiness. It's bad enough
for there to be a typo in in sample code, but errors like these make it
clear that the authors just don't know their subject.

(I wonder if the availability of shoddy books on the subject is some
kind of indication that vrml might be coming of age?)

Quote:
> When I run this in the Cosmo-player it complaines about the use of
wallPos
> in translation. Is this illegal use of a field?

Yes.

Quote:
> If I wanted to make a PROTO describing av box with fixed depth, but
with
> hight and width as the only parameters, how should that be done? I
have
> tried

> geometry Box {
>     size 0.5 height width
> }

> but I get the same error as width the code above.

Yep, same problem. (NB: Generally the z value is referred to
as "depth", and x is referred to as "width".)

Quote:
> I there a solution for this?

Yes. Don't do that. First, fields in a PROTO's implementation are
mapped to fields in the interface with IS statements. For example:

  PROTO MyBox [
    field SFVec3f size 2 2 2
  ] {
    Box {
      size IS size
    }
  }

Second, you cannot IS just part of a field, it's all or nothing.

There are a few potential solutions to your problem. They all involve
scripting. Basically, use an SFVec2f field in your PROTO's interface,
and have an initialize method either send the appropriate SFVec3f
eventOut or compute the geometry. If you don't need your PROTO to serve
as a geometry node, the former is definitely the easiest:

  PROTO FixedWidthBox [
    field SFVec2f size 2 2
  ] {
    DEF T Transform {
      children [
        Shape {
          appearance
            Appearance {
              material
                Material {}
            }
          geometry
            Box {
              size 1 1 1
            }
        }
      ]
    }
    DEF S Script {
      field SFVev2f size IS size
      eventOut SFVec3f scale_changed
      url [
        "javascript:
        initialize() {
          scale_changed = new SFVec3f(0.5, size.x, size.y);
        }"
      ]
    }
    ROUTE S.scale_changed TO T.set_scale
  }

Note that since Box's size field is not an exposedField, you cannot
send it events. If you do need a geometry node, then your script will
need to generate appropriate values to send to an IndexedFaceSet node.

--
Braden N. McDaniel

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

Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.



Fri, 22 Feb 2002 03:00:00 GMT  
 Using field as value for another field

Quote:

> (I wonder if the availability of shoddy books on the subject is some
> kind of indication that VRML might be coming of age?)

I don't know about that, but the amount of spam that's shown
up on this newsgroup recently might be a sign of something or
other.

Btw, sorry for a non-informative response.  In recompense, but
still horribly off-topic, I've got a free beta version of a
set-and-forget Windows news reader and attachment extractor at
http://home.hiwaay.net/~crispen/src/checknews.zip

Actually, the "free beta" is a come-on.  The newsreader will
always be free (GPLed).  I'd appreciate it if some of y'all
would try to break it.  Send bug reports to me, not this
newsgroup.

Instructions for use (assuming you can't figure it out for
yourself) are in the C source (though I wouldn't recommend
reading any farther than that in the source unless you want
a good laugh at my Windows newbie mistakes).

Point it at your favorite dirty pictures newsgroup, take a nap,
and when you wake up, you'll have a disk full of something or
other.
--
Bob Crispen
crispen at hiwaay dot net
What we're looking for: destinations.
What we end up getting: journeys.



Fri, 22 Feb 2002 03:00:00 GMT  
 
 [ 5 post ] 

 Relevant Pages 

1. How to lookup a value for a field using data from another file

2. How to hide fields from FORM while getting values using Lookups in Clarion/ASP

3. accessing recordset field values using labview Active X

4. accessing recordset field values using labview Active X

5. Comparing value in an input field to any value from another file

6. Determining if a field is a substring of another field

7. comparing flat file fields to database fields

8. Dealing with commas as a field separator AND possibly within a field

9. SQLSelect - Loading database/table field data into an Edit field

10. Field names in a field...

11. Field Standards - Setting Standards for cretin types of fields

12. Appending Records with AutoIncrement Field Key-fields

 

 
Powered by phpBB® Forum Software