Class Primitive
- java.lang.Object
-
- renderer.scene.primitives.Primitive
-
- Direct Known Subclasses:
LineSegment
,Point
public abstract class Primitive extends Object
APrimitive
is something that we can build geometric shapes out of (a "graphics primitive").See https://en.wikipedia.org/wiki/Geometric_primitive
We have two geometric primitives,
Each
Primitive
holds two lists of integer indices.One list is of indices into its
Model
'sList
ofVertex
objects. These are the vertices that determine the primitive's geometry.The other list is of indices into its
Model
'sList
ofColor
objects.The two lists of integer indices must always have the same length. For every
Vertex
index in aPrimitive
there must be aColor
index.
-
-
Field Summary
Fields Modifier and Type Field Description List<Integer>
cIndexList
List<Integer>
vIndexList
-
Constructor Summary
Constructors Modifier Constructor Description protected
Primitive()
Construct an emptyPrimitive
.protected
Primitive(int... indices)
protected
Primitive(List<Integer> vIndexList, List<Integer> cIndexList)
Construct aPrimitive
object using the two givenList
s of integer indices.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description void
addIndex(int... indices)
void
addIndices(int vIndex, int cIndex)
void
setColorIndex(int cIndex)
Give thisPrimitive
the uniformColor
indexed by the given color index.void
setColorIndices(int... cIndices)
Set theColor
index list to the given array of indices.abstract String
toString()
For debugging.
-
-
-
Field Detail
-
vIndexList
public final List<Integer> vIndexList
-
cIndexList
public final List<Integer> cIndexList
-
-
Constructor Detail
-
Primitive
protected Primitive()
Construct an emptyPrimitive
.
-
Primitive
protected Primitive(int... indices)
Construct aPrimitive
with the given array of indices for theVertex
andColor
index lists.NOTE: This constructor does not put any
Vertex
orColor
objects into thisPrimitive
'sModel
object. This constructor assumes that the given indices are valid (or will be valid by the time thisPrimitive
gets rendered).
-
Primitive
protected Primitive(List<Integer> vIndexList, List<Integer> cIndexList)
Construct aPrimitive
object using the two givenList
s of integer indices.NOTE: This constructor does not put any
Vertex
orColor
objects into thisPrimitive
'sModel
object. This constructor assumes that the given indices are valid (or will be valid by the time thisPrimitive
gets rendered).- Parameters:
vIndexList
-List
of integer indices into aVertex
listcIndexList
-List
of integer indices into aColor
list- Throws:
NullPointerException
- ifvIndexList
isnull
NullPointerException
- ifcIndexList
isnull
IllegalArgumentException
- ifvIndexList
andcIndexList
are not the same size
-
-
Method Detail
-
addIndex
public void addIndex(int... indices)
-
addIndices
public void addIndices(int vIndex, int cIndex)
-
setColorIndices
public void setColorIndices(int... cIndices)
Set theColor
index list to the given array of indices.NOTE: This method does not put any
Color
objects into thisPrimitive
'sModel
object. This method assumes that the given indices are valid (or will be valid by the time thisPrimitive
gets rendered).- Parameters:
cIndices
- array ofColor
indices for thisPrimitive
- Throws:
IllegalArgumentException
- ifcIndices
does not have the correct length for thisPrimitive
-
setColorIndex
public void setColorIndex(int cIndex)
Give thisPrimitive
the uniformColor
indexed by the given color index.NOTE: This method does not put a
Color
object into thisPrimitive
'sModel
object. This method assumes that the given index is valid (or will be valid by the time thisPrimitive
gets rendered).- Parameters:
cIndex
- integer color index to use for thisPrimitive
'sColor
-
-