org.jmol.g3d
Class Sphere3D

java.lang.Object
  extended by org.jmol.g3d.Sphere3D

public class Sphere3D
extends java.lang.Object

Implements high performance rendering of shaded spheres.

Drawing spheres quickly is critically important to Jmol. These routines implement high performance rendering of spheres in 3D.

If you can think of a faster way to implement this, please let us know.

There is a lot of bit-twiddling going on here, which may make the code difficult to understand for non-systems programmers.

Ellipsoid code added 4/2008 -- Bob Hanson hansonr@stolaf.edu

Author:
Miguel, miguel@jmol.org

Field Summary
private  boolean addAllPixels
           
private  double[] coef
           
private  int depth
           
private  int diameter
           
private  float[][] dxyz
           
private static byte[][][] ellipsoidShades
           
(package private)  Graphics3D g3d
           
private  int height
           
private  javax.vecmath.Matrix3f mat
           
private static int maxOddSizeSphere
           
private static int maxSphereCache
           
(package private) static int maxSphereDiameter
           
(package private) static int maxSphereDiameter2
           
private  int maxX
           
private  int maxY
           
private  int maxZ
           
private  javax.vecmath.Matrix4f mDeriv
           
private  int minX
           
private  int minY
           
private  int minZ
           
private static int nIn
           
private static int nOut
           
private  javax.vecmath.Point3i[] octantPoints
           
private  int offsetPbufBeginLine
           
private  int planeShade
           
private  int[] planeShades
           
private  javax.vecmath.Point3f ptTemp
           
private static int SDIM
           
private  int selectedOctant
           
private static int SHADE_SLAB_CLIPPED
           
private  int[] shades
           
private  int slab
           
private static int SLIM
           
private static int[][] sphereShapeCache
           
private  boolean tScreened
           
private  int width
           
private  int x
           
private  int y
           
private  int z
           
private  int[] zbuf
           
private  double[] zroot
           
 
Constructor Summary
Sphere3D(Graphics3D g3d)
           
 
Method Summary
private static void createEllipsoidShades()
           
private static int[] createSphereShape(int diameter)
           
(package private) static void flushSphereCache()
           
private static int getEllipsoidShade(float x, float y, float z, int radius, javax.vecmath.Matrix4f mDeriv)
           
private  int getPlaneShade(int xCurrent, int yCurrent, double[] zroot)
           
private static int[] getSphereShape(int diameter)
           
(package private)  void render(int[] shades, boolean tScreened, int diameter, int x, int y, int z, javax.vecmath.Matrix3f mat, double[] coef, javax.vecmath.Matrix4f mDeriv, int selectedOctant, javax.vecmath.Point3i[] octantPoints)
           
private  void renderLarge()
           
private  void renderQuadrant(int xSign, int ySign)
           
private  void renderQuadrantClipped(int radius, int xSign, int ySign)
           
private  void renderQuadrantUnclipped(int radius, int xSign, int ySign)
           
private  void renderShapeClipped(int[] sphereShape)
           
private  void renderShapeUnclipped(int[] sphereShape)
           
private  void setPlaneDerivatives()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

g3d

Graphics3D g3d

maxSphereCache

private static final int maxSphereCache
See Also:
Constant Field Values

maxOddSizeSphere

private static final int maxOddSizeSphere
See Also:
Constant Field Values

maxSphereDiameter

static final int maxSphereDiameter
See Also:
Constant Field Values

maxSphereDiameter2

static final int maxSphereDiameter2
See Also:
Constant Field Values

sphereShapeCache

private static final int[][] sphereShapeCache

zroot

private double[] zroot

nOut

private static int nOut

nIn

private static int nIn

mat

private javax.vecmath.Matrix3f mat

coef

private double[] coef

mDeriv

private javax.vecmath.Matrix4f mDeriv

selectedOctant

private int selectedOctant

octantPoints

private javax.vecmath.Point3i[] octantPoints

planeShade

private int planeShade

zbuf

private int[] zbuf

width

private int width

height

private int height

depth

private int depth

slab

private int slab

offsetPbufBeginLine

private int offsetPbufBeginLine

addAllPixels

private boolean addAllPixels

minX

private int minX

maxX

private int maxX

minY

private int minY

maxY

private int maxY

minZ

private int minZ

maxZ

private int maxZ

x

private int x

y

private int y

z

private int z

diameter

private int diameter

tScreened

private boolean tScreened

shades

private int[] shades

SHADE_SLAB_CLIPPED

private static final int SHADE_SLAB_CLIPPED
See Also:
Constant Field Values

ptTemp

private final javax.vecmath.Point3f ptTemp

planeShades

private final int[] planeShades

dxyz

private final float[][] dxyz

ellipsoidShades

private static byte[][][] ellipsoidShades

SLIM

private static final int SLIM
See Also:
Constant Field Values

SDIM

private static final int SDIM
See Also:
Constant Field Values
Constructor Detail

Sphere3D

Sphere3D(Graphics3D g3d)
Method Detail

flushSphereCache

static void flushSphereCache()

getSphereShape

private static int[] getSphereShape(int diameter)

createSphereShape

private static int[] createSphereShape(int diameter)

render

void render(int[] shades,
            boolean tScreened,
            int diameter,
            int x,
            int y,
            int z,
            javax.vecmath.Matrix3f mat,
            double[] coef,
            javax.vecmath.Matrix4f mDeriv,
            int selectedOctant,
            javax.vecmath.Point3i[] octantPoints)

renderShapeUnclipped

private void renderShapeUnclipped(int[] sphereShape)

renderShapeClipped

private void renderShapeClipped(int[] sphereShape)

renderLarge

private void renderLarge()

renderQuadrant

private void renderQuadrant(int xSign,
                            int ySign)

renderQuadrantUnclipped

private void renderQuadrantUnclipped(int radius,
                                     int xSign,
                                     int ySign)

renderQuadrantClipped

private void renderQuadrantClipped(int radius,
                                   int xSign,
                                   int ySign)

setPlaneDerivatives

private void setPlaneDerivatives()

getPlaneShade

private int getPlaneShade(int xCurrent,
                          int yCurrent,
                          double[] zroot)

createEllipsoidShades

private static void createEllipsoidShades()

getEllipsoidShade

private static int getEllipsoidShade(float x,
                                     float y,
                                     float z,
                                     int radius,
                                     javax.vecmath.Matrix4f mDeriv)