|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--render.Geometry
Handles the manipulation, creation, and storage of geometric objects for use in the renderer.
Each Geometry can have children Geometries extending in a tree structure. Each Geometry has its own transform matrix, Material, and a set of vertices and faces that define the object geometry. Note: to add texture to a geometry other than the mesh, add the u,v components to the vertices.
Field Summary | |
static double[][] |
Bezier
Bezier basis matrix. |
static double[][] |
BezierInverse
Inverse of the bezier basis matrix. |
static double[][] |
BSpline
B-Spline basis matrix. |
static double[][] |
CatmullRom
Catmull-Rom basis matrix. |
Geometry[] |
child
Stores the children geometries of the current geometry. |
int[][] |
faces
Index of the faces that specifies the order and vertices that define individual faces. |
Matrix |
globalMatrix
The global transform matrix used to record modifications to the shape's geometry (like superquadric, or adding slight noise imperfections to the surface). |
static double[][] |
Hermite
Hermite basis matrix. |
Material |
material
Stores the shape's material properties. |
Matrix |
matrix
The transform matrix of the Geometry (used to keep track of translations, rotations, and scaling transformations). |
protected boolean |
modified
Flag set when the shape has been modified. |
double[] |
noiseOrigin
Origin of the noise space, default [0, 0, 0]. |
static int |
pullMask
Used to describe which children are to be transformed using the pull function. |
static double |
pullWeight
Adjusts the influence-wieght of the pull function. |
double[][] |
refVertices
A set of vertices used as an original reference when changes are made to the current set of vertices. |
int |
verticedepth
if we don't have a texture then we set it as 6, if we have a texture to apply, the depth is 8 |
double[][] |
vertices
Array of vertices defining the geometric shape. |
Constructor Summary | |
Geometry()
Constructor sets up the local and global transformation matrices. |
Method Summary | |
Geometry |
add()
Adds a new child shape to this shape. |
Geometry |
add(Geometry s)
Add an existing shape, as a child to this shape. |
void |
addImprovedNoise(double freq,
double ampl)
Adds noise to each vertex in the geometry and recursively to its children using improvedNoise. |
void |
addNoise(double freq,
double ampl)
Adds noise to the global transformation matrix. |
void |
addNoise(Matrix mat,
double freq,
double ampl)
Adds noise (with frequency freq and amplitude ampl) to the desired matrix mat. |
Geometry |
ball(int n)
Creates a unit sphere with resolution n composed of 6 n by n patches. |
Geometry |
bezeledCube(double r)
Creates a bezeled cube with variable bezel of radius r. |
Geometry |
child(int n)
Returns the nth child of the geometry . |
boolean |
computedMeshNormals()
Returns whether or nor the mesh normals have been computed yet. |
void |
computeMeshNormals()
Computes normals for the wireframe mesh. |
void |
computePolyhedronNormals()
Computes normals for each vertex of each face of the polyhedron shape. |
boolean |
contains(Geometry s)
Find out whether the argument is a sub-geometry of this geometry object. |
void |
copyVertex(double[] src,
double[] dst)
Copies the coordinates and normal values of the original vertex to the target vertex. |
double[][] |
copyVertices(double[][] src)
Returns a new 2-d array with a copy of vertices passed as the parameter. |
double[][] |
copyVertices(double[][] src,
double[][] dst)
Copies and returns the contents of vertex array src to dst. |
Geometry |
cube()
Sets the current shape geometry to a unit cube. |
Geometry |
cylinder(int k)
Creates a k-sided polygon approximation to a cylinder. |
Geometry |
delete(Geometry s)
Delete a child of a shape. |
Geometry |
delete(int n)
Delete the nth child of a shape. |
Geometry |
disk(int k)
Creates a k-sided regular polygon approximation to a circular disk. |
void |
displaceByImprovedNoise(double freq,
double ampl)
Displaces the shape geometry (each vertex) and its children by noise determined by frequency and amplitude. |
Geometry |
extrusion(double[][] O,
double[][] P)
Extrudes a path along another path where O defines the path of the cross-section and P defines the path of the wire. |
Geometry |
gear(int nTeeth)
Creates a 3D gear with nTeeth number of teeth. |
Geometry |
gearDisk(int nTeeth)
Creates a 2D gear disk with an nTeetch number of teeth. |
Geometry |
gearTube(int k)
Creates a hollow cylindrical geared tube with k teeth. |
Geometry |
gearTube(int m,
double[][] path)
Creates a jointed gear-tube with m number of teeth, along the specified path. |
Matrix |
getMatrix()
Gets the transformation matrix for this shape. |
int |
getMeshCols()
Internal number of mesh columns. |
int |
getMeshRows()
Returns the number of rows in the mesh. |
double[] |
getOffset()
Get the x,y,z offset from the parent object. |
Geometry |
getParent()
Returns the parent geometry object. |
Geometry |
globe(int m,
int n)
Creates a longitude/latitude partitioned sphere where m and n specify longitude and latitude respectively. |
Geometry |
globe(int m,
int n,
double uLo,
double uHi,
double vLo,
double vHi)
Creates a longitude/latitude partitioned sphere delimited by ranges in the east-west and north-south directions. |
boolean |
isDoubleSided()
Returns the double sided status of the shape, true if the object or its material is double-sided, false otherwise. |
Geometry |
lathe(int m,
int n,
double[] Z,
double[] R)
Extrudes a curve of varying radius around a circle. |
Geometry |
latheGen(int m,
double[] T,
double[] C,
boolean round)
Extrudes a curve of varying radius around a circle of resolution m defined by the the coordinates in T (containing the succesive z coordinates) and C (containing the succesive radii). |
static double[][] |
makeCircle(int n,
double radius)
Creates a regular n-sided polygonal approximation to a circle with given radius. |
static void |
makeCurve(double[] X,
double[] Y,
double[] T,
double[] C)
Makes a smooth curve |
static double[][] |
makeGear(int nTeeth)
Creates a geared path (triangular extrusions from a circle) with a given number of teeth. |
static double[][] |
makePath(int n,
double[][] key)
Creates a smooth path composed of n subsegments that passes through the desired key points (uses hermite spline). |
Geometry |
mesh(int m,
int n)
Creates a new m by n rectangular mesh ( rows by columns ). |
Geometry |
patch(int m,
int n,
double[][] basisMatrix,
double[] data)
Creates a bicubic m by n patch |
Geometry |
pill(int k,
double len,
double bulge)
Creates a pill with resolution k, length len, and degree of roundness bulge. |
Geometry |
pill(int k,
double len,
double bulge,
double taper)
Creates a tapered pill with resolution k, length len, and degree of roundness bulge and a taper of the southern hemisphere. |
Geometry |
polygon(double[] X,
double[] Y)
Creates a polygon defined by the X and Y coordinates. |
int |
pull(Matrix m,
double x0,
double x1,
double x2,
double y0,
double y1,
double y2,
double z0,
double z1,
double z2)
Deforms a geometric shape according to the beginning, middle, and end parameters in each dimension. |
int |
pull(Matrix oldRelMatrix,
Matrix newRelMatrix,
double x0,
double x1,
double x2,
double y0,
double y1,
double y2,
double z0,
double z1,
double z2)
Deforms a geometric shape according to the beginning, middle, and end parameters in each dimension. |
void |
recomputeMeshNormals()
Forces a recomputation of the mesh normals. |
Geometry |
setDoubleSided(boolean tf)
Sets the flag indicating whether the object is double sided. |
Geometry |
setMaterial(Material m)
Set the Material for this shape to be Material m. |
void |
setMatrix(Matrix m)
Set the transformation matrix for this shape. |
void |
setOffset(double x,
double y,
double z)
Set the x,y,z offset from the parent object. |
void |
sew(Geometry s,
int a,
int b)
Attempts to sew the s geometry to the current shape geometry if the a and b parameters are both nonzero. |
void |
sew(Geometry s,
int a,
int b,
Matrix m)
Attempts to sew the s geometry to the current shape geometry if the a and b parameters are both nonzero according to transformation matrix m. |
Geometry |
subdivide(int I,
int J,
int m,
int n)
Subdivides one quad (I, J) of a bicubic mesh into a new m by n mesh. |
Geometry |
superquadric(double p,
double h)
Deforms the current shape geometry in a similar manner to a quadric, but is just controlled by two parameters (p-center side "inflation", h-corner "inflation"). |
void |
superquadric(Matrix mat,
double p,
double h)
Deforms the current shape geometry in a similar manner to a quadric, but is just controlled by two parameters (p-center side "inflation", h-corner "inflation"). |
Geometry |
torus(int m,
int n,
double r)
Creates a torus with resolution m by n and radius r. |
Geometry |
tube(int k)
Creates a hollow cylindrical tube with resolution k. |
Geometry |
tube(int m,
double taper)
Creates a tapered tube, where m denotes the number of steps around the circle and taper indicates the additional scaling of the southern end of the tube. |
Geometry |
wire(int m,
double[][] path,
double r)
Extrudes a wire/jointed-tube along the specified keypoints, with radius r, m segments approximating roundness, along the path determined by the key points. |
Geometry |
wire(int m,
int n,
double[][] key,
double r)
Extrudes a wire/jointed-tube along the specified keypoints, with radius r, m segments approximating roundness, and n segments approximating the path along the key points. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
public Material material
public Geometry[] child
public Matrix matrix
public Matrix globalMatrix
superquadric(double, double)
,
addNoise(double, double)
public int[][] faces
public double[][] vertices
public double[][] refVertices
public int verticedepth
protected boolean modified
public static double pullWeight
pull(render.Matrix, double, double, double, double, double, double, double, double, double)
public static int pullMask
pull(render.Matrix, double, double, double, double, double, double, double, double, double)
public double[] noiseOrigin
public static double[][] Bezier
public static double[][] BSpline
public static double[][] CatmullRom
public static double[][] Hermite
public static double[][] BezierInverse
Constructor Detail |
public Geometry()
Method Detail |
public Geometry getParent()
public boolean contains(Geometry s)
s
- Geometry to be tested
public void recomputeMeshNormals()
public boolean computedMeshNormals()
public Geometry child(int n)
n
- the index of the child requested
public Geometry setDoubleSided(boolean tf)
tf
- value of the flag
Material.setDoubleSided(boolean)
public boolean isDoubleSided()
public Geometry add()
public Geometry add(Geometry s)
s
- shape Geometry to be added
public Geometry delete(Geometry s)
s
- shape to be deleted from list of children
public Geometry delete(int n)
n
- the index of the child to be deleted
public Geometry setMaterial(Material m)
m
- the desired Material
public void setMatrix(Matrix m)
m
- the new matrix for the shapepublic Matrix getMatrix()
public void setOffset(double x, double y, double z)
x
- x offsety
- y offsetz
- z offsetpublic double[] getOffset()
public double[][] copyVertices(double[][] src)
src
- array of vertices to be duplicated.
public double[][] copyVertices(double[][] src, double[][] dst)
src
- the original vertex arraydst
- the destination to hold a copy of the original vertices
public Geometry mesh(int m, int n)
m
- number of rowsn
- number of columns
public Geometry cube()
public Geometry bezeledCube(double r)
r
- radius of bezel
public Geometry polygon(double[] X, double[] Y)
X
- array of x coordinatesY
- array of corresponding y coordinates
public Geometry disk(int k)
k
- number of sides of the regular polygon
public Geometry gearDisk(int nTeeth)
nTeeth
- number of teeth on the gear
gear(int)
public Geometry cylinder(int k)
k
- number of subdivisions per component of the cyliner
public Geometry gear(int nTeeth)
nTeeth
- number of teeth subdivsions
gearDisk(int)
public Geometry pill(int k, double len, double bulge)
k
- number of subdivisions of regular polygons used in
approximating the actual shapes.len
- the proportional length (height) of the cylinderbulge
- the degree of roundess of the edges. 1 = half sphere.
0 = flat surface
pill(int k, double len, double bulge, double taper)
public Geometry pill(int k, double len, double bulge, double taper)
k
- number of subdivisions of regular polygons used in
approximating the actual shapes.len
- the proportional length (height) of the cylinderbulge
- the degree of roundess of the edges. 1 = half sphere.
0 = flat surfacetaper
- additional scaling of the southern hemisphere
( 1 = original size).
public Geometry ball(int n)
n
- resolution of the meshes that compose the sphere
globe(int, int)
public Geometry globe(int m, int n)
m
- number of longitude subdivisionsn
- number of latitude subdivisions
ball(int)
public Geometry globe(int m, int n, double uLo, double uHi, double vLo, double vHi)
m
- number of longitude subdivisionsn
- number of latitude subdivisionsuLo
- low end of the east-west range [0..1]uHi
- high end of the east-west range [0..1]vLo
- low end of the north-south range [0..1]vHi
- high end of the north-south range [0..1]
public Geometry tube(int k)
k
- number of regular subdivisions approximating the surface
tube(int m, double taper)
public Geometry gearTube(int k)
k
- number of teeth
public Geometry torus(int m, int n, double r)
m
- number of latitude subdivisionsn
- number of longitude subdivisionsr
- radius of the ring
public Geometry wire(int m, int n, double[][] key, double r)
m
- number of sides of the regular polygon approximating the
circular cross section of the wiren
- number of sections approximating the path along the
key points.key
- the list of points defining the pathr
- radius of the wire
public Geometry wire(int m, double[][] path, double r)
m
- number of sides of the regular polygon approximating the
circular cross section of the wirepath
- the list of key points defining the pathr
- radius of the wire
public Geometry gearTube(int m, double[][] path)
m
- number of teeth of the gearpath
- the set of points defining the key joints of the wire tube.
public Geometry extrusion(double[][] O, double[][] P)
O
- a set of vertices and normals defining the cross sectionP
- a set of vertices and normals defining the path of the wire.
public int getMeshRows()
public int getMeshCols()
public void computePolyhedronNormals()
public void computeMeshNormals()
public Geometry tube(int m, double taper)
m
- the number of steps around the circle
( regular polygonal approximation)taper
- the scale factor of the southern end of the tube.
tube(int m)
public Geometry lathe(int m, int n, double[] Z, double[] R)
Algorithm:
The path is first expanded out to a smooth curve, so that it is sampled evenly in n steps. The curve preserves local maxima and minima in radius (eg: if a keypoint has a greater radius than both its neighbors, then that point will be a local maximum in the resulting curve).
Then this expanded path is extruded around a circle.
m
- the number of steps around the circlen
- the number of steps to sample along the pathZ
- keypoints along the curve that contain successive z coordinatesR
- keypoints along the curve that contain successive radii
public Geometry latheGen(int m, double[] T, double[] C, boolean round)
m
- number of segments approximating the roundness of the tubeT
- keypoints along the curve that contain successive z coordinatesC
- keypoints along the curve that contain successive radiiround
- // good question. ij
lathe(int m, int n, double[] Z, double[] R)
public static double[][] makePath(int n, double[][] key)
n
- number of subdivisions in pathkey
- a set of points defining key positions
public static double[][] makeGear(int nTeeth)
nTeeth
- number of teeth subdivisions in the circle
public static double[][] makeCircle(int n, double radius)
n
- number of sides in the polygonradius
- the radius of the circle
public static void makeCurve(double[] X, double[] Y, double[] T, double[] C)
public Geometry superquadric(double p, double h)
p
- controls the amount of scaling of the centers of sides of
the quadric ( p >= 0 )h
- controls the amount of scaling of the corners relative to the
rest of the shape ( h >= 0 )
superquadric(Matrix mat, double p, double h)
public void superquadric(Matrix mat, double p, double h)
mat
- the transformation matrix basis for the superquadricp
- controls the amount of scaling of the centers of sides of
the quadric ( p >= 0 )h
- controls the amount of scaling of the corners relative to the
rest of the shape ( h >= 0 )superquadric(double p, double h)
public void addNoise(double freq, double ampl)
freq
- the frequency of noiseampl
- the amplitude of noiseaddNoise(double freq, double ampl)
public void addNoise(Matrix mat, double freq, double ampl)
mat
- matrix to be modifiedfreq
- frequency of noiseampl
- amplitude of noisepublic void displaceByImprovedNoise(double freq, double ampl)
freq
- frequency of noiseampl
- amplitude of noiseaddImprovedNoise(double freq, double ampl)
public void addImprovedNoise(double freq, double ampl)
freq
- desired frequency of noiseampl
- desired amplitude of noisedisplaceByImprovedNoise(double freq, double ampl)
,
ImprovedNoise
public void sew(Geometry s, int a, int b)
s
- geometry mesh to be seweda
- b
- sew(Geometry s, int a, int b, Matrix m)
public void sew(Geometry s, int a, int b, Matrix m)
s
- geometry mesh to be seweda
- b
- m
- matrix that modifies the sewing transformationsew(Geometry s, int a, int b)
public void copyVertex(double[] src, double[] dst)
src
- original source vertexdst
- target destination vertexpublic int pull(Matrix m, double x0, double x1, double x2, double y0, double y1, double y2, double z0, double z1, double z2)
0 - beginning, 1 - middle, 2 - end. To indicate infinity (a constant transformation) set two adjacent parameters to the same value. Setting all three parameters to the same value transforms the shape geometry consistently across the entire axis of the parameters.
m
- the object's transformation matrixx0
- location of beginning of deformation along the x axisx1
- location of beginning of deformation along the x axisx2
- location of beginning of deformation along the x axisy0
- location of beginning of deformation along the y axisy1
- location of beginning of deformation along the y axisy2
- location of beginning of deformation along the y axisz0
- location of beginning of deformation along the z axisz1
- location of beginning of deformation along the z axisz2
- location of beginning of deformation along the z axis
public int pull(Matrix oldRelMatrix, Matrix newRelMatrix, double x0, double x1, double x2, double y0, double y1, double y2, double z0, double z1, double z2)
0 - beginning, 1 - middle, 2 - end. To indicate infinity (a constant transformation) set two adjacent parameters to the same value. Setting all three parameters to the same value transforms the shape geometry consistently across the entire axis of the parameters.
oldRelMatrix
- the object's initial transformation
(usually the identity matrix)newRelMatrix
- the object's final transformation matrixx0
- location of beginning of deformation along the x axisx1
- location of beginning of deformation along the x axisx2
- location of beginning of deformation along the x axisy0
- location of beginning of deformation along the y axisy1
- location of beginning of deformation along the y axisy2
- location of beginning of deformation along the y axisz0
- location of beginning of deformation along the z axisz1
- location of beginning of deformation along the z axisz2
- location of beginning of deformation along the z axis
public Geometry subdivide(int I, int J, int m, int n)
I
- row index of quadJ
- column index of quadm
- number of rows of new patchn
- number of columns of the new patch
public Geometry patch(int m, int n, double[][] basisMatrix, double[] data)
m
- number of rows of the patchn
- number of columns in the patchbasisMatrix
- data
-
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |