aboutsummaryrefslogtreecommitdiff
path: root/iosApp/WhirlyGlobe.xcframework/ios-arm64/WhirlyGlobe.framework/Headers/MaplyGeomBuilder.h
blob: 65a43740b502aedf88542ae44a0c8029664e305f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
/*
 *  MaplyGeomModelBuilder.h
 *  WhirlyGlobeComponent
 *
 *  Created by Steve Gifford on 1/20/16
 *  Copyright 2011-2022 mousebird consulting
 *
 *  Licensed under the Apache License, Version 2.0 (the "License");
 *  you may not use this file except in compliance with the License.
 *  You may obtain a copy of the License at
 *  http://www.apache.org/licenses/LICENSE-2.0
 *
 *  Unless required by applicable law or agreed to in writing, software
 *  distributed under the License is distributed on an "AS IS" BASIS,
 *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *  See the License for the specific language governing permissions and
 *  limitations under the License.
 *
 */

#import <UIKit/UIKit.h>
#import <WhirlyGlobe/MaplyCoordinate.h>
#import <WhirlyGlobe/MaplyRenderController.h>
#import <WhirlyGlobe/MaplyGeomModel.h>

/** 
    Geometry State is used to describe the visual look of objects as they're added.
    
    Set the various fields in the geometry state to control how geometry looks when you add it.
            There are defaults for all of these fields.
  */
@interface MaplyGeomState : NSObject

/// Color to use for the geometry
@property (nonatomic,strong) UIColor *color;

/// Background color for text
@property (nonatomic,strong) UIColor *backColor;

/// UIImage for MaplyTexture to apply to geometry
@property (nonatomic,strong) id texture;

/// For more than one texture, use addTexture
- (void)addTexture:(MaplyTexture *)texture;

@end

/** 
    The geometry builder is used to construct 3D models.
    
    You use the geometry builder when you have a custom 3D model to build.  This can include things like airport runways, buildings, or anything else that's particular to a certain location.
    
    Start by construting the builder and then adding polygons and strings to it.
    
    You can combine multiple geometry builders together to build up repeated portions of a model.
    
    The builder has an "immediate mode" where you add points individually to build up polygons and then add those.  This is one of the simpler ways to use the system.
  */
@interface MaplyGeomBuilder : NSObject

/// Intialize with the view controller the model will be used in.
- (id)initWithViewC:(NSObject<MaplyRenderControllerProtocol> *)viewC;

/** 
    Create a rectangle around the origin.
    
    This creates a flat rectangle around the origin (0,0,0) with z = 0.
    
    @param size The size of the rectangle (x,y).
    
    @param state The visual state to use when creating the geometry.
  */
- (void)addRectangleAroundOrigin:(MaplyCoordinateD)size state:(MaplyGeomState *)state;

/** 
    Create a rectangle around the origin.
 
    This creates a flat rectangle around the origin (0,0,0) with z = 0.
 
    @param x Horizontal size of the rectangle.
 
    @param y Vertical size of the rectangle.
 
    @param state The visual state to use when creating the geometry.
 */
- (void)addRectangleAroundOriginX:(double)x y:(double)y state:(MaplyGeomState *)state;

/** 
    Create a rectangle around the given point.
 
    This creates a flat rectangle around the point x,y with z = 0.
 
    @param x X location around which to create the rectangle.
 
    @param y Y location around which to create the rectangle.
 
    @param width Horizontal size of the rectangle.
 
    @param height Vertical size of the rectangle.
 
    @param state The visual state to use when creating the geometry.
 */
- (void)addRectangleAroundX:(double)x y:(double)y width:(double)width height:(double)height state:(MaplyGeomState *)state;

/** 
    Add an attributed string to the geometry builder.
    
    Add an attributed string, which contains information about color and front to the geometry builder.
    
    @param str String to add to the geometry.
    
    @param state The visual state to use when creating the geometry.
  */
- (void)addAttributedString:(NSAttributedString *)str state:(MaplyGeomState *)state;

/** 
    Add a string to the geometry.
    
    Add a string at (0,0) to the geometry with the given font and visual state.  The font determines size.
    
    @param str String to add to geometry.
    
    @param font Font to use for the string.
    
    @param state The visual state to use when creating the geometry.
  */
- (void)addString:(NSString *)str font:(UIFont *)font state:(MaplyGeomState *)state;

/** 
    Add a string to the geometry.
 
    Add a string at (0,0) to the geometry with the given font and visual state.
 
    The string will be scaled to match the width and/or height given.  If one of width or height is 0.0 it will be calculated from the other.
 
    @param str String to add to geometry.
 
    @param width Width of the string in the final geometry.  If set to 0.0, will be calculated.
 
    @param height Height of the string in the final geometry.  If set to 0.0, will be calculated.
 
    @param font Font to use for the string.
 
    @param state The visual state to use when creating the geometry.
 */
- (void)addString:(NSString *)str width:(double)width height:(double)height font:(UIFont *)font state:(MaplyGeomState *)state;

/** 
    Add a polygon with the given visual state.
    
    Tesselates the given polygon and adds the resulting triangles to the geometry.
    
    @param pts An array of 3D points.
    
    @param numPts Number of points in the 3D array.
    
    @param state The visual state to use when creating the geometry.
  */
- (void)addPolygonWithPts:(MaplyCoordinate3dD *)pts numPts:(int)numPts state:(MaplyGeomState *)state;

/** 
    Add a polygon with the given visual state.
 
    Tesselates the given polygon and adds the resulting triangles to the geometry.
 
    @param pts An array of 3D points.
 
    @param tex Texture coordinates.  One for each point.
 
    @param norms Normals to go with the points.
 
    @param numPts Number of points in the 3D array.
 
    @param state The visual state to use when creating the geometry.
 */
- (void)addPolygonWithPts:(MaplyCoordinate3dD *)pts tex:(MaplyCoordinateD *)tex norms:(MaplyCoordinate3dD *)norms numPts:(int)numPts state:(MaplyGeomState *)state;

/** 
    Add a point in immediate mode.
    
    When in immediate mode points are collected until an addCurPoly call.  This adds a 3D point.
  */
- (void)addCurPointX:(double)x y:(double)y z:(double)z;

/** 
    Add a point in immediate mode
    
    When in immediate mode points are collected until an addCurPoly call.  This add a point at (x,y,0).
  */
- (void)addCurPointX:(double)x y:(double)y;

/** 
    Add the current polygon in immediate mode.
    
    When in immediate mode points are collected until you call this method.  Then the points will be tesselated into a set of triangles and added to the geometry with the given visual state.
  */
- (void)addCurPoly:(MaplyGeomState *)state;

/** 
    Scale the geometry and strings by this amount.
    
    The geometry and strings are scaled by the given amount in each dimension.
  */
- (void)scale:(MaplyCoordinate3dD)scale;

/** 
    Scale the geometry and strings by the given amount.
    
    The geometry and strings are scaled by (x,y,z).
  */
- (void)scaleX:(double)x y:(double)y z:(double)z;

/** 
    Translate the geometry and strings by the given amount.
    
    The geometry and strings are translated by the given coordinate.
  */
- (void)translate:(MaplyCoordinate3dD)trans;

/** 
    Translate the geometry and strings by the given amount.
    
    The geometry and strings are translated by (x,y,z).
 */
- (void)translateX:(double)x y:(double)y z:(double)z;

/** 
    Rotate the geometry around the given axis by the given angle.
    
    Roate around the given 3D axis by the number of radians in angle.
    
    @param angle The angle in radians to rotate by.
    
    @param axis The axis to rotate around.  (0,0,1) would rotate around the Z axis.
  */
- (void)rotate:(double)angle around:(MaplyCoordinate3dD)axis;

/** 
    Rotate the geometry around the given axis by the given angle.
 
    Roate around the given 3D axis by the number of radians in angle.
 
    @param angle The angle in radians to rotate by.
 
    @param x X component of the axis to rotate around.
 
    @param y Y component of the axis to rotate around.
 
    @param z Z component of the axis to rotate around.
 */
- (void)rotate:(double)angle aroundX:(double)x y:(double)y z:(double)z;

/** 
    Apply a transform to the geometry and strings.
    
    This applies a general 4x4 transform to the geometry and strings.  You can construct the MaplyMatrix using a number of different options and combine multiple matrices.
  */
- (void)transform:(MaplyMatrix *)matrix;

/** 
    Add the geometry from another builder.
    
    Multiple geometry builders can be combined to build complex objects.
    
    This method copies geometry and strings, including their transforms to the current builder.
  */
- (void)addGeomFromBuilder:(MaplyGeomBuilder *)modelBuilder;

/** 
    Add the geometry from another builder, applying the given transform.
    
    Multiple geometry builders can be combined to build complex objects.
    
    This method transform the source geometry and strings and copies them into the current builder.
  */
- (void)addGeomFromBuilder:(MaplyGeomBuilder *)modelBuilder transform:(MaplyMatrix *)matrix;

/** 
    Calculate the bounding box of geometry and strings.
    
    Calculates the lower left and upper right corners of a rectangular solid that surrounds the geometry and strings for this builder.
    
    This returns false if there is no valid geometry (or strings) and takes transforms into account if there is.
  */
- (bool)getSizeLL:(MaplyCoordinate3dD *)ll ur:(MaplyCoordinate3dD *)ur;

/** 
    Calculate and returns the size of the geometry and strings.
    
    Calculates the size of the geometry and strings in the builder, taking transforms into account.
  */
- (MaplyCoordinate3dD)getSize;

/** 
    Generate a valid MaplyGeomModel that can be instanced and used as a 3D model.
    
    This call returns a MaplyGeomModel.  You'll need a model to make MaplyGeomModelInstance objects and for the addModelInstances:desc:mode: call to a NSObject<MaplyRenderControllerProtocol> (map or globe).
  */
- (MaplyGeomModel *)makeGeomModel:(MaplyThreadMode)threadMode;

@end