Skip to content

Instantly share code, notes, and snippets.

@Ciechan
Created May 14, 2014 19:08
Show Gist options
  • Save Ciechan/0449012865bb0a28947f to your computer and use it in GitHub Desktop.
Save Ciechan/0449012865bb0a28947f to your computer and use it in GitHub Desktop.
Cleaned up headers for CAMeshTransform, CALight, and mesh&lights properties of CALayer
#ifndef CALayer_CAMeshTransform_CALight_h
#define CALayer_CAMeshTransform_CALight_h
typedef struct CAMeshFace {
unsigned int indices[4];
float w[4];
} CAMeshFace;
typedef struct CAPoint3D {
CGFloat x;
CGFloat y;
CGFloat z;
} CAPoint3D;
typedef struct CAMeshVertex {
CGPoint from;
CAPoint3D to;
} CAMeshVertex;
extern NSString * const kCADepthNormalizationNone;
extern NSString * const kCADepthNormalizationWidth;
extern NSString * const kCADepthNormalizationHeight;
extern NSString * const kCADepthNormalizationMin;
extern NSString * const kCADepthNormalizationMax;
extern NSString * const kCADepthNormalizationAverage;
@interface CAMeshTransform : NSObject <NSCoding, NSCopying, NSMutableCopying>
@property (readonly) NSInteger subdivisionSteps; // defaults to -1
@property (readonly, copy) NSString *depthNormalization; // defaults to kCADepthNormalizationNone
@property (readonly) NSUInteger faceCount;
@property (readonly) NSUInteger vertexCount;
+ (instancetype)meshTransformWithVertexCount:(NSUInteger)vertexCount
vertices:(CAMeshVertex *)vertices
faceCount:(NSUInteger)faceCount
faces:(CAMeshFace *)faces
depthNormalization:(NSString *)depthNormalization;
- (instancetype)initWithVertexCount:(NSUInteger)vertexCount
vertices:(CAMeshVertex *)vertices
faceCount:(NSUInteger)faceCount
faces:(CAMeshFace *)faces
depthNormalization:(NSString *)depthNormalization;
- (CAMeshFace)faceAtIndex:(NSUInteger)faceIndex;
- (CAMeshVertex)vertexAtIndex:(NSUInteger)vertexIndex;
@end
@interface CAMutableMeshTransform : CAMeshTransform
@property NSInteger subdivisionSteps;
@property (copy) NSString *depthNormalization;
+ (instancetype)meshTransform;
- (void)addFace:(CAMeshFace)face;
- (void)removeFaceAtIndex:(NSUInteger)faceIndex;
- (void)replaceFaceAtIndex:(NSUInteger)faceIndex withFace:(CAMeshFace)face;
- (void)addVertex:(CAMeshVertex)vertex;
- (void)removeVertexAtIndex:(NSUInteger)vertexIndex;
- (void)replaceVertexAtIndex:(NSUInteger)vertexIndex withVertex:(CAMeshVertex)vertex;
@end
extern NSString * const kCALightTypeAmbient;
extern NSString * const kCALightTypeDirectional;
extern NSString * const kCALightTypePoint;
extern NSString * const kCALightTypeSpot;
@interface CALight : NSObject <NSCopying, NSCoding>
@property (copy) NSString *name;
@property (copy) NSString *type;
@property (copy) NSString *imageBlendMode;
@property (getter=isEnabled) BOOL enabled;
@property float imageNormalAngle;
@property float imageRotation;
@property (retain) id image;
@property float coneEdgeSoftness;
@property float coneAngle;
@property float falloff;
@property float falloffDistance;
@property CAPoint3D position;
@property CAPoint3D direction; // defaults to {0.0, 0.0, 1.0}
@property CGColorRef color;
@property float specularIntensity;
@property float diffuseIntensity;
@property float ambientIntensity;
@property float intensity;
+ (id)lightWithType:(NSString *)lightType;
- (id)initWithType:(NSString *)lightType;
@end
@interface CALayer (PrivateMeshAndLights)
@property (copy) CAMeshTransform *meshTransform;
@property BOOL acceptsLights; // defaults to YES
@property (copy) NSArray *lights;
@property float metallicity;
@property float shininess;
@property float specularReflectance;
@property float diffuseReflectance;
@property float ambientReflectance;
@end
#endif
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment