setModelMatrix function

void setModelMatrix(
  1. Matrix4 modelMatrix,
  2. Vector3 forwardDirection,
  3. Vector3 upDirection,
  4. double tx,
  5. double ty,
  6. double tz
)

Constructs an OpenGL model matrix in modelMatrix. Model transformation is the inverse of the view transformation. Model transformation is also known as "camera" transformation. Model matrix is commonly used to compute a object location/orientation into the full model-view stack.

forwardDirection specifies the direction of the forward vector. upDirection specifies the direction of the up vector. tx,ty,tz specifies the position of the object.

Implementation

void setModelMatrix(Matrix4 modelMatrix, Vector3 forwardDirection,
    Vector3 upDirection, double tx, double ty, double tz) {
  final right = forwardDirection.cross(upDirection)..normalize();
  final c1 = right;
  final c2 = upDirection;
  final c3 = -forwardDirection;
  modelMatrix.setValues(c1[0], c1[1], c1[2], 0.0, c2[0], c2[1], c2[2], 0.0,
      c3[0], c3[1], c3[2], 0.0, tx, ty, tz, 1.0);
}