• Sort Posts • 6 replies

Hi,

I would like to rotate the 3D model (not dynamically, just from start),

I used the function : SampleUtils::rotatePoseMatrix(90,0,1,0,&modelViewMatrix.data); to rotate AR render, but the object doesn't move... i can translate it & scale it, but the rotate doesn't work... I don't know why,

@ GabrielS:

I would suggest to do the operations in the following order:

1. translate

2. rotate (all rotations here)

3. scale

As the scaling operation will un-normalize the rotation part of your 4x4 matrix and might theoretically have some impact on the following rotation,

so it is safer to first rotate and then scale.

For example you could try something like this (and see if that actually rotates your model 90 degrees around Z for instance):

SampleUtils::translatePoseMatrix(0.0f, 0.0f, kObjectScale, &modelViewMatrix.data);

SampleUtils::rotatePoseMatrix(90.0f, 0.0f, 0.0f, 1.0f, &modelViewMatrix.data);

SampleUtils::scalePoseMatrix(kObjectScale, kObjectScale, kObjectScale, &modelViewMatrix.data);

SampleUtils::multiplyMatrix(&projectionMatrix.data, &modelViewMatrix.data, &modelViewProjection.data);

If that works, then you could add the other two rotations (one rotation at a time, checking every time by running the app), so to see whether or not the problem shows up when applying more than one rotation.

If you want to add a rotate to your object, just add this JS function to the object that you want to rotate.
It is a 'auto' rotate script, you can change the degree of the rotation speed.

Code:

var degrees : float = 15;

function Update () {

transform.RotateAround (Vector3.zero, Vector3.up, degrees * Time.deltaTime);

}

Basically that set of operations is moving, scaling, and then rotating your model within a coordinate system that is relative to the camera's perspective ( camera space ). The multiplyMatrix operation is then producing a projection transformation matrix ( modelViewProjection ) from the product of this model view and the camera's projection matrix, which describes the camera's frustum. This is how the 3D scene is mapped to a 2D rendering with the correct scaling of objects, and clipping of the scene, for the camera perspective.

Why re-invent the wheel? Try the Unity3d game engine.

hi,

the SDK I am using is Vuforia-sdk-1-5-9. here is the code :

// to move-modify-alter the AR renderer
SampleUtils::translatePoseMatrix(20.0f, -40.0f, kObjectScale,
&modelViewMatrix.data);
SampleUtils::scalePoseMatrix(kObjectScale, kObjectScale, kObjectScale,
&modelViewMatrix.data);
SampleUtils::rotatePoseMatrix(90,0,1,0,&modelViewMatrix.data);
SampleUtils::rotatePoseMatrix(180,1,0,0,&modelViewMatrix.data);
SampleUtils::rotatePoseMatrix(90,0,0,1,&modelViewMatrix.data);
SampleUtils::multiplyMatrix(&projectionMatrix.data,
&modelViewMatrix.data ,
&modelViewProjection.data);

Which of the SDK's are you using? If you can post the code section that you're referring to, I'll explain what's happening.