Moscrif API Docs for: 2012q3
Show:

View3D Class

Library: core

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());
}

Methods

this

() View3D

Create new instance of View3D class.

Returns:

applyToCanvas

(
  • canvas
)

Apply transformations to canvas object.

Parameters:

  • canvas Canavas

    Object 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());
}

dotWithNormal

(
  • dx
  • dy
  • dz
)

Parameters:

getMatrix

() Matrix

Gets current transformation matrix.

Returns:

Matrix: Current transformation matrix

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 Float

    Angle to rotate (in degrees).

rotateY

(
  • degrees
)

Rotate canvas around y axis.

Parameters:

  • degrees Float

    Angle to rotate (in degrees)

rotateZ

(
  • degrees
)

Rotate canvas around z axis.

Parameters:

  • degrees Float

    Angle 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.

translate

(
  • x
  • y
  • z
)

Moves canvas on x, y orientation z axis.

Parameters:

  • x Float

    Shift on the x axis.

  • y Float

    Shift on the y axis.

  • z Float

    Shift on the z axis.