Package com.sun.j3d.utils.geometry

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

/*     */ package com.sun.j3d.utils.geometry;
/*     */
/*     */ import java.io.PrintStream;
/*     */ import java.util.Hashtable;
/*     */ import javax.media.j3d.Appearance;
/*     */ import javax.media.j3d.Group;
/*     */ import javax.media.j3d.Material;
/*     */ import javax.media.j3d.Shape3D;
/*     */ import javax.vecmath.Color3f;
/*     */
/*     */ public abstract class Primitive extends Group
/*     */ {
/*     */   public static final int GENERATE_NORMALS = 1;
/*     */   public static final int GENERATE_TEXTURE_COORDS = 2;
/*     */   public static final int GENERATE_NORMALS_INWARD = 4;
/*     */   public static final int GEOMETRY_NOT_SHARED = 16;
/*     */   public static final int ENABLE_GEOMETRY_PICKING = 32;
/*     */   public static final int ENABLE_APPEARANCE_MODIFY = 64;
/*     */   static final int SPHERE = 1;
/*     */   static final int CYLINDER = 2;
/*     */   static final int CONE = 4;
/*     */   static final int BOX = 8;
/*     */   static final int TOP_DISK = 16;
/*     */   static final int BOTTOM_DISK = 32;
/*     */   static final int CONE_DIVISIONS = 64;
/* 113 */   int numTris = 0;
/* 114 */   int numVerts = 0;
/*     */   int flags;
/* 231 */   static Hashtable geomCache = new Hashtable();
/*     */
/*     */   public Primitive()
/*     */   {
/* 127 */     this.flags = 0;
/* 128 */     setCapability(1);
/* 129 */     setCapability(12);
/*     */   }
/*     */
/*     */   public int getNumTriangles()
/*     */   {
/* 137 */     return this.numTris;
/*     */   }
/*     */
/*     */   /** @deprecated */
/*     */   public void setNumTriangles(int num)
/*     */   {
/* 144 */     System.err.println("Warning: setNumTriangles has no effect");
/*     */   }
/*     */
/*     */   public int getNumVertices()
/*     */   {
/* 152 */     return this.numVerts;
/*     */   }
/*     */
/*     */   /** @deprecated */
/*     */   public void setNumVertices(int num)
/*     */   {
/* 159 */     System.err.println("Warning: setNumVertices has no effect");
/*     */   }
/*     */
/*     */   public int getPrimitiveFlags()
/*     */   {
/* 166 */     return this.flags;
/*     */   }
/*     */
/*     */   /** @deprecated */
/*     */   public void setPrimitiveFlags(int fl)
/*     */   {
/* 174 */     System.err.println("Warning: setPrimitiveFlags has no effect");
/*     */   }
/*     */
/*     */   public abstract Shape3D getShape(int paramInt);
/*     */
/*     */   public Appearance getAppearance()
/*     */   {
/* 185 */     return getShape(0).getAppearance();
/*     */   }
/*     */
/*     */   public abstract Appearance getAppearance(int paramInt);
/*     */
/*     */   public void setAppearance(int partid, Appearance ap)
/*     */   {
/* 205 */     getShape(partid).setAppearance(ap);
/*     */   }
/*     */
/*     */   public abstract void setAppearance(Appearance paramAppearance);
/*     */
/*     */   public void setAppearance()
/*     */   {
/* 219 */     Color3f aColor = new Color3f(0.1F, 0.1F, 0.1F);
/* 220 */     Color3f eColor = new Color3f(0.0F, 0.0F, 0.0F);
/* 221 */     Color3f dColor = new Color3f(0.6F, 0.6F, 0.6F);
/* 222 */     Color3f sColor = new Color3f(1.0F, 1.0F, 1.0F);
/*     */
/* 224 */     Material m = new Material(aColor, eColor, dColor, sColor, 100.0F);
/* 225 */     Appearance a = new Appearance();
/* 226 */     m.setLightingEnable(true);
/* 227 */     a.setMaterial(m);
/* 228 */     setAppearance(a);
/*     */   }
/*     */
/*     */   String strfloat(float x)
/*     */   {
/* 235 */     return new Float(x).toString();
/*     */   }
/*     */
/*     */   protected void cacheGeometry(int kind, float a, float b, float c, int d, int e, int flags, GeomBuffer geo)
/*     */   {
/* 242 */     String key = new String(kind + strfloat(a) + strfloat(b) + strfloat(c) + d + e + flags);
/*     */
/* 244 */     geomCache.put(key, geo);
/*     */   }
/*     */
/*     */   protected GeomBuffer getCachedGeometry(int kind, float a, float b, float c, int d, int e, int flags)
/*     */   {
/* 250 */     String key = new String(kind + strfloat(a) + strfloat(b) + strfloat(c) + d + e + flags);
/*     */
/* 252 */     Object cache = geomCache.get(key);
/*     */
/* 254 */     return (GeomBuffer)cache;
/*     */   }
/*     */ }

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

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

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.