edu.byu.phun
Class Win3D

java.lang.Object
  extended by edu.byu.phun.PropertyContainer
      extended by edu.byu.phun.Win3D

public class Win3D
extends PropertyContainer

This creates an instance of a 3D window on the screen. Initially the window is empty. The programmer can add(Obj3D) any of the Obj3D objects to this window to have them displayed as part of the window's scene.


Field Summary
static java.awt.Frame myFrame
          This is the Java AWT Frame that is used to contain the 3D window.
 
Constructor Summary
Win3D(java.lang.String title)
          Creates a new window for display of 3D graphics.
Win3D(java.lang.String title, int left, int top, int width, int height)
          Creates a new window for display of 3D graphics at a particular size and location.
 
Method Summary
 void add(Obj3D obj)
          This will add a new object to the scene being viewed by the camera.
 Color getAmbientLight()
          This will return the current settings for ambient light.
 Color getBackground()
          This will return the current background color of the object.
 Color getLightAColor()
          Returns the color of light A, one of the directional light sources.
 Color getLightBColor()
          Returns the color of light B, one of the directional light sources.
 Point3d getLookAt()
          This returns the point that the camera is currently looking at.
 Point3d getLookFrom()
          This returns the point where the camera is looking from.
 GroupObj getSceneObject()
          Returns the object that contains the scene being displayed.
 void pause(int milliseconds)
          This will cause the program to wait for a certain number of milliseconds.
 void remove(java.lang.String name)
          This will look for an object that has the specified name and will remove it from the scene.
 void setAmbientLight(Color color)
          This will set the ambient light using a Color object.
 void setAmbientLight(double red, double green, double blue)
          Ambient light is a fiction used to provide fill lighting in a scene.
 void setBackground(Color color)
          This will set the background color for the 3D window.
 void setBackground(double red, double green, double blue)
          This will set the background color to be displayed in the window behind all other objects in the window.
 void setLightAColor(Color color)
          This will set the color of one of the directional light sources.
 void setLightAColor(double red, double green, double blue)
          This will set the color of one of the directional light sources.
 void setLightBColor(Color color)
          This will set the color of one of the directional light sources.
 void setLightBColor(double red, double green, double blue)
          This will set the color of one of the directional light sources.
 void setLookAt(double x, double y, double z)
          This will set the point that the camera for the window is looking at.
 void setLookAt(Point3d atPoint)
          This will set the point that the camera for the window is looking at.
 void setLookFrom(double x, double y, double z)
          This will set the point where the camera is positioned in 3 space.
 void setLookFrom(Point3d from)
          This will set the point where the camera is positioned in 3 space.
 void setSceneObject(GroupObj newScene)
          This will change the scene.
 
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, toString, wait, wait, wait
 

Field Detail

myFrame

public static java.awt.Frame myFrame
This is the Java AWT Frame that is used to contain the 3D window.

Constructor Detail

Win3D

public Win3D(java.lang.String title)
Creates a new window for display of 3D graphics.

Parameters:
title - the title in the window's header bar.

Win3D

public Win3D(java.lang.String title,
             int left,
             int top,
             int width,
             int height)
Creates a new window for display of 3D graphics at a particular size and location.

Parameters:
title - the title in the window's header bar.
left - the location of the left side of the window.
top - the location of the top of the window.
width - the width of the window.
height - the height of the window.
Method Detail

getSceneObject

public GroupObj getSceneObject()
Returns the object that contains the scene being displayed. This can be used to manipulate the contents of the scene.

Returns:
the scene object.

setSceneObject

public void setSceneObject(GroupObj newScene)
This will change the scene. This allows for a complete change of the scene to be displayed.

Parameters:
newScene - the new scene to be displayed.

setAmbientLight

public void setAmbientLight(double red,
                            double green,
                            double blue)
Ambient light is a fiction used to provide fill lighting in a scene. Ambient light is "everywhere" and shining in every direction. In reality this would be reflected light from floors, walls and other objects. Initially the ambient light is set to (0.5,0.5,0.5), which is a white light of medium brightness. This method can change that setting.

Setting the ambient light to black (0,0,0) would be like deep space where there are no reflecting surroundings. Setting the ambient light to white (1,1,1) would be like being outside or in a brightly lit room.

Parameters:
red - the red component 0.0-no light, 1.0-maximum light.
green - the green component 0.0-no light, 1.0-maximum light.
blue - the blue component 0.0-no light, 1.0-maximum light.

setAmbientLight

public void setAmbientLight(Color color)
This will set the ambient light using a Color object.

Parameters:
color - the color to which ambient light should be set.
See Also:
setAmbientLight(double, double, double)

getAmbientLight

public Color getAmbientLight()
This will return the current settings for ambient light.

Returns:
the color of ambient light.

setLightAColor

public void setLightAColor(double red,
                           double green,
                           double blue)
This will set the color of one of the directional light sources. This will set the color of light A.

Parameters:
red - - red component of the light 0.0-1.0
green - - green component of the light 0.0-1.0
blue - - blue component of the light 0.0-1.0

setLightAColor

public void setLightAColor(Color color)
This will set the color of one of the directional light sources. This sets the color of light A.

Parameters:
color - the color of the light.

getLightAColor

public Color getLightAColor()
Returns the color of light A, one of the directional light sources.

Returns:
the color of light A.

setLightBColor

public void setLightBColor(double red,
                           double green,
                           double blue)
This will set the color of one of the directional light sources. This will set the color of light B.

Parameters:
red - - red component of the light 0.0-1.0
green - - green component of the light 0.0-1.0
blue - - blue component of the light 0.0-1.0

setLightBColor

public void setLightBColor(Color color)
This will set the color of one of the directional light sources. This sets the color of light B.

Parameters:
color - the color of the light.

getLightBColor

public Color getLightBColor()
Returns the color of light B, one of the directional light sources.

Returns:
the color of light B.

setBackground

public void setBackground(double red,
                          double green,
                          double blue)
This will set the background color to be displayed in the window behind all other objects in the window. The default is black.

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

setBackground

public void setBackground(Color color)
This will set the background color for the 3D window. The default is black.

Parameters:
color - the new background color

getBackground

public Color getBackground()
This will return the current background color of the object.

Returns:
the background color of the window.

setLookAt

public void setLookAt(double x,
                      double y,
                      double z)
This will set the point that the camera for the window is looking at. This point in 3 space will appear in the center of the window.

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

setLookAt

public void setLookAt(Point3d atPoint)
This will set the point that the camera for the window is looking at. This point in 3 space will appear in the center of the window.

Parameters:
atPoint - the new look at point.

setLookFrom

public void setLookFrom(double x,
                        double y,
                        double z)
This will set the point where the camera is positioned in 3 space. This is where the camera is looking from.

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

setLookFrom

public void setLookFrom(Point3d from)
This will set the point where the camera is positioned in 3 space. This is where the camera is looking from.

Parameters:
from - the new look from point.

getLookAt

public Point3d getLookAt()
This returns the point that the camera is currently looking at.

Returns:
the current look at point.

getLookFrom

public Point3d getLookFrom()
This returns the point where the camera is looking from.

Returns:
the current look from point.

add

public void add(Obj3D obj)
This will add a new object to the scene being viewed by the camera. The object will immediately appear if it is not behind some other object and is within the view of the camera.

Parameters:
obj - the object to be added.

remove

public void remove(java.lang.String name)
This will look for an object that has the specified name and will remove it from the scene.

Parameters:
name - the name of the object to be removed. This is case sensitive.

pause

public void pause(int milliseconds)
This will cause the program to wait for a certain number of milliseconds. It will not return until that time has expired.

Parameters:
milliseconds - the number of thousandths of a second that the program is to be paused.