Archive for October, 2007

Web hosting comparison - 15.3.1 LoaderBase java.lang.Object | +–com.sun.j3d.loaders.LoaderBase LoaderBaseis a convenience

Saturday, October 27th, 2007

15.3.1 LoaderBase java.lang.Object | +–com.sun.j3d.loaders.LoaderBase LoaderBaseis a convenience class to manage the setting and retrieval of typical Loaderinformation, such as base URL and load flags. Developers implementing their own Loadercan populate, return, and interrogate a LoaderBaseinstance to provide a consis tent API for end-user developers. 15.3.2 SceneBase interface java.lang.Object | +–com.sun.j3d.loaders.SceneBase SceneBaseis a convenience class to manage the setting and retrieval of typical Sceneinformation, such as: Background nodes Behavior nodes Description Fog nodes FOV parameters Lights Objects Sound nodes Developers implementing their own Loadercan populate, return, and interrogate a SceneBaseinstance to provide a consistent API for end-user developers. 15.3.3 Using the ObjectFile loader The following example loads a simple Wavefront format .obj file (the hand1.obj file from the Sun Morphing demo). Note that it is also necessary to create lights for the scene and assign an Appearanceand Materialto the loaded Wavefront object. Figure 15 .3 shows rendered output. 262
Note: In case you are looking for affordable and reliable webhost to host and run your j2ee application check Vision J2ee Web Hosting services.

2,1,0, //9 //these are vertices for the hole (Business web hosting)

Friday, October 26th, 2007

2,1,0, //9 //these are vertices for the hole 1,3,0, //10 2,3,0, //11 3,2,0, //12 3,1,0, //13 2,2,0};//14 //triangulate the polygon GeometryInfo gi = new GeometryInfo( GeometryInfo.POLYGON_ARRAY ); gi.setCoordinates( m_VertexArray ); //the first 10 points make up the outer edge of the polygon, //the next five make up the hole int[] stripCountArray = {10,5}; int[] countourCountArray = {stripCountArray.length}; gi.setContourCounts( countourCountArray ); gi.setStripCounts( stripCountArray ); Triangulator triangulator = new Triangulator(); triangulator.triangulate( gi ); //also generate normal vectors so that the surface can be light NormalGenerator normalGenerator = new NormalGenerator(); normalGenerator.generateNormals( gi ); //create an appearance Appearance ap = new Appearance(); //render as a wireframe PolygonAttributes polyAttrbutes = new PolygonAttributes(); polyAttrbutes.setPolygonMode( PolygonAttributes.POLYGON_LINE ); polyAttrbutes.setCullFace( PolygonAttributes.CULL_NONE ) ; ap.setPolygonAttributes( polyAttrbutes ); //add both a wireframe and a solid version //of the triangulated surface Shape3D shape1 = new Shape3D( gi.getGeometryArray(), ap ); Shape3D shape2 = new Shape3D( gi.getGeometryArray() ); After the geometry has been triangulated and normal vectors have been calculated, the geometry can be very easily stripified: //invoke the Stripifier on the GeometryInfo Stripifier st = new Stripifier() st.stripify(gi); //extract the stripified GeometryArray Shape3D shape2 = new Shape3D( gi.getGeometryArray() ); 15.3 Object loaders Sun has defined the com.sun.j3d.loaders.Loaderinterface that provides a standard set of methods for accessing the information read in from a 3D data file format. Because there is such a wide variety of 3D data file formats available, the Loaderinterfac e is fairly high level and does not return graphical information directly but encapsulates it in an object implementing the Sceneinterface. 261
Check Tomcat Web Hosting services for best quality webspace to host your web application.

array. This coordinate array should first define the (My space web page)

Friday, October 26th, 2007

array. This coordinate array should first define the outer boundary of the polygon, using counterclockwi se winding. Then define any polygons that are to be excluded from the generated composite triangular surface. This simple example in figure 15.1 defines two contours: the outer polygon and one hole. The stripCountArrayis an array of integers that delineates one con tour from the next. In figure 15.1, the stripCountArraywould be int[] stripCountArray = {4,3}; Figure 15.1 Counterclockwise winding for defining a polygon and a hole for Triangulation Figure 15.2 Output from TriangulatorTest: The surface generated rendered both as a solid (left) and as a wireframe (right) The first contour (A,B,C,D) contains four vertices, and the hole (F,G,H) contains three vertices. The Triangulatorclass is not very well documented, so the following example should illustrate the concepts of polygon triangulation using the Triangulatorclass. In particular, the contourCountArrayelement is misleadingly documented and should be set t o the number of contours (1 + the number of holes). This is always the same as the length of the stripCountArray. Why the contourCountArrayis necessary is not clear. From TriangulatorTest.java //Generate a surface from 10 vertices and //create a hole in the surface by removing //a hole defined using 5 vertices. Note that the hole //must be entirely within the outer polygon. private double[] m_VertexArray = {1,1,0, //0 0,3,0, //1 1,5,0, //2 2,4,0, //3 4,5,0, //4 3,3,0, //5 4,2,0, //6 4,0,0, //7 3,0,0, //8 260
Note: If you are looking for cheap and reliable webhost to host and run your mysql application check mysql web server services.

CHAPTER 15 Geometry utility classes and object loaders (Web server extensions)

Thursday, October 25th, 2007

CHAPTER 15 Geometry utility classes and object loaders 15.1 Introduction 15.2 Triangulator, normal vector generator, stripifier 15.3 Object loaders 15.4 Summary This chapter explains some of the utility classes that Java 3D supplies to help you import or generate geometry for your scenes. 15.1 Introduction Java 3D comes with three utility classes that facilitate runtime geometry creation: Triangulatorconverts a list of points and connectivity information into a GeometryArray composed of triangles. NormalGeneratorgenerates Normal vectors for a list of triangles. Stripifierredefines an existing triangle list such that the triangles are specified in longs strips, with adjacent triangles sharing as many vertices as possible. Triangle lists are stripified to speed rendering by graphics hardware and software underlying Java 3D. The geometry compression classes allow Java 3D to create an internal compressed representation of geometry information. If the graphics hardware supports using compressed geometry, the result may be faster rendering time and lower memory usage. Geometry compression can also be useful for applications that need to send Java 3D geometry across network connections using serialization or Java RMI. Refer to the API documentation for further details. The Java 3D object loaders define an architecture for writing files to import geometry data into Java 3D. Sun supplies two loaders as part of the Java 3D utilities package: Lightwave 3D Object file In addition, the Java 3D/VRML working groups maintain a VRML loader to import VRML (WRL) files into Java 3D. The VRML loader must be downloaded separately (VRML97.JAR). The example VrmlPickingTestuses the VRML97 loader. The VRML97 loader is no longer be ing developed and is being replaced by the loaders being developed for the X3D standard, hosted at http://www.web3d.org. 15.2 Triangulator, normal vector generator, stripifier Triangulation is a mechanism to convert arbitrary polygons to triangular surfaces for rendering. The com.sun.j3d.utils.geometry.Triangulatorclass can be used not only to convert an arbitrary n-sided polygon (which does not have to be planar) to triangul ar surfaces, but also to create holes in the generated composite surface. To use the Triangulator, put your vertex coordinates into a double or float 259
We highly recommend you visit web and email hosting services if you need stable and cheap web hosting platform for your web applications.

Figure 14.27 Transparency = 0.2, PolygonAttributes.CULL_NONE. Shape3D with (Web hosting comparison)

Thursday, October 25th, 2007

Figure 14.27 Transparency = 0.2, PolygonAttributes.CULL_NONE. Shape3D with transparent image applied (texture2n.gif) from AppearanceTest. 1 = MODULATE, 2 = DECAL, 3 = BLEND, 4 = REPLACE 14.6 Animated (video) texture mapping Many recent computer games use animated texture maps, for example, to map an MPEG video clip onto the face of a cube. 3D accelerator hardware is also starting to support video textures. Drawing animated textures is at present problematic in Java 3D because, although you can draw into an ImageComponentand use it as a texture image, the ImageComponentis copied into texture memory. Java 3D 1.2 should go some way to addressing this issue, but performance problems are likely to remain an issue for some time. For very simple texture animations (a few frames), each frame of the animation can be pasted (either at runtime or as a preprocess) into a composite texture image. At runtime the texture coordinates of vertices can be modified to cycle through the various frames of the animation. 14.7 Summary This chapter has given you a taste of the power of texture mapping and the important role it plays in most 3D applications, be they educational, scientific, or entertainment. Texture mapping requires a little more work from the application developer, in terms of learning new terminology and methods, but the end results justify the extra development time. Clever use of lighting and texture mapping sets the great, visually immersive 3D applications apart from flat, uninspiring computer graphics. 258
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.

Linux web host - Figure 14.25 Shape3D with an opaque image applied

Wednesday, October 24th, 2007

Figure 14.25 Shape3D with an opaque image applied (texture0n.jpg) from AppearanceTest. 1 = MODULATE, 2 = DECAL, 3 = BLEND, 4 = REPLACE Figure 14.26 uses a transparent version (texture2n.gif) of the original texture image. The white background of the texture image has been marked as a transparent color in the GIF image. Figure 14.26 Shape3D with transparent image applied (texture2n.gif) from AppearanceTest. 1 = MODULATE, 2 = DECAL, 3 = BLEND, 4 = REPLACE Figure 14.27 uses the transparent texture image but also disables back-face removal using PolygonAttributes.CULL_NONE. Frame 2 (DECAL) suffered from continuous redraw because the back faces were redrawn over the front faces, and then the back faces were redrawn. 257
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.

Free web hosting music - //the color cube with the left mouse button

Wednesday, October 24th, 2007

//the color cube with the left mouse button MouseRotate mouseRot = new MouseRotate( subTg ); subTg.addChild( mouseRot ); //assign a transformChanged callback, because we want //to be notified whenever the rotation of the ColorCube changed //(”this” implements MouseBehaviorCallback ); mouseRot.setupCallback( this ); mouseRot.setSchedulingBounds( getApplicationBounds() ); transTg.addChild( subTg ); return transTg; } //this is a callback method that the MouseRotate behavior calls //when its Transform3D has been modified (by the user) public void transformChanged(int type, Transform3D transform) { //update the rotation of the TextureAttributes m_TextureAttributes.setTextureTransform( transform ); } 14.5 Using transparent geometry with transparent texture images The Textureclass allows texture images to have red, green, blue, and alpha (transparency) channels through the RGBA mode. Appearances(and hence geometry) can also have transparency information, either through per-vertex COLOR_4colors, or through the TransparencyAtttributes NodeComponent. Figures 14.25 14.27 illustrate what happens when partially transparent images are applied to partially transparent Shape3Ds. The easiest way to use transparent images is to use the GIF image format, which can include a transparent color. Most bitmap editors, such as JASC PaintShop Pro or Adobe Photoshop, can save GIF images with a transparent color. Figures 14.25 14.27 were generated using the AppearanceTestexample application. The Boxhad the appearance attributes shown on table 14.5. Table 14.5 Box appearance attributes Transparency: 0.5, NICEST Material: Ambient = white, Diffuse = white, Emissive = blue, Specular = black, Shininess = 1 Texture: MagFilter = BASE_LEVEL_LINEAR, MinFilter = MULTI_LEVEL_LINEAR MIPMAPs were enabled. The front face (smaller) of the cube uses per-vertex colors with transparency and hence is unaffected by the overall TransparencyAttributes of the Box s Appearance. Figure 14.25 is provided for contrast; it uses the opaque texture image (texture0n.jpg). 256
We recommend high quality webhost to host and run your jsp application: christian web host services.

//create a Box with an applied Texture image (Web hosting reseller)

Wednesday, October 24th, 2007

//create a Box with an applied Texture image //and a RotationInterpolator to rotate the box protected BranchGroup createSceneBranchGroup() { BranchGroup objRoot = super.createSceneBranchGroup(); TransformGroup objTrans = new TransformGroup(); objTrans.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE); objTrans.setCapability(TransformGroup.ALLOW_TRANSFORM_READ); Transform3D yAxis = new Transform3D(); Alpha rotationAlpha = new Alpha(-1, Alpha.INCREASING_ENABLE, 0, 0, 4000, 0, 0, 0, 0, 0); //create the rotation interpolator to rotate the scene RotationInterpolator rotator = new RotationInterpolator(rotationAlpha, objTrans, yAxis, 0.0f, (float) Math.PI*2.0f); rotator.setSchedulingBounds( createApplicationBounds() ); objTrans.addChild(rotator); //create the box final int nScale = 50; Appearance app = new Appearance(); Box box = new Box( nScale, nScale, nScale, Primitive.GENERATE_NORMALS | Primitive.GENERATE_TEXTURE_COORDS, app ); //load the texture image TextureLoader texLoader = new TextureLoader( “texture.gif”, this ); app.setTexture( texLoader.getTexture() ); //set the texture attributes and ensure we can write //to the Transform for the texture attributes m_TextureAttributes = new TextureAttributes(); m_TextureAttributes.setCapability( TextureAttributes.ALLOW_TRANSFORM_WRITE ); app.setTextureAttributes( m_TextureAttributes ); //connect all the elements objTrans.addChild( box ); objRoot.addChild( objTrans ); objRoot.addChild( createRotator() ); return objRoot; } //private TransformGroup createRotator() { //create a ColorCube to illustrate the current rotation TransformGroup transTg = new TransformGroup(); Transform3D t3d = new Transform3D(); t3d.setTranslation( new Vector3d( -70, -70, 50 ) ); transTg.setTransform( t3d ); TransformGroup subTg = new TransformGroup(); subTg.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE); subTg.addChild( new ColorCube(10.0) ); //attach a MouseRotate behavior so we can rotate 255
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.

Web hosting asp - Figure 14.23 Material colors set as in figure

Tuesday, October 23rd, 2007

Figure 14.23 Material colors set as in figure 14.14 and texture image applied using REPLACE mode Refer to the Java 3D API Specification for more details on the texture mapping equations. 14.4.3 Transform A rotational transformation can also be applied to the texture image prior to texture mapping. This is a fairly unusual operation but might prove useful for specialized operations or to implement special effects. The TextureTransformTestexample creates a texture mapped Boxand allows the user to interactively rotate the texture applied to the Boxusing the mouse (figure 14.24). Figure 14.24 Applying a Transform to an applied texture image. TextureTransformTest allows a texture image to be interactively rotated using a MouseRotate behavior. The ColorCube at the lower left of the two frames shows the current rotation Note that only the rotational components of the Transform3Dappear to be used. From TextureTransformTest.java 254
If you are looking for cheap and quality webhost to host and run your website check Jboss Web Hosting services.

Figure 14.21 (Web hosting services) Material colors set as in figure

Tuesday, October 23rd, 2007

Figure 14.21 Material colors set as in figure 14.14 and texture image applied using MODULATE mode Figure 14.22 Material colors set as in figure 14.14 and texture image applied using BLEND mode 253
We recommend you use shared web hosting services, because many users agree that it is cheap, reliable and customer-satisfying webhost.