Archive for October, 2007

How to cite a web site - Sorted PickResult 0: PickResult: sgp:javax.media.j3d.Locale@124fb8e : javax.media.j3d.BranchGroup :

Wednesday, October 31st, 2007

Sorted PickResult 0: PickResult: sgp:javax.media.j3d.Locale@124fb8e : javax.media.j3d.BranchGroup : com.sun.j3d.utils.geometry.Sphere, Sphere : javax.media.j3d.Shape3D, Spherejavax.media.j3d.TriangleStripArray@12b486c The transformation matrix required to convert the terminal node of the scenegraph path (Shape3D) to Virtual World coordinates is displayed. This is the transformation matrix that was in effect when the pick took place. LocalToVworld Transform: -0.5243562077058301, -0.8502316137753383, 0.04644104194946784, 0.35220520974733893 0.3928339572694004, -0.19315917400790997, 0.8990945531548112, 5.215472765774056 -0.7554680995624017, 0.4896894285499475, 0.4352840614012915, 0.5764203070064573 0.0, 0.0, 0.0, 1.0 Next, the intersection information for the ray is displayed. In this case, the ray intersected six Nodesin the model. For each intersection, the distance of the intersection from the ViewPlatformis calculated along with the point s coordinates in Virtual World coordinates. As you can see from the Z-coordinates and distances, five of the intersections were with Nodesat the front of the Spherewhile one was with a node at the rear of the Sphere. node:javax.media.j3d.Shape3D@12b485a PickIntersection: geomIndex = 0 dist:13.190385327169809 ptVW:(0.3082159939737674, 5.101595194311164, -0.40544525181089597) PickIntersection: geomIndex = 0 dist:11.285273011880047 ptVW:(0.2697997524391042, 4.782074528439611, 1.4723671948932975) PickIntersection: geomIndex = 0 dist:11.28272787795884 ptVW:(0.2766647006417829, 4.784127302928557, 1.4754390646997604) PickIntersection: geomIndex = 0 dist:11.282690605316592 ptVW:(0.26386760841671225, 4.797646503054273, 1.4773578620510737) PickIntersection: geomIndex = 0 dist:11.279971427880689 ptVW:(0.27735265885195876, 4.796380438058344, 1.4802262351804227) PickIntersection: geomIndex = 0 dist:11.28272787795884 ptVW:(0.2766647006417829, 4.784127302928557, 1.4754390646997604) Sorted Object 0: Sphere Closest Object: Sphere The second illustrated pick intersection is more complex (figure 16.2). As you can see, the sphere is still the closest intersection; however, the pick ray passes through the entire model. In this example (output following), the VRML part intersections are (sorted from nearest to farthest): 1. Sphere: 2 intersections 2. Cone: 2 intersections 3. Cone: 2 intersections 4. Box: 2 intersections 272
If you are searching for cheap webhost for your web application, please visit MySQL5 Web Hosting services.

16.7 VRML picking example The (Free web host) VrmlPickingTestexample illustrates how

Wednesday, October 31st, 2007

16.7 VRML picking example The VrmlPickingTestexample illustrates how the PickCanvasand PickResultclasses can be used. The example loads a VRML format data file and allows the user to rotate, translate, and scale the loaded model. When the mouse is clicked, a list is generated of the intersections of the model with a PickCylinderRaythat passes perpendicularly through the clicked screen location into the 3D scene. All the intersections with the model are reported, as well as the closest intersection. When a mouse click occurs, VrmlPickingTestproduces the following output (which corresponds to clicking the mouse in the position shown in figure 16.1. The output is a list of the PickResultobjects (sorted from nearest to farthest): *** MouseClick *** First, the path through the scenegraph to the intersected node is displayed. In this case, the path is the VirtualUniverse s Locale, a BranchGroup, the Sphereprimitive (user data is Sphere ), then finally a Shape3Dcontaining a TriangleStripArray. Figure 16.1 A VRML scene loaded into the VrmlPickingTest example. Note the position of the cursor (the hand icon), which corresponds to the scene intersections in the code which follows 271
If you are in need for cheap and reliable webhost to host your website, we recommend http web server services.

Vector3f getNormal(PickIntersection pi, int vertexIndex) { int index;

Tuesday, October 30th, 2007

Vector3f getNormal(PickIntersection pi, int vertexIndex) { int index; Vector3d normal = new Vector3f(); GeometryArray ga = pickIntersection.getGeometryArray(); if (pickIntersection.geometryIsIndexed()) { index = ga.getNormalIndex(vertexIndex); } else { index = vertexIndex; } ga.getNormal(index, normal); return normal; } The color, normal, and texture coordinate information for the intersected primitive and the intersection point can be queryed. The geometry includes them, and the corresponding READcapability bits are set. PickTool.setCapabilities(Node, int)can be used to set the capability bits to allow this data to be queryed. 16.6 PickResult java.lang.Object | +–com.sun.j3d.utils.picking.PickResult PickResultstores information about a pick hit. Detailed information about the pick and each intersection of the PickShapewith the picked Nodecan be inquired. The PickResultis constructed with basic information, and more detailed information is generated as needed. The additional information is only available if capability bits on the scenegraph Nodesare set properly; PickTool.setCapabilities(Node, int)can be used to ensure correct capabilities are set. Inquiring data that is not available due to capabilities not being set will generate a CapabilityNotSetException. A PickResultcan be used to calculate intersections on Nodewhich is not part of a live scenegraph using the constructor which takes a local to VWorldtransformation for the Node. Pick hits on TriangleStripprimitives will store the triangle points in the PickIntersectionwith the vertices in counterclockwise order. For triangles that start with an odd numbered vertex, this will be the opposite of the order of the points in the TriangleStrip. This way the triangle in the PickIntersectionwill be displayed the same way as the triangle in the strip. If the Shape3Dbeing picked has multiple geometry arrays, the arrays are stored in the PickResultand referred to by a geometry index. If the Shape3Drefers to a CompressedGeometry, the geometry is decompressed into an array of Shape3Dnodes that can be queryed. The geometry NodeComponentsfor the Shape3Dnodes are stored and used as if the Shape3Dhad multiple geometries. If there are multiple CompressedGeometrieson the Shape3D, the decompressed Shape3Dsand GeometryArrayswill be stored sequentially. The intersection point for Morphnodes cannot be calculated using the displayed geometry due to limitations in the current Java3D core API (the current geometry of the Morphcannot be inquired). Instead, the geometry at index 0 in the Morphis used. This limitation may be eliminated in a future release of Java3D. 270
Go visit our java server pages services for a reliable, lowcost webhost to satisfy all your needs.

+–com.sun.j3d.utils.picking.PickTool | +–com.sun.j3d.utils.picking.PickCanvas (Sri lanka web server) PickCanvas, a subclass of PickTool,

Tuesday, October 30th, 2007

+–com.sun.j3d.utils.picking.PickTool | +–com.sun.j3d.utils.picking.PickCanvas PickCanvas, a subclass of PickTool, simplifies picking using mouse events from an AWT Canvas. This class allows picking using Canvasx,y locations by generating the appropriate pick shape. The pick tolerance specifies the distance from the pick center to include in the pick shape. A tolerance of 0.0 may slightly speed up picking, but also makes it very difficult to pick points and lines. The pick canvas can be used to make a series of picks; for example, to initialize the pick canvas, do the following: PickCanvas pickCanvas = new PickCanvas(canvas, scene); pickCanvas.setMode(PickTool.GEOMETRY_INTERSECT_INFO); pickCanvas.setTolerance(4.0f); Then for each mouse event: pickCanvas.setShapeLocation(mouseEvent); PickResult[] results = pickCanvas.pickAll(); For the pickAllSortedor pickClosestmethods, the picks will be sorted by the distance from the ViewPlatformto the intersection point. 16.5 PickIntersection java.lang.Object | +–com.sun.j3d.utils.picking.PickIntersection PickIntersectionholds information about an intersection of a PickShapewith a Nodeas part of a PickResult. Information about the intersected geometry, intersected primitive, intersection point, and closest vertex can be queryed. The intersected geometry is indicated by an index into the list of geometry arrays on the PickResult. It can also be queryed from this object. The intersected primitive indicates which primitive out of the GeometryArraywas intersected (where the primitive is a point, line, triangle, or quad, not a com.sun.j3d.utils.geometry.Primitive). For example, the intersection would indicate which triangle out of a triangle strip was intersected. The methods which return primitive data will have one value if the primitive is a point, two values if the primitive is a line, three values if the primitive is a triangle, and four values if the primitive is quad. The primitive s VWorldcoordinates are saved when the intersection is calculated. The local coordinates, normal color, and texture coordinates for the primitive can also be queryed if they are present and readable. The intersection point is the location on the primitive which intersects the pick shape closest to the center of the pick shape. The intersection point s location in VWorldcoordinates is saved when the intersection is calculated. The local coordinates, and the normal, color, and texture coordinates of the intersection can be interpolated if they are present and readable. The closest vertex is the vertex of the primitive closest to the intersection point. The vertex index, VWorld coordinates, and local coordinates of the closest vertex can be queryed. The normal, color, and texture coordinate of the closest vertex can be queryed from the geometry array: 269
We would like to recommend you tested and proved virtual web hosting services, which you will surely find to be of great quality.

the SceneGraphPath to the picked Node. Geometry nodes (Web hosting domain names)

Monday, October 29th, 2007

the SceneGraphPath to the picked Node. Geometry nodes in the scene must have the ALLOW_INTERSECT capability set for this mode. Same as GEOMETRY, but the PickResult will include information on each intersection of the pick shape with the geometry. The intersection information includes the subprimitive picked (i.e., the point, line, triangle, or quad), the closest vertex to the center of the pick shape, and the intersection’s coordinate, normal, color, and texture coordinates. To allow this to be generated, Shape3D and Morph nodes must have the ALLOW_GEOMETRY_READ capability GEOMETRY_INTERSECT_INFO set, and GeometryArrays must have the ALLOW_FORMAT_READ, ALLOW_COUNT_READ, and ALLOW_COORDINATE_READ capabilities set, plus the ALLOW_COORDINATE_INDEX_READ capability for indexed geometry. To query the intersection color, normal, or texture coordinates, the corresponding READ capability bits must be set on the GeometryArray. The utility method PickTool.setCapabilities(Node, int)can be used before the scenegraph is made live to set the capabilities of Shape3D, Morph, or Geometrynodes to allow picking. A PickResultfrom a lower level of detail pick can be used to inquire about more detailed information if the capability bits are set. This can be used to filter the PickResultsbefore the more computationally intensive intersection processing. For example, the application can do a BOUNDSpick and then selectively query intersections on some of the PickResults. This will save the effort of doing intersection computation on the other PickResults. However, querying the intersections from a GEOMETRYpick will make the intersection computation happen twice, so use GEOMETRY_INTERSECT_INFOif you want to inquire the intersection information on all the PickResults. When using pickAllSortedor pickClosestmethods, the picks will be sorted by the distance from the start point of the pick shape to the intersection point. Morphnodes cannot be picked using the displayed geometry in GEOMETRY_INTERSECT_INFOmode due to limitations in the current Java3D core API (the current geometry of the Morphcannot be queryed). Instead, they are picked by using the geometry at index 0 in the Morph. This limitation may be eliminated in a future release of Java3D. If the pick shape is a PickBounds, the pick result will contain only the scenegraph path, even if the mode is GEOMETRY_INTERSECT_INFO. 16.4 PickCanvas java.lang.Object | 268
If you are in need for cheap and reliable webhost to host your website, we recommend http web server services.

+–javax.media.j3d.PickShape PickShapesare used by the PickToolto provide information (Web server iis)

Monday, October 29th, 2007

+–javax.media.j3d.PickShape PickShapesare used by the PickToolto provide information about the volume of space, segment, or infinite ray that the objects in the scene should be tested against. Java 3D supports the PickShapeslisted in table 16.1: Table 16.1 PickShapes supported by Java 3D PickShapes Description PickBounds PickBounds is a finite pick shape defined with a Bounds object. PickConeRay PickConeRay is an infinite cone ray pick shape. PickConeSegment PickConeSegment is a finite cone segment pick shape. PickCylinderRay PickCylinderRay is an infinite cylindrical ray pick shape. PickCylinderSegment PickCylinderSegment is a finite cylindrical segment pick shape. PickPoint PickPoint is a pick shape defined as a single point. PickRay PickRay is an infinite ray pick shape. PickSegment PickSegment is a line segment pick shape. By using the appropriate PickShapeyou can find the objects in your scene that Fall within a given volume (PickBounds) Intersect with an infinite cone, such as a ray of light shining from a torch (PickConeRay) Intersect with a finite length cone, such as the objects within a torch ray, within a given distance (PickConeSegment) Intersect with a laser beam (PickCylinderRay) Intersect with a blind-man s stick (PickCylinderSegment) Intersect with a point (PickPoint) Intersect with a very narrow laser beam (PickRay) Intersect with a very narrow blind-man s stick (PickSegment) 16.3 PickTool java.lang.Object | +–com.sun.j3d.utils.picking.PickTool PickToolis the base class for picking operations. The picking methods will return a PickResultobject for each object picked, which can then be queried to obtain more detailed information about the specific objects that were picked. The pick mode specifies the detail level of picking before the PickResultis returned (see table 16.2). Table 16.2 PickTools PickTool Mode Description BOUNDS Pick using the bounds of the pickable nodes. The PickResult returned will contain the SceneGraphPath to the picked Node. GEOMETRY Pick using the geometry of the pickable nodes. The PickResult returned will contain 267
Note: In case you are looking for affordable and reliable webhost to host and run your j2ee application check Vision J2ee Web Hosting services.

Web site hosting - CHAPTER 16 Object interaction picking and collision detection 16.1

Monday, October 29th, 2007

CHAPTER 16 Object interaction picking and collision detection 16.1 Introduction to picking 16.2 PickShapes 16.3 PickTool 16.4 PickCanvas 16.5 PickIntersection 16.6 PickResult 16.7 VRML picking example 16.8 Using picking for collision detection 16.9 Conclusions Two example applications of Java 3D s support for picking are presented here. The first example, in section 16.7, loads a VRML scene and reports the name of the object from the VRML scene that was picked when a mouse click occurs. The second example uses Java 3D s Bounds-based picking to implement simple collision detection. The example creates four Sphereobjects within a cube, which ricochet off each other and the walls of the cube. 16.1 Introduction to picking Picking is the act of identifying objects in the 3D scene, usually with a pointing device, such as the mouse. Java 3D s support for behaviors and picking can also be used to implement simple collision detection and response within a 3D scene. Picking is central to many of the direct-manipulation UI paradigms. Using direct manipulation, for example, you would translate an object by clicking it and moving the mouse, as opposed to typing the object ID and its new position into an edit field. For precision work, the edit field will work best; however, it abstracts the user from the 3D scene as compared to direct manipulation. Java 3D 1.2 includes some new classes that make picking relatively easy. These classes are a big improvement over the 1.1 picking classes, which have been widely deprecated. Before going into the details of the examples, I will describe the Java 3D 1.2 picking classes. The Java documentation for the picking classes is excellent, probably the best in Java 3D, so it is useful to familiarize yourself with it. 16.2 PickShapes java.lang.Object | 266
We would like to recommend you tested and proved virtual web hosting services, which you will surely find to be of great quality.

PLAY Xj3D Loader (Web host music) Extensible 3D (X3D) Task Group

Sunday, October 28th, 2007

PLAY Xj3D Loader Extensible 3D (X3D) Task Group (former VRML97-Java Working Group) VRML97 X3D 15 Sept 2000 FullSail OpenFLT Loader Shawn Kendall OpenFLT 1 Aug 1999 Lw3dLoader Sun LWS (Lightwave Scene Format) uses LWO (Lightwave Object Format) 13 Jun 1998 ObjLoad Sun OBJ (Wavefront) 12 Jun 1998 NFF OBJ Loader Scott Metzger NFF (WorldToolKit) OBJ (Wavefront) 15 Jun 1998 Loader3DS Starfire Research 3DS(3D-Studio) March 2001 Import3DS Aaron Mulder 3DS (3D-Studio) 13 Jun 1998 Load3DS Wesley Layne 3DS (3D-Studio) 25 Feb 2001 Load3DS Rycharde Hawkes 3DS (3D-Studio) 16 Jun 1998 VTK Loader Arish Ali VTK (Visual Toolkit) 15 Sept 2000 Different loaders have different limitations and bugs. You should experiment with loaders and file formats until you find one that works for the files you need to display. 15.4 Summary Java 3D includes relatively basic support for processing geometry using the utility classes in the com.sun.j3d.utils.geometrypackage. The utilities are easy to use, and are useful for simple triangulation. For more powerful geometry manipulation operati ons (such as mesh generation or decimation you will have to convert one of the many utility libraries, usually written in C). The interfaces and classes defined in the com.sun.j3d.loaderspackage however have proved to be very useful. They have defined a standard upon which many of the community Java 3D developers can build, and a large variety of loaders have been released mos t are free. 265
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.

catch (Exception e) { (Web design conference) scene = null; System.err.println(e);

Sunday, October 28th, 2007

catch (Exception e) { scene = null; System.err.println(e); } if( scene == null ) System.exit(1); //retrieve the Shape3D object from the scene BranchGroup branchGroup = scene.getSceneGroup(); shape = (Shape3D) branchGroup.getChild(0); //create an Appearance and Material Appearance app = new Appearance(); Color3f objColor = new Color3f(1.0f, 0.7f, 0.8f); Color3f black = new Color3f(0.0f, 0.0f, 0.0f); app.setMaterial(new Material(objColor, black, objColor, black, 80.0f)); //assign the appearance to the Shape shape.setAppearance( app ); //connect the scenegraph objTrans2.addChild( scene.getSceneGroup() ); objTrans1.addChild( objTrans2 ); objRoot.addChild( objTrans1 ); return objRoot; } 15.3.4 Third-party object loaders There are a wide variety of object loaders available for use with Java 3D. The list of available loaders is maintained by Bill Day at http://www.j3d.org. Data file loaders available for most of the common 3D data file formats are listed in table 15.1. Table 15.1 Data file loaders Loader Author File Format(s) Last Updated Milkshape3D Loader Gregory Pierce Milkshape3D 30 Aug 2001 Milkshape3D Loader Kevin Duling Milkshape3D 28 Aug 2001 AC3D Loader Ryan Wilhm/j3d.org AC3D 28 Aug 2001 NCSA Portfolio NCSA 3DS (3D-Studio) PDB (Protein Data Bank) DEM (Digital Elevation Map) IOB (Imagine) COB (Caligari trueSpace) OBJ (Wavefront) DXF (Drawing Interchange File) AutoCAD VRML 97 15 Sept 2000 264
Visit our web design programs services for an affordable and reliable webhost to suit all your needs.

Make my own web site - Figure 15.3 A Wavefront OBJ file loaded using

Saturday, October 27th, 2007

Figure 15.3 A Wavefront OBJ file loaded using the Sun ObjectFile loader From LoaderTest.java protected BranchGroup createSceneBranchGroup() { BranchGroup objRoot = super.createSceneBranchGroup(); //create a TransformGroup to flip the hand onto its end //and enlarge it. TransformGroup objTrans1 = new TransformGroup(); Transform3D tr = new Transform3D(); objTrans1.getTransform( tr ); tr.rotX(90.0 * Math.PI / 180.0); tr.setScale( 10.0 ); objTrans1.setTransform( tr ); //create a TransformGroup to rotate the hand TransformGroup objTrans2 = new TransformGroup(); objTrans2.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE); objTrans2.setCapability(TransformGroup.ALLOW_TRANSFORM_READ); BoundingSphere bounds = new BoundingSphere( new Point3d(0.0,0.0,0.0), 100.0); //create a RotationInterpolator behavior to rotate the hand Transform3D yAxis = new Transform3D(); Alpha rotationAlpha = new Alpha(-1, Alpha.INCREASING_ENABLE, 0, 0, 4000, 0, 0, 0, 0, 0); RotationInterpolator rotator = new RotationInterpolator( rotationAlpha, objTrans2, yAxis, 0.0f, (float) Math.PI*2.0f); rotator.setSchedulingBounds(bounds); objTrans2.addChild(rotator); //Set up the global lights Color3f lColor1 = new Color3f(0.7f, 0.7f, 0.7f); Vector3f lDir1 = new Vector3f(-1.0f, -1.0f, -1.0f); Color3f alColor = new Color3f(0.2f, 0.2f, 0.2f); AmbientLight aLgt = new AmbientLight(alColor); aLgt.setInfluencingBounds(bounds); DirectionalLight lgt1 = new DirectionalLight(lColor1, lDir1); lgt1.setInfluencingBounds(bounds); objRoot.addChild(aLgt); objRoot.addChild(lgt1); //load the object file Scene scene = null; Shape3D shape = null; //read in the geometry information from the data file ObjectFile objFileloader = new ObjectFile( ObjectFile.RESIZE ); try { scene = objFileloader.load( “hand1.obj”); } 263
In case you need affordable webhost to host your website, our recommendation is ecommerce web host services.