Log in or register to post comments

Rotate 3D AR Model

August 2, 2012 - 1:45am #1

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[0]); 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,

Thanks by advance.

Rotate 3D AR Model

October 8, 2012 - 8:12am #7

@ 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[0]);

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

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

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

 

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.

 

Rotate 3D AR Model

October 6, 2012 - 8:55am #6

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

}

 

 

Rotate 3D AR Model

August 7, 2012 - 6:50pm #5

This article may be helpful - http://www.songho.ca/opengl/gl_transform.html

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.

Rotate 3D AR Model

August 4, 2012 - 3:56am #4

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

Rotate 3D AR Model

August 2, 2012 - 8:10am #3

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[0]);
            SampleUtils::scalePoseMatrix(kObjectScale, kObjectScale, kObjectScale,
                                         &modelViewMatrix.data[0]);
            SampleUtils::rotatePoseMatrix(90,0,1,0,&modelViewMatrix.data[0]);
            SampleUtils::rotatePoseMatrix(180,1,0,0,&modelViewMatrix.data[0]);
            SampleUtils::rotatePoseMatrix(90,0,0,1,&modelViewMatrix.data[0]);
            SampleUtils::multiplyMatrix(&projectionMatrix.data[0],
                                        &modelViewMatrix.data[0] ,
                                        &modelViewProjection.data[0]);

Rotate 3D AR Model

August 2, 2012 - 6:28am #2

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.

Log in or register to post comments