assign to an Appearance. //load the texture image
} //return a Shape3D that is a triangulated texture-mapped polygon //based on the texture coordinates and name of texture image in the //input file protected Shape3D createTextureGeometry( String szFile, boolean bWireframe ) { //load all the texture data from the file and //create the geometry coordinates TextureGeometryInfo texInfo = createTextureCoordinates( szFile ); if( texInfo == null ) { System.err.println( “Could not load texture info for file:” + szFile ); return null; } //print some stats on the loaded file System.out.println( “Loaded File: ” + szFile ); System.out.println( ” Texture image: ” + texInfo.m_szImage ); System.out.println( ” Texture coordinates: ” + texInfo.m_TexCoordArray.length ); //create an Appearance and assign a Material Appearance app = new Appearance(); PolygonAttributes polyAttribs = null; //create the PolygonAttributes and attach to the Appearance, //note that we use CULL_NONE so that the “rear” side //of the geometry is visible with the applied texture image if( bWireframe == false ) { polyAttribs = new PolygonAttributes( PolygonAttributes.POLYGON_FILL, PolygonAttributes.CULL_NONE, 0 ); } else { polyAttribs = new PolygonAttributes( PolygonAttributes.POLYGON_LINE, PolygonAttributes.CULL_NONE, 0 ); } app.setPolygonAttributes( polyAttribs ); //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 ); //create a GeometryInfo for the QuadArray that was populated. GeometryInfo gi = new GeometryInfo( GeometryInfo.POLYGON_ARRAY ); gi.setCoordinates( texInfo.m_CoordArray ); gi.setTextureCoordinates( texInfo.m_TexCoordArray ); //use the triangulator utility to triangulate the polygon int[] stripCountArray = {texInfo.m_CoordArray.length}; int[] countourCountArray = {stripCountArray.length}; 235
Note: If you are looking for good and high quality web space to host and run your application check Lunarwebhost Java Web Hosting services