Class Position
- java.lang.Object
-
- renderer.scene.Position
-
public final class Position extends Object
APositiondata structure represents a geometric object in a distinct location in three-dimensional view space as part of aScene.A
Positionobject holds references to aModelobject and aMatrixobject. TheModelrepresents the geometric object in theScene. TheMatrixdetermines the model's location and orientation in theCamera's view coordinate system. ThePosition's matrix helps us solve the problem of placing and moving a model in a scene.When the renderer renders this
Position'sModelinto aFrameBuffer, the first stage of the rendering pipeline,Model2World, multiplies everyVertexin theModel's vertex list by thisPosition'sMatrix, which converts the coordinates in eachVertexfrom the model's own local coordinate system to the world coordinate system (which is "shared" by all the other models in the scene). This matrix multiplication has the effect of "placing" the model in world space at an appropriate location (using the translation part of the matrix) and in the appropriate orientation (using the rotation part of the matrix).
-
-
Constructor Summary
Constructors Constructor Description Position(Model model)Position(Model model, String name)Position(Model model, String name, Matrix matrix)Position(Model model, String name, Matrix matrix, boolean visible, boolean debug)Construct aPositionobject with all the given data.Position(Model model, Matrix matrix)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description MatrixgetMatrix()Get a reference to thisPosition'sMatrixobject.ModelgetModel()Get a reference to thisPosition'sModelobject.PositionsetModel(Model model)Set thisPosition'sModelobject.StringtoString()For debugging.Positiontransform(Matrix matrix)Set thisPosition's transformationMatrix.
-
-
-
Constructor Detail
-
Position
public Position(Model model)
- Parameters:
model-Modelobject to place at thisPosition- Throws:
NullPointerException- ifmodelisnull
-
Position
public Position(Model model, String name)
- Parameters:
model-Modelobject to place at thisPositionname-Stringname for thisPosition- Throws:
NullPointerException- ifmodelisnullNullPointerException- ifnameisnull
-
Position
public Position(Model model, String name, Matrix matrix)
Construct aPositionwith the given transformationMatrix, the givenStringname, and the givenModelobject.- Parameters:
model-Modelobject to place at thisPositionname-Stringname for thisPositionmatrix- transformationMatrixfor thisPosition- Throws:
NullPointerException- ifmodelisnullNullPointerException- ifnameisnullNullPointerException- ifmatrixisnull
-
Position
public Position(Model model, Matrix matrix)
- Parameters:
model-Modelobject to place at thisPositionmatrix- transformationMatrixfor thisPosition- Throws:
NullPointerException- ifmodelisnullNullPointerException- ifmatrixisnull
-
Position
public Position(Model model, String name, Matrix matrix, boolean visible, boolean debug)
Construct aPositionobject with all the given data.- Parameters:
model-Modelobject to place at thisPositionname-Stringname for thisPositionmatrix- transformationMatrixfor thisPositionvisible- boolean that determines thisPosition's visibilitydebug- boolean that determines if thisPositionis logged- Throws:
NullPointerException- ifmodelisnullNullPointerException- ifnameisnullNullPointerException- ifmatrixisnull
-
-
Method Detail
-
getModel
public Model getModel()
Get a reference to thisPosition'sModelobject.- Returns:
- a reference to this
Position'sModelobject
-
setModel
public Position setModel(Model model)
Set thisPosition'sModelobject.- Parameters:
model-Modelobject to place at thisPosition- Returns:
- a reference to this
Positionobject to facilitate chaining method calls - Throws:
NullPointerException- ifmodelisnull
-
getMatrix
public Matrix getMatrix()
Get a reference to thisPosition'sMatrixobject.- Returns:
- a reference to this
Position'sMatrixobject
-
transform
public Position transform(Matrix matrix)
Set thisPosition's transformationMatrix.- Parameters:
matrix-Matrixobject to use in thisPosition- Returns:
- a reference to this
Positionobject to facilitate chaining method calls - Throws:
NullPointerException- ifmatrixisnull
-
-