On Monday, December 13, 1999 1:48 PM, Rick Goldberg
[SMTP:[EMAIL PROTECTED]] wrote:
> You can check out some EAI work here:
>
>
http://www.web3d.org/cgi-bin/cvsweb.cgi/other/unsupported/eai-vrml-java3d/
>
> I don't see why adding one method to vrml.Browser over adding a
> wrapper for each vrml.* is any uglier, btw. If you don't mind I'd
> like to use it for the SAI.
>
>

Feel free to use it in the SAI.

Here's how I solved the event delivery problem.  I added a causeEvent to
the Node class.  This takes an eventName and a field.  It uses the
field.update() method to cause a setValue on the field.

    public void causeEvent(String eventOutName, Field field)
    throws InvalidEventOutException {
        Field f;

        String fieldName = Field.baseName(eventOutName);
        f = (Field)FieldSpec.get(fieldName);
        if( f == null ) {
            throw new InvalidEventOutException("No field named " +
fieldName);
        } else if( (f.fieldType & Field.EVENT_OUT) != Field.EVENT_OUT ) {
            throw new InvalidEventOutException("Field is not an
EVENT_OUT");
        }
        f.update(field);
    }

In order to get access to the VRML field I added a get namedObjs which
returns a hashtable of all the DEFed objects(scene.defTable).

So using VRML97Player as an example.  I have a touchSensor named "foo".  I
want to send a touchTime event of the current time:

        Hashtable hash = browser.getNamedObjs();

        TouchSensor ts = (TouchSensor) hash.get("foo");
        if (ts != null) {
                System.out.println("touching TouchSensor");
                SFTime time = new SFTime(Time.getNow());
                ts.causeEvent("touchTime",time);
        }
        else System.out.println("!found: ts_" + source + "-SENSOR");


One area that might be wrong is my getNamedObjs returns the reference to
the Hashtable directly.  It might need to be a cloned.  A little fuzzy on
that.   Wouldn't want someone changing the DEFed table.

If ya like this can you add it to CVS?  David hasn't gotten me access yet.
 Attached is Browser.java and Node.java


Node.java

Browser.java

Reply via email to