preventing zooming at some limit - iphone

In my ipad openGL based application I am drawing a 2D and 3D object and rotating it according to the user's finger motion....On pinching the screen user is enable to zoom those objects...But what I want is to prevent zooming the object at some limit, say more than 2x of the object size user cannot zoom in and user cannot zoom out more than object's original size
I am zooming the object with help of "CATransform3DScale"
Any hint please....
Thanks in advance and help appreciated.

If you are using the UIPinchGestureRecognizer and setting the scale value of it directly as your 3D scale value then just do something like
if(scale >= 2.0f){
scale = 2.0f;
}
that's basically what i do.

Related

Pitch camera while zooming

I'm trying to change the pitch of the mapbox camera while zooming. I know I can set a default/max pitch level and that the user is able to change the pitch of the camera by themselves, I'm however looking for a way to map a zoom level range to a pitch range. While scrolling/zooming I want the pitch to change according to this range.
I've tried the following:
function onMapboxZoom(e: MapboxEvent) {
const zoom = e.target.getZoom();
const pitch = mapRange(zoom, 6, 10, 0, 65);
e.target.setPitch(pitch);
}
The problem I'm having with this approach is that I think the zoom interpolation that mapbox uses to create a smooth zooming effect is cancelled by my manual pitch change. The result is that the smoothness of zooming is gone and that it requires a lot of scroll events to zoom in properly. Which makes sense I guess. I was wondering if anyone has tackled this problem before and if/how this can be achieved while maintaining a smooth zoom behavior.
Thanks!

Cocos2d-x zoom in zoom out in rendertexture

I are working on a coloring game for kids.I have used bucket fill and it working fine but the problem is coloring image contains some small areas which are impossible to fill by touching on it. I wanted to Implement zoom in and zoom out so that kids can zoom in to small area fill it and zoom out. I have tried scaling rendertexture but it scale around anchor point. Is there a way that I can scale around the touch location ?
Scaling will always be done around the anchor point. You have to reposition your RenderTexture, after scaling, so your touch location remains centered.

cocos2d: Show entire layer then zoom in on character

I have my main game layer that is larger than the screen when the scene currently starts you see the character (a ship in this case) in the screen but I want to show the entire layer to the user first, and then animate back a zoom level of 1.
How can I achieve this? I know I can use the scale property on CCLayer but how can I tell how much of the view I am seeing such that I can show all of it?
Animate your zoom using a CCAction such as CCScaleTo and set the end scale of the zoom in the CCScaleTo action to whatever you want as derived by comparing the screensize to the layer size. For example, to zoom in to a 2X magnification, your CCScaleTo would scale to a 2.0 scale. You could get even fancier and use the size of a particular object in the layer in comparison to the size of the layer and size of the screen to calculate a scale that brings the desired object to exactly the size you want after zooming.

Detecting Zoom Level on iPhone

I'm using the UIImagePickerController to control the camera and overlay millimeter tick marks in preview for measuring closeup macro shots, and I'd like to be able to detect the current zoom level and scale it properly.
Is there any way to determine the current zoom level in camera preview?
Unfortunately no, since the UIImagePickerController API doesn't give you access to the camera zoom level, nor to any subviews or other properties that might have access to that information.
As Michael Dautermann points out, based on the answer to this question, you could use the cameraViewTransform property of UIImagePickerController to implement your own zoom by setting up the right CGAffineTransform and also the right pinch gesture to zoom in/out. Since you'd be controlling the zoom yourself, you'd always know the zoom level and be able to use it to adjust the tick marks.

How to differentiate if user zoomed in or zoomed out on view?

How to differentiate if user zoomed in or zoomed out on a view?
Is there any direct property/method available to detect the same?
Thanks
If you are using UIPinchGestureRecognizer then you can do that using gestureRecognizer.velocity property.
Value of velocity is negative when current scale is smaller then previous and positive when it scale increases.