Class Position
- java.lang.Object
-
- renderer.scene.Position
-
public final class Position extends Object
APosition
data structure represents a geometric object in a distinct location in three-dimensional view space as part of aScene
.A
Position
object holds references to aModel
object and aMatrix
object. TheModel
represents the geometric object in theScene
. TheMatrix
determines 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
'sModel
into aFrameBuffer
, the first stage of the rendering pipeline,Model2World
, multiplies everyVertex
in theModel
's vertex list by thisPosition
'sMatrix
, which converts the coordinates in eachVertex
from 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 aPosition
object with all the given data.Position(Model model, Matrix matrix)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Matrix
getMatrix()
Get a reference to thisPosition
'sMatrix
object.Model
getModel()
Get a reference to thisPosition
'sModel
object.Position
setModel(Model model)
Set thisPosition
'sModel
object.String
toString()
For debugging.Position
transform(Matrix matrix)
Set thisPosition
's transformationMatrix
.
-
-
-
Constructor Detail
-
Position
public Position(Model model)
- Parameters:
model
-Model
object to place at thisPosition
- Throws:
NullPointerException
- ifmodel
isnull
-
Position
public Position(Model model, String name)
- Parameters:
model
-Model
object to place at thisPosition
name
-String
name for thisPosition
- Throws:
NullPointerException
- ifmodel
isnull
NullPointerException
- ifname
isnull
-
Position
public Position(Model model, String name, Matrix matrix)
Construct aPosition
with the given transformationMatrix
, the givenString
name, and the givenModel
object.- Parameters:
model
-Model
object to place at thisPosition
name
-String
name for thisPosition
matrix
- transformationMatrix
for thisPosition
- Throws:
NullPointerException
- ifmodel
isnull
NullPointerException
- ifname
isnull
NullPointerException
- ifmatrix
isnull
-
Position
public Position(Model model, Matrix matrix)
- Parameters:
model
-Model
object to place at thisPosition
matrix
- transformationMatrix
for thisPosition
- Throws:
NullPointerException
- ifmodel
isnull
NullPointerException
- ifmatrix
isnull
-
Position
public Position(Model model, String name, Matrix matrix, boolean visible, boolean debug)
Construct aPosition
object with all the given data.- Parameters:
model
-Model
object to place at thisPosition
name
-String
name for thisPosition
matrix
- transformationMatrix
for thisPosition
visible
- boolean that determines thisPosition
's visibilitydebug
- boolean that determines if thisPosition
is logged- Throws:
NullPointerException
- ifmodel
isnull
NullPointerException
- ifname
isnull
NullPointerException
- ifmatrix
isnull
-
-
Method Detail
-
getModel
public Model getModel()
Get a reference to thisPosition
'sModel
object.- Returns:
- a reference to this
Position
'sModel
object
-
setModel
public Position setModel(Model model)
Set thisPosition
'sModel
object.- Parameters:
model
-Model
object to place at thisPosition
- Returns:
- a reference to this
Position
object to facilitate chaining method calls - Throws:
NullPointerException
- ifmodel
isnull
-
getMatrix
public Matrix getMatrix()
Get a reference to thisPosition
'sMatrix
object.- Returns:
- a reference to this
Position
'sMatrix
object
-
transform
public Position transform(Matrix matrix)
Set thisPosition
's transformationMatrix
.- Parameters:
matrix
-Matrix
object to use in thisPosition
- Returns:
- a reference to this
Position
object to facilitate chaining method calls - Throws:
NullPointerException
- ifmatrix
isnull
-
-