catransform3d

How to get the actual size of transformed CALayer?

懵懂的女人 提交于 2019-12-13 12:05:47
问题 I have a 200x200 pixel CALayer instance to which I've applied two transformations: scaled down to 50% applied a 3D perspective Now I want to align the transformed layer with another layer. To do that I need the size (width and height) of the transformed layer. The problem is that layer.bounds still returns 200x200 for the layer, but because of the perspective transformation the actual visible width is less and the height more than 200 . The bounds of the presentation layer return 0 , by the

Rotate X, Y and Z axis all together

僤鯓⒐⒋嵵緔 提交于 2019-12-12 10:45:37
问题 I first 3D rotate a flat figure in Illustrator or Photoshop, get the exact angles(x, y and z) applied to it in the design tool and then apply the same angles to a UILabel placed on top of the image to synchronize them visually. I've figured out how to rotate 2 axis at the same time by using CATransform3DConcat but then I'm not sure how to apply the third. float angleX = -18 * M_PI / 180; CATransform3D t1 = CATransform3DMakeRotation(angleX, 1, 0, 0); float angleY = -26 * M_PI / 180;

Using CATransform3D

半世苍凉 提交于 2019-12-11 10:57:02
问题 I'm trying to make a rotation on a tableview to tilt the table (to give the effect of a 3d text crawl similar to the star wars opening crawl). After looking around I found this question objective-с CALayer UIView real rotation and the accepted answer seems to do what I want, however when I apply the code to my TableView it does nothing and the table appears as usual. This is the code I am copying: float distance = 50; CATransform3D basicTrans = CATransform3DIdentity; basicTrans.m34 = 1.0 /

My CALayer transform holds after animation, but the perspective disappears

余生长醉 提交于 2019-12-10 14:14:54
问题 I have the following code that rotates a CALayer by -45degrees on the Y axis: #define D2R(x) (x * (M_PI/180.0)) - (void) swipe:(UISwipeGestureRecognizer *)recognizer { CATransform3D transform = CATransform3DMakeRotation(D2R(-45), 0, 1.0, 0); transform.m34 = -1.0 / 850; CABasicAnimation *transformAnimation = [CABasicAnimation animationWithKeyPath: @"transform"]; transformAnimation.fillMode = kCAFillModeForwards; transformAnimation.removedOnCompletion = NO; transformAnimation.toValue = [NSValue

“renderInContext:” and CATransform3D

半腔热情 提交于 2019-12-09 04:27:23
问题 I have an view that have mutiples views inside it, and an image presentation (aka. 'cover flow') into that too... And I need to make a screenshot programatically ! Since docs says that "renderInContext:" will not render 3d animations : "Important The Mac OS X v10.5 implementation of this method does not support the entire Core Animation composition model. QCCompositionLayer, CAOpenGLLayer, and QTMovieLayer layers are not rendered. Additionally, layers that use 3D transforms are not rendered,

How to calculate 3D transformation matrix for rectangle to quadrilateral

南楼画角 提交于 2019-12-08 04:20:15
问题 Hoping someone can help, i'm trying to work out how to transform an image from a rectangle to a quadrilateral with given x,y screen coordinates for each corner. So far I have put the image on a CALayer but need to work out the CATransform3D to warp the rectangle to needed quadrilateral. An example of what I am trying to achieve is below (from a to b). Example Rect to Quad image If I am wrong and cant be done using CATransform3D is there any other way this can be achieved with a example please

Why does a CATransform3DMakeRotation not take (0,0,1) as rotating around the Z-axis?

落花浮王杯 提交于 2019-12-08 03:36:46
问题 If I do a transform to an NSView in Cocoa's app: self.view.layer.transform = CATransform3DMakeRotation(30 * M_PI / 180, 0, 0, 1); I see the square not rotated around the Z-axis, but rotated as if that vector is pointing downward and outward. I need to make it self.view.layer.transform = CATransform3DMakeRotation(30 * M_PI / 180, 1, 1, 1); to make it rotate around the Z-axis, as shown in the picture on this question. However, if I set an NSTimer and then update the transform in the update

CATransform3DRotate with m34 parameter need to know angle to fit specific height

爱⌒轻易说出口 提交于 2019-12-06 16:17:51
问题 I have the following transform code: //preparing transform CATransform3D basicTrans = CATransform3DIdentity; basicTrans.m34 =1.0/-projection; //calculating angle double angle= [[self angleValueForBlockHeight:height] doubleValue]; double rangle; if (up) { rangle=angle/360*(2.0*M_PI); } else { rangle=(360.0-angle)/360*(2.0*M_PI); }; //NSLog(@" angle: %g", angle); //transforming bView.layer.transform = CATransform3DRotate(basicTrans, rangle, 1.0f, 0.0f, 0.0f); As you can see I'm rotating bView

How can I draw and rotate an Arrow at an Orientation in 3D Space?

倾然丶 夕夏残阳落幕 提交于 2019-12-06 12:23:56
I want to draw an image like the following in a certain orientation. Assume that the device lies flat on a table the image above shows how the arrow should be drawn. The angle between the device and the table is called alpha and it is zero in this case. The arrow points straight to a predefined location point. If you rotate the device on the table the arrow will point alway to the target direction just like a compass. I did the update of the image position with the following code in 2D space: // Create the image for the compass let arrowImageView: UIImageView = UIImageView(frame: CGRectMake

3D Cube Problem! Part 1

廉价感情. 提交于 2019-12-06 07:33:28
问题 I have created a 3D cube in iphone using CALayer's . Now I wanted to rotate that cube( CALayer ) at 90˚ when user double taps on it. I was able to rotate that cube( CALayer ) to 90˚ once but when I double tap the cube( CALayer ) is not rotating. Here is the code that I used to rotate the cube( CALayer ) CATransform3D x = CATransform3DRotate(currentLayer.sublayerTransform, M_PI / 2, 0, 0, 1); currentLayer.transform = x; Can anyone help in this. What I'm doing wrong. PS. For the people who are