public class GShape extends java.lang.Object implements Drawable2D, Drawable3D, java.io.Serializable
Modifier and Type | Field and Description |
---|---|
private java.util.List<Cutout> |
cutouts |
private java.util.List<Edge> |
edges |
private boolean |
isActive |
private boolean |
isSelected |
private Material |
material |
private java.lang.String |
name |
private int |
numberOfConnections |
private Vector2D |
position2D |
private Vector3D |
position3D |
private float |
scalingFactor |
private float |
scalingFactor3D |
private static long |
serialVersionUID |
private Shape |
shape |
private java.util.List<Vector2D> |
vertices |
private java.util.List<Vector3D> |
vertices3D |
Constructor and Description |
---|
GShape(java.util.List<Vector2D> initVertices,
Vector3D position,
Shape shape)
Creates edges with the 3D and 2D representation of this form (one edge between each pair of vertices)
Uses a standard material.
|
Modifier and Type | Method and Description |
---|---|
void |
addCutout(Cutout cutout) |
void |
addCutout(GShape cutout) |
void |
addNumberOfConnections(int connections) |
private float |
calculateAngleBetweenNormals(GShape master,
GShape slave) |
private boolean |
containsAtLeastOnePointFromList(java.util.List<toxi.geom.Vec2D> points) |
GShape |
copy(Shape shape)
Form copy for printing - using the outline vertices as new shape form
(keeps the outline without actually having the connections)
|
Shape |
copyCompleteStructure()
Copy everything, including cut-outs, to make another identical object
|
private Vector2D |
correctIntersection(Edge edge) |
private void |
createCover2D(processing.core.PGraphics p,
java.util.ArrayList<Vector2D> vectors,
Vector2D position) |
private void |
createCover3D(processing.core.PGraphics p,
boolean isTop) |
private java.util.List<toxi.geom.Line2D> |
createListOfLines(java.util.List<toxi.geom.Vec2D> vectors) |
private void |
createSides(processing.core.PGraphics p,
java.util.ArrayList<Vector2D> vectors) |
void |
draw2D(processing.core.PGraphics p,
Transformation t)
Complete 2D drawing - draw cover and edges
|
void |
draw3D(processing.core.PGraphics p,
Transformation t)
Complete 3D drawing - draw sides, cover and edges
|
Vector2D |
get2Dperpendicular(Vector2D v1,
Vector2D v2)
Calculates the perpendicular vector between two points in the 2D space
(the "inwards" direction of the form)
|
Vector3D |
get3Dperpendicular(Vector3D v1,
Vector3D v2)
Calculates the perpendicular vector between two points in the 3D space
(the "inwards" direction of the form)
|
java.util.List<Cutout> |
getCutouts() |
java.util.List<Edge> |
getEdges() |
Material |
getMaterial() |
java.lang.String |
getName() |
Vector3D |
getNormalVector() |
int |
getNumberOfConnections() |
Vector2D |
getPosition2D() |
Vector3D |
getPosition3D() |
float |
getScalingFactor() |
float |
getScalingFactor3D() |
Shape |
getShape() |
java.util.ArrayList<Vector2D> |
getTenons() |
int |
getThickness() |
java.util.List<Vector2D> |
getVertices() |
private java.util.List<toxi.geom.Vec2D> |
getVerticesIncludingPosition2D() |
boolean |
isActive()
check, if cut-out is made active (can be manipulated)
|
boolean |
isSelected() |
boolean |
mouseOver(Vector2D mousePosition)
check if mouse is over cut-out or the corresponding connecting line
|
private boolean |
noLineIntersections(java.util.List<toxi.geom.Vec2D> vectors1,
java.util.List<toxi.geom.Vec2D> vectors2) |
boolean |
overlapsWith(GShape s)
checks, if this form overlaps with another form
|
void |
recalculate(java.util.List<Vector2D> basicShape)
Recalculate form (edges) of the shape, if the form of its parent shape is modified
|
private void |
removeAllCutouts()
remove all cut-outs from this shape (clean up for deletion)
|
void |
removeCutout(Cutout cutout) |
void |
rotateAroundAxis(Vector3D rotationAxis,
float theta)
Rotates the form in the 3D space
|
private float |
safeAngleBetween(Vector3D masterEdgeDirection,
Vector3D slaveEdgeDirection) |
void |
scale2D(float scaleFactor) |
void |
setActive(boolean isActive) |
private void |
setFillColor(processing.core.PGraphics p) |
void |
setMaterial(Material material)
Changes the material of the object, and updates the outline
of itself and other connected forms corresponding to the new
(changed) thickness
|
void |
setName(java.lang.String name)
Name (identifier) a shape.
|
void |
setPosition2D(Vector2D position)
Change the position of the object in 2D space
|
void |
setScalingFactor(float factor) |
void |
setScalingFactor3D(float factor) |
void |
setSelected(boolean selected) |
private java.util.ArrayList<Vector3D> |
transformTo3D(boolean isTop,
java.util.ArrayList<Vector2D> vectors2D) |
void |
translate2D(Vector2D direction) |
void |
translate3D(Vector3D translationVector) |
private static final long serialVersionUID
private int numberOfConnections
private Vector2D position2D
private Vector3D position3D
private boolean isSelected
private boolean isActive
private java.util.List<Vector2D> vertices
private java.util.List<Vector3D> vertices3D
private java.util.List<Cutout> cutouts
private java.util.List<Edge> edges
private Shape shape
private Material material
private java.lang.String name
private float scalingFactor
private float scalingFactor3D
public GShape(java.util.List<Vector2D> initVertices, Vector3D position, Shape shape)
initVertices
- Form of the shape in 2D viewposition
- of this form in 3Dshape
- type of form, to which this form belongpublic java.util.List<Cutout> getCutouts()
public void setScalingFactor(float factor)
factor
- for scaling the 2D viewpublic float getScalingFactor()
public void setScalingFactor3D(float factor)
factor
- for scaling the 3D viewpublic float getScalingFactor3D()
public void recalculate(java.util.List<Vector2D> basicShape)
basicShape
- changed form in 2Dpublic void addCutout(GShape cutout)
cutout
- add this cut-out to this formpublic void removeCutout(Cutout cutout)
cutout
- remove this cut-out from the formpublic int getNumberOfConnections()
public void addNumberOfConnections(int connections)
connections
- a number of new connected edgespublic Shape getShape()
public int getThickness()
public Material getMaterial()
public Vector3D getPosition3D()
public boolean isSelected()
public java.util.List<Edge> getEdges()
public java.util.List<Vector2D> getVertices()
public boolean overlapsWith(GShape s)
s
- checking for overlaps with this formprivate boolean noLineIntersections(java.util.List<toxi.geom.Vec2D> vectors1, java.util.List<toxi.geom.Vec2D> vectors2)
private java.util.List<toxi.geom.Line2D> createListOfLines(java.util.List<toxi.geom.Vec2D> vectors)
private boolean containsAtLeastOnePointFromList(java.util.List<toxi.geom.Vec2D> points)
private java.util.List<toxi.geom.Vec2D> getVerticesIncludingPosition2D()
public java.util.ArrayList<Vector2D> getTenons()
private java.util.ArrayList<Vector3D> transformTo3D(boolean isTop, java.util.ArrayList<Vector2D> vectors2D)
private float safeAngleBetween(Vector3D masterEdgeDirection, Vector3D slaveEdgeDirection)
private float calculateAngleBetweenNormals(GShape master, GShape slave)
public Vector2D get2Dperpendicular(Vector2D v1, Vector2D v2)
v1
- first vectorv2
- second vectorpublic Vector3D get3Dperpendicular(Vector3D v1, Vector3D v2)
v1
- first vectorv2
- second vectorpublic Vector2D getPosition2D()
public void setMaterial(Material material)
material
- the new material for the formpublic void setSelected(boolean selected)
selected
- set true, if mouse is over cut-outpublic void scale2D(float scaleFactor)
scaleFactor
- scale cut-out for printingpublic void setPosition2D(Vector2D position)
position
- new position of the formpublic void translate2D(Vector2D direction)
direction
- how the form should be moved in the 2D spacepublic void rotateAroundAxis(Vector3D rotationAxis, float theta)
rotationAxis
- around which the rotation took placetheta
- how much to rotatepublic void translate3D(Vector3D translationVector)
translationVector
- how the form should be moved in the 3D spacepublic Vector3D getNormalVector()
public void draw2D(processing.core.PGraphics p, Transformation t)
draw2D
in interface Drawable2D
p
- where to drawpublic void draw3D(processing.core.PGraphics p, Transformation t)
draw3D
in interface Drawable3D
p
- where to drawprivate void createSides(processing.core.PGraphics p, java.util.ArrayList<Vector2D> vectors)
private void createCover3D(processing.core.PGraphics p, boolean isTop)
private void createCover2D(processing.core.PGraphics p, java.util.ArrayList<Vector2D> vectors, Vector2D position)
private void setFillColor(processing.core.PGraphics p)
public boolean mouseOver(Vector2D mousePosition)
mousePosition
- the current mouse positionpublic GShape copy(Shape shape)
shape
- the form to which this form should belongpublic Shape copyCompleteStructure()
private void removeAllCutouts()
public void addCutout(Cutout cutout)
cutout
- add this cut-out to this shapepublic java.lang.String getName()
public void setName(java.lang.String name)
name
- the name of the shapepublic boolean isActive()
public void setActive(boolean isActive)
isActive
- set true, if mouse is pressed when mouse is over cut-out