org.jmol.g3d

Class Sphere3D

public class Sphere3D extends 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
booleanaddAllPixels
double[]coef
intdepth
intdiameter
float[][]dxyz
static byte[][][]ellipsoidShades
Graphics3Dg3d
intheight
Matrix3fmat
static intmaxOddSizeSphere
static intmaxSphereCache
static intmaxSphereDiameter
static intmaxSphereDiameter2
intmaxX
intmaxY
intmaxZ
Matrix4fmDeriv
intminX
intminY
intminZ
static intnIn
static intnOut
Point3i[]octantPoints
intoffsetPbufBeginLine
intplaneShade
int[]planeShades
Point3fptTemp
intselectedOctant
int[]shades
intslab
static int[][]sphereShapeCache
static intSDIM
static intSHADE_SLAB_CLIPPED
static intSLIM
booleantScreened
intwidth
intx
inty
intz
int[]zbuf
double[]zroot
intzShift
Constructor Summary
Sphere3D(Graphics3D g3d)
Method Summary
static voidcreateEllipsoidShades()
static int[]createSphereShape(int diameter)
static voidflushSphereCache()
static intgetEllipsoidShade(float x, float y, float z, int radius, Matrix4f mDeriv)
intgetPlaneShade(int xCurrent, int yCurrent, double[] zroot)
static int[]getSphereShape(int diameter)
voidrender(int[] shades, boolean tScreened, int diameter, int x, int y, int z, Matrix3f mat, double[] coef, Matrix4f mDeriv, int selectedOctant, Point3i[] octantPoints)
voidrenderLarge()
voidrenderQuadrant(int xSign, int ySign)
voidrenderQuadrantClipped(int radius, int xSign, int ySign)
voidrenderQuadrantUnclipped(int radius, int xSign, int ySign)
voidrenderShapeClipped(int[] sphereShape)
voidrenderShapeUnclipped(int[] sphereShape)
voidsetPlaneDerivatives()

Field Detail

addAllPixels

private boolean addAllPixels

coef

private double[] coef

depth

private int depth

diameter

private int diameter

dxyz

private final float[][] dxyz

ellipsoidShades

private static byte[][][] ellipsoidShades

g3d

Graphics3D g3d

height

private int height

mat

private Matrix3f mat

maxOddSizeSphere

private static final int maxOddSizeSphere

maxSphereCache

private static final int maxSphereCache

maxSphereDiameter

static final int maxSphereDiameter

maxSphereDiameter2

static final int maxSphereDiameter2

maxX

private int maxX

maxY

private int maxY

maxZ

private int maxZ

mDeriv

private Matrix4f mDeriv

minX

private int minX

minY

private int minY

minZ

private int minZ

nIn

private static int nIn

nOut

private static int nOut

octantPoints

private Point3i[] octantPoints

offsetPbufBeginLine

private int offsetPbufBeginLine

planeShade

private int planeShade

planeShades

private final int[] planeShades

ptTemp

private final Point3f ptTemp

selectedOctant

private int selectedOctant

shades

private int[] shades

slab

private int slab

sphereShapeCache

private static final int[][] sphereShapeCache

SDIM

private static final int SDIM

SHADE_SLAB_CLIPPED

private static final int SHADE_SLAB_CLIPPED

SLIM

private static final int SLIM

tScreened

private boolean tScreened

width

private int width

x

private int x

y

private int y

z

private int z

zbuf

private int[] zbuf

zroot

private double[] zroot

zShift

private int zShift

Constructor Detail

Sphere3D

Sphere3D(Graphics3D g3d)

Method Detail

createEllipsoidShades

private static void createEllipsoidShades()

createSphereShape

private static int[] createSphereShape(int diameter)

flushSphereCache

static void flushSphereCache()

getEllipsoidShade

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

getPlaneShade

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

getSphereShape

private static int[] getSphereShape(int diameter)

render

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

renderLarge

private void renderLarge()

renderQuadrant

private void renderQuadrant(int xSign, int ySign)

renderQuadrantClipped

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

renderQuadrantUnclipped

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

renderShapeClipped

private void renderShapeClipped(int[] sphereShape)

renderShapeUnclipped

private void renderShapeUnclipped(int[] sphereShape)

setPlaneDerivatives

private void setPlaneDerivatives()