assign to an Appearance. //load the texture image
assign to an Appearance. //load the texture image and assign to the appearance TextureLoader texLoader = new TextureLoader( texInfo.m_szImage, Texture.RGB, this ); Texture tex = texLoader.getTexture(); app.setTexture( tex ); 4. Create a GeometryInfoobject to store the texture and vertex coordinates (POYGON_ARRAY). //create a GeometryInfo for the QuadArray that was populated. GeometryInfo gi = new GeometryInfo( GeometryInfo.POLYGON_ARRAY ); 5. Assign the texture and vertex coordinates to the GeometryInfoobject. //assign coordinates gi.setCoordinates( texInfo.m_CoordArray ); gi.setTextureCoordinates( texInfo.m_TexCoordArray ); 6. Triangulate the GeometryInfoobject. //use the triangulator utility to triangulate the polygon int[] stripCountArray = {texInfo.m_CoordArray.length}; int[] countourCountArray = {stripCountArray.length}; gi.setContourCounts( countourCountArray ); gi.setStripCounts( stripCountArray ); Triangulator triangulator = new Triangulator(); triangulator.triangulate( gi ); 7. Generate Normal vectors for the GeometryInfoobject. //generate normal vectors for the triangles, //not strictly necessary as we are not lighting the scene //but generally useful NormalGenerator normalGenerator = new NormalGenerator(); normalGenerator.generateNormals( gi ); 8. Create a Shape3Dobject based on the GeometryInfoobject. //wrap the GeometryArray in a Shape3D and assign appearance new Shape3D( gi.getGeometryArray(), app ); Please refer to TextureTest.java for the full example. The important methods are listed in full next. //create a TransformGroup, position it, and add the texture //geometry as a child node protected TransformGroup createTextureGroup( String szFile, double x, double y, double z, boolean bWireframe ) { TransformGroup tg = new TransformGroup(); Transform3D t3d = new Transform3D(); t3d.setTranslation( new Vector3d( x,y,z ) ); tg.setTransform( t3d ); Shape3D texShape = createTextureGeometry( szFile, bWireframe ); if( texShape != null ) tg.addChild( texShape ); return tg; 234
Note: If you are looking for good and high quality web space to host and run your application check Lunarwebhost Java Web Hosting services