MaplyGeomBuilder
Objective-C
@interface MaplyGeomBuilder : NSObject
Swift
class MaplyGeomBuilder : NSObject
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.
-
Intialize with the view controller the model will be used in.
Declaration
Objective-C
- (id)initWithViewC:(NSObject<MaplyRenderControllerProtocol> *)viewC;
Swift
init!(viewC: (NSObjectProtocol & MaplyRenderControllerProtocol)!)
-
Create a rectangle around the origin.
This creates a flat rectangle around the origin (0,0,0) with z = 0.
Declaration
Objective-C
- (void)addRectangleAroundOrigin:(MaplyCoordinateD)size state:(MaplyGeomState *)state;
Swift
func addRectangleAroundOrigin(_ size: MaplyCoordinateD, state: MaplyGeomState!)
Parameters
size
The size of the rectangle (x,y).
state
The visual state to use when creating the geometry.
-
Create a rectangle around the origin.
This creates a flat rectangle around the origin (0,0,0) with z = 0.
Declaration
Objective-C
- (void)addRectangleAroundOriginX:(double)x y:(double)y state:(MaplyGeomState *)state;
Swift
func addRectangleAroundOriginX(_ x: Double, y: Double, state: MaplyGeomState!)
Parameters
x
Horizontal size of the rectangle.
y
Vertical size of the rectangle.
state
The visual state to use when creating the geometry.
-
Create a rectangle around the given point.
This creates a flat rectangle around the point x,y with z = 0.
Declaration
Objective-C
- (void)addRectangleAroundX:(double)x y:(double)y width:(double)width height:(double)height state:(MaplyGeomState *)state;
Swift
func addRectangleAroundX(_ x: Double, y: Double, width: Double, height: Double, state: MaplyGeomState!)
Parameters
x
X location around which to create the rectangle.
y
Y location around which to create the rectangle.
width
Horizontal size of the rectangle.
height
Vertical size of the rectangle.
state
The visual state to use when creating the geometry.
-
Add an attributed string to the geometry builder.
Add an attributed string, which contains information about color and front to the geometry builder.
Declaration
Objective-C
- (void)addAttributedString:(NSAttributedString *)str state:(MaplyGeomState *)state;
Swift
func add(_ str: NSAttributedString!, state: MaplyGeomState!)
Parameters
str
String to add to the geometry.
state
The visual state to use when creating the geometry.
-
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.
Declaration
Objective-C
- (void)addString:(NSString *)str font:(id)font state:(MaplyGeomState *)state;
Swift
func add(_ str: String!, font: Any!, state: MaplyGeomState!)
Parameters
str
String to add to geometry.
font
Font to use for the string.
state
The visual state to use when creating the geometry.
-
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.
Declaration
Objective-C
- (void)addString:(NSString *)str width:(double)width height:(double)height font:(id)font state:(MaplyGeomState *)state;
Swift
func add(_ str: String!, width: Double, height: Double, font: Any!, state: MaplyGeomState!)
Parameters
str
String to add to geometry.
width
Width of the string in the final geometry. If set to 0.0, will be calculated.
height
Height of the string in the final geometry. If set to 0.0, will be calculated.
font
Font to use for the string.
state
The visual state to use when creating the geometry.
-
Add a polygon with the given visual state.
Tesselates the given polygon and adds the resulting triangles to the geometry.
Declaration
Objective-C
- (void)addPolygonWithPts:(MaplyCoordinate3dD *)pts numPts:(int)numPts state:(MaplyGeomState *)state;
Swift
func addPolygon(withPts pts: UnsafeMutablePointer<MaplyCoordinate3dD>!, numPts: Int32, state: MaplyGeomState!)
Parameters
pts
An array of 3D points.
numPts
Number of points in the 3D array.
state
The visual state to use when creating the geometry.
-
Add a polygon with the given visual state.
Tesselates the given polygon and adds the resulting triangles to the geometry.
Declaration
Objective-C
- (void)addPolygonWithPts:(MaplyCoordinate3dD *)pts tex:(MaplyCoordinateD *)tex norms:(MaplyCoordinate3dD *)norms numPts:(int)numPts state:(MaplyGeomState *)state;
Swift
func addPolygon(withPts pts: UnsafeMutablePointer<MaplyCoordinate3dD>!, tex: UnsafeMutablePointer<MaplyCoordinateD>!, norms: UnsafeMutablePointer<MaplyCoordinate3dD>!, numPts: Int32, state: MaplyGeomState!)
Parameters
pts
An array of 3D points.
tex
Texture coordinates. One for each point.
norms
Normals to go with the points.
numPts
Number of points in the 3D array.
state
The visual state to use when creating the geometry.
-
Add a point in immediate mode.
When in immediate mode points are collected until an addCurPoly call. This adds a 3D point.
Declaration
Objective-C
- (void)addCurPointX:(double)x y:(double)y z:(double)z;
Swift
func addCurPointX(_ x: Double, y: Double, z: Double)
-
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).
Declaration
Objective-C
- (void)addCurPointX:(double)x y:(double)y;
Swift
func addCurPointX(_ x: Double, y: Double)
-
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.
Declaration
Objective-C
- (void)addCurPoly:(MaplyGeomState *)state;
Swift
func addCurPoly(_ state: MaplyGeomState!)
-
Scale the geometry and strings by this amount.
The geometry and strings are scaled by the given amount in each dimension.
Declaration
Objective-C
- (void)scale:(MaplyCoordinate3dD)scale;
Swift
func scale(_ scale: MaplyCoordinate3dD)
-
Scale the geometry and strings by the given amount.
The geometry and strings are scaled by (x,y,z).
Declaration
Objective-C
- (void)scaleX:(double)x y:(double)y z:(double)z;
Swift
func scaleX(_ x: Double, y: Double, z: Double)
-
Translate the geometry and strings by the given amount.
The geometry and strings are translated by the given coordinate.
Declaration
Objective-C
- (void)translate:(MaplyCoordinate3dD)trans;
Swift
func translate(_ trans: MaplyCoordinate3dD)
-
Translate the geometry and strings by the given amount.
The geometry and strings are translated by (x,y,z).
Declaration
Objective-C
- (void)translateX:(double)x y:(double)y z:(double)z;
Swift
func translateX(_ x: Double, y: Double, z: Double)
-
Rotate the geometry around the given axis by the given angle.
Roate around the given 3D axis by the number of radians in angle.
Declaration
Objective-C
- (void)rotate:(double)angle around:(MaplyCoordinate3dD)axis;
Swift
func rotate(_ angle: Double, around axis: MaplyCoordinate3dD)
Parameters
angle
The angle in radians to rotate by.
axis
The axis to rotate around. (0,0,1) would rotate around the Z 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.
Declaration
Objective-C
- (void)rotate:(double)angle aroundX:(double)x y:(double)y z:(double)z;
Swift
func rotate(_ angle: Double, aroundX x: Double, y: Double, z: Double)
Parameters
angle
The angle in radians to rotate by.
x
X component of the axis to rotate around.
y
Y component of the axis to rotate around.
z
Z component of the axis to rotate around.
-
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.
Declaration
Objective-C
- (void)transform:(MaplyMatrix *)matrix;
Swift
func transform(_ matrix: MaplyMatrix!)
-
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.
Declaration
Objective-C
- (void)addGeomFromBuilder:(MaplyGeomBuilder *)modelBuilder;
Swift
func addGeom(from modelBuilder: MaplyGeomBuilder!)
-
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.
Declaration
Objective-C
- (void)addGeomFromBuilder:(MaplyGeomBuilder *)modelBuilder transform:(MaplyMatrix *)matrix;
Swift
func addGeom(from modelBuilder: MaplyGeomBuilder!, transform matrix: MaplyMatrix!)
-
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.
Declaration
Objective-C
- (_Bool)getSizeLL:(MaplyCoordinate3dD *)ll ur:(MaplyCoordinate3dD *)ur;
Swift
func getSizeLL(_ ll: UnsafeMutablePointer<MaplyCoordinate3dD>!, ur: UnsafeMutablePointer<MaplyCoordinate3dD>!) -> Bool
-
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.
-
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
(map or globe). Declaration
Objective-C
- (MaplyGeomModel *)makeGeomModel:(MaplyThreadMode)threadMode;
Swift
func makeGeomModel(_ threadMode: MaplyThreadMode) -> MaplyGeomModel!