viromedia / virocore

ViroCore cross-platform AR/VR renderer
MIT License
370 stars 108 forks source link

[Feature Request] Setting Node's Transform & Camera's Projection Transform #309

Open fzaiatz opened 5 years ago

fzaiatz commented 5 years ago

Environment

Please provide the following information about your environment:

  1. OS: Max
  2. Version: 1.16.0
  3. Device(s): Samsung Galaxy S8

Description

I'm trying to use Viro as the render engine for a Vuforia project (it needs to be Vuforia I'm afraid). Thing is, once an image is detected, I receive the modelMatrix and the projectionMatrix. In iOS, using SceneKit, I simply do this:

// Create a Node, attach a new Camera, and set the node as pointOfView
SCNCamera* camera = [SCNCamera camera];
_cameraNode = [SCNNode node];
_cameraNode.camera = camera;
[scene.rootNode addChildNode:_cameraNode];
_renderer.pointOfView = _cameraNode;

// Then, every frame, I update the projectionTransform...
_cameraNode.camera.projectionTransform = [self SCNMatrix4FromVuforiaMatrix44:projectionMatrix];

// ... and apply the modelMatrix
SCNMatrix4 extrinsic = [self SCNMatrix4FromVuforiaMatrix44:modelMatrix];
 _cameraNode.transform = SCNMatrix4Invert(extrinsic);

With ViroCore, the setup is very similar:

Node pointOfView = new Node();
Camera camera = new Camera();
pointOfView.setCamera(camera);
viroView.setPointOfView(pointOfView);

I need to know how to do what I'm doing in SceneKit with Viro. I believe this is not supported by Viro (based on the current public API). If that's the case, would it be possible to add it in a next release? This is a go/no-go issue for us :(

dthian commented 5 years ago

Usually a model matrix is used to move vertices of a model from model space to world space. So i'm not sure why you are trying to apply it to a CameraNode's transform.

Or perhaps, do you just mean to apply a transformation matrix for the camera's node. If so, you might be able to just the transform on the pointOfView node, like any other viro node.

fzaiatz commented 5 years ago

We agree on that. Thing is, the Camera's projection needs to be modified as well somehow. Also its near and far values. Any way of doing that?

(BTW, the code I've provided before is a working code for a SceneKit-Vuforia integration)

dthian commented 5 years ago

Hey @fzaiatz, the configurable properties are shown in the Camera Class.

Unfortunately, the APIs do not currently expose the ability to set the projection matrix directly for the camera. Feel free to modify this github issue into a feature request however.

fzaiatz commented 5 years ago

Great, just did! Please let me know once it has been considered (or not) to be included in a next release.

Thanks again

dthian commented 5 years ago

Thanks @fzaiatz, this probably isn't going to be considered in the next release. But we'll update this issue once we've triaged this feature into our roadmap.