public class Model extends java.lang.Object
Model
data structure represents a distinct geometric object
in a Scene
. A Model
data structure is mainly a List
of Vertex
object and another list of LineSegment
objects.
Each LineSegment
object contains two integers that are the indices
of two Vertex
objects from the Models
's vertex list. The
two Vertex
objects contain the coordinates, in the camera coordinate
system, of the line segment's two endpoints.
A Model
represent the geometric object as a "wire-frame" of line
segments, that is, the geometric object is drawn as a collection of "edges".
This is a fairly simplistic way of doing 3D graphics and we will
improve this in later renderers.
See
http://en.wikipedia.org/wiki/Wire-frame_model
or
https://www.google.com/search?q=graphics+wireframe&tbm=isch
Modifier and Type | Field and Description |
---|---|
java.util.List<LineSegment> |
lineSegmentList |
java.util.List<Vertex> |
vertexList |
boolean |
visible |
Constructor and Description |
---|
Model()
Construct an empty
Model object. |
Model(Model model)
A "copy constructor".
|
Modifier and Type | Method and Description |
---|---|
void |
addLineSegment(int i0,
int i1)
|
void |
addLineSegment(Vertex v0,
Vertex v1)
|
void |
addVertex(Vertex... vArray)
|
void |
setColor(java.awt.Color c)
|
void |
setColorRandom()
|
void |
setRandomColors()
|
void |
setRandomLineSegmentColors()
|
java.lang.String |
toString()
For debugging.
|
public java.util.List<LineSegment> lineSegmentList
public java.util.List<Vertex> vertexList
public boolean visible
public Model()
Model
object.public Model(Model model)
Model
's Vertex
list and
LineSegment
list.model
- Model
to make a copy ofpublic void addLineSegment(int i0, int i1)
LineSegment
to this Model
's List
of
line segments.
NOTE: This method does not add any vertices to the Model
's
Vertex
list. This method assumes that the appropriate vertices
have been added to the Model
's Vertex
list.
i0
- 1st integer index of LineSegment
to add to this Model
i1
- 2nd integer index of LineSegment
to add to this Model
public void addLineSegment(Vertex v0, Vertex v1)
LineSegment
to this Model
's List
of
line segments.
This method adds (copies of) the two give Vertex
objects to
this Model
's vertex list and then costructs an appropriate
LineSegment
object to add to this Model
's line
segment list.
This method provides a convenient way to build up a Model
but
it may not build an efficient Model
. Using this mehtod may lead
to a lot of redundant Vertex
objects in this Model
's
vertex list.
v0
- 1st Vertex
of LineSegment
to add to this Model
v1
- 2nd Vertex
of LineSegment
to add to this Model
public void addVertex(Vertex... vArray)
vArray
- array of Vertex
objects to add to this Model
public void setColor(java.awt.Color c)
c
- Color
for all of this model's Vertex
objectspublic void setColorRandom()
public void setRandomColors()
public void setRandomLineSegmentColors()
LineSegment
in this Model
to a different random Color
.
NOTE: This works best when the LineSegment
objects in this Model
do not share any
Vertex
objects.
public java.lang.String toString()
toString
in class java.lang.Object
String
representation of this Model
object