Log in or register to post comments

Partial screen rendering on iOS

February 27, 2018 - 8:12am #1

I was able to adapt the code from the Vuforia samples to support rendering in a non-fullscreen capacity. However, I'm not sure how to calculate the transform for content rendered on augmentations. I've actually adopted some code from this sample to use SceneKit for rendering. That code gets the transform from a trackable result, inverts it, and uses that as the transform for a camera node in the SceneKit scene. This works well, but only if the view occupies the entire device screen. If the view takes up, say, half the screen, the rendered SceneKit content is half as tall as it should be. Here's how that sample renders a scene:

for (int i = 0; i < state.getNumTrackableResults(); ++i) {
  // get the pose for this trackable
  const Vuforia::TrackableResult* result = state.getTrackableResult(i);
  Vuforia::Matrix44F modelViewMatrix = Vuforia::Tool::convertPose2GLMatrix(result->getPose());

  // translate and scale pose (this is the same process as used in the Vuforia sample code)
  VuforiaEAGLViewUtils::translatePoseMatrix(0.0f, 0.0f, _objectScale, &modelViewMatrix.data[0]);
  VuforiaEAGLViewUtils::scalePoseMatrix(_objectScale,  _objectScale,  _objectScale, &modelViewMatrix.data[0]);
  // convert the Vuforia matrix to a SceneKit matrix, invert it, and apply it to the camera
  [self setCameraMatrix:modelViewMatrix];

  // render the scene for this augmentation using SceneKit
  CFAbsoluteTime currentTime = CFAbsoluteTimeGetCurrent() - _startTime;
  [_renderer renderAtTime: currentTime];

As you can see, this doesn't take into account any sort of transformation for the bounds of the current view. How could I modify this to respect the reduced view size of a view that does not occupy the full screen? Images showing how this manifests are attached.

Image icon half_screen.png1.67 MB
Image icon full_screen.png2.75 MB
Log in or register to post comments