Camera for Spotlight - camera

I have two orthographic cameras. The first one is for the main display and the other one is used for a spotlight effect.
What I want is, if I move the second camera (spotlight), I want the view port rect to be normalized as well. Right now, if I move the second camera's Transform, it looks at the camera's direction but the display is not moving.
So, if the display is at the bottom-right corner, and I move the camera at the top-left corner, I want to display the camera at the top-left corner as well instead of displaying it at the bottom-right corner.
Also, I'm building it on iPad.

Related

Move view hiding its side in android

Moving a view I try to hide all parts of view that cross some vertical line, so view starts to loose its width to 0.
The image describes better what I want.
I mean not just shrink a width with scaleX but hide, because this command compresses the photo horizontally, and I need to hide it without distortion.
How can I do it?
On the image a photo started to move left with translationX hiding line by line left side of the photo during this movement. Also, the photo is not at left edge of screen - it's on the center
View has left(and x) attribute in its LayoutParams.
How can I dynamically set the position of view in Android?
When left attribute is negative, it is hidden under the parent view.
If you want an animation, here is the document!
https://developer.android.com/develop/ui/views/animations/reposition-view

Using MapKit, MKMapview how can I orientate the map by aligning two coordinates vertical on the screen

I have two coordinates that represent a portion of a route, and I want to orientate the MKMapView such that the route, polyline is displayed going from the bottom of the screen to the top of the screen.
Currently I first calculate the angle between the two coordinates, and then rotate the map by setting the camera heading, where 90 degrees is facing north and vertically centred on the screen.
Is there perhaps an easier approach, sample code would be great in either Swift or Objective-C.
Currently I first calculate the angle between the two coordinates, and then rotate the map by setting the camera heading, where 90 degrees is facing north and vertically centred on the screen.
You've got the right idea. There's no way to set the map view's heading directly, so setting the camera heading is the right way to go. Be sure to set the map view's rotationEnabled property to YES to get the map view to use the camera's heading, and if you want to always see the map in plan view (i.e. looking straight down), you can set pitchEnabled to NO.

Cocoa - NSTextField with only top-left and bottom-left rounded corners

I'm trying to make an NSTextField with only two rounded corners on the top-left and bottom-left. I tried to do the following, but in this case I get all corners rounded:
[self.myTextField:YES];
self.myTextField.layer.cornerRadius = 5;
What should I do to have only two (or for example one) rounded corners?
I'm a little out of my lane in OS X, but what you want to do is embed whatever corner art you like into an image and present those on an image view behind the NSTextField.
Resize the image view exactly as you do the text field, but first set the image's capInsets property. Size the insets to exclude the corners from scaling as the extent of the image changes. (Make sure your corner art is placed at the extreme edges of the image).

Rotate a camera on its centre

What I want to do is to rotate a camera on it's centre while the camera position is steady. So as a result when the user clicks and moves the mouse he will get all the perspectives possible from that point of view.
I am using trackback controls so I have tried things like:
controls.target.set(camera.position.x,camera.position.y,camera.position.z);
but it does not give the wanted result. I am looking something like camera rotation on axes x,y,z while the camera position is the same.
How do I do it?
If you want to keep TrackballControls, set a very close target (set the camera position and the controls.target to very close coordinates, but different ones).
Otherwise use PointerLockControls

What's the RIGHT way to draw an image in the upper left corner on a mac?

I have an NSView in a ScrollView and I'm trying to draw an image in it. The problem is that I want the upper left corner of the image locked to the upper left corner of the frame, instead of the lower left corner, which is what the View wants me to do. I will need to be able to zoom in and out, and rotate.
currently, I have a kludge of a system where I calculate how much I have to translate my image based on the size of the image and the size of the window. In order to do this, I needed to create an extra view outside the scrollview, so that I could get the size of the window, not including decorations. Then I can calculate the size of the view based on the size of the image and the size of the window, and based on THAT, I can figure out where to translate the image to.
My only other thought was to use the isFlipped: method, but that ends up reversing my image L-R which is bad.
Is there another way I should be doing this?
If you want 0,0 to be in the upper-left corner, then overriding -isFlipped to return YES is the way to go. It should not affect the coordinate systems of any subviews (I think!), but images drawn directly into the flipped view will appear upside-down unless you apply a transform to them.
View Programming Guide for Cocoa: View Geometry