

The sample code performs the rendering of the 3D models within the OpenGL rendering thread. Code that renders 3D models in the OpenGL rendering thread On Android and iOS platforms, the Vuforia native SDK samples are used to show how to render simple static (non-animated) models using OpenGL ES 2.0. Vuforia Engine uses OpenGL ES to render 3D content. How To Render Static 3D Models using OpenGL ES For Multi-targets you can query the size of individual parts. You can obtain the trackable size of image targets and frame markers at run time by casting the Trackable object to the specific class (ImageTarget or Marker) and calling the getSize() method. In this case, the model is scaled by kObjectScale and then translated up the Z axis by kObjectScale. Note that the transforms are applied from the bottom to the top. SampleUtils::multiplyMatrix(& projectionMatrix.data, SampleUtils::scalePoseMatrix(kObjectScale, kObjectScale, kObjectScale, SampleUtils::translatePoseMatrix(0.0f, 0.0f, kObjectScale, The ImageTargets sample uses the following set of transforms:(C++) We can apply translations, rotations, and scales to the pose matrix to make the final modelViewMatrix. By default, the pose matrix places content in the center of the target with X to the right, Y to the top, and Z coming out of the target:

Now that the trackables are sized correctly, you can position and scale the 3D content to sit correctly on the target. Otherwise, the 3D content sitting on the frame marker would not properly occlude the 3D content sitting on the image target. If the printed frame marker is 1/4 the size of the printed image target, then the frame marker object should be created at 1/4 the size of the image target object. Assume that you want to track a frame marker on top of an image target. This is the case when multiple trackables will be tracked at the same time. If the application uses multiple trackables it may be important to size them relative to their real-world sizes. Of course, you can always adjust the near and far planes. A target with the width of 100 would be reasonable. A target of size 1 would be too small, while a target of size 2000 would be too big. Use a target size that would fall within the near plane at 2 and the far plane at 2000. ProjectionMatrix = Vuforia::Tool::getProjectionGL(cameraCalibration, 2.0f, 2000.0f)

The units correspond to OpenGL scene units and thus need to work with the perspective frustum set up by the projection matrix.įor example, assume that you set up a projection matrix using the following code: (C++) The width is entered when you create a new target, while the height is automatically calculated from the aspect ratio of the image. The size of an ImageTarget is defined when the target is created in the TMS.
