java left logo
java middle logo
java right logo
 

Home arrow Other API Tips arrow Java3D arrow Using TexCoordGeneration to generate the texture coordinates
 
 
Main Menu
Home
Java Tutorials
Book Reviews
Java SE Tips
Java ME Tips
Java EE Tips
Other API Tips
Java Applications
Java Libraries
Java Games
Java Network
Java Forums
Java Blog




Most Visited Tips
Java SE Tips
Java ME Tips
Java EE Tips
Other API Tips
Java Applications
Java Libraries
Java Games
Book Reviews
Top Rated Tips
Java SE Tips
Java ME Tips
Java EE Tips
Other API Tips
Java Applications
Java Libraries
Java Games
Book Reviews


Statistics
Registered Users: 4100
Java SE Tips: 614
Java ME Tips: 202
Java EE Tips: 183
Other API Tips: 779
Java Applications: 298
Java Libraries: 209
Java Games: 16
Book Reviews:
 
 
 
Using TexCoordGeneration to generate the texture coordinates E-mail
User Rating: / 2
PoorBest 

Assigning texture coordinates to each vertex of the geometry is a necessary step in texturing visual objects. This process can be time consuming as well as difficult for large and/or complex visual objects.

Texture coordinates are often assigned with code specific to a visual object. However, another solution is to automate the assignment of texture coordinates via some method. This method could be used for any visual object whether large or small, complex or simple. This approach is exactly what a TexCoordGeneration (texture coordinate generation) object does.

public class TexCoordGenApp extends JFrame {

    Appearance createAppearance(){
        Appearance appear = new Appearance();

        // Create a TexCoordGeneration object
        TexCoordGeneration tcg = new TexCoordGeneration(TexCoordGeneration.OBJECT_LINEAR,
                                                        TexCoordGeneration.TEXTURE_COORDINATE_2);
        appear.setTexCoordGeneration(tcg);

        // Prepare the Texture
        String filename = "earth.jpg";
        TextureLoader loader = new TextureLoader(filename, this);
        ImageComponent2D image = loader.getImage();

        if(image == null) {
            System.out.println("load failed for texture: "+filename);
        }

        Texture2D texture = new Texture2D(Texture.BASE_LEVEL, Texture.RGBA,
                                      image.getWidth(), image.getHeight());
        texture.setImage(0, image);
        texture.setEnable(true);

        appear.setTexture(texture);

        return appear;
    }

    public BranchGroup createSceneGraph() {
        ...
        
        Sphere sphere=new Sphere(0.4f,createAppearance());
        objSpin.addChild(sphere);

        ...
    }
}

 Related Tips

 
< Prev   Next >

Page 1 of 0 ( 0 comments )

You can share your information about this topic using the form below!

Please do not post your questions with this form! Thanks.


Name (required)


E-Mail (required)

Your email will not be displayed on the site - only to our administrator
Homepage(optional)



Comment Enable HTML code : Yes No



 
       
         
     
 
 
 
   
 
 
java bottom left
java bottom middle
java bottom right
RSS 0.91 FeedRSS 1.0 FeedRSS 2.0 FeedATOM FeedOPML Feed

Home - About Us - Privacy Policy
Copyright 2005 - 2008 www.java-tips.org
Java is a trademark of Sun Microsystems, Inc.