Archive for July, 2007

SharedGroupscan be very useful in minimizing the memory (Web hosting compare)

Friday, July 27th, 2007

SharedGroupscan be very useful in minimizing the memory footprint of an application because a single SharedGroupcan be referenced hundreds of times within a scenegraph to position repeating geometry within a scene. 5.9 Primitive java.lang.Object | +–javax.media.j3d.SceneGraphObject | +–javax.media.j3d.Node | +–javax.media.j3d.Group | +–com.sun.j3d.utils.geometry.Primitive Primitiveis a Group-derived class that serves as the base class for the geometric primitives (Box, Sphere, Cone, etc.) that are defined in the Java 3D utilspackage. Objects of the Primitiveclass should not be instantiated directly, and the Primitiveclass is very difficult to extend usefully. For a full discussion of the Primitiveclass, see chapter 8. 5.10 TransformGroup java.lang.Object | +–javax.media.j3d.SceneGraphObject | +–javax.media.j3d.Node | +–javax.media.j3d.Group | +–javax.media.j3d.TransformGroup The TransformGroup Nodeis central to almost all scenegraph designs. A TransformGroup incorporates the rotation, translation, and scaling information that is applied to all of its child Nodes. Without the TransformGroup, scenegraphs would be static, always positioned at 0,0,0, uniformly unit scaled, and without rotation about any of the axes. Not a very interesting interactive scene. The TranformGroupcontrols orientation of its child Nodes through the Transform3Dobject that it encapsulates (figure 5.5). The Transform3Dobject represents such transformations using a typical 4 4 transformation matrix. The 4 4 matrix of double precision numbers allows scaling, rotation, and translation information to be stored and applied by a single matrix. 81
If you are searching for cheap webhost for your web application, please visit MySQL5 Web Hosting services.

java.lang.Object | +–javax.media.j3d.SceneGraphObject | +–javax.media.j3d.Node | +–javax.media.j3d.Leaf |

Thursday, July 26th, 2007

java.lang.Object | +–javax.media.j3d.SceneGraphObject | +–javax.media.j3d.Node | +–javax.media.j3d.Leaf | +–javax.media.j3d.Link The Link Nodeis used in association with a SharedGroup. Since the SharedGroupcan appear in several locations in the scenegraph, and a Nodeobject can only have a single parent Node, a unique Link Nodemust be used as a placeholder within the scenegraph for the SharedGroup Node. When the scenegraph is traversed, and the Link Nodeis encountered, the traversal algorithm will step into the SharedGroupthat is internally referenced by the Link Node(figure 5.4). Figure 5.4 A Switch Node with two child Link Nodes. Both Link Nodes reference the same SharedGroup (SG). This type of structure is not possible without using Link Nodes as a single Node can only have one parent Node From NodesTest.java //create the SharedGroup SharedGroup sharedGroup1 = new SharedGroup(); //add geometry to the SharedGroup sharedGroup1.addChild ( createLabel( “4. Shared Group 1″, labelScale ) ); //add the first Link for the SharedGroup switchGroup.addChild( new Link( sharedGroup1 ) ); //add the second Link for the SharedGroup switchGroup.addChild( new Link( sharedGroup1 ) ); //Note. The InterpolatorTest example also uses SharedGroups //and Link Nodes in a more substantial manner. 80
You need excellent and relaible webhost company to host your web applications? Then pay a visit to Inexpensive Web Hosting services.

Geocities web hosting - An OrderedGroup(or DecalGroupwhich is derived from OrderedGroup) can

Thursday, July 26th, 2007

An OrderedGroup(or DecalGroupwhich is derived from OrderedGroup) can be useful for defining the rendering order for essentially coplanar surfaces, such as a road lying on terrain, or a cloth covering a table (figure 5.3). Note that both of these examples make implicit assumptions about the range of possible viewing angles for the objects, if the viewer can sit underneath the table, the tablecloth should not be rendered before the table! Other uses for an OrderedGroupmight be to implement signs or labels for geometric objects the labels should always be rendered on top of the objects they are labeling, irrespective of the viewer s position. Figure 5.3 The effect of rendering three coplanar child Nodes using an OrderedGroup. The item at index 0 (a Text2D object with the text 3. OrderedGroup ), overlaps the item at index 1 (Child 1), which overlaps the item at index 2 (Child 2) From NodesTest.java OrderedGroup orderedGroup = new OrderedGroup(); orderedGroup.addChild ( createLabel( “3. OrderedGroup”, labelScale ) ); orderedGroup.addChild( createLabel( “Child 1″, labelScale ) ); orderedGroup.addChild( createLabel( “Child 2″, labelScale ) ); 5.8 SharedGroup and link java.lang.Object | +–javax.media.j3d.SceneGraphObject | +–javax.media.j3d.Node | +–javax.media.j3d.Group | +–javax.media.j3d.SharedGroup The SharedGroup Nodedefines a scenegraph management Nodethat can be attached to several parent Nodes. The SharedGroupitself can be arbitrarily complex but must occur (as a whole) as a Leaf Node within the scenegraph. A SharedGroupmust be wrapped in an instance of a Linkobject before being added to the scenegraph. The Linkmust have one unique parent. SharedGroups cannot contain the following Nodes: Background Behavior-derived Clip Fog Soundscape ViewPlatform 79
From our experience, we can recommend PHP5 Web Hosting services, if you need affordable webhost to host and run your web application.

| +–javax.media.j3d.Group | +–javax.media.j3d.BranchGroup BranchGroupdefines a Group Nodethat (Web site management)

Wednesday, July 25th, 2007

| +–javax.media.j3d.Group | +–javax.media.j3d.BranchGroup BranchGroupdefines a Group Nodethat can be dynamically inserted or removed from a parent Group at runtime. In addition the root parent Groupof the scenegraph must be a BranchGroupsince only BranchGroupscan be inserted into a Locale. To allow a BranchGroupto be dynamically removed from its parent, the BranchGroupmust have the BranchGroup.ALLOW_DETACHcapability set. To allow a BranchGroupto be dynamically inserted (or attached) into a parent Groupthe Groupmust have the capability Group.ALLOW_CHILDREN_EXTEND. Why these capabilities have been divided between the Groupand BranchGroupclasses is not quite clear. BranchGroupsare typically used as return values by the methods that build the various components of an application scenegraph. For example, an F1 racing application might define the following abstract class: abstract class F1Object extends Object { BranchGroup m_BranchGroup = null; public F1Object(); protected BranchGroup createBranchGroup(); public getBranchGroup() { if( m_BranchGroup == null ) m_BranchGroup = createBranchGroup(); return m_BranchGroup; } } The F1Objectabstract class forces the application developer to define the createBranchGroupvirtual method in a derived class. The createBranchGroupmethod is responsible for creating a BranchGroup containing the child Nodesrequired to define the Geometryand Behaviorsfor the F1Objectbeing created. This very simple OO design allows an F1Object Managerclass to be defined that maintains a Vector(or Listor Map) of generic F1Objectsand is responsible for their creation and removal from the applications scenegraph. The objects derived from F1Objectare themselves easily reusable because their geometry generation and management routines are all packages with the class itself. The setUserDatamethod (defined in the section on Group Nodes) can be used to track F1Object instances once they have been inserted into the scenegraph. 5.7 OrderedGroup java.lang.Object | +–javax.media.j3d.SceneGraphObject | +–javax.media.j3d.Node | +–javax.media.j3d.Group | +–javax.media.j3d.OrderedGroup The OrderedGroup Nodeis a less commonly used scenegraph element. It allows an application developer to have basic control over the rendering order of the children of a Group Node. 78
If you are in need for cheap and reliable webhost to host your website, we recommend http web server services.

Web hosting billing - Figure 5.2 Seven frames from the NodesTest example.

Wednesday, July 25th, 2007

Figure 5.2 Seven frames from the NodesTest example. A Switch Node is created with seven child elements, and a SwitchInterpolator is used to cycle between them. Note that the items at index 3 (row 2, column 1) and 6 (row 3, column 1) use a Link Node to share a single SharedGroup If you choose to use the SwitchInterpolatorclass, do not add the Interpolatoras a BEWARE child of the Switch Nodeitself, or the moment the Interpolatoris activated it will deactivate itself, hence stopping the Interpolator. 5.6 BranchGroup java.lang.Object | +–javax.media.j3d.SceneGraphObject | +–javax.media.j3d.Node 77
We recommend cheap and reliable webhost to host and run your web applications: Coldfusion Web Hosting services.

//assign the visibility mask to the Switch (Disney web site) switchGroup.setChildMask(

Tuesday, July 24th, 2007

//assign the visibility mask to the Switch switchGroup.setChildMask( visibleNodes ); The output of the SwitchTest example is shown in figure 5.1. Figure 5.1 The effect of using a BitSet mask and a Switch Node. On the left, the Switch Node has been created with the Switch.CHILD_ALL attribute. On the right, a BitSet has been created to display the third, sixth, and seventh Node through a call to setChildMask. The child elements being controlled by the Switch Node are Text2D objects The Switch Nodecan be used to implement modal static scenegraphs, that is, scenegraphs that are essentially of a fixed structure but which the user can influence through adding or removing prebuilt sections. Switch Nodescan also be used to implement simple animation using the SwitchInterpolator Behavior(figure 5.2). The SwitchInterpolatorattaches to a Switch Nodeand cycles the active child of the Switch Nodeusing an Alphaobject. For example, a simple 3D flip-book style animation could be achieved by adding several versions of a 3D model to a Switch Nodeand triggering a SwitchInterpolatorto cycle from one model to another. 76
Searching for affordable and reliable webhost to host and run your web applications? Go to our java web server services and you will be pleased.

else System.out.println( “Failed to find child object during (My web site)

Tuesday, July 24th, 2007

else System.out.println( “Failed to find child object during remove operation.” ); } Note that in the preceding example, the implicit thisis an instance of a class derived from Groupthat has the capability to remove child Nodes based on an internal data structure. 5.5 Switch java.lang.Object | +–javax.media.j3d.SceneGraphObject | +–javax.media.j3d.Node | +–javax.media.j3d.Group | +–javax.media.j3d.Switch The Switch Nodeprovides the facility to define a Group Nodethat can conditionally display or hide its child Nodes (see table 5.4). Table 5.4 Switch Node modes Effect Usage example All child Nodes new Switch( Switch.CHILD_ALL ) No child Nodes new Switch( Switch.CHILD_NONE ) A single child Node switchNode.setWhichChild( nIndex ) Specifiable child Nodes new Switch( Switch.CHILD_MASK ), switchNode.setChildMask( java.util.BitSet childMask ) For example, to create a Switch Nodethat displays child Nodesat index 3, 6, and 7 use the following: From SwitchTest.java //create the Switch Node Switch switchGroup = new Switch( Switch.CHILD_MASK ); switchGroup.setCapability( Switch.ALLOW_SWITCH_WRITE ); switchGroup.addChild( createLabel( “Child Node 1″, labelScale ) ); switchGroup.addChild( createLabel( “Child Node 2″, labelScale ) ); switchGroup.addChild( createLabel( “Child Node 3″, labelScale ) ); switchGroup.addChild( createLabel( “Child Node 4″, labelScale ) ); switchGroup.addChild( createLabel( “Child Node 5″, labelScale ) ); switchGroup.addChild( createLabel( “Child Node 6″, labelScale ) ); switchGroup.addChild( createLabel( “Child Node 7″, labelScale ) ); //create the logical mask to control Node visibility java.util.BitSet visibleNodes = new java.util.BitSet( switchGroup.numChildren() ); //make the third, sixth and seventh nodes visible visibleNodes.set( 2 ); visibleNodes.set( 5 ); visibleNodes.set( 6 ); 75
We would like to recommend you tested and proved virtual web hosting services, which you will surely find to be of great quality.

OrderedGroup A (Free web space) Group that renders its children in

Monday, July 23rd, 2007

OrderedGroup A Group that renders its children in a defined order, irrespective of location Primitive A geometric Group used to manage geometry in the utils package SharedGroup A Group that can be reused across the scenegraph and can be attached to multiple parents Switch A Group that can conditionally display its child Nodes TransformGroup A Group that has an associated geometric transformation containing rotation, translation, and scale information that is applied to its child Nodes before rendering Note that an instance of any of the Group-derived classes, including SharedGroup, can only be added to a single location within the scenegraph. Attempting to add a scenegraph node to a scenegraph that already has an assigned parent (i.e., a node that has already been added to the scenegraph) will result in a run-time exception. I discuss reusing scenegraph branches using a SharedGroupand a Linklater in this chapter. 5.4.1 Remove a child Node by reference It is useful to be able to remove a child Nodefrom its parent Groupwithout knowing the child Node s index. Unfortunately, because scenegraph Nodesare removed from a Groupusing void removeChild(int index), there is no easy way to remove a Shape3Dobject from a Groupif you do not know the index at which it was originally inserted. In the following example, I remove a Shape3Dobject that corresponds to the internal, application-specific data structure. By storing the application-specific data structure in the UserDatafield of the Shape3D, I can retrieve the index of the Shape3Dand remove it from its parent Groupobject. ClassificationObjectis an application-specific data structure that is stored in each child Nodeto identify it. To store the ClassificationObjectin the Node, use node.setUserData( classificationObject ); public void removeChildObject( ClassificationObject targetObj ) { //we need to remove the object by index, so we have to iterate //through our objects to find it. //get an enumeration containing all the child nodes Enumeration enum = getAllChildren(); int nIndex = 0; Node obj = null; //scan through the child nodes until we find the one that //corresponds to our data structure. while( enum.hasMoreElements() != false ) { obj = (Node) enum.nextElement(); if( targetObj != obj.getUserData() ) nIndex++; else break; } //if we found the object, we can now remove it by index. if( nIndex Please visit our professional web hosting services to find out about cheap and reliable webhost service that will surely answer all your demands.

return group; } Note that the propagation of (Web site construction)

Monday, July 23rd, 2007

return group; } Note that the propagation of Boundsup the scenegraph hierarchy (from child to parent) does not occur with CollisionBounds. Cube4 has CollisionBoundsof ( 10, 10, 10) > (10,10,10) but these do not influence the Boundsof the parent Group1. Surprisingly, the CollisionBoundsof Cube4 do not influence the CollisionBoundsof the parent Group1 either. It appears that the application programmer is responsible for manually propagating CollisionBoundsfrom child to parent Nodes. 5.4 Group java.lang.Object | +–javax.media.j3d.SceneGraphObject | +–javax.media.j3d.Node | +–javax.media.j3d.Group Groupdefines a scenegraph Nodethat contains a collection of child Nodes. It defines the following child Nodemanagement methods: void addChild(Node child) java.util.Enumeration getAllChildren() Node getChild(int index) void insertChild(Node child, int index) void moveTo(BranchGroup branchGroup) int numChildren() void removeChild(int index) void setChild(Node child, int index) These methods essentially delegate, in obvious ways, to the internal collection that manages the child Nodes within the Group. Table 5.2 shows the capabilities defined by Group. Table 5.2 Capabilities defined by Group Capability bit Description ALLOW_CHILDREN_EXTEND Allows child Nodes to be added to the Group ALLOW_CHILDREN_READ Allows reading of child Nodes (e.g., getChild method) ALLOW_CHILDREN_WRITE Allows writing of child Nodes (e.g., setChild method) ALLOW_COLLISION_BOUNDS_READ Allows reading of collision Bounds ALLOW_COLLISION_BOUNDS_WRITE Allows writing of collision Bounds Groupis an important base class for the Java 3D Nodemanagement classes, and it can also be instantiated in its own right. For increased flexibility, however, I recommend BranchGroup Nodesbecause they can be dynamically added or removed from the scenegraph. The classes derived from Groupare shown in table 5.3. Table 5.3 Classes derived from Group Class Description BranchGroup A dynamically insertable and removable Group 73
From our experience, we are can tell you that you can find a reliable and cheap webhost service at Java Web Hosting services.

Cube4 Bounding box: Lower = 6.0 6.0 6.0 (Starting a web site)

Monday, July 23rd, 2007

Cube4 Bounding box: Lower = 6.0 6.0 6.0 Upper = 6.0 6.0 6.0 true Cube5 Bounding box: Lower = 6.0 6.0 6.0 Upper = 6.0 6.0 6.0 true Group2 Bounding Sphere: Center = ( 0.01, 0.01,0.00) Radius = 8.62 true PointsArray Bounding box: Lower = 4.97 4.98 5.00 Upper = 4.95 4.96 4.97 true Group1 contains the five ColorCubes, as created earlier in the section. The largest ColorCubehas a BoundingBoxof ( 6, 6, 6) > (6,6,6). The radius of the smallest BoundingSphereto enclose the largest ColorCubeis therefore radius = sqrt( 62 + 62 + 62) = 10.392. This BoundingSphereis automatically created by Java 3D and assigned to the parent Group(Group1) of the ColorCubes. Note that Group1 has the property setBoundsAutoCompute( true ). Group2 contains a Shape3Dobject composed from 200 random points in a PointArray(positioned between 5 and 5 in the x-, y-, and z-axes). Java 3D automatically creates a BoundingBoxto enclose the points composing the Shape3Dobject approximately: ( 5, 5, 5) > (5,5,5). The BoundingBoxis automatically assigned to the Shape3Dobject containing the PointArray. The Boundsfor the Shape3D object are propagated up the scenegraph hierarchy as a BoundingSphereand assigned to Group2. The center of the BoundingSphereis positioned to minimize the radius (in this case approximately 0,0,0). The radius of the BoundingSphereis approximately computed from radius = sqrt( 52 + 52 + 52) = 8.660. The parent of Group1, Group2, and RotationInterpolatoris TransformGroup. TransformGroupcombines the Boundsobjects for its children to compute its own Bounds. In this case, as the Boundsof the children are all approximately centered at (0,0,0), which is equal to the Bounds of Group1 (which is the largest). The top-level parent BranchGroupnode has the attribute setBoundsAutoCompute( NOTE false ). //routine to create a Shape3D object made from a point cloud //of 200 random points protected Group createPoints() { Group group = new Group(); final int kNumPoints = 200; final double kRadius = 10.0; Point3d points[] = new Point3d[kNumPoints]; for( int n = 0; n Searching for affordable and reliable webhost to host and run your web applications? Go to our java web server services and you will be pleased.