BS Contact J : Java-EAI : Manipulating fields Here's a little example to demonstrate Field manipulation: We have a simple sphere whose material node we want to manipulate. The diffuseColor of the sphere is to change every 1/3 second. First, get an instance of the BS Contact J applet. Then connect to the material node of the sphere (which has to be DEFed already), and to its diffuseColor field. Then place a call in the main method of the applet which changes the value of the sphere's diffuseColor field every 1/3 second. |
|
|
|
The start method could look like this: public void start(){ // connect to blaxxun3d // wait till everything
is loaded // connect to nodes System.out.println("Got nodes."); // main loop // calculate new values // sync renderer // send them to the
sphere // continue rendering // wait some time |
|
The most important line of code here is the one that sets the diffuseColor
field: All other fields can be manipulated in the same way; only the method differs: use
nodeArrayField.setValue(startIndex, endIndex, sourceArrayOfNodes)
|