0

I have a vertex (Which i will not be showing/rendering in the scene)

float vertex[] = {
            1.0f, 1.0f, 1.0f,
};

And i have a mesh, which i have translated and rotated using:

Matrix.translateM(World.mModelMatrix, tmOffset, globalPositionX, globalPositionY, globalPositionZ);


Matrix.rotateM(World.mModelMatrix, rmOffset, globalRotationZ, 0, 0, 1);
Matrix.rotateM(World.mModelMatrix, rmOffset, globalRotationY, 0, 1, 0);
Matrix.rotateM(World.mModelMatrix, rmOffset, globalRotationX, 1, 0, 0);

How can apply those translations and rotations to the vertex, and get its global position (x,y,z) after?

BDL
  • 21,052
  • 22
  • 49
  • 55
Rami Dabain
  • 4,709
  • 12
  • 62
  • 106

1 Answers1

0

Use the Matrix.multiplyMV method:

float vertex[] = { 1.0f, 1.0f, 1.0f, 1.0f };
float result[] = { 0.0f, 0.0f, 0.0f, 0.0f };

Matrix.multiplyMV(result, 0, matrix, 0, vertex, 0);

Note, that you will have to add a homogeneous coordinate to your vector to make it work.

BDL
  • 21,052
  • 22
  • 49
  • 55