Class Primitive
- java.lang.Object
-
- renderer.scene.primitives.Primitive
-
- Direct Known Subclasses:
LineSegment,Point
public abstract class Primitive extends Object
APrimitiveis 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
Primitiveholds two lists of integer indices.One list is of indices into its
Model'sListofVertexobjects. These are the vertices that determine the primitive's geometry.The other list is of indices into its
Model'sListofColorobjects.The two lists of integer indices must always have the same length. For every
Vertexindex in aPrimitivethere must be aColorindex.
-
-
Field Summary
Fields Modifier and Type Field Description List<Integer>cIndexListList<Integer>vIndexList
-
Constructor Summary
Constructors Modifier Constructor Description protectedPrimitive()Construct an emptyPrimitive.protectedPrimitive(int... indices)protectedPrimitive(List<Integer> vIndexList, List<Integer> cIndexList)Construct aPrimitiveobject using the two givenLists of integer indices.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description voidaddIndex(int... indices)voidaddIndices(int vIndex, int cIndex)voidsetColorIndex(int cIndex)Give thisPrimitivethe uniformColorindexed by the given color index.voidsetColorIndices(int... cIndices)Set theColorindex list to the given array of indices.abstract StringtoString()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 aPrimitivewith the given array of indices for theVertexandColorindex lists.NOTE: This constructor does not put any
VertexorColorobjects into thisPrimitive'sModelobject. This constructor assumes that the given indices are valid (or will be valid by the time thisPrimitivegets rendered).
-
Primitive
protected Primitive(List<Integer> vIndexList, List<Integer> cIndexList)
Construct aPrimitiveobject using the two givenLists of integer indices.NOTE: This constructor does not put any
VertexorColorobjects into thisPrimitive'sModelobject. This constructor assumes that the given indices are valid (or will be valid by the time thisPrimitivegets rendered).- Parameters:
vIndexList-Listof integer indices into aVertexlistcIndexList-Listof integer indices into aColorlist- Throws:
NullPointerException- ifvIndexListisnullNullPointerException- ifcIndexListisnullIllegalArgumentException- ifvIndexListandcIndexListare 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 theColorindex list to the given array of indices.NOTE: This method does not put any
Colorobjects into thisPrimitive'sModelobject. This method assumes that the given indices are valid (or will be valid by the time thisPrimitivegets rendered).- Parameters:
cIndices- array ofColorindices for thisPrimitive- Throws:
IllegalArgumentException- ifcIndicesdoes not have the correct length for thisPrimitive
-
setColorIndex
public void setColorIndex(int cIndex)
Give thisPrimitivethe uniformColorindexed by the given color index.NOTE: This method does not put a
Colorobject into thisPrimitive'sModelobject. This method assumes that the given index is valid (or will be valid by the time thisPrimitivegets rendered).- Parameters:
cIndex- integer color index to use for thisPrimitive'sColor
-
-