// TerminatorNode class package fc.vrml.util; import vrml.*; import vrml.field.*; import vrml.node.*; public class TerminatorScript extends Script{ private ConstSFBool sfboolfield; private ConstSFColor sfcolorfield; private ConstSFFloat sffloatfield; private ConstSFImage sfimagefield; private ConstSFInt32 sfint32field; private ConstSFNode sfnodefield; private ConstSFRotation sfrotationfield; private ConstSFString sfstringfield; private ConstSFTime sftimefield; private ConstSFVec2f sfvec2ffield; private ConstSFVec3f sfvec3ffield; private ConstMFColor mfcolorfield; private ConstMFFloat mffloatfield; private ConstMFInt32 mfint32field; private ConstMFNode mfnodefield; private ConstMFRotation mfrotationfield; private ConstMFString mfstringfield; private ConstMFVec2f mfvec2ffield; private ConstMFVec3f mfvec3ffield; private SFBool sfbooleventout; private SFColor sfcoloreventout; private SFFloat sffloateventout; private SFImage sfimageeventout; private SFInt32 sfint32eventout; private SFNode sfnodeeventout; private SFRotation sfrotationeventout; private SFString sfstringeventout; private SFTime sftimeeventout; private SFVec2f sfvec2feventout; private SFVec3f sfvec3feventout; private MFColor mfcoloreventout; private MFFloat mffloateventout; private MFInt32 mfint32eventout; private MFNode mfnodeeventout; private MFRotation mfrotationeventout; private MFString mfstringeventout; private MFVec2f mfvec2feventout; private MFVec3f mfvec3feventout; private SFBool autoinitializefield; public void initialize(){ sfboolfield= (ConstSFBool) getField("sfboolvalueue"); sfcolorfield= (ConstSFColor) getField("sfcolorvalue"); sffloatfield=(ConstSFFloat) getField("sffloatvalue"); sfimagefield=(ConstSFImage) getField("sfimagevalue"); sfint32field=(ConstSFInt32) getField("sfint32value"); sfnodefield=(ConstSFNode) getField("sfnodevalue"); sfrotationfield=(ConstSFRotation) getField("sfrotationvalue"); sfstringfield=(ConstSFString) getField("sfstringvalue"); sftimefield=(ConstSFTime) getField("sftimevalue"); sfvec2ffield=(ConstSFVec2f) getField("sfvec2fvalue"); sfvec3ffield=(ConstSFVec3f) getField("sfvec3fvalue"); mfcolorfield=(ConstMFColor) getField("mfcolorvalue"); mffloatfield=(ConstMFFloat) getField("mffloatvalue"); mfint32field=(ConstMFInt32) getField("mfiInt32value"); mfnodefield=(ConstMFNode) getField("mfnodevalue"); mfrotationfield=(ConstMFRotation) getField("mfrotationvalue"); mfstringfield=(ConstMFString) getField("mfstringvalue"); mfvec2ffield=(ConstMFVec2f) getField("mfvec2fvalue"); mfvec3ffield=(ConstMFVec3f) getField("mfvec3fvalue"); autoinitializefield=(SFBool) getField("autoinitialize"); sfbooleventout= (SFBool) getEventOut("sFBoolValue_changed"); sfcoloreventout= (SFColor) getEventOut("sFColorValue_changed"); sffloateventout=(SFFloat) getEventOut("sFFloatValue_changed"); sfimageeventout=(SFImage) getEventOut("sFImageValue_changed"); sfint32eventout=(SFInt32) getEventOut("sFInt32Value_changed"); sfnodeeventout=(SFNode) getEventOut("sFNodeValue_changed"); sfrotationeventout=(SFRotation) getEventOut("sFRotationValue_changed"); sfstringeventout=(SFString) getEventOut("sFStringValue_changed"); sftimeeventout=(SFTime) getEventOut("sFTimeValue_changed"); sfvec2feventout=(SFVec2f) getEventOut("sFVec2fValue_changed"); sfvec3feventout=(SFVec3f) getEventOut("sFVec3fValue_changed"); mfcoloreventout=(MFColor) getEventOut("mFColorValue_changed"); mffloateventout=(MFFloat) getEventOut("mFFloatValue_changed"); mfint32eventout=(MFInt32) getEventOut("mFInt32Value_changed"); mfnodeeventout=(MFNode) getEventOut("mFNodeValue_changed"); mfrotationeventout=(MFRotation) getEventOut("mFRotationValue_changed"); mfstringeventout=(MFString) getEventOut("mFStringValue_changed"); mfvec2feventout=(MFVec2f) getEventOut("mFVec2fvalue_changed"); mfvec3feventout=(MFVec3f) getEventOut("mFVec3fValue_changed"); autoinitializefield= (SFBool) getField("autoinitialize"); if (autoinitializefield.getValue()==true){ // for each field set value of eventout to field sfbooleventout.setValue(sfboolfield.getValue()); //sfcoloreventout.setValue((ConstSFColor)sfcolorfield.getValue()); float[] tempsfcolor=new float[3]; sfcolorfield.getValue(tempsfcolor);sfcoloreventout.setValue(tempsfcolor); sffloateventout.setValue(sffloatfield.getValue()); int tempsfnumpixels=sfimagefield.getWidth()*sfimagefield.getHeight();byte[] tempsfpixels=new byte[tempsfnumpixels]; sfimagefield.getPixels(tempsfpixels);sfimageeventout.setValue(sfimagefield.getWidth(), sfimagefield.getHeight(), sfimagefield.getComponents(), tempsfpixels); sfint32eventout.setValue(sfint32field.getValue()); sfnodeeventout.setValue(sfnodefield.getValue()); float[] tempsfrotation=new float[4]; sfrotationfield.getValue(tempsfrotation); sfrotationeventout.setValue(tempsfrotation); sfstringeventout.setValue(sfstringfield.getValue()); double tempsftime=sftimefield.getValue();sftimeeventout.setValue(tempsftime); float[] tempsfvec2f=new float[2];sfvec2ffield.getValue(tempsfvec2f); float[] tempsfvec3f=new float[3];sfvec3ffield.getValue(tempsfvec3f); int mfcolorsize=mfcolorfield.getSize();float[][] tempmfcolor = new float[mfcolorsize][3];mfcoloreventout.setValue(tempmfcolor); int mffloatsize=mffloatfield.getSize();float[] tempmffloat = new float[mffloatsize];mffloateventout.setValue(tempmffloat); int mfint32size=mfint32field.getSize();int[] tempmfint32=new int[mfint32size];mfint32eventout.setValue(tempmfint32); int mfnodesize=mfnodefield.getSize();BaseNode[] tempmfnode = new BaseNode[mfnodesize];mfnodefield.getValue(tempmfnode);mfnodeeventout.setValue(tempmfnode); int mfrotationsize=mfrotationfield.getSize();float[][] tempmfrotation=new float[mfrotationsize][4];mfrotationfield.getValue(tempmfrotation);mfrotationeventout.setValue(tempmfrotation); int mfstringsize=mfstringfield.getSize();String[] tempmfstring=new String[mfstringsize];mfstringfield.getValue(tempmfstring);mfstringeventout.setValue(tempmfstring); int mfvec2fsize=mfvec2ffield.getSize();float[][] tempmfvec2f=new float[mfvec2fsize][2];mfvec2ffield.getValue(tempmfvec2f);mfvec2feventout.setValue(tempmfvec2f); int mfvec3fsize=mfvec3ffield.getSize();float[][] tempmfvec3f=new float[mfvec3fsize][3];mfvec3ffield.getValue(tempmfvec3f);mfvec3feventout.setValue(tempmfvec3f); // if autoinitialize false only send value on first eventIn to PROTO. } } // end initialize public void processEvent(Event e){ if(e.getName()=="set_SFBoolValue"){ sfbooleventout.setValue((ConstSFBool)e.getValue()); } if(e.getName()=="set_SFColorValue"){ sfcoloreventout.setValue((ConstSFColor)e.getValue());} if(e.getName()=="set_SFFloatValue"){ sffloateventout.setValue((ConstSFFloat)e.getValue()); } if(e.getName()=="set_SFImageValue"){ sfimageeventout.setValue((ConstSFImage)e.getValue()); } if(e.getName()=="set_SFInt32Value"){ sfint32eventout.setValue((ConstSFInt32)e.getValue()); } if(e.getName()=="set_SFNodeValue"){ sfnodeeventout.setValue((ConstSFNode)e.getValue()); } if(e.getName()=="set_SFRotationValue"){ sfrotationeventout.setValue((ConstSFRotation)e.getValue());} if(e.getName()=="set_SFStringValue"){ sfstringeventout.setValue((ConstSFString)e.getValue()); } if(e.getName()=="set_SFTimeValue"){ sftimeeventout.setValue((ConstSFTime)e.getValue());} if(e.getName()=="set_SFVec2fValue"){ sfvec2feventout.setValue((ConstSFVec2f)e.getValue());} if(e.getName()=="set_SFVec3fValue"){ sfvec3feventout.setValue((ConstSFVec3f)e.getValue());} if(e.getName()=="set_MFColorValue"){ mfcoloreventout.setValue((ConstMFColor)e.getValue());} if(e.getName()=="set_MFFloatValue"){ mffloateventout.setValue((ConstMFFloat)e.getValue());} if(e.getName()=="set_MFInt32Value"){ mfint32eventout.setValue((ConstMFInt32)e.getValue());} if(e.getName()=="set_MFNodeValue"){ mfnodeeventout.setValue((ConstMFNode)e.getValue());} if(e.getName()=="set_MFRotationValue"){ mfrotationeventout.setValue((ConstMFRotation)e.getValue());} if(e.getName()=="set_MFStringValue"){ mfstringeventout.setValue((ConstMFString)e.getValue());} if(e.getName()=="set_MFVec2fValue"){ mfvec2feventout.setValue((ConstMFVec2f)e.getValue());} if(e.getName()=="set_MFVec3fValue"){ mfvec3feventout.setValue((ConstMFVec3f)e.getValue());} } } //copyright 1997 FC VRML GROUP