public abstract class MatrixHelper extends Object
MatrixStackHelper
.Constructor and Description |
---|
MatrixHelper(AbstractScene scn)
|
Modifier and Type | Method and Description |
---|---|
abstract void |
applyModelView(Mat source)
Multiplies the current modelview matrix by the one specified through the parameters.
|
void |
applyProjection(Mat source)
Multiplies the current projection matrix by the one specified through the parameters.
|
void |
beginScreenDrawing()
Computes the world coordinates of an screen object so that drawing can be done
directly with 2D screen coordinates.
|
void |
bind()
|
void |
bind(boolean recompute) |
void |
cacheProjectionViewInverse(boolean optimise)
Cache
inv (P x M) (and also (P x M) ) so that
AbstractScene.unprojectedCoordinatesOf(Vec) is
optimized. |
void |
endScreenDrawing()
Ends screen drawing.
|
abstract Mat |
getModelView(Mat target)
Copy the current modelview matrix into the specified target.
|
Mat |
getProjection(Mat target)
Copy the current projection matrix into the specified target.
|
boolean |
isProjectionViewInverseCached()
Returns
true if P x M and inv (P x M) are being cached, and
false otherwise. |
void |
loadModelView()
Computes the view matrix from
AbstractScene.eye()
parameters and loads it into the matrix helper. |
void |
loadModelView(boolean recompute)
Same as
setModelView(gScene.eye().getView(recompute)) . |
void |
loadProjection()
Computes the projection matrix from
AbstractScene.eye() parameters and loads it into the
matrix helper. |
void |
loadProjection(boolean recompute)
Same as
setProjection(gScene.eye().getProjection(recompute)) . |
abstract Mat |
modelView() |
void |
popModelView()
Replace the current modelview matrix with the top of the stack.
|
void |
popProjection()
Replace the current projection matrix with the top of the stack.
|
abstract void |
printModelView()
Print the current modelview matrix.
|
void |
printProjection()
Print the current projection matrix.
|
Mat |
projection() |
Mat |
projectionView() |
Mat |
projectionViewInverse()
cacheProjectionViewInverse(boolean) should be called first for this method
to take effect. |
void |
pushModelView()
Push a copy of the modelview matrix onto the stack.
|
void |
pushProjection()
Push a copy of the projection matrix onto the stack.
|
abstract void |
resetModelView()
Set the current modelview matrix to identity.
|
void |
resetProjection()
Set the current projection matrix to identity.
|
void |
rotate(float angle)
Two dimensional rotation.
|
void |
rotate(float angle,
float vx,
float vy,
float vz)
Rotate about a vector in space.
|
void |
rotateX(float angle)
Rotate around the X axis.
|
void |
rotateY(float angle)
Rotate around the Y axis.
|
void |
rotateZ(float angle)
Rotate around the Z axis.
|
void |
scale(float s)
Scale equally in all dimensions.
|
void |
scale(float sx,
float sy)
Scale in X and Y.
|
void |
scale(float x,
float y,
float z)
Scale in X, Y, and Z.
|
AbstractScene |
scene()
Returns the scene this object belongs to
|
abstract void |
setModelView(Mat source)
Set the current modelview matrix to the contents of another.
|
void |
setProjection(Mat source)
Set the current projection matrix to the contents of another.
|
void |
translate(float tx,
float ty)
Translate in X and Y.
|
void |
translate(float tx,
float ty,
float tz)
Translate in X, Y, and Z.
|
public MatrixHelper(AbstractScene scn)
scn
- public AbstractScene scene()
public void bind(boolean recompute)
public void bind()
public boolean isProjectionViewInverseCached()
true
if P x M
and inv (P x M)
are being cached, and
false
otherwise.public void cacheProjectionViewInverse(boolean optimise)
inv (P x M)
(and also (P x M)
) so that
AbstractScene.unprojectedCoordinatesOf(Vec)
is
optimized.public Mat projectionView()
projection()
* modelView()
.public Mat projectionViewInverse()
cacheProjectionViewInverse(boolean)
should be called first for this method
to take effect.projection()
* modelView()
)public void loadProjection(boolean recompute)
setProjection(gScene.eye().getProjection(recompute))
.setProjection(Mat)
,
Eye.getProjection(boolean)
public void loadProjection()
AbstractScene.eye()
parameters and loads it into the
matrix helper. Used in bind()
.Eye.getProjection(boolean)
public void loadModelView(boolean recompute)
setModelView(gScene.eye().getView(recompute))
.setModelView(Mat)
,
Eye.getView(boolean)
public void loadModelView()
AbstractScene.eye()
parameters and loads it into the matrix helper. Used in bind()
. If
includeView
is false
Eye.getView(boolean)
public void pushModelView()
public void popModelView()
public void pushProjection()
public void popProjection()
public void resetProjection()
public void applyProjection(Mat source)
public void setProjection(Mat source)
public void translate(float tx, float ty)
public void translate(float tx, float ty, float tz)
public void rotate(float angle)
Same as rotateZ (this is identical to a 3D rotation along the z-axis) but included for clarity. It'd be weird for people drawing 2D graphics to be using rotateZ. And they might kick our a-- for the confusion.
public void rotateX(float angle)
public void rotateY(float angle)
public void rotateZ(float angle)
public void rotate(float angle, float vx, float vy, float vz)
public void scale(float s)
public void scale(float sx, float sy)
Not recommended for use in 3D, because the z-dimension is just scaled by 1, since there's no way to know what else to scale it by.
public void scale(float x, float y, float z)
public abstract void resetModelView()
public abstract void applyModelView(Mat source)
public abstract Mat modelView()
public abstract Mat getModelView(Mat target)
public Mat projection()
public Mat getProjection(Mat target)
public abstract void setModelView(Mat source)
public abstract void printModelView()
public void printProjection()
public void beginScreenDrawing()
All screen drawing should be enclosed between beginScreenDrawing()
and
endScreenDrawing()
. Then you can just begin drawing your screen shapes.
Attention: If you want your screen drawing to appear on top of your 3d scene
then draw first all your 3d before doing any call to a beginScreenDrawing()
and endScreenDrawing()
pair.
endScreenDrawing()
public void endScreenDrawing()
beginScreenDrawing()
for details.beginScreenDrawing()
Processing Library proscene by Jean Pierre Charalambos. (c) 2014-2017 National University of Colombia