Is there a way I can let the camera zoom but not rotate? - objective-c

Is there a way I can let the SceneKit's camera zoom but not rotate? And how can I delimitate the maximum and minimum zoom the user can do with the camera?

It depends what you mean by zoom – if you mean to do the same thing as 'zooming' a camera lens, you want to modify the yFov and xFov (field of view) attributes of the SCNCamera object. The camera stays in the exact same location, but changes its field of view like a zoom lens.
I cannot see how you can rotate the camera while zooming it – I’d need to see more context of where you’re using the camera. If you don’t touch the SCNNode the camera is attached to, you can’t possibly rotate it.

You're talking about user camera movement with allowsCameraControl, right? I don't think that's really meant to be the basis for a sophisticated user camera movement scheme, more of a simple debugging aid. If you really want fine control over how the user can move the camera, you're best served by creating your own camera node and moving it / changing its properties in response to whatever user input you want to handle (gesture recognizers, game controllers, etc).
I suppose you might be able to constrain the automatic user camera by implementing a scene renderer delegate willRenderScene method. You'd have to get the current pointOfView node, check its position and camera parameters, and change them if they're outside whatever bounds you want. But A) I'm not sure this would work, and B) it's probably not a great idea — it's sort of like messing with the internal view hierarchy of a system control class.

Related

Replicating Camera View - DeviceOrientationControls to TrackballControls

I am trying to replicate a view from a phone (using DeviceOrientationControls) to a desktop (using TrackballControls). I am passing the view state (camera position & direction) through an intermediary server, and have that part mostly working.
I'm having trouble setting the camera rotation on the desktop. The cameras are sync'd to look at the same point, but the view on the desktop (receiving the view state from the phone) rotates around the view angle.
I definitely don't fully understand quaternions or rotation order. I've tried applying those, but clearly I'm out of my element. I guess I'm just looking for some hints on how to sync the camera rotation on the desktop.
Looks like I had a (trackball) controls.update() in my animate() that was blowing away the rotation that I was setting. Camera position and direction are not changed by this, but the rotation (or the "roll" of the camera) was.
In TrackballControls, it would be nice to have a setting for programmatically updating the camera's rotation that wouldn't get squashed by a call to rotateCamera(). I'll have to think about that, because it doesnt seem like it would be easy to implement.

Unity2d; How to raise(lift) camera during game mode at a fixed y axis minimum

I may be making this harder than what it really is, but I am also pretty new to developing games. Currently I am making a practice scene to get back used to the unity engine as I have not had time to use it since last summer. My issue is that I can not figure out how to lift the camera in game mode. Notice my photo below, and how much of the "underground" is showing. I want to raise the camera to keep it at the very least a specific y axis value, so that I can make less of the ground visible, and more of the background visible. If I am over complicating this, please also let me know. Thank you
If main camera is still then just lift the camera in scene view you can see changes in game view.
Or if camera moves with respect to player then you have to use a script and attach it to camera and get a reference of player transform in the script and according to the player position change position of the camera. Add an offset value in y component of the camera.

Taking Control of ARCamera on Unity3D with Vuforia

The position and rotation of Vuforia's ARcam are determined by their algorithms to give the AR effect. I'd like to know how to do the following:
When some object is clicked the camera goes to some specific position (for that I need to somehow take control of the camera).
Also have to possibility to yield control of the camera back to Vuforia.
You'll want to use a second camera in this instance. Position the second camera at the AR Camera position, then adjust the depths to make the new camera the view that you see. Then you can tween its position to the predefined one you have.
Do the reverse to get control back to the AR Camera.

Orthographic camera and zoom controls in SceneKit

When using a camera with myCameraNode.camera.usesOrthographicProjection = YES;, as far as I can tell you can't zoom as you normally would using the default controls given by myScene.allowsCameraControl = YES; – the only way to zoom that I can tell is by changing myCameraNode.scale = (SCNVector3*)...
Is there a way to somehow bind the scroll wheel to this scale parameter, while retaining the standard camera controls for rotation/translation? Or to otherwise 'fix' the default camera controls?
Edit: I think I'm misunderstanding how the camera works. The two-finger zoom gesture does still work with orthographic projection, but it seems like it only lets me zoom out and not let me zoom in any further. I suspect it may be related to the myCameraNode.scale, but if I don't set that parameter the objects in my scene are huge and I only see a tiny fraction of it (and the larger the scale the smaller my objects get).
The built-in camera controls on SCNView are pretty basic, probably best used only for debugging. For a production app, it's better to control the camera yourself, especially if you're using orthographic projection. Set up your own event handling that controls the orthographicScale property of the camera, and you're set.
Followup on comment:
The scale property on SCNNode controls how big a node's content is relative to its parent node — it's a coordinate space transformation, just like rotation and position. It's not really appropriate for implementing camera zoom. In a perspective projection, you use the camera's xFov and/or yFov properties to zoom (and I presume that's what the built-in camera controls do). The API doesn't define what the controls do for an orthographic camera, so anything you observe about its behavior is probably undefined and might be a bug... you might not be able to rely on it staying that way.
If there's more you'd like the built-in camera controls to handle, I'd recommend filing an enhancement request.

Three.js 3rd person camera

I'm trying to create a 3rd person camera view in three.js
I'm using the THREE.FirstPersonControls(); on my camera. Then setting the rotation and positions of my "player" objects to be the same as the camera with some offsets.
This does not seem to work.
What i'm more wondering is if I should be adding my FirstPersonControls to the camera and then rendering the "player" infront of it. Or adding the controls to the player then making the camera always point at the back of the player?
EDIT:
I've tried setting the player object to be a sub object of the camera using camera.add(player);
but moving the camera around is not moving the player. I thought adding an child element would mean they move together?
EDIT 2:
I took another approach of adding both the camera and the player to a group then adding my 1st person controls to that group... Now both the camera and the player do get rendered. But it's completely thrown off how the first person controls worked. (e.g. looking down goes left etc etc)
Thanks for any help,
James
First of all, the Controls were designed to be controlling a camera, and not an object. And since by default, objects look "up" the z-axis, and cameras look "down" the z-axis, it is unlikely that the Controls will work as expected when applied to something other than a camera.
Secondly, the Controls are part of the examples, and not the library, so they are not officially supported. You are free to hack away at them.
One way to achieve what you want is to make the camera a child of your player. Something like this:
player.add( camera );
camera.position.set( 0, 50, 100 );
You may, in your render loop, need to set:
camera.lookAt( player.position );
Then you want to control the player with the mouse or keyboard. Your best bet is to write your own controller to do that. There are plenty of examples on the net.