Class Model
- java.lang.Object
-
- renderer.scene.Model
-
- Direct Known Subclasses:
Axes2D,Axes3D,BarycentricTriangle,Box,Circle,CircleSector,Cone,ConeFrustum,ConeSector,Cube,Cube2,Cube4,Cylinder,CylinderSector,Disk,DiskSector,Dodecahedron,GRSModel,Icosahedron,Icosidodecahedron,ObjSimpleModel,Octahedron,PanelXY,PanelXZ,PanelYZ,ParametricCurve,ParametricSurface,Pyramid,PyramidFrustum,Ring,RingSector,Sphere,SphereSector,SphereSubdivided,Square,SquareGrid,Tetrahedron,Torus,TorusSector,TriangularPrism,TriangularPyramid,ViewFrustumModel
public class Model extends Object
AModelobject represents a distinct geometric object in aScene. AModeldata structure is mainly aListofVertexobjects, aListofPrimitiveobjects, and a list ofColorobjects.Each
Vertexobject contains the xyz-coordinates, in theModel's own coordinate system, for one point from theModel.Each
Colorobject represents a color associated to one (or more)Vertexobjects.The
Vertexobjects represents points from the geometric object that we are modeling. In the real world, a geometric object has an infinite number of points. In 3D graphics, we "approximate" a geometric object by listing just enough points to adequately describe the object. For example, in the real world, a rectangle contains an infinite number of points, but it can be adequately modeled by just its four corner points. (Think about a circle. How many points does it take to adequately model a circle? Look at theCirclemodel.)Each
Primitiveobject is either aLineSegmentor aPoint.Each
LineSegmentobject contains four integers, two integers that are the indices of twoVertexobjects from theModel's vertex list, and two integers that are indices of twoColorobjects from theModel's color list. The two vertices are the line segment's two endpoints, and each of the two colors is associated with one of the two endpoints.Each
Pointobject contains two integers, one integer index of aVertexfrom theModel's vertex list, and one integer index of aColorfrom theModel's color list.We use
LineSegmentobjects to represent the space between the model's vertices. For example, while a rectangle can be approximated by its four corner points, those same four points could also represent two parallel line segments, or they could represent two lines that cross each other. By using four line segments that connect around the four points, we get a good, unambiguous representation of a rectangle.If we modeled a circle using just points, we would probably need to use hundreds of points. But if we connect every two adjacent points with a short line segment, we can get a good model of a circle with just a few dozen points.
Our
Model's represent geometric objects as a "wire-frame" of line segments, that is, a 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
https://en.wikipedia.org/wiki/Wire-frame_model
or
https://www.google.com/search?q=computer+graphics+wireframe&tbm=isch
-
-
Constructor Summary
Constructors Constructor Description Model()Construct an emptyModelobject.Model(String name)Construct an emptyModelobject with the given {link String} name.Model(List<Vertex> vertexList, List<Primitive> primitiveList, List<Color> colorList, String name, boolean visible)Construct aModelobject with all the given data.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddColor(Color... cArray)voidaddPrimitive(Primitive... pArray)voidaddVertex(Vertex... vArray)PrimitivegetPrimitive(int index)StringtoString()For debugging.
-
-
-
Constructor Detail
-
Model
public Model()
Construct an emptyModelobject.
-
Model
public Model(String name)
Construct an emptyModelobject with the given {link String} name.- Parameters:
name- a {link String} that is a name for thisModel- Throws:
NullPointerException- ifnameisnull
-
Model
public Model(List<Vertex> vertexList, List<Primitive> primitiveList, List<Color> colorList, String name, boolean visible)
Construct aModelobject with all the given data.- Parameters:
vertexList- aVertex{link List} for thisModelprimitiveList- aPrimitive{link List} for thisModelcolorList- aColor{link List} for thisModelname- a {link String} that is a name for thisModelvisible- abooleanthat determines thisModel's visibility- Throws:
NullPointerException- ifvertexListisnullNullPointerException- ifprimitiveListisnullNullPointerException- ifcolorListisnullNullPointerException- ifnameisnull
-
-
Method Detail
-
addVertex
public final void addVertex(Vertex... vArray)
- Parameters:
vArray- array ofVertexobjects to add to thisModel- Throws:
NullPointerException- if anyVertexisnull
-
getPrimitive
public final Primitive getPrimitive(int index)
-
addPrimitive
public final void addPrimitive(Primitive... pArray)
Add aPrimitive(or Primitives) to thisModel'sListof primitives.NOTE: This method does not add any vertices to the
Model'sVertexlist. This method assumes that the appropriate vertices have been added to theModel'sVertexlist.- Parameters:
pArray- array ofPrimitiveobjects to add to thisModel- Throws:
NullPointerException- if anyPrimitiveisnull
-
addColor
public final void addColor(Color... cArray)
- Parameters:
cArray- array ofColorobjects to add to thisModel- Throws:
NullPointerException- if anyColorisnull
-
-