|
8 | 8 |
|
9 | 9 | #import "CCNode.h"
|
10 | 10 |
|
| 11 | + |
| 12 | +typedef NS_ENUM(NSUInteger, CCLightNodeType) |
| 13 | +{ |
| 14 | + CCLightNodePoint = 0, |
| 15 | + CCLightNodeDirectional = 1, |
| 16 | + CCLightNodeSpot = 2, |
| 17 | +}; |
| 18 | + |
11 | 19 | /**
|
12 | 20 | * CCLightNode allows the user to define lights that will be used with
|
13 | 21 | * CCEffectLighting.
|
|
19 | 27 | /// @name Accessing Node Attributes
|
20 | 28 | /// -----------------------------------------------------------------------
|
21 | 29 |
|
22 |
| -/** The color of the light. As described below, the color is modulated by the |
| 30 | +/** The type of the light. The contribution of point lights is dependent on |
| 31 | + * the relative positions of the light and the node it is lighting. The |
| 32 | + * contribution of directional lights is only dependent on the light's |
| 33 | + * orientation (as if it is infinitely far away). Spot lights behave like |
| 34 | + * point lights but they also have a direction vector and cutoff angle. |
| 35 | + * If the angle between the light's direction vector and the vector from |
| 36 | + * the light to the node exceeds the cutoff angle then the light no longer |
| 37 | + * contributes to the lighting of the node. |
| 38 | + */ |
| 39 | +@property (nonatomic, assign) CCLightNodeType type; |
| 40 | + |
| 41 | +/** The primary color of the light. As described below, the color is modulated by the |
23 | 42 | * intensity value to determine the contribution of the light to the lighting
|
24 |
| - * effect. |
| 43 | + * effect. This color is used when computing the light's position and orientation |
| 44 | + * dependent contribution to the lighting effect. |
25 | 45 | */
|
26 | 46 | @property (nonatomic, strong) CCColor* color;
|
27 | 47 |
|
28 |
| -/** The overall brightness of the light. This value is in the range [0..1] with |
29 |
| - * 0 resulting in no contribution from this light in the final image (the light |
| 48 | +/** The brightness of the light's primary color. This value is in the range [0..1] |
| 49 | + * with 0 resulting in no contribution from this light in the final image (the light |
30 | 50 | * effectively becomes black) and 1 resulting in full contribution from this
|
31 |
| - * light (the light's full color contributes). |
| 51 | + * light. |
32 | 52 | */
|
33 | 53 | @property (nonatomic, assign) float intensity;
|
34 | 54 |
|
| 55 | +/** The ambient color of the light. As described below, the color is modulated by the |
| 56 | + * ambient intensity value to determine the contribution of the light to the lighting |
| 57 | + * effect. The ambient color contributes to the lighting effect independent of the light's |
| 58 | + * position and orientation relative to the affected node. |
| 59 | + */ |
| 60 | +@property (nonatomic, strong) CCColor* ambientColor; |
| 61 | + |
| 62 | +/** The brightness of the light's ambient color. This value is in the range [0..1] |
| 63 | + * with 0 resulting in no contribution from the ambient color to the final image |
| 64 | + * (the ambient color effectively becomes black) and 1 resulting in full contribution |
| 65 | + * from this light. |
| 66 | + */ |
| 67 | +@property (nonatomic, assign) float ambientIntensity; |
| 68 | + |
| 69 | + |
35 | 70 |
|
36 | 71 | /// -----------------------------------------------------------------------
|
37 | 72 | /// @name Initializing a CCLightNode object
|
38 | 73 | /// -----------------------------------------------------------------------
|
39 | 74 |
|
40 | 75 |
|
41 | 76 | /**
|
42 |
| - * Initializes a CCLightNode object with a white color and full intensity. |
| 77 | + * Initializes a point light with a white color and full intensity. |
43 | 78 | *
|
44 | 79 | * @return The CCLightNode object.
|
45 | 80 | */
|
|
48 | 83 | /**
|
49 | 84 | * Initializes a CCLightNode object with the specified parameters.
|
50 | 85 | *
|
| 86 | + * @param type The type of the light. |
| 87 | + * @param color The primary color of the light. |
| 88 | + * @param intensity The brightness of the light's primary color. |
| 89 | + * @param ambientColor The ambient color of the light. |
| 90 | + * @param ambientIntensity The brightness of the light's ambient color. |
| 91 | + * |
51 | 92 | * @return The CCLighttNode object.
|
52 | 93 | */
|
53 |
| --(id)initWithColor:(CCColor *)color intensity:(float)intensity; |
| 94 | +-(id)initWithType:(CCLightNodeType)type color:(CCColor *)color intensity:(float)intensity ambientColor:(CCColor *)ambientColor ambientIntensity:(float)ambientIntensity; |
54 | 95 |
|
55 | 96 |
|
56 | 97 | /// -----------------------------------------------------------------------
|
|
60 | 101 | /**
|
61 | 102 | * Creates a CCLightNode object with the specified parameters.
|
62 | 103 | *
|
63 |
| - * @param color Color of the light. |
64 |
| - * @param intensity The overall brightness of the light. |
| 104 | + * @param type The type of the light. |
| 105 | + * @param color The primary color of the light. |
| 106 | + * @param intensity The brightness of the light's primary color. |
| 107 | + * @param ambientColor The ambient color of the light. |
| 108 | + * @param ambientIntensity The brightness of the light's ambient color. |
65 | 109 | *
|
66 | 110 | * @return An initialized CCLightNode object.
|
67 | 111 | */
|
68 |
| -+(id)lightWithColor:(CCColor *)color intensity:(float)intensity; |
| 112 | ++(id)lightWithType:(CCLightNodeType)type color:(CCColor *)color intensity:(float)intensity ambientColor:(CCColor *)ambientColor ambientIntensity:(float)ambientIntensity; |
69 | 113 |
|
70 | 114 |
|
71 | 115 | @end
|
0 commit comments