Shapes 3D
3.0
|
Public Member Functions | |
Shape3D () | |
abstract Shape3D | getThis () |
void | addPickHandler (Object obj, String methodName) |
Shape3D | pickable (boolean pickable) |
boolean | pickable () |
int | nbrParts () |
Shape3D | use (int parts_to_use) |
Shape3D | tag (String tag) |
Shape3D | tag (String tag, int parts) |
String[] | tags () |
Shape3D | drawMode (int mode) |
Shape3D | drawMode (int mode, int parts) |
int[] | drawModes () |
Shape3D | fill (int col) |
Shape3D | fill (int col, int parts) |
int[] | fills () |
Shape3D | stroke (int col) |
Shape3D | stroke (int col, int parts) |
int[] | strokes () |
Shape3D | strokeWeight (float weight) |
Shape3D | strokeWeight (float weight, int parts) |
float[] | strokeWeights () |
Shape3D | scale (float scale) |
float | scale () |
Shape3D | movie (PApplet pApplet, PImage movie) |
Shape3D | movie (PApplet pApplet, PImage movie, int parts) |
Shape3D | texture (PApplet app, String filename) |
Shape3D | texture (PImage texture) |
Shape3D | texture (PApplet app, String filename, int parts) |
Shape3D | texture (PImage texture, int parts) |
PImage[] | textures () |
Shape3D | uv (float u0, float u1, float v0, float v1) |
Shape3D | uv (float u0, float u1, float v0, float v1, int parts) |
Shape3D | uvt (TransformUV transformer) |
Shape3D | uvt (TransformUV transformer, int parts) |
Shape3D | uvwrap (int wrap) |
Shape3D | uvwrap (int wrap, int parts) |
Shape3D | mesh (int nbrColSlices, int nbrRowSlices) |
Shape3D | mesh (int nbrColSlices, int nbrRowSlices, int parts) |
Shape3D | visible (boolean visible) |
Shape3D | visible (boolean visible, int parts) |
boolean[] | visibles () |
Shape3D | moveTo (PVector pos) |
Shape3D | moveTo (float x, float y, float z) |
Shape3D | moveTo (float[] xyz) |
float | x () |
float | y () |
float | z () |
PVector | getPosVec () |
PVector | getPosVec (PVector target) |
float[] | getPosArray () |
float[] | getPosArray (float[] target) |
PVector | getRotVec () |
PVector | getRotVec (PVector target) |
float[] | getRotArray () |
float[] | getRotArray (float[] target) |
Shape3D | rotateTo (PVector angles) |
Shape3D | rotateTo (float[] angles) |
Shape3D | rotateTo (float x, float y, float z) |
Shape3D | rotateToX (float x) |
Shape3D | rotateToY (float y) |
Shape3D | rotateToZ (float z) |
Shape3D | rotateBy (float x, float y, float z) |
Shape3D | rotateBy (float[] angle) |
Shape3D | rotateBy (PVector angles) |
Shape3D | rotateByX (float x) |
Shape3D | rotateByY (float y) |
Shape3D | rotateByZ (float z) |
void | draw (PGraphics pg) |
void | drawPickBuffer (PGraphics pg) |
Static Public Member Functions | |
static void | showSurfaceNormals () |
static void | showSurfaceNormals (int color, float weight, float length) |
static void | hideSurfaceNormals () |
static int | nextPickColor () |
static Picked | pick (PApplet app, PGraphics canvas, int x, int y) |
static Picked[] | pick (PApplet app, PGraphics canvas, int x0, int y0, int x1, int y1) |
static Picked[] | mergePicks (Picked[] picked) |
static void | keepPickBufferImage (boolean keep) |
static PImage | pickBufferImage () |
static int | nbrShapes3D () |
Public Attributes | |
String | tag |
int | tagNo = 0 |
Public Attributes inherited from shapes3d.utils.SConstants | |
int | WIRE = 0x00000011 |
int | SOLID = 0x00000012 |
int | TEXTURE = 0x00000014 |
int | DRAWALL = WIRE | SOLID | TEXTURE |
int | WHITE = 0xFFFFFFFF |
int | BLACK = 0xFF000000 |
int | GREY = 0xFFC0C0C0 |
int | RED = 0xFFFF0000 |
int | GREEN = 0xFF00FF00 |
int | BLUE = 0xFF0000FF |
int | YELLOW = 0xFFFFFF00 |
int | PURPLE = 0xFFFF00FF |
int | CYAN = 0xFF00FFFF |
int | ORANGE = 0xFFFFC000 |
int | CW = 1 |
int | CCW = 2 |
int | ALL = 0b11111111 |
int | BOTTOM = 0b00000001 |
int | TOP = 0b00000010 |
int | FRONT = 0b00000100 |
int | BACK = 0b00001000 |
int | LEFT = 0b00010000 |
int | RIGHT = 0b00100000 |
int | BODY = 0b00000001 |
int | END0 = 0b00000010 |
int | END1 = 0b00000100 |
float | ONE_DEG_T = (float) (Math.PI / 180.0) |
PathOrthogonal | ORTHO_X = new PathOrthogonal.PathNormalX() |
PathOrthogonal | ORTHO_Y = new PathOrthogonal.PathNormalY() |
PathOrthogonal | ORTHO_Z = new PathOrthogonal.PathNormalZ() |
PathOrthogonal | ORTHO_A = new PathOrthogonal.PathNormalAMC() |
TransformUV | ROT_0 = TransformUV.ROT0 |
TransformUV | ROT_90 = TransformUV.ROT90 |
TransformUV | ROT_180 = TransformUV.ROT180 |
TransformUV | ROT_270 = TransformUV.ROT270 |
TransformUV | FLIP_H = TransformUV.FLIPH |
TransformUV | FLIP_V = TransformUV.FLIPV |
Rotation | ROTATION_ZERO = new Rotation() |
int | T_BOX = 0x1001 |
int | T_DOME = 0x1002 |
int | T_CONE = 0x1003 |
int | T_ELLIPSOID = 0x1004 |
int | T_EXTRUSION = 0x1005 |
int | T_LATHESTOCK = 0x1006 |
int | T_MD2 = 0x1007 |
int | T_SKYBOX = 0x1008 |
int | T_SKYDOME = 0x1009 |
int | T_TERRAIN = 0x100A |
int | T_TUBE = 0x100B |
int | C_LATHESURFACE = 0x2001 |
int | C_OVAL = 0x2002 |
int | C_POLYGON = 0x2003 |
int | P_BCURVE2D = 0x3001 |
int | P_BCURVE3D = 0x3002 |
int | P_BSPLINE2D = 0x3003 |
int | P_BSPLINE3D = 0x3004 |
int | P_LINEAR = 0x3005 |
int | P_LISSAJOUS = 0x3006 |
int | P_RING = 0x3007 |
int | P_SPIRAL = 0x3008 |
Protected Member Functions | |
abstract void | calcShape () |
abstract void | makeParts () |
abstract void | releaseMemory () |
void | fireEvent (Object...objects) |
Protected Attributes | |
PGraphics | on_canvas |
PMatrix | on_canvas_matrix |
PVector | pos = new PVector(0,0,0) |
PVector | rot = new PVector(0,0,0) |
PVector | up = new PVector(0,1,0) |
PVector | centreRot = new PVector(0,0,0) |
float | shapeScale = 1.0f |
_ShapePart[] | shapeParts = new _ShapePart[0] |
int | useParts = ALL |
int | pickColor |
boolean | pickable = true |
Object | eventHandlerObject = null |
Method | eventHandlerMethod = null |
String | eventHandlerMethodName |
Static Protected Attributes | |
static HashMap< Integer, Shape3D > | mapColor2Shape = new HashMap<Integer, Shape3D>() |
static HashMap< PGraphics, PGraphics > | mapCanvas2ColorBuffer = new HashMap<PGraphics, PGraphics>() |
static List< Shape3D > | shapesMade = new ArrayList<Shape3D>() |
static Set< Picked > | marqueeSelection = new HashSet<Picked>() |
static boolean | show_normals = false |
static int | normal_color = 0xFFFF00FF |
static float | normal_weight = 1.0f |
static float | normal_length = 10 |
static int | nextPickColor = 0xFF000000 |
static boolean | keepCopy = false |
static PImage | pbImage = null |
This is the base class for all 3D shapes.
Each shape may consist of 1-8 parts, for instance the
So when shape picking it is not only possible to detect which shape is picked but also the actual part.
shapes3d.Shape3D.Shape3D | ( | ) |
All child classes should call this constructor.
void shapes3d.Shape3D.addPickHandler | ( | Object | obj, |
String | methodName | ||
) |
Attempt to create the default pick event handler for this shape. The default event handler is a method that returns void and has a single parameter of the same type as the control class generating the event and a method name specific for that class.
obj | the object to handle the event |
methodName | the method to execute in the object handler class |
Shape3D shapes3d.Shape3D.drawMode | ( | int | mode | ) |
The draw mode can be either
S3D.SOLID - solid color as set with fill() method
S3D.WIRE - wire frame colour and wire thickness set with stroke() and strokeWeight() methods
S3D.TEXTURE - an image or movie is used to fill the shape
or any combination by or'ing them together e.g. S3D.SOLID | S3D.WIRE
Sets the drawing mode for all parts of the shape.
mode | the draw mode |
Shape3D shapes3d.Shape3D.drawMode | ( | int | mode, |
int | parts | ||
) |
The draw mode can be either
S3D.SOLID - solid color as set with fill() method
S3D.WIRE - wire frame colour and wire thickness set with stroke() and strokeWeight() methods
S3D.TEXTURE - an image or movie is used to fill the shape
or any combination by or'ing them together e.g. S3D.SOLID | S3D.WIRE
Sets the drawing mode for the specified parts of the shape.
mode | the draw mode |
parts | the parts to be textured |
int [] shapes3d.Shape3D.drawModes | ( | ) |
Get an array of the draw modes for the shape parts.
Shape3D shapes3d.Shape3D.fill | ( | int | col | ) |
Set the fill color for all the shape parts.
col | the color to use |
Shape3D shapes3d.Shape3D.fill | ( | int | col, |
int | parts | ||
) |
Set the fill color for the specified shape parts.
col | the color to use |
parts | the parts affected |
int [] shapes3d.Shape3D.fills | ( | ) |
|
protected |
Attempt to fire an event for this control.
The method called must have a single parameter which is the object firing the event. If the method to be called is to have different parameters then it should be overridden in the child class The method
float [] shapes3d.Shape3D.getPosArray | ( | ) |
float [] shapes3d.Shape3D.getPosArray | ( | float[] | target | ) |
Get the current position as an array.
If target is not null it is used to store the current position.
target | use this object to store position |
PVector shapes3d.Shape3D.getPosVec | ( | ) |
PVector shapes3d.Shape3D.getPosVec | ( | PVector | target | ) |
Get the current rotations as a PVector
target | use this object to store position |
float [] shapes3d.Shape3D.getRotArray | ( | ) |
float [] shapes3d.Shape3D.getRotArray | ( | float[] | target | ) |
Get the current rotations as an array.
If target is not null it is used to store the current position.
target | use this object to store rotations |
PVector shapes3d.Shape3D.getRotVec | ( | ) |
PVector shapes3d.Shape3D.getRotVec | ( | PVector | target | ) |
Get the current rotations as a PVector
target | use this object to store rotations |
|
static |
Shapes3D can keep an image of the last pick buffer. This is useful for debugging but should not be used otherwise because it use significant processor time.
keep | true if we want to keep a copy of the buffer |
This method accepts an array of Picked objects, possibly from a marquee selection and merge the results so that each pick object is for a unique shape and the part flag will indicate all the parts selected for that object.
The original Picked object array is unchanged.
picked | the array of picked objects (1 for each part picked) |
Shape3D shapes3d.Shape3D.moveTo | ( | PVector | pos | ) |
Sets the shape's current position.
pos | the new position |
Shape3D shapes3d.Shape3D.moveTo | ( | float | x, |
float | y, | ||
float | z | ||
) |
Sets the shape's current position.
x | x coordinate |
y | y coordinate |
z | z coordinate |
Shape3D shapes3d.Shape3D.moveTo | ( | float[] | xyz | ) |
Sets the shape's current position.
Position is unchanged if the parameter array has less than 3 elements.
xyz | the [xyz] coordinates |
Shape3D shapes3d.Shape3D.movie | ( | PApplet | pApplet, |
PImage | movie | ||
) |
Use a processing.video.Movie object as a texture for all parts of this shape.
pApplet | the enclosing PApplet object |
movie | the movie to use as a texture |
Shape3D shapes3d.Shape3D.movie | ( | PApplet | pApplet, |
PImage | movie, | ||
int | parts | ||
) |
Use a processing.video.Movie object as a texture for the specified parts of this shape.
pApplet | the enclosing PApplet object |
movie | the movie to use as a texture |
parts | the parts affected |
int shapes3d.Shape3D.nbrParts | ( | ) |
Get the number of parts created for this shape
|
static |
Return the number of shapes created so far.
|
static |
Will find the shape nearest to the viewer that is drawn at the given pixel position.
The user must specify the drawing canvas to use.
app | allows access to Processing methods / functions |
canvas | the canvas to use |
x | x position to test |
y | y position to test |
|
static |
Will find all shapes that are visible in a rectangular area of the canvas. The area is defined by any two diagonally opposed corners.
app | allows access to Processing methods / functions |
canvas | the canvas to use |
x0 | horizontal position of a corner 0 of the selection area |
y0 | vertical position of a corner 0 of the selection area |
x1 | horizontal position of a corner 1 of the selection area |
y1 | vertical position of a corner 1 of the selection area |
comp | the comparator used to sort the pick results. |
Shape3D shapes3d.Shape3D.pickable | ( | boolean | pickable | ) |
Determines whether this shape can be picked. If false then shapes behind this shape can be picked instead.
pickable | if true this shape can be picked |
boolean shapes3d.Shape3D.pickable | ( | ) |
Is this shape pickable
|
static |
Get a copy of the last pick buffer used. If you want to use this facility then enable it with the keepPickBufferImage(boolean) method.
Shape3D shapes3d.Shape3D.rotateBy | ( | float | x, |
float | y, | ||
float | z | ||
) |
Rotate shape from its current rotation state by the specified angles (radians)
x | add this angle to the current x rotation angle |
y | add this angle to the current y rotation angle |
z | add this angle to the current z rotation angle |
Shape3D shapes3d.Shape3D.rotateBy | ( | float[] | angle | ) |
Rotate shape from its current rotation state by the specified angles (radians) in the array.
Ignored if the array has less than 3 elements.
angle | an array of relative angles |
Shape3D shapes3d.Shape3D.rotateBy | ( | PVector | angles | ) |
Rotate shape from its current rotation state by the specified angles (radians) in the PVector.
angles | a PVector containing the XYZ relative angles |
Shape3D shapes3d.Shape3D.rotateByX | ( | float | x | ) |
Change the rotation about the x axis by the specified amount.
x | the angle in radians |
Shape3D shapes3d.Shape3D.rotateByY | ( | float | y | ) |
Change the rotation about the y axis by the specified amount.
y | the angle in radians |
Shape3D shapes3d.Shape3D.rotateByZ | ( | float | z | ) |
Change the rotation about the z axis by the specified amount.
z | the angle in radians |
Shape3D shapes3d.Shape3D.rotateTo | ( | PVector | angles | ) |
Set the current rotations.
angles | a PVector containing the x/y/z rotations in radians. |
Shape3D shapes3d.Shape3D.rotateTo | ( | float[] | angles | ) |
Set the current rotations. Ignored if the array has less than 3 elements.
angles | an array containing the x/y/z rotations in radians. |
Shape3D shapes3d.Shape3D.rotateTo | ( | float | x, |
float | y, | ||
float | z | ||
) |
Set the current rotations.
x | rotation about x axis |
y | rotation about y axis |
z | rotation about z axis |
Shape3D shapes3d.Shape3D.rotateToX | ( | float | x | ) |
Set the rotation about the x axis
x | the angle in radians |
Shape3D shapes3d.Shape3D.rotateToY | ( | float | y | ) |
Set the rotation about the y axis
y | the angle in radians |
Shape3D shapes3d.Shape3D.rotateToZ | ( | float | z | ) |
Set the rotation about the z axis
z | the angle in radians |
Shape3D shapes3d.Shape3D.scale | ( | float | scale | ) |
Set the scale for this shape
scale | the scale to be used for the rendered shape |
float shapes3d.Shape3D.scale | ( | ) |
Shape3D shapes3d.Shape3D.stroke | ( | int | col | ) |
Set the stroke color for all the shape parts
col | the color to use |
Shape3D shapes3d.Shape3D.stroke | ( | int | col, |
int | parts | ||
) |
Set the stroke color for the specified shape parts
col | the color to use |
parts | the parts affected |
int [] shapes3d.Shape3D.strokes | ( | ) |
Shape3D shapes3d.Shape3D.strokeWeight | ( | float | weight | ) |
Set the stroke weight for all the shape parts
weight | the stroke weight to use |
Shape3D shapes3d.Shape3D.strokeWeight | ( | float | weight, |
int | parts | ||
) |
Set the stroke weight for all the shape parts
weight | the stroke weight to use |
parts | the parts affected |
float [] shapes3d.Shape3D.strokeWeights | ( | ) |
Get an array of the stroke weights for the shape parts.
Shape3D shapes3d.Shape3D.tag | ( | String | tag | ) |
Set the tag to be used for all parts.
tag | the tag the descriptor string |
Shape3D shapes3d.Shape3D.tag | ( | String | tag, |
int | parts | ||
) |
Set the tag for all the specified parts.
tag | the descriptor string |
parts | the parts affected |
String [] shapes3d.Shape3D.tags | ( | ) |
Get an array of the tags for the shape parts.
Shape3D shapes3d.Shape3D.texture | ( | PApplet | app, |
String | filename | ||
) |
Use a processing.core.PImage object as a texture for all parts of this shape.
app | the enclosing PApplet object |
filename | the image filename |
Shape3D shapes3d.Shape3D.texture | ( | PImage | texture | ) |
Use a processing.core.PImage object as a texture for all parts of this shape.
texture | the PImage to use as the texture |
Shape3D shapes3d.Shape3D.texture | ( | PApplet | app, |
String | filename, | ||
int | parts | ||
) |
Use a processing.core.PImage object as a texture for the specified parts of this shape.
pApplet | the enclosing PApplet object |
filename | the image filename |
parts | the parts to be textured |
Shape3D shapes3d.Shape3D.texture | ( | PImage | texture, |
int | parts | ||
) |
Use a processing.core.PImage object as a texture for the specified parts of this shape.
texture | the PImage to use as the texture |
parts | the parts to be textured |
PImage [] shapes3d.Shape3D.textures | ( | ) |
Shape3D shapes3d.Shape3D.use | ( | int | parts_to_use | ) |
The following methods
drawMode, fill, stroke, strokeWeight, visible, texture, movie, uv
have two versions, the two parameter version
method_name(value, parts)
where the first parameter is the value to apply and the second specifies which shape parts to apply the value to.
The second version has just a single parameter
method_name(value)
where the parameter is the value to apply. By default this value will be applied to all the shape parts.
This method allows you to specify which parts should be modified with this version of the method.
To revert back to the original default behaviour call
shape.use(S3D.ALL);
parts_to_use | the shape parts modified in the single parameter method |
Shape3D shapes3d.Shape3D.uv | ( | float | u0, |
float | u1, | ||
float | v0, | ||
float | v1 | ||
) |
Set the texture coordinates for all shape parts.
u0 | horizontal texture coordinate |
u1 | horizontal texture coordinate |
v0 | vertical texture coordinate |
v1 | vertical texture coordinate |
Shape3D shapes3d.Shape3D.uv | ( | float | u0, |
float | u1, | ||
float | v0, | ||
float | v1, | ||
int | parts | ||
) |
Set the texture coordinates for the specified shape parts.
u0 | horizontal texture coordinate |
u1 | horizontal texture coordinate |
v0 | vertical texture coordinate |
v1 | vertical texture coordinate |
parts | the parts to be affected |
Shape3D shapes3d.Shape3D.uvt | ( | TransformUV | transformer | ) |
Use this to transform the UV coordinates for all parts.
transformer | the UV transformation to apply |
Shape3D shapes3d.Shape3D.uvt | ( | TransformUV | transformer, |
int | parts | ||
) |
Use this to transform the UV coordinates for the specified parts.
transformer | the UV transformation to apply |
parts | combined part flags |
Shape3D shapes3d.Shape3D.uvwrap | ( | int | wrap | ) |
Use this to decide whether the texture is repeated or clamped.
The parameter must be either REPEAT or CLAMP, any other value will be ignored.
wrap | REPEAT or CLAMP |
Shape3D shapes3d.Shape3D.uvwrap | ( | int | wrap, |
int | parts | ||
) |
Use this to decide whether the texture is repeated or clamped for the specified parts.
The parameter must be either REPEAT or CLAMP, any other value will be ignored.
wrap | REPEAT or CLAMP |
parts | combined part flags |
Shape3D shapes3d.Shape3D.visible | ( | boolean | visible | ) |
Makes all shape parts visible or invisible.
visible | true if you want to see this shape |
Shape3D shapes3d.Shape3D.visible | ( | boolean | visible, |
int | parts | ||
) |
Makes the specified shape parts visible or invisible.
visible | true if you want to see this shape |
parts | combined part flags |
boolean [] shapes3d.Shape3D.visibles | ( | ) |
String shapes3d.Shape3D.tag |
User defined tag for this shape.
This can be any text the user likes or finds useful. When a shape is created this is initialised to the name of the class e.g. Toroid, Cone etc.
int shapes3d.Shape3D.tagNo = 0 |
User defined tag number.
This can be any number the user likes or finds useful.