[x3d-public] X3D Java SAI. ROUTE Event Source/Destination discussion

Don Brutzman brutzman at nps.edu
Thu Jan 19 06:07:26 PST 2017


I've implemented code that should cover gaps encountered.  Checked in, uploading.  Please retest.

On 1/18/2017 3:16 AM, yottzumm at gmail.com wrote:
> www_web3d_org/x3d/content/examples/X3dForWebAuthors/KelpForestExhibit/StripedSurfPerchPlaque
>
> Exception in thread "main" org.web3d.x3d.sai.InvalidFieldValueException: ROUTE has source-destination type mismatch. ROUTE event destination must have accessType='inputOutput' or accessType='outputOnly'. ,       FROM BlueRockfishTouchSensor.touchTime (TouchSensor.SFTime.outputOnly) TO BLUEROCKFISHCLOCK.set_startTime (TimeSensor.UnknownField_TimeSensor.UnknownField_TimeSensor)
>
>         at org.web3d.x3d.java.Core.ROUTEObject.validate(ROUTEObject.java:496)
>
>         at org.web3d.x3d.java.Core.SceneObject.validate(SceneObject.java:427)
>
>         at org.web3d.x3d.java.Core.X3DObject.validate(X3DObject.java:1434)
>
>         at org.web3d.x3d.java.Core.X3DObject.toFileJSON(X3DObject.java:657)
>
>         at www_web3d_org.x3d.content.examples.X3dForWebAuthors.KelpForestExhibit.StripedSurfPerchPlaque.main(StripedSurfPerchPlaque.java:347)
>
>
>
>
>
> I am constructing field objects like this:
>
>                 fieldObject field0_0_4_0_0 = new fieldObject();
>
>                   field0_0_4_0_0.setName("xtranslation");
>
>                   field0_0_4_0_0.setAccessType("inputOutput");
>
>                   field0_0_4_0_0.setType("SFVec3f");
>
>                   field0_0_4_0_0.setValue("0 0 0");
>
> And not like this:
>
> fieldObject outputColorsField = new fieldObject(outputColorsFieldName, fieldObject.TYPE_MFCOLOR, fieldObject.ACCESSTYPE_OUTPUTONLY);

That is OK, a string is a string.  However the second form are string constants, so spelling typos are caught at compile time and not possible at run time.

> However, in this particular file, no fields are present.  So I guess I’ll have to construct them for each route as I build the route?  Thanks, trying to automate.  Also, I’m trying to figure out what to do WHEN the fields are present.

It is good practice to build everything explicitly.  Since they are fieldObjects, there are default values for everything.  See the DEFAULT string enumeration in javadoc or look at fieldObject initialize() method if you want to check.

> Or can the validate routines ignore the accessType if it’s not specified?  Or construct the fieldObject when a string is specified in a ROUTEs fromField or toField?

type and accessType are required by X3D spec, and so defaults in code are provide (matching XML defaults) and an author has to override them.

> Question, if we do put the fields in the code, will they appear in the JSON when we don’t want them to?

uh, let's find out!

all the best, Don
-- 
Don Brutzman  Naval Postgraduate School, Code USW/Br       brutzman at nps.edu
Watkins 270,  MOVES Institute, Monterey CA 93943-5000 USA   +1.831.656.2149
X3D graphics, virtual worlds, navy robotics http://faculty.nps.edu/brutzman



More information about the x3d-public mailing list