![]() |
WhirlyGlobe
1.2
A 3D interactive globe toolkit for iOS
|
00001 /* 00002 * TextureAtlas.h 00003 * WhirlyGlobeLib 00004 * 00005 * Created by Steve Gifford on 3/28/11. 00006 * Copyright 2011 mousebird consulting 00007 * 00008 * Licensed under the Apache License, Version 2.0 (the "License"); 00009 * you may not use this file except in compliance with the License. 00010 * You may obtain a copy of the License at 00011 * http://www.apache.org/licenses/LICENSE-2.0 00012 * 00013 * Unless required by applicable law or agreed to in writing, software 00014 * distributed under the License is distributed on an "AS IS" BASIS, 00015 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 00016 * See the License for the specific language governing permissions and 00017 * limitations under the License. 00018 * 00019 */ 00020 00021 #import <vector> 00022 #import <UIKit/UIKit.h> 00023 #import <OpenGLES/ES1/gl.h> 00024 #import <OpenGLES/ES1/glext.h> 00025 #import <OpenGLES/ES2/gl.h> 00026 #import <OpenGLES/ES2/glext.h> 00027 00028 #import "Identifiable.h" 00029 #import "WhirlyVector.h" 00030 #import "Texture.h" 00031 #import "GlobeScene.h" 00032 00033 namespace WhirlyGlobe 00034 { 00035 00042 class SubTexture : public Identifiable 00043 { 00044 public: 00045 00047 void setFromTex(const TexCoord &texOrg,const TexCoord &texDest); 00048 00049 // Convert the texture coordinate to the destination texture 00050 TexCoord processTexCoord(const TexCoord &); 00051 00052 // Convert a list of texture coordinates to the dest texture 00053 void processTexCoords(std::vector<TexCoord> &); 00054 00056 bool operator < (const SubTexture &that) const { return this->myId < that.myId; } 00057 00059 SimpleIdentity texId; 00060 00062 Affine2f trans; 00063 }; 00064 00065 } 00066 00074 @interface TextureAtlas : NSObject 00075 { 00077 WhirlyGlobe::SimpleIdentity texId; 00079 unsigned int texSizeX,texSizeY; 00081 unsigned int gridSizeX,gridSizeY; 00083 unsigned int cellSizeX,cellSizeY; 00085 bool *layoutGrid; 00086 00088 NSMutableArray *images; 00089 } 00090 00092 @property (nonatomic,readonly) WhirlyGlobe::SimpleIdentity texId; 00093 00096 - (id)inithWithTexSizeX:(unsigned int)texSizeX texSizeY:(unsigned int)texSizeY cellSizeX:(unsigned int)cellSizeX cellSizeY:(unsigned int)cellSizeY; 00097 00101 - (BOOL)addImage:(UIImage *)image texOrg:(WhirlyGlobe::TexCoord &)org texDest:(WhirlyGlobe::TexCoord &)dest; 00102 00104 - (BOOL)getImageLayout:(UIImage *)image texOrg:(WhirlyGlobe::TexCoord &)org texDest:(WhirlyGlobe::TexCoord &)dest; 00105 00108 - (WhirlyGlobe::Texture *)createTexture:(UIImage **)retImage; 00109 00110 @end 00111 00121 @interface TextureAtlasBuilder : NSObject 00122 { 00124 unsigned int texSizeX,texSizeY; 00126 unsigned int cellSizeX,cellSizeY; 00127 00129 NSMutableArray *atlases; 00130 00132 std::vector<WhirlyGlobe::SubTexture> mappings; 00133 } 00134 00137 - (id)initWithTexSizeX:(unsigned int)texSizeX texSizeY:(unsigned int)texSizeY; 00138 00141 - (WhirlyGlobe::SimpleIdentity)addImage:(UIImage *)image; 00142 00145 - (void)processIntoScene:(WhirlyGlobe::GlobeScene *)scene texIDs:(std::set<WhirlyGlobe::SimpleIdentity> *)texIDs; 00146 00147 @end