View3D Class
This class allows to create basic 3D transformations. This class calculates transformations and then apply them to the normal view object.
Example:
app.onDraw = function (sender, canvas)
{
canvas.clear(0xffffffff);
// move center of coordinates to the middle of the screen
canvas.translate(System.width / 2, System.height / 2);
// create new view3d object
var view3d = new View3D();
view3d.rotateY(45);
// apply rotating to the canvas
view3d.applyToCanvas(canvas);
// draw square to the midle of the screen
canvas.drawRect(-100, -100, 100, 100, new Paint());
}
Item Index
Methods
- this constructor
- applyToCanvas
- dotWithNormal
- getMatrix
- restore
- rotateX
- rotateY
- rotateZ
- save
- translate
Methods
applyToCanvas
canvas
Apply transformations to canvas object.
Parameters:
-
canvas
CanavasObject to the application of transformations
Example:
app.onDraw = function (sender, canvas)
{
canvas.clear(0xffffffff);
// move center of coordinates to the middle of the screen
canvas.translate(System.width / 2, System.height / 2);
// create new view3d object
var view3d = new View3D();
view3d.rotateY(45);
// apply rotating to the canvas
view3d.applyToCanvas(canvas);
// draw square to the midle of the screen
canvas.drawRect(-100, -100, 100, 100, new Paint());
}
getMatrix
() Matrix
Gets current transformation matrix.
Returns:
restore
()
This call balances a previous call to save(), and is used to remove all modifications to the matrix/clip state since the last save call. An error occurs if restore() is called more times than save().
rotateX
degrees
Rotate canvas around x axis.
Parameters:
-
degrees
FloatAngle to rotate (in degrees).
rotateY
degrees
Rotate canvas around y axis.
Parameters:
-
degrees
FloatAngle to rotate (in degrees)
rotateZ
degrees
Rotate canvas around z axis.
Parameters:
-
degrees
FloatAngle to rotate (in degrees)
save
()
This call saves the current matrix and clip information, and pushes a copy onto a private stack. Subsequent calls to translate, scale, rotate etc. all operate on this copy. When the balancing call to restore() is made, this copy is deleted and the previous matrix/clip state is restored.