home previous
next contents![]() Shout3D 1.0 - User Guide
|
![]() |
Java Programming with Shout3D 1.0Creating New Panels and AppletsIn order to create new Applets that behave differently from those provided, you will typically need to create one Applet class subclassed from Shout3DApplet and one Panel class subclassed from Shout3DPanel. Many examples are included in the Shout3d_runtime\codebase\applets directory.
Creating New Node ClassesGeneral: New classes may be derived from the Node class or any of its subclasses. The Shout3D API provides ways to add new fields, watch the field values (with FieldObservers) and respond to changes in the field values (with onFieldChanged). The example Shout3d_runtime\codebase\custom_nodes\Pyramid.java shows an example. Pyramid example: The Pyramid class is a subclass of IndexedFaceSet that adds three fields, width, depth, and height. In the constructor, it sets the coord and coordIndex fields to be a pyramid shape. Then it watches for changes to width/depth/height and adjusts the coords accordingly. Adding a new Node Class: To add a new Node class, subclass any of the existing Node classes and put the java file in the Shout3d_runtime\codebase\custom_nodes directory (files placed elsewhere will not successfully be read in from .s3d files) Creating an instance of the New Node Class: Once the new Node class has been created and placed in the custom_nodes directory, any applets should be able to create and use the node class just like any other node. Reading an instance of the New Node Class from an .s3d file: There is no way to make the vrml2tos3d converter generate files containing anything other than those in the s3d package under codebase. However, .s3d files are vrml-like and may be edited to a minor degree to create files that instance custom nodes. The example Shout3d_runtime\codebase\s3d\onePyramid.s3d is an example of this. So long as the new node class is located in the custom_nodes directory, then instances of the class may be included in the .s3d file.
|