edu.byu.phun
Class Obj3D

java.lang.Object
  extended by edu.byu.phun.PropertyContainer
      extended by edu.byu.phun.Obj3D
Direct Known Subclasses:
BoxObj, ConeObj, CylinderObj, GroupObj, SphereObj

public class Obj3D
extends PropertyContainer

This is a super class of all 3D objects that can be placed in the scene of a Win3D or as a part in a GroupObj.

This class defines all of the operations that can be performed on a 3D object including:


Constructor Summary
Obj3D()
           
 
Method Summary
 BoundingBox getBounds()
          Returns a bounding box for this object.
 Color getColor()
          This returns the color of the object.
 Point3d getLocation()
          This will return the location of the origin of the object.
 java.lang.String getName()
          Returns the name associated with this object.
 double getRotX()
          Returns the rotation angle about X in degrees.
 double getRotY()
          Returns the rotation angle about Y in degrees.
 double getRotZ()
          Returns the rotation angle about Z in degrees.
 double getScaleX()
          Returns the scale factor for X.
 double getScaleY()
          Returns the scale factor for Y.
 double getScaleZ()
          Returns the scale factor for Z.
 double getShininess()
          This will return the shininess of the object.
 void setColor(Color newColor)
          Changes the color of the object.
 void setColor(double red, double green, double blue)
          This sets the color of the object.
 void setLocation(double x, double y, double z)
          This will change the location of the object's origin.
 void setLocation(Point3d newLoc)
          This will set the location of the object to a new position.
 void setName(java.lang.String newName)
          Changes the name associated with this object.
 void setRotX(double xDegrees)
          Sets the counter-clockwise rotation about X
 void setRotY(double yDegrees)
          Sets the counter-clockwise rotation about Y
 void setRotZ(double zDegrees)
          Sets the counter-clockwise rotation about Z
 void setScale(double newScale)
          This will uniformly scale X, Y and Z so that Y will have the newScale.
 void setScale(double scaleX, double scaleY, double scaleZ)
          This will set the scale factors for the object.
 void setScaleX(double scaleX)
          This will change the X scale without changing other scales.
 void setScaleY(double scaleY)
          This will change the height of the object in Y by scaling it using scaleY.
 void setScaleZ(double scaleZ)
          This will change the depth of the object in Z by scaling it.
 void setShininess(double shininess)
          This will set the shininess of the object.
 java.lang.String toString()
           
 
Methods inherited from class edu.byu.phun.PropertyContainer
getPropertyC, getPropertyD, getPropertyP, getPropertyS, propertyIsColor, propertyIsDouble, propertyIsPoint, propertyIsSettable, propertyIsString, propertyNames, setProperty, setProperty
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Obj3D

public Obj3D()
Method Detail

setLocation

public void setLocation(Point3d newLoc)
This will set the location of the object to a new position.

Parameters:
newLoc - the new location for the origin of the object.

setLocation

public void setLocation(double x,
                        double y,
                        double z)
This will change the location of the object's origin.

Parameters:
x - the X coordinate
y - the Y coordinate
z - the Z coordinate

getLocation

public Point3d getLocation()
This will return the location of the origin of the object.

Returns:
the object's origin.

setScale

public void setScale(double scaleX,
                     double scaleY,
                     double scaleZ)
This will set the scale factors for the object. These are multiplied times the object to make it larger or smaller.

Parameters:
scaleX - the new scale factor for X.
scaleY - the new scale factor for Y.
scaleZ - the new new scale factor for Z.

setScale

public void setScale(double newScale)
This will uniformly scale X, Y and Z so that Y will have the newScale. This provides a simple mechanism for changing the size of an object without changing its relative shape.

Parameters:
newScale - the new scale factor for all dimensions.

setScaleX

public void setScaleX(double scaleX)
This will change the X scale without changing other scales.

Parameters:
scaleX - the scale factor for X.

getScaleX

public double getScaleX()
Returns the scale factor for X.

Returns:
the X scale factor.

setScaleY

public void setScaleY(double scaleY)
This will change the height of the object in Y by scaling it using scaleY.

Parameters:
scaleY - the new scale factor for Y.

getScaleY

public double getScaleY()
Returns the scale factor for Y.

Returns:
the Y scale factor.

setScaleZ

public void setScaleZ(double scaleZ)
This will change the depth of the object in Z by scaling it.

Parameters:
scaleZ - the new scale factor for Z.

getScaleZ

public double getScaleZ()
Returns the scale factor for Z.

Returns:
the Z scale factor.

setRotX

public void setRotX(double xDegrees)
Sets the counter-clockwise rotation about X

Parameters:
xDegrees - counter-clockwise rotation about X in degrees.

setRotY

public void setRotY(double yDegrees)
Sets the counter-clockwise rotation about Y

Parameters:
yDegrees - counter-clockwise rotation about Y in degrees.

setRotZ

public void setRotZ(double zDegrees)
Sets the counter-clockwise rotation about Z

Parameters:
zDegrees - counter-clockwise rotation about Z in degrees.

getRotX

public double getRotX()
Returns the rotation angle about X in degrees.

Returns:
the counter-clockwise rotation angle about X.

getRotY

public double getRotY()
Returns the rotation angle about Y in degrees.

Returns:
the counter-clockwise rotation angle about Y.

getRotZ

public double getRotZ()
Returns the rotation angle about Z in degrees.

Returns:
the counter-clockwise rotation angle about Z.

getColor

public Color getColor()
This returns the color of the object.

Returns:
the color.

setColor

public void setColor(double red,
                     double green,
                     double blue)
This sets the color of the object. Colors are specified between 0.0 (dark) and 1.0 (fully lighted) in red, green and blue.

Examples.

Parameters:
red - the red component
green - the green component
blue - the blue component

setColor

public void setColor(Color newColor)
Changes the color of the object.

Parameters:
newColor - the new color
See Also:
setColor(double, double, double)

getShininess

public double getShininess()
This will return the shininess of the object.

Returns:
0 for not shiny at all and 1 for maximum shine.

setShininess

public void setShininess(double shininess)
This will set the shininess of the object. 0.0 is for no shine at all and 1.0 is for maximum shine. The default is 0.5.

Parameters:
shininess - the shininess of the object.

getName

public java.lang.String getName()
Returns the name associated with this object.

Returns:
the object name.
See Also:
setName(String)

setName

public void setName(java.lang.String newName)
Changes the name associated with this object. This name is used to find this object within groups.

Parameters:
newName - the new name.

getBounds

public BoundingBox getBounds()
Returns a bounding box for this object. The default implementation is to get the transformed shell points and compute the min and max values.

Returns:
the bounds of the object.

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object
See Also:
Object.toString()