diff options
Diffstat (limited to 'libs/cocos2d/CCCamera.h')
| -rwxr-xr-x | libs/cocos2d/CCCamera.h | 95 |
1 files changed, 95 insertions, 0 deletions
| diff --git a/libs/cocos2d/CCCamera.h b/libs/cocos2d/CCCamera.h new file mode 100755 index 0000000..19a7712 --- /dev/null +++ b/libs/cocos2d/CCCamera.h | |||
| @@ -0,0 +1,95 @@ | |||
| 1 | /* | ||
| 2 | * cocos2d for iPhone: http://www.cocos2d-iphone.org | ||
| 3 | * | ||
| 4 | * Copyright (c) 2008-2010 Ricardo Quesada | ||
| 5 | * Copyright (c) 2011 Zynga Inc. | ||
| 6 | * | ||
| 7 | * Permission is hereby granted, free of charge, to any person obtaining a copy | ||
| 8 | * of this software and associated documentation files (the "Software"), to deal | ||
| 9 | * in the Software without restriction, including without limitation the rights | ||
| 10 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
| 11 | * copies of the Software, and to permit persons to whom the Software is | ||
| 12 | * furnished to do so, subject to the following conditions: | ||
| 13 | * | ||
| 14 | * The above copyright notice and this permission notice shall be included in | ||
| 15 | * all copies or substantial portions of the Software. | ||
| 16 | * | ||
| 17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
| 18 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
| 19 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
| 20 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
| 21 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
| 22 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
| 23 | * THE SOFTWARE. | ||
| 24 | */ | ||
| 25 | |||
| 26 | |||
| 27 | |||
| 28 | #import "CCNode.h" | ||
| 29 | |||
| 30 | /** | ||
| 31 | A CCCamera is used in every CCNode. | ||
| 32 | Useful to look at the object from different views. | ||
| 33 | The OpenGL gluLookAt() function is used to locate the | ||
| 34 | camera. | ||
| 35 | |||
| 36 | If the object is transformed by any of the scale, rotation or | ||
| 37 | position attributes, then they will override the camera. | ||
| 38 | |||
| 39 | IMPORTANT: Either your use the camera or the rotation/scale/position properties. You can't use both. | ||
| 40 | World coordinates won't work if you use the camera. | ||
| 41 | |||
| 42 | Limitations: | ||
| 43 | |||
| 44 | - Some nodes, like CCParallaxNode, CCParticle uses world node coordinates, and they won't work properly if you move them (or any of their ancestors) | ||
| 45 | using the camera. | ||
| 46 | |||
| 47 | - It doesn't work on batched nodes like CCSprite objects when they are parented to a CCSpriteBatchNode object. | ||
| 48 | |||
| 49 | - It is recommended to use it ONLY if you are going to create 3D effects. For 2D effecs, use the action CCFollow or position/scale/rotate. | ||
| 50 | |||
| 51 | */ | ||
| 52 | |||
| 53 | @interface CCCamera : NSObject | ||
| 54 | { | ||
| 55 | float eyeX_; | ||
| 56 | float eyeY_; | ||
| 57 | float eyeZ_; | ||
| 58 | |||
| 59 | float centerX_; | ||
| 60 | float centerY_; | ||
| 61 | float centerZ_; | ||
| 62 | |||
| 63 | float upX_; | ||
| 64 | float upY_; | ||
| 65 | float upZ_; | ||
| 66 | |||
| 67 | BOOL dirty_; | ||
| 68 | } | ||
| 69 | |||
| 70 | /** whether of not the camera is dirty */ | ||
| 71 | @property (nonatomic,readwrite) BOOL dirty; | ||
| 72 | |||
| 73 | /** returns the Z eye */ | ||
| 74 | +(float) getZEye; | ||
| 75 | |||
| 76 | /** sets the camera in the defaul position */ | ||
| 77 | -(void) restore; | ||
| 78 | /** Sets the camera using gluLookAt using its eye, center and up_vector */ | ||
| 79 | -(void) locate; | ||
| 80 | /** sets the eye values in points */ | ||
| 81 | -(void) setEyeX: (float)x eyeY:(float)y eyeZ:(float)z; | ||
| 82 | /** sets the center values in points */ | ||
| 83 | -(void) setCenterX: (float)x centerY:(float)y centerZ:(float)z; | ||
| 84 | /** sets the up values */ | ||
| 85 | -(void) setUpX: (float)x upY:(float)y upZ:(float)z; | ||
| 86 | |||
| 87 | /** get the eye vector values in points */ | ||
| 88 | -(void) eyeX:(float*)x eyeY:(float*)y eyeZ:(float*)z; | ||
| 89 | /** get the center vector values in points */ | ||
| 90 | -(void) centerX:(float*)x centerY:(float*)y centerZ:(float*)z; | ||
| 91 | /** get the up vector values */ | ||
| 92 | -(void) upX:(float*)x upY:(float*)y upZ:(float*)z; | ||
| 93 | |||
| 94 | |||
| 95 | @end | ||
