diff options
Diffstat (limited to 'libs/cocos2d/CCGrid.h')
| -rwxr-xr-x | libs/cocos2d/CCGrid.h | 121 |
1 files changed, 121 insertions, 0 deletions
| diff --git a/libs/cocos2d/CCGrid.h b/libs/cocos2d/CCGrid.h new file mode 100755 index 0000000..e5e77e8 --- /dev/null +++ b/libs/cocos2d/CCGrid.h | |||
| @@ -0,0 +1,121 @@ | |||
| 1 | /* | ||
| 2 | * cocos2d for iPhone: http://www.cocos2d-iphone.org | ||
| 3 | * | ||
| 4 | * Copyright (c) 2009 On-Core | ||
| 5 | * | ||
| 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy | ||
| 7 | * of this software and associated documentation files (the "Software"), to deal | ||
| 8 | * in the Software without restriction, including without limitation the rights | ||
| 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
| 10 | * copies of the Software, and to permit persons to whom the Software is | ||
| 11 | * furnished to do so, subject to the following conditions: | ||
| 12 | * | ||
| 13 | * The above copyright notice and this permission notice shall be included in | ||
| 14 | * all copies or substantial portions of the Software. | ||
| 15 | * | ||
| 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
| 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
| 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
| 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
| 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
| 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
| 22 | * THE SOFTWARE. | ||
| 23 | * | ||
| 24 | */ | ||
| 25 | |||
| 26 | |||
| 27 | #import <Foundation/Foundation.h> | ||
| 28 | |||
| 29 | #import "CCNode.h" | ||
| 30 | #import "CCCamera.h" | ||
| 31 | #import "ccTypes.h" | ||
| 32 | |||
| 33 | @class CCTexture2D; | ||
| 34 | @class CCGrabber; | ||
| 35 | |||
| 36 | /** Base class for other | ||
| 37 | */ | ||
| 38 | @interface CCGridBase : NSObject | ||
| 39 | { | ||
| 40 | BOOL active_; | ||
| 41 | int reuseGrid_; | ||
| 42 | ccGridSize gridSize_; | ||
| 43 | CCTexture2D *texture_; | ||
| 44 | CGPoint step_; | ||
| 45 | CCGrabber *grabber_; | ||
| 46 | BOOL isTextureFlipped_; | ||
| 47 | } | ||
| 48 | |||
| 49 | /** wheter or not the grid is active */ | ||
| 50 | @property (nonatomic,readwrite) BOOL active; | ||
| 51 | /** number of times that the grid will be reused */ | ||
| 52 | @property (nonatomic,readwrite) int reuseGrid; | ||
| 53 | /** size of the grid */ | ||
| 54 | @property (nonatomic,readonly) ccGridSize gridSize; | ||
| 55 | /** pixels between the grids */ | ||
| 56 | @property (nonatomic,readwrite) CGPoint step; | ||
| 57 | /** texture used */ | ||
| 58 | @property (nonatomic, retain) CCTexture2D *texture; | ||
| 59 | /** grabber used */ | ||
| 60 | @property (nonatomic, retain) CCGrabber *grabber; | ||
| 61 | /** is texture flipped */ | ||
| 62 | @property (nonatomic, readwrite) BOOL isTextureFlipped; | ||
| 63 | |||
| 64 | +(id) gridWithSize:(ccGridSize)gridSize texture:(CCTexture2D*)texture flippedTexture:(BOOL)flipped; | ||
| 65 | +(id) gridWithSize:(ccGridSize)gridSize; | ||
| 66 | |||
| 67 | -(id) initWithSize:(ccGridSize)gridSize texture:(CCTexture2D*)texture flippedTexture:(BOOL)flipped; | ||
| 68 | -(id)initWithSize:(ccGridSize)gridSize; | ||
| 69 | -(void)beforeDraw; | ||
| 70 | -(void)afterDraw:(CCNode*)target; | ||
| 71 | -(void)blit; | ||
| 72 | -(void)reuse; | ||
| 73 | |||
| 74 | -(void)calculateVertexPoints; | ||
| 75 | |||
| 76 | @end | ||
| 77 | |||
| 78 | //////////////////////////////////////////////////////////// | ||
| 79 | |||
| 80 | /** | ||
| 81 | CCGrid3D is a 3D grid implementation. Each vertex has 3 dimensions: x,y,z | ||
| 82 | */ | ||
| 83 | @interface CCGrid3D : CCGridBase | ||
| 84 | { | ||
| 85 | GLvoid *texCoordinates; | ||
| 86 | GLvoid *vertices; | ||
| 87 | GLvoid *originalVertices; | ||
| 88 | GLushort *indices; | ||
| 89 | } | ||
| 90 | |||
| 91 | /** returns the vertex at a given position */ | ||
| 92 | -(ccVertex3F)vertex:(ccGridSize)pos; | ||
| 93 | /** returns the original (non-transformed) vertex at a given position */ | ||
| 94 | -(ccVertex3F)originalVertex:(ccGridSize)pos; | ||
| 95 | /** sets a new vertex at a given position */ | ||
| 96 | -(void)setVertex:(ccGridSize)pos vertex:(ccVertex3F)vertex; | ||
| 97 | |||
| 98 | @end | ||
| 99 | |||
| 100 | //////////////////////////////////////////////////////////// | ||
| 101 | |||
| 102 | /** | ||
| 103 | CCTiledGrid3D is a 3D grid implementation. It differs from Grid3D in that | ||
| 104 | the tiles can be separated from the grid. | ||
| 105 | */ | ||
| 106 | @interface CCTiledGrid3D : CCGridBase | ||
| 107 | { | ||
| 108 | GLvoid *texCoordinates; | ||
| 109 | GLvoid *vertices; | ||
| 110 | GLvoid *originalVertices; | ||
| 111 | GLushort *indices; | ||
| 112 | } | ||
| 113 | |||
| 114 | /** returns the tile at the given position */ | ||
| 115 | -(ccQuad3)tile:(ccGridSize)pos; | ||
| 116 | /** returns the original tile (untransformed) at the given position */ | ||
| 117 | -(ccQuad3)originalTile:(ccGridSize)pos; | ||
| 118 | /** sets a new tile */ | ||
| 119 | -(void)setTile:(ccGridSize)pos coords:(ccQuad3)coords; | ||
| 120 | |||
| 121 | @end | ||
