java left logo
java middle logo
java right logo
 

Home arrow Other API Tips arrow Java3D arrow Using LineArray to draw coordinate system
 
 
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 LineArray to draw coordinate system E-mail
User Rating: / 15
PoorBest 

In 3D computer graphics, everything is modeled and rendered with vertex-based data.LineArray object describes a set of vertices, and each two vertices defines the endpoints of a line.

This program uses multiple LineArray objects to draw lines to represent the x, y, and z axis.


Image

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

  public BranchGroup createSceneGraph() {
    BranchGroup objRoot = new BranchGroup();
    
    // Create X axis
    LineArray axisXLines=new LineArray(2,LineArray.COORDINATES);
    objRoot.addChild(new Shape3D(axisXLines));
      
    axisXLines.setCoordinate(0,new Point3f(-1.0f,0.0f,0.0f));
    axisXLines.setCoordinate(1,new Point3f(1.0f,0.0f,0.0f));        
    
    // Create Y axis  
    LineArray axisYLines=new LineArray(2,LineArray.COORDINATES|LineArray.COLOR_3);
    objRoot.addChild(new Shape3D(axisYLines));
      
    axisYLines.setCoordinate(0,new Point3f(0.0f,-1.0f,0.0f));
    axisYLines.setCoordinate(1,new Point3f(0.0f,1.0f,0.0f));
      
    // Create Z axis with arrow
    Point3f z1=new Point3f(0.0f,0.0f,-1.0f);
    Point3f z2=new Point3f(0.0f,0.0f,1.0f);
      
    LineArray axisZLines=new LineArray(10,LineArray.COORDINATES|LineArray.COLOR_3);
    objRoot.addChild(new Shape3D(axisZLines));
      
    axisZLines.setCoordinate(0,z1);
    axisZLines.setCoordinate(1,z2);
    axisZLines.setCoordinate(2,z2);
    axisZLines.setCoordinate(3,new Point3f(0.1f,0.1f,0.9f));
    axisZLines.setCoordinate(4,z2);
    axisZLines.setCoordinate(5,new Point3f(-0.1f,0.1f,0.9f));
    axisZLines.setCoordinate(6,z2);
    axisZLines.setCoordinate(7,new Point3f(0.1f,-0.1f,0.9f));
    axisZLines.setCoordinate(8,z2);
    axisZLines.setCoordinate(9,new Point3f(-0.1f,-0.1f,0.9f));
      
    return objRoot;
  }
}

 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.