java left logo
java middle logo
java right logo
 

Home arrow Other API Tips arrow Java3D arrow Creating your own Cylinder using TriangleStripArray
 
 
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: 4092
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:
 
 
 
Creating your own Cylinder using TriangleStripArray E-mail
User Rating: / 6
PoorBest 

The GeometryStripArray is an abstract class from which strip primitives (for creating compound lines and surfaces) are derived. GeometryStripArray is the superclass of LineStripArray, TriangleStripArray,and TriangleFanArray.

This program shows how to use a TriangleFanArray object to model the geometry of a Cone. The TriangleFanArray contains four independent fans: two exterior faces(circular disks) and two internal faces (cones). Only one TriangleFanArray object is needed to represent the four fans.


Image

public class OwnCylinder extends JFrame{
  public OwnCylinder() {
    ...
  }

  /**
   * Create the geometry for the cylinder
   */
  private Geometry createGeometry() {
    float height = 0.5f;
    float radius = 0.1f;
    int verticesNum = 40;
    float[] vertices = new float[verticesNum * 3];

    float perR = (float) (* Math.PI / (verticesNum / 1));
    for (int i = 0; i < verticesNum; i += 2) {
      vertices[(i + 13= vertices[i * 3(float) (radius * Math
          .cos(i / * perR));
      vertices[(i + 12= vertices[i * 2(float) (radius * Math
          .sin(i / * perR));
      vertices[i * 1= height;
      vertices[(i + 110;
    }

    TriangleStripArray quadArray = new TriangleStripArray(verticesNum,
        GeometryArray.COORDINATES,new int[] { verticesNum });
    quadArray.setCoordinates(0, vertices);

    return quadArray;
  }

  public BranchGroup createSceneGraph() {    
    BranchGroup objRoot = new BranchGroup();

    // Add the cylinder
    objRoot.addChild(new Shape3D(createGeometry()));

    return objRoot;
  }
  
  public static void main(String[] args) {
    ...
  }
}

 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.