java left logo
java middle logo
java right logo
 

Home arrow Other API Tips arrow Java3D arrow How to change the boundary mode of Texture
 
 
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: 4097
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:
 
 
 
How to change the boundary mode of Texture E-mail
User Rating: / 2
PoorBest 

The boundary mode setting determines what mapping takes place when the texture coordinates go beyond the 0 to 1 range of the image space. The choices are to wrap the image, or to clamp it.Wrapping, which means to repeat the image as needed, is the default. Clamping the image uses the color from the edge of the image anywhere outside of the 0 to 1 range. These settings are made independently in the s and t dimensions.


Image

private BranchGroup createSceneGraph(SimpleUniverse su){

    ...
    
    
    MyBox box1=new MyBox(0.6f,0.6f);
    Appearance appear=box1.getAppearance();
    // Use the Texture with the default settings of boundary mode
    appear.setTexture(createTexture());
    
        // Map the texture coordinate
    TexCoord2f[] texCoords = new TexCoord2f[24]
    for (int i = 0; i < texCoords.length; i += 4) {
      texCoords[inew TexCoord2f(1.5f0.0f);
      texCoords[i + 1new TexCoord2f(0.0f0.0f);
      texCoords[i + 2new TexCoord2f(0.0f1.5f);
      texCoords[i + 3new TexCoord2f(1.5f1.5f);
    }
  
    QuadArray quadArray=(QuadArray)box1.getGeometry();
    quadArray.setTextureCoordinates(00, texCoords);
    tg1.addChild(box1);
    
    MyBox box2=new MyBox(0.6f,0.6f);
    appear=box2.getAppearance();
    Texture texture=createTexture();
    // Change the boundary mode
    texture.setBoundaryModeT(Texture.CLAMP);
    texture.setBoundaryModeS(Texture.WRAP);
    appear.setTexture(texture);
    
        // Map the texture coordinate
    texCoords = new TexCoord2f[24];
    for (int i = 0; i < texCoords.length; i += 4) {
      texCoords[inew TexCoord2f(1.5f0.0f);
      texCoords[i + 1new TexCoord2f(0.0f0.0f);
      texCoords[i + 2new TexCoord2f(0.0f1.5f);
      texCoords[i + 3new TexCoord2f(1.5f1.5f);
    }
  
    quadArray=(QuadArray)box2.getGeometry();
    quadArray.setTextureCoordinates(00, texCoords);
    tg2.addChild(box2);
    
    MyBox box3=new MyBox(0.6f,0.6f);
    appear=box3.getAppearance();
    texture=createTexture();
    // Change the boundary mode
    texture.setBoundaryModeT(Texture.WRAP);
    texture.setBoundaryModeS(Texture.CLAMP);
    
    appear.setTexture(texture);
    
        // Map the texture coordinate
    texCoords = new TexCoord2f[24];
    
    for (int i = 0; i < texCoords.length; i += 4) {
      texCoords[inew TexCoord2f(1.5f0.0f);
      texCoords[i + 1new TexCoord2f(0.0f0.0f);
      texCoords[i + 2new TexCoord2f(0.0f1.5f);
      texCoords[i + 3new TexCoord2f(1.5f1.5f);
    }
    
    quadArray=(QuadArray)box3.getGeometry();
    quadArray.setTextureCoordinates(00, texCoords);
    tg3.addChild(box3);
    
    MyBox box4=new MyBox(0.6f,0.6f);
    appear=box4.getAppearance();
    texture=createTexture();
    // Change the boundary mode
    texture.setBoundaryModeT(Texture.CLAMP);
    texture.setBoundaryModeS(Texture.CLAMP);
    
    appear.setTexture(texture);
    
        // Map the texture coordinate
    texCoords = new TexCoord2f[24];
    for (int i = 0; i < texCoords.length; i += 4) {
      texCoords[inew TexCoord2f(1.5f0.0f);
      texCoords[i + 1new TexCoord2f(0.0f0.0f);
      texCoords[i + 2new TexCoord2f(0.0f1.5f);
      texCoords[i + 3new TexCoord2f(1.5f1.5f);
    }
    
    quadArray=(QuadArray)box4.getGeometry();
    quadArray.setTextureCoordinates(00, texCoords);
    tg4.addChild(box4);
    
    ...
}

 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.