java left logo
java middle logo
java right logo
 

Home arrow Other API Tips arrow Java3D arrow How to define the surface normals
 
 
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: 4086
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 define the surface normals E-mail
User Rating: / 0
PoorBest 

As known, normals are required for shaded visual objects. When creating visual objects using Geometry classes, use one of the setNormal() methods to specify per vertex normal vectors.

Through defining the surface normals of the geometry of box, this program illustrates how to define the surface normals for the Shape created by GeometryArray.


Image

private Geometry createGeometry(){

    int pNum=24;

    // Define the geometry which need to define the normals
    QuadArray quadArray=new QuadArray(pNum,
       GeometryArray.COORDINATES|GeometryArray.NORMALS);

    // Create a array of Vector3f to store the normal for per vertex
    Vector3f[] normals=new Vector3f[pNum];
    
    ...
    
    int i=0;
    
    for(i=0;i<4;i++){
      normals[i]=new Vector3f(0.0f,0.0f,1.0f);
    }
    for(;i<8;i++){
      normals[i]=new Vector3f(1.0f,0.0f,0.0f);  
    }
    for(;i<12;i++){
      normals[i]=new Vector3f(0.0f,0.0f,-1.0f);
    }
    for(;i<16;i++){
      normals[i]=new Vector3f(-1.0f,0.0f,0.0f);
    }
    for(;i<20;i++){
      normals[i]=new Vector3f(0.0f,1.0f,0.0f);
    }
    for(;i<24;i++){
      normals[i]=new Vector3f(0.0f,-1.0f,0.0f);
    }
    
    quadArray.setCoordinates(0,points);
    // Set the normals for this geometry
    quadArray.setNormals(0,normals);
    
    return quadArray;
}

 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.