|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.vizzini.ui.graphics.shape.AbstractShape
public abstract class AbstractShape
Provides base functionality for 3D shapes. The coordinate system is screen based (+Z into the screen).
^ +Z / / +-----> +X | | V +YOther shapes can be placed "on" or relative to this one with
add
. Specify their center with setCenter
relative to
this.
Field Summary | |
---|---|
protected boolean |
_isWireframe
Flag indicating whether to draw this as a wireframe or solid. |
protected Vector[] |
_points
The absolute point relative to the center. |
protected Vector |
_screenCenter
The center in screen coordinates. |
protected Vector[] |
_screenPoints
The shape's points in screen coordinates. |
protected ShapeGroup |
_shapeGroup
Collection of child shapes to this shape. |
protected double |
_zNormal
The z normal value. |
Constructor Summary | |
---|---|
AbstractShape(double width,
double height,
double depth)
Construct this object with the given parameters. |
Method Summary | |
---|---|
void |
add(IShape shape)
Add the given shape as a child of this. |
void |
clear()
Clear all child shapes. |
int |
compareTo(Object object)
Compare this shape to the given object. |
protected void |
computeCenteredScreenPoints()
Translate the screen points by the screen center. |
double |
computeNormalZComponent(int i1,
int i2,
int i3)
Compute the normal z component of the plane define by the points with the given indices in screen coordinates. |
protected Vector |
computeScreenCenter(Quaternion q,
Vector v,
double magnify,
int offsetX,
int offsetY)
Compute the center in screen coordinates. |
void |
computeScreenPoints(Quaternion q,
Vector v,
double magnify,
int offsetX,
int offsetY,
double d)
Compute the points of this shape in screen coordinates. |
boolean |
contains(Point point)
Return true if the given point is within this shape. |
protected IState |
createState()
Create the state. |
protected StatefulSupport |
createStatefulSupport()
Create a stateful support object. |
void |
drawOn(Graphics g,
double magnify)
Draw this shape on the given graphics with the given magnification. |
protected void |
drawOn(Graphics g,
double magnify,
boolean isWireframe)
Draw this shape on the given graphics with the given magnification. |
protected void |
drawOnSolid(Graphics g,
double magnify)
Draw a solid representation of this shape on the given graphics with the given magnification. |
protected void |
drawOnWireframe(Graphics g,
double magnify)
Draw a wireframe representation of this shape on the given graphics with the given magnification. |
IState |
getAbsoluteState()
Return the absolute state. |
Rectangle |
getBounds()
Return the bounding box of the screen coordinates. |
ShapeGroup |
getChildren()
Return the child shapes. |
Color |
getColor()
Return the color of this shape. |
protected Color |
getColorForIntensity(double intensity)
Return this shape's color scaled by the given intensity. |
double |
getDepth()
|
Vector |
getDimensions()
Return the dimensions in world coordinates. |
double |
getHeight()
|
double |
getMinDimension()
Return the minimum dimension. |
String |
getName()
|
Vector |
getScreenCenter()
Return this shape's center in screen coordinates. |
ShapeGroup |
getShapeGroup()
Return the shape group. |
IState |
getState()
Return the state. |
IStateful |
getStatefulParent()
Return the parent. |
String |
getTextureFilepath()
Return the texture filepath. |
double |
getWidth()
|
protected boolean |
isInFrontOf(IShape s)
Return true if the given shape is in front of this. |
boolean |
isLightSource()
|
boolean |
isTextureFilepathSet()
Return true if a texture filepath is set. |
boolean |
isVisible()
Return true if this is visible. |
boolean |
isWireframe()
Return true if this is wireframe. |
void |
remove(IShape shape)
Remove the given child shape. |
void |
setColor(Color color)
Set the color. |
void |
setLightSource(boolean isLightSource)
|
void |
setName(String name)
|
void |
setStatefulParent(IStateful parent)
Set the parent. |
void |
setTextureFilepath(String textureFilepath)
Set the texture filepath. |
void |
setVisible(boolean isVisible)
Set the visibility flag. |
void |
setWireframe(boolean isWireframe)
Set the wireframe flag. |
String |
toString()
Return a string representation of this object. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
protected boolean _isWireframe
protected Vector[] _points
protected Vector _screenCenter
protected Vector[] _screenPoints
protected ShapeGroup _shapeGroup
protected double _zNormal
Constructor Detail |
---|
public AbstractShape(double width, double height, double depth)
width
- Width.height
- Height.depth
- Depth.Method Detail |
---|
public void add(IShape shape)
add
in interface IShape
shape
- The new child shape.public void clear()
clear
in interface IShape
public int compareTo(Object object)
compareTo
in interface Comparable
public final double computeNormalZComponent(int i1, int i2, int i3)
computeNormalZComponent
in interface IShape
public void computeScreenPoints(Quaternion q, Vector v, double magnify, int offsetX, int offsetY, double d)
computeScreenPoints
in interface IShape
q
- Rotation of the parent to world coordinates.v
- The parent position in world coordinates..magnify
- The magnification.offsetX
- The offset X coordinate.offsetY
- The offset Y coordinate.d
- Perspective constant.public boolean contains(Point point)
contains
in interface IShape
public void drawOn(Graphics g, double magnify)
drawOn
in interface IShape
g
- The graphics.magnify
- The magnification.public IState getAbsoluteState()
getAbsoluteState
in interface IStateful
public Rectangle getBounds()
getBounds
in interface IShape
public ShapeGroup getChildren()
getChildren
in interface IShape
public Color getColor()
getColor
in interface IShape
public double getDepth()
getDepth
in interface IShape
public Vector getDimensions()
getDimensions
in interface IShape
public double getHeight()
getHeight
in interface IShape
public double getMinDimension()
getMinDimension
in interface IShape
public String getName()
getName
in interface IShape
public Vector getScreenCenter()
getScreenCenter
in interface IShape
public ShapeGroup getShapeGroup()
public IState getState()
getState
in interface IStateful
public IStateful getStatefulParent()
getStatefulParent
in interface IStateful
public String getTextureFilepath()
IShape
getTextureFilepath
in interface IShape
public double getWidth()
getWidth
in interface IShape
public boolean isLightSource()
isLightSource
in interface IShape
public boolean isTextureFilepathSet()
isTextureFilepathSet
in interface IShape
public boolean isVisible()
isVisible
in interface IShape
public boolean isWireframe()
isWireframe
in interface IShape
public void remove(IShape shape)
remove
in interface IShape
public void setColor(Color color)
setColor
in interface IShape
public void setLightSource(boolean isLightSource)
setLightSource
in interface IShape
isLightSource
- the isLightSource to setpublic void setName(String name)
setName
in interface IShape
name
- the name to setpublic void setStatefulParent(IStateful parent)
setStatefulParent
in interface IStateful
public void setTextureFilepath(String textureFilepath)
IShape
setTextureFilepath
in interface IShape
textureFilepath
- the textureFilepath to setpublic void setVisible(boolean isVisible)
setVisible
in interface IShape
public void setWireframe(boolean isWireframe)
setWireframe
in interface IShape
public String toString()
toString
in interface IShape
toString
in class Object
protected void computeCenteredScreenPoints()
protected Vector computeScreenCenter(Quaternion q, Vector v, double magnify, int offsetX, int offsetY)
q
- The parent quaternion.v
- The parent center.magnify
- The magnification.offsetX
- The offset X coordinate.offsetY
- The offset Y coordinate.protected IState createState()
protected StatefulSupport createStatefulSupport()
protected void drawOn(Graphics g, double magnify, boolean isWireframe)
g
- The graphics.magnify
- The magnification.isWireframe
- Flag indicating if this shape is wireframe or solid.protected void drawOnSolid(Graphics g, double magnify)
g
- The graphics.magnify
- The magnification.protected void drawOnWireframe(Graphics g, double magnify)
g
- The graphics.magnify
- The magnification.protected Color getColorForIntensity(double intensity)
intensity
- The desired color intensity between 0.0 and 1.0.protected boolean isInFrontOf(IShape s)
s
- Shape to compare.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
Copyright © 2007 Vizzini.org. All Rights Reserved. | 2007.12.25.03.00.02 |