Skip to content

Commit 15eb61d

Browse files
author
Thayer J Andrews
committed
CCEffectGlass - API documentation
1 parent 20550c7 commit 15eb61d

File tree

1 file changed

+83
-0
lines changed

1 file changed

+83
-0
lines changed

cocos2d/CCEffectGlass.h

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,17 +8,100 @@
88

99
#import "CCEffect.h"
1010

11+
/**
12+
* CCEffectGlass uses reflection and refraction to simulate the appearance of a transparent object
13+
* contained within an environment. Refraction is controlled with a single refraction strength value,
14+
* the normal map, and a refraction environment sprite. Reflection is controlled with two fresnel
15+
* reflectance values, the normal map, and a reflection environment sprite (which may be different
16+
* from the refraction environment).
17+
*
18+
*/
1119
@interface CCEffectGlass : CCEffect
1220

21+
/// -----------------------------------------------------------------------
22+
/// @name Accessing Effect Attributes
23+
/// -----------------------------------------------------------------------
24+
25+
/** The refraction strength value. This value is in the range [-1..1] with -1
26+
* resulting in maximum minification of the refracted image, 0 resulting in no
27+
* refraction, and 1 resulting in maximum magnification of the refracted image.
28+
*/
1329
@property (nonatomic) float refraction;
30+
31+
/** The bias term in the fresnel reflectance equation:
32+
* reflectance = max(0.0, fresnelBias + (1 - fresnelBias) * pow((1 - nDotV), fresnelPower))
33+
* This value is in the range [0..1] and it controls the constant (view angle independent) contribution
34+
* to the reflectance equation.
35+
*/
1436
@property (nonatomic) float fresnelBias;
37+
38+
/** The power term in the fresnel reflectance equation:
39+
* reflectance = max(0.0, fresnelBias + (1 - fresnelBias) * pow((1 - nDotV), fresnelPower))
40+
* This value is in the range [0..inf] and it controls the view angle dependent contribution
41+
* to the reflectance equation.
42+
*/
1543
@property (nonatomic) float fresnelPower;
44+
45+
/** The environment that will be refracted by the affected node. Typically this is a
46+
* sprite that serves as the background for the affected node so it appears that the viewer
47+
* is seeing the refracted environment through the refracting node.
48+
*/
1649
@property (nonatomic) CCSprite *refractionEnvironment;
50+
51+
/** The environment that will be refracted by the affected node. Typically this is a sprite
52+
* that is not visible in the scene as it is conceptually "behind the viewer" and only visible
53+
* where reflected by the affected node.
54+
*/
1755
@property (nonatomic) CCSprite *reflectionEnvironment;
56+
57+
/** The normal map that encodes the normal vectors of the affected node. Each pixel in the normal
58+
* map is a 3 component vector that is perpendicular to the surface of the sprite at that point.
59+
*/
1860
@property (nonatomic) CCSpriteFrame *normalMap;
1961

62+
63+
/// -----------------------------------------------------------------------
64+
/// @name Initializing a CCEffectGlass object
65+
/// -----------------------------------------------------------------------
66+
67+
/**
68+
* Initializes a CCEffectGlass object with the following default parameters:
69+
* refraction : 1.0
70+
* refractionEnvironment : nil
71+
* reflectionEnvironment : nil
72+
* normalMap : nil
73+
*
74+
* @return The CCEffectGlass object.
75+
*/
2076
-(id)init;
77+
78+
/**
79+
* Initializes a CCEffectGlass object with the supplied parameters.
80+
*
81+
* @param refraction The refraction strength.
82+
* @param refractionEnvironment The environment image that will be refracted by the affected node.
83+
* @param reflectionEnvironment The environment image that will be reflected by the affected node.
84+
* @param normalMap The normal map of the affected node. This can also be specified as a property of the affected sprite.
85+
*
86+
* @return The CCEffectGlass object.
87+
*/
2188
-(id)initWithRefraction:(float)refraction refractionEnvironment:(CCSprite *)refractionEnvironment reflectionEnvironment:(CCSprite *)reflectionEnvironment normalMap:(CCSpriteFrame *)normalMap;
89+
90+
91+
/// -----------------------------------------------------------------------
92+
/// @name Creating a CCEffectGlass object
93+
/// -----------------------------------------------------------------------
94+
95+
/**
96+
* Creates a CCEffectGlass object with the supplied parameters.
97+
*
98+
* @param refraction The refraction strength.
99+
* @param refractionEnvironment The environment image that will be refracted by the affected node.
100+
* @param reflectionEnvironment The environment image that will be reflected by the affected node.
101+
* @param normalMap The normal map of the affected node. This can also be specified as a property of the affected sprite.
102+
*
103+
* @return The CCEffectGlass object.
104+
*/
22105
+(id)effectWithRefraction:(float)refraction refractionEnvironment:(CCSprite *)refractionEnvironment reflectionEnvironment:(CCSprite *)reflectionEnvironment normalMap:(CCSpriteFrame *)normalMap;
23106

24107
@end

0 commit comments

Comments
 (0)