Package com.sun.j3d.utils.geometry

Source Code of com.sun.j3d.utils.geometry.Cylinder

/*     */ package com.sun.j3d.utils.geometry;
/*     */
/*     */ import javax.media.j3d.Appearance;
/*     */ import javax.media.j3d.Node;
/*     */ import javax.media.j3d.Shape3D;
/*     */
/*     */ public class Cylinder extends Primitive
/*     */ {
/*     */   float radius;
/*     */   float height;
/*     */   int xdivisions;
/*     */   int ydivisions;
/*     */   static final int MID_REZ_DIV_X = 15;
/*     */   static final int MID_REZ_DIV_Y = 1;
/*     */   public static final int BODY = 0;
/*     */   public static final int TOP = 1;
/*     */   public static final int BOTTOM = 2;
/*     */
/*     */   public Cylinder()
/*     */   {
/* 105 */     this(1.0F, 2.0F, 1, 15, 1, null);
/*     */   }
/*     */
/*     */   public Cylinder(float radius, float height)
/*     */   {
/* 115 */     this(radius, height, 1, 15, 1, null);
/*     */   }
/*     */
/*     */   public Cylinder(float radius, float height, Appearance ap)
/*     */   {
/* 129 */     this(radius, height, 1, 15, 1, ap);
/*     */   }
/*     */
/*     */   public Cylinder(float radius, float height, int primflags, Appearance ap)
/*     */   {
/* 144 */     this(radius, height, primflags, 15, 1, ap);
/*     */   }
/*     */
/*     */   public Shape3D getShape(int partId)
/*     */   {
/* 156 */     if ((partId > 2) || (partId < 0)) return null;
/* 157 */     return (Shape3D)getChild(partId);
/*     */   }
/*     */
/*     */   public void setAppearance(Appearance ap)
/*     */   {
/* 166 */     ((Shape3D)getChild(0)).setAppearance(ap);
/* 167 */     ((Shape3D)getChild(1)).setAppearance(ap);
/* 168 */     ((Shape3D)getChild(2)).setAppearance(ap);
/*     */   }
/*     */
/*     */   public Appearance getAppearance(int partId)
/*     */   {
/* 182 */     if ((partId > 2) || (partId < 0)) return null;
/* 183 */     return getShape(partId).getAppearance();
/*     */   }
/*     */
/*     */   public Cylinder(float radius, float height, int primflags, int xdivision, int ydivision, Appearance ap)
/*     */   {
/* 204 */     this.radius = radius;
/* 205 */     this.height = height;
/* 206 */     this.xdivisions = xdivision;
/* 207 */     this.ydivisions = ydivision;
/* 208 */     this.flags = primflags;
/* 209 */     boolean outside = (this.flags & 0x4) == 0;
/*     */
/* 211 */     Quadrics q = new Quadrics();
/* 212 */     GeomBuffer gbuf = null;
/* 213 */     Shape3D[] shape = new Shape3D[3];
/*     */
/* 215 */     GeomBuffer cache = getCachedGeometry(2, 0.0F, radius, height, xdivision, ydivision, primflags);
/*     */
/* 218 */     if (cache != null)
/*     */     {
/* 220 */       shape[0] = new Shape3D(cache.getComputedGeometry());
/* 221 */       this.numVerts += cache.getNumVerts();
/* 222 */       this.numTris += cache.getNumTris();
/*     */     }
/*     */     else {
/* 225 */       gbuf = q.cylinder(height, radius, xdivision, ydivision, outside);
/*     */
/* 227 */       shape[0] = new Shape3D(gbuf.getGeom(this.flags));
/* 228 */       this.numVerts += gbuf.getNumVerts();
/* 229 */       this.numTris += gbuf.getNumTris();
/* 230 */       if ((primflags & 0x10) == 0) {
/* 231 */         cacheGeometry(2, 0.0F, radius, height, xdivision, ydivision, primflags, gbuf);
/*     */       }
/*     */
/*     */     }
/*     */
/* 236 */     if ((this.flags & 0x40) != 0) {
/* 237 */       shape[0].setCapability(14);
/* 238 */       shape[0].setCapability(15);
/*     */     }
/*     */
/* 241 */     if ((this.flags & 0x20) != 0) {
/* 242 */       shape[0].setCapability(12);
/*     */     }
/*     */
/* 245 */     addChild(shape[0]);
/*     */
/* 248 */     cache = getCachedGeometry(16, radius, radius, height / 2.0F, xdivision, xdivision, primflags);
/*     */
/* 250 */     if (cache != null)
/*     */     {
/* 252 */       shape[1] = new Shape3D(cache.getComputedGeometry());
/* 253 */       this.numVerts += cache.getNumVerts();
/* 254 */       this.numTris += cache.getNumTris();
/*     */     }
/*     */     else {
/* 257 */       gbuf = q.disk(radius, xdivision, height / 2.0D, outside);
/*     */
/* 259 */       shape[1] = new Shape3D(gbuf.getGeom(this.flags));
/* 260 */       this.numVerts += gbuf.getNumVerts();
/* 261 */       this.numTris += gbuf.getNumTris();
/* 262 */       if ((primflags & 0x10) == 0) {
/* 263 */         cacheGeometry(16, radius, radius, height / 2.0F, xdivision, xdivision, primflags, gbuf);
/*     */       }
/*     */
/*     */     }
/*     */
/* 269 */     if ((this.flags & 0x40) != 0) {
/* 270 */       shape[1].setCapability(14);
/* 271 */       shape[1].setCapability(15);
/*     */     }
/*     */
/* 274 */     if ((this.flags & 0x20) != 0) {
/* 275 */       shape[1].setCapability(12);
/*     */     }
/*     */
/* 278 */     addChild(shape[1]);
/*     */
/* 281 */     cache = getCachedGeometry(32, radius, radius, -height / 2.0F, xdivision, xdivision, primflags);
/*     */
/* 284 */     if (cache != null)
/*     */     {
/* 286 */       shape[2] = new Shape3D(cache.getComputedGeometry());
/* 287 */       this.numVerts += cache.getNumVerts();
/* 288 */       this.numTris += cache.getNumTris();
/*     */     }
/*     */     else {
/* 291 */       gbuf = q.disk(radius, xdivision, -height / 2.0D, !outside);
/* 292 */       shape[2] = new Shape3D(gbuf.getGeom(this.flags));
/* 293 */       this.numVerts += gbuf.getNumVerts();
/* 294 */       this.numTris += gbuf.getNumTris();
/* 295 */       if ((primflags & 0x10) == 0) {
/* 296 */         cacheGeometry(32, radius, radius, -height / 2.0F, xdivision, xdivision, primflags, gbuf);
/*     */       }
/*     */
/*     */     }
/*     */
/* 302 */     if ((this.flags & 0x40) != 0) {
/* 303 */       shape[2].setCapability(14);
/* 304 */       shape[2].setCapability(15);
/*     */     }
/*     */
/* 307 */     if ((this.flags & 0x20) != 0) {
/* 308 */       shape[2].setCapability(12);
/*     */     }
/*     */
/* 311 */     addChild(shape[2]);
/*     */
/* 314 */     if (ap == null)
/* 315 */       setAppearance();
/*     */     else
/* 317 */       setAppearance(ap);
/*     */   }
/*     */
/*     */   public Node cloneNode(boolean forceDuplicate)
/*     */   {
/* 344 */     Cylinder c = new Cylinder(this.radius, this.height, this.flags, this.xdivisions, this.ydivisions, getAppearance());
/*     */
/* 346 */     c.duplicateNode(this, forceDuplicate);
/* 347 */     return c;
/*     */   }
/*     */
/*     */   public void duplicateNode(Node originalNode, boolean forceDuplicate)
/*     */   {
/* 377 */     super.duplicateNode(originalNode, forceDuplicate);
/*     */   }
/*     */
/*     */   public float getRadius()
/*     */   {
/* 386 */     return this.radius;
/*     */   }
/*     */
/*     */   public float getHeight()
/*     */   {
/* 395 */     return this.height;
/*     */   }
/*     */
/*     */   public int getXdivisions()
/*     */   {
/* 404 */     return this.xdivisions;
/*     */   }
/*     */
/*     */   public int getYdivisions()
/*     */   {
/* 413 */     return this.ydivisions;
/*     */   }
/*     */ }

/* Location:           Z:\System\Library\Java\Extensions\j3dutils.jar
* Qualified Name:     com.sun.j3d.utils.geometry.Cylinder
* JD-Core Version:    0.6.2
*/
TOP

Related Classes of com.sun.j3d.utils.geometry.Cylinder

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.