HomeDigital EditionSys-Con RadioSearch Java Cd
Advanced Java AWT Book Reviews/Excerpts Client Server Corba Editorials Embedded Java Enterprise Java IDE's Industry Watch Integration Interviews Java Applet Java & Databases Java & Web Services Java Fundamentals Java Native Interface Java Servlets Java Beans J2ME Libraries .NET Object Orientation Observations/IMHO Product Reviews Scalability & Performance Security Server Side Source Code Straight Talking Swing Threads Using Java with others Wireless XML
 

"Glow Shapes Glow"
Vol. 3, Issue 6, P.18

	

Listing 1: Creating shapes.

Viewpoint{
 position 0 0 10
}

/// Here is my Box at -5,0,0 (relative to the origin) //////////////////////
///////////////////////////////////////////////////////
Transform{
 translation -5 0 0
 children[
  Shape{
   appearance Appearance{
               material DEF boxColor Material{
                                    ambientIntensity 0
                                    diffuseColor .2 0 0
				    emissiveColor .2 0 0
				    shininess .2
				    specularColor 0 0 0
				    transparency 0
				   }
              }
   geometry Box{
 	     size 2 2 2
	    }
  }
 ]
}

/// Here is my Sphere at 0,0,0 (relative to the origin) ///////////////////////
//////////////////////////////////////////////////////////////////

Transform{
 translation 0 0 0
 children[
  Shape{
   appearance Appearance{
               material DEF sphereColor Material{
                                    ambientIntensity 0
                                    diffuseColor 0 .2 0
				    emissiveColor 0 .2 0
				    shininess .2
				    specularColor 0 0 0
				    transparency 0
				   }
              }
   geometry Sphere{
 	     radius 1
	    }
  }
 ]
}

/// Here is my Cone at 5,0,0 (relative to the origin) ///////////////////////////////////////////////////////
Transform{
 translation 5 0 0
 children[
  Shape{
   appearance Appearance{
               material DEF coneColor Material{
                                    ambientIntensity 0
                                    diffuseColor 0 0 .2
				    emissiveColor 0 0 .2
				    shininess .2
				    specularColor 0 0 0
				    transparency 0
				   }
              }
   geometry Cone{
 	     bottomRadius 1
	     height 2
	    }
  }
 ]
}

Listing 2: TouchSensor node as child node.

Viewpoint{
 position 0 0 10
}

/// Here is my Box at -5,0,0 (relative to the origin) ///////////////////////////////////////////////////////

Transform{
 translation -5 0 0
 children[
  DEF boxSensor TouchSensor{
  }
  Shape{
   appearance Appearance{
               material DEF boxColor Material{
                                    ambientIntensity 0
                                    diffuseColor .2 0 0
				    emissiveColor .2 0 0
				    shininess .2
				    specularColor 0 0 0
				    transparency 0
				   }
              }
   geometry Box{
 	     size 2 2 2
	    }
  }
 ]
}

/// Here is my Sphere at 0,0,0 (relative to the origin) //////////////////////////////////////////////////////////////////

Transform{
 translation 0 0 0
 children[
  DEF sphereSensor TouchSensor{
  }
  Shape{
   appearance Appearance{
               material DEF sphereColor Material{
                                    ambientIntensity 0
                                    diffuseColor 0 .2 0
				    emissiveColor 0 .2 0
				    shininess .2
				    specularColor 0 0 0
				    transparency 0
				   }
              }
   geometry Sphere{
 	     radius 1
	    }
  }
 ]
}

/// Here is my Cone at 5,0,0 (relative to the origin) ///////////////////////////////////////////////////////

Transform{
 translation 5 0 0
 children[
  DEF coneSensor TouchSensor{
  }
  Shape{
   appearance Appearance{
               material DEF coneColor Material{
                                    ambientIntensity 0
                                    diffuseColor 0 0 .2
				    emissiveColor 0 0 .2
				    shininess .2
				    specularColor 0 0 0
				    transparency 0
				   }
              }
   geometry Cone{
 	     bottomRadius 1
	     height 2
	    }
  }
 ]
}

Listing 3.

/////////////////////////////////////////////////////////
Example for VRML Developers Journal - Guy D. Huggins   /////
///   D   E   L   T   A      V - http://www.deltav.net   ///////////////////////////////////////////////////////

/// Let's get a little closer  
///////////////////////////////////////////////////////

Viewpoint{
 position 0 0 10
}

/// Here is my Box at -5,0,0 (relative to the origin) ///////////////////////////////////////////////////////
Transform{
 translation -5 0 0
 children[
  DEF boxSensor TouchSensor{
  }
  Shape{
   appearance Appearance{
               material DEF boxColor Material{
                                    ambientIntensity 0
                                    diffuseColor .2 0 0
				    emissiveColor .2 0 0
				    shininess .2
				    specularColor 0 0 0
				    transparency 0
				   }
              }
   geometry Box{
 	     size 2 2 2
	    }
  }
  DEF boxScript Script{
		eventIn SFBool clicked
		eventOut SFColor b_color
		eventOut SFColor s_color
		eventOut SFColor c_color
		url "javascript:
			function clicked()
			{
				b_color = new SFColor(1, 0, 0);
				s_color = new SFColor(0, .2, 0);
				c_color = new SFColor(0, 0, .2);
			}"
 }
 ]
}

/// Here is my Sphere at 0,0,0 (relative to the origin) ///////////////////////////////////////////////////////
Transform{
 translation 0 0 0
 children[
  DEF sphereSensor TouchSensor{
  }
  Shape{
   appearance Appearance{
               material DEF sphereColor Material{
                                    ambientIntensity 0
                                    diffuseColor 0 .2 0
				    emissiveColor 0 .2 0
				    shininess .2
				    specularColor 0 0 0
				    transparency 0
				   }
              }
   geometry Sphere{
 	     radius 1
	    }
  }
    DEF sphereScript Script{
		eventIn SFBool clicked
		eventOut SFColor b_color
		eventOut SFColor s_color
		eventOut SFColor c_color
		url "javascript:
			function clicked()
			{
				b_color = new SFColor(.2, 0, 0);
				s_color = new SFColor(0, 1, 0);
				c_color = new SFColor(0, 0, .2);
			}"
 }
 ]
}

/// Here is my Cone at 5,0,0 (relative to the origin) ///////////////////////////////////////////////////////

Transform{
 translation 5 0 0
 children[
  DEF coneSensor TouchSensor{
  }
  Shape{
   appearance Appearance{
               material DEF coneColor Material{
                                    ambientIntensity 0
                                    diffuseColor 0 0 .2
				    emissiveColor 0 0 .2
				    shininess .2
				    specularColor 0 0 0
				    transparency 0
				   }
              }
   geometry Cone{
 	     bottomRadius 1
	     height 2
	    }
  }
    DEF coneScript Script{
		eventIn SFBool clicked
		eventOut SFColor b_color
		eventOut SFColor s_color
		eventOut SFColor c_color
		url "javascript:
			function clicked()
			{
				b_color = new SFColor(.2, 0, 0);
				s_color = new SFColor(0, .2, 0);
				c_color = new SFColor(0, 0, 1);
			}"
 }
 ]
}

Listing 4: Adding routing statements.

Viewpoint{
 position 0 0 10
}

/// Here is my Box at -5,0,0 (relative to the origin) ///////////////////////////////////////////////////////

Transform{
 translation -5 0 0
 children[
  DEF boxSensor TouchSensor{
  }
  Shape{
   appearance Appearance{
               material DEF boxColor Material{
                                    ambientIntensity 0
                                    diffuseColor .2 0 0
				    emissiveColor .2 0 0
				    shininess .2
				    specularColor 0 0 0
				    transparency 0
				   }
              }
   geometry Box{
 	     size 2 2 2
	    }
  }
  DEF boxScript Script{
		eventIn SFBool clicked
		eventOut SFColor b_color
		eventOut SFColor s_color
		eventOut SFColor c_color
		url "javascript:
			function clicked()
			{
				b_color = new SFColor(1, 0, 0);
				s_color = new SFColor(0, .2, 0);
				c_color = new SFColor(0, 0, .2);
			}"
 }
 ]
}

///Here is my Sphere at 0,0,0 (relative to the origin) ///////////////////////////////////////////////////////

Transform{
 translation 0 0 0
 children[
  DEF sphereSensor TouchSensor{
  }
  Shape{
   appearance Appearance{
               material DEF sphereColor Material{
                                    ambientIntensity 0
                                    diffuseColor 0 .2 0
				    emissiveColor 0 .2 0
				    shininess .2
				    specularColor 0 0 0
				    transparency 0
				   }
              }
   geometry Sphere{
 	     radius 1
	    }
  }
    DEF sphereScript Script{
		eventIn SFBool clicked
		eventOut SFColor b_color
		eventOut SFColor s_color
		eventOut SFColor c_color
		url "javascript:
			function clicked()
			{
				b_color = new SFColor(.2, 0, 0);
				s_color = new SFColor(0, 1, 0);
				c_color = new SFColor(0, 0, .2);
			}"
 }
 ]
}

/// Here is my Cone at 5,0,0 (relative to the origin) ///////////////////////////////////////////////////////

Transform{
 translation 5 0 0
 children[
  DEF coneSensor TouchSensor{
  }
  Shape{
   appearance Appearance{
               material DEF coneColor Material{
                                    ambientIntensity 0
                                    diffuseColor 0 0 .2
				    emissiveColor 0 0 .2
				    shininess .2
				    specularColor 0 0 0
				    transparency 0
				   }
              }
   geometry Cone{
 	     bottomRadius 1
	     height 2
	    }
  }
    DEF coneScript Script{
		eventIn SFBool clicked
		eventOut SFColor b_color
		eventOut SFColor s_color
		eventOut SFColor c_color
		url "javascript:
			function clicked()
			{
				b_color = new SFColor(.2, 0, 0);
				s_color = new SFColor(0, .2, 0);
				c_color = new SFColor(0, 0, 1);
			}"
 }
 ]
}

/// Here are the ROUTE statements 
//////////////////

ROUTE boxSensor.isActive TO boxScript.clicked
ROUTE boxScript.b_color TO boxColor.set_diffuseColor
ROUTE boxScript.s_color TO sphereColor.set_diffuseColor
ROUTE boxScript.c_color TO coneColor.set_diffuseColor
ROUTE sphereSensor.isActive TO sphereScript.clicked
ROUTE sphereScript.b_color TO boxColor.set_diffuseColor
ROUTE sphereScript.s_color TO sphereColor.set_diffuseColor
ROUTE sphereScript.c_color TO coneColor.set_diffuseColor
ROUTE coneSensor.isActive TO coneScript.clicked
ROUTE coneScript.b_color TO boxColor.set_diffuseColor
ROUTE coneScript.s_color TO sphereColor.set_diffuseColor
ROUTE coneScript.c_color TO coneColor.set_diffuseColor
  
      
 

All Rights Reserved
Copyright ©  2004 SYS-CON Media, Inc.
  E-mail: [email protected]

Java and Java-based marks are trademarks or registered trademarks of Sun Microsystems, Inc. in the United States and other countries. SYS-CON Publications, Inc. is independent of Sun Microsystems, Inc.