Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.

Messages - Shizzn

Pages: [1]
Support / Vuforia - Position and Rotate Objects with Model-View Matrix
« on: December 21, 2015, 08:37:04 pm »
Hi guys,

I want to share my solution to the problem of positioning and rotating 3D-objects from jPCT-AE with OpenGLs Model-View Matrix (e.g. Vuforia tracking data) because I was asked to give help concerning this topic.
A picture of the Model-View Matrix and its components is attached. I created this picture as a part of my bachelor thesis.

A little warning:
I haven't used jPCT-AE with Vuforia for more than 2 years ;)
Furthermore, the code snippets are simpified.

You can get the Model-View Matrix by tracking markers with the Vuforia SDK. The tracking data will be used to show 3D-objects on the marker:

In the onDrawFrame-Method I apply the origin (position) of the Object3D-object via a SimpleVector by using the Translation-Vector of the Model-View Matrix
Code: [Select]
mSimpleVector.set(modelViewMat[12], modelViewMat[13], modelViewMat[14]);

After that I apply the rotation by converting the Model-View-Matrix float-array to a RotationMatrix:
Code: [Select]

Code: [Select]
protected Matrix ArrayToMatrix(float array[]) {
// Declare variables
float[] insertDump = new float[16]; // The array holding the values in
// the new Matrix
int targetElement = 0; // Points to the next location in the insertDump
// to add data

// Loop through the rows of the Matrix3f
for (int sourceRow = 0; sourceRow < 3; sourceRow++) {

// Insert the 3 elements from the Matrix3f into the Matrix. The
// fourth element has been initialized to 0.0f.
insertDump[targetElement] = array[targetElement];
insertDump[targetElement + 1] = array[targetElement + 1];
insertDump[targetElement + 2] = array[targetElement + 2];

// Move the target ahead by four spaces
targetElement += 4;

// The final row consists of { 0.0f, 0.0f, 0.0f, 1.0f }, since this is a
// rotation matrix
insertDump[15] = 1.0f;

// Create the new Matrix and load in the values
Matrix output = new Matrix();

// Return
return output;

In my finished project I have a two-dimensional array of 16 Model-View Matrices, so I can place 3DObjects on up to 16 Vuforia Markers. That's why my original code would be too complicated.
My project, which I developed as a part of my bachelor thesis, shows 3D-Letters on the markers, so that the user can put them together to an existing word. (see the following YouTube-Link)

If you have more questions concerning that topic, you can ask me. But I have to repeat my warning: I haven't used jPCT-AE with Vuforia for more than 2 years :D
If any important information is missing, please tell me.

Happy coding

Bugs / 3ds-File Import - Pivot-Point not working
« on: September 01, 2013, 04:56:46 pm »
Hi Egon,

in my jPCT-AE-Project, I try to import an 3ds-object (created with Blender), but the pivot-point of the 3ds-file is not imported/converted. As you might remember, I use Vuforia for the tracking of a marker and need jPCT-AE to set the Rotation and Translation of 3D-objects. The objects are displayed correctly, but some of them (in my case the objects are 3D-Letters) aren't in the center of the marker because the Pivot-Point in jPCT-AE is not in the center of the object. So, here's my Bug-Report:

Bug: The Pivot-Point of an imported 3ds-object is not converted to the Object3D-object.

What did I try to solve the problem?
  • change Config.useRotationPivotFrom3DS
  • use Config.oldStyle3DSLoader
  • scale the object with Blender (instead of jPCT)
  • check the Pivot-Point of the 3ds-object with 3dsMax

What's the effect?
jPCT-AE doesn't take the Pivot-Point of the object, but the center of the bounding box of the object, even if Config.useRotationPivotFrom3DS is true. The difference is shown on pivot_bug_1.png in the attachments: The Pivot-Point is marked with big arrows. The center of the bounding box is marked with the coordinate axes.

What's my workaround?
I load the objects via Loader.load3DS (doesn't matter, whether Config.useRotationPivotFrom3DS is activated or not) and set their RotationPivot-Point (setRotationPivot) to (0, 0, 0). Then, jPCT-AE does not take the center of the bounding box, but Blender's world center. This can be seen on pivot_bug_2.png: The Pivot-Point is little 'yellow' dot with the arrows. The world's center is in the middle of the crosshair.

As you see, I checked many cases and tried several scenarios. One of my biggest concerns was, that Blender does not export the Pivot-Point. But as mentioned earlier, I imported the 3ds-object with 3dsMax, checked the Pivot-Point and realized that it was at the right position. That's why I think, that jPCT-AE does not import the Pivot-point of the object correctly.


[attachment deleted by admin]

Support / Re: Vuforia Rotation Matrix to jPCT Rotation Matrix
« on: August 27, 2013, 01:34:46 pm »
Okay, thanks for your help.
Now, I know that Vuforia's 4x4 model view matrix does contain the rotation and position of the tracked marker. And the 180 degrees rotation of this matrix (described on the wiki page) is equivalent to transposing the rotation matrix, because the 'object behind marker'-effekt is the same as mine.
I guess I'll handle the objects' rotation and position with the modelview matrix, altough I'll have to adjust the objects' heights.

I think the 'Integrating JPCT-AE with Vuforia' Wiki page is a good start, but should have some background information on certain things. (e.g. content of the matrices or how to position objects)

If I make progress with my Android Application, I'll post some screenshots in a new thread;)

Thanks, again.

Viele Gre

Support / Re: Vuforia Rotation Matrix to jPCT Rotation Matrix
« on: August 27, 2013, 12:39:11 pm »
The problem is that this wiki page only covers positioning the camera and not the objects.
That's why there is only used the 4x4 modelviewmatrix, which somehow describes the position of the camera to each tracked marker. WRONG
But I use the pose matrix (because it contains the rotations and translation of each tracked marker in respect to the camera).

The vuforia rotation matrix just needs to be adjusted. That's why I'm wondering if there is a method in jPCT or matrix operation which can apply an rotation to an rotation matrix.

Support / Vuforia Rotation Matrix to jPCT Rotation Matrix
« on: August 27, 2013, 12:10:21 pm »
Hallo and howdy,

I successfully integrated Vuforia into my jPCT-AE project and instead of changing the camera Position I change the position of the 3D-Objects in relation to the camera.
Therefore I use the pose matrix of the Vuforia SDK which is a 3x4 matrix:
poseMatrix = [R|t]
R is the 3x3 rotation matrix
t is the 1x3 translation matrix

I track several markers and put one 3D-Object on each of them. To set the position of the marker I use the translation matrix. This works like a charm.

But I have problems setting the rotation of the objects. I use the setRotationMatrix method of the Object3D class.
Therefore I first hardcode my Vuforia 3x3 rotation matrix in a 4x4 jPCT rotation matrix like described in this jPCT-Thread.
This works. But the coordinate system of jPCT is rotated 180 degrees around the x axis with respect to Vuforia's coordinate system.
That's why the 3D-Objects just rotate in the wrong direction. With transposing Vuforia's 3x3 rotation matrix I get the right rotation but the objects seem to be behind the marker. This is pretty ugly.
I could just move the objects in front of the marker but this is not the way I want to solve this problem, because I have several (probably) different sized objects.

My Question: Can Vuforia's rotation matrix be changed (rotated) to a jPCT's rotation matrix with respect to their different coordination systems?


Pages: [1]