Jump to content

Category:Mscr:Editor.GeoBuilder

From Ironworks Games Wiki

A type of Geo that can be procedurally created in the editor.

This allows you to create simple or complex primitives that you can place in your maps with all the benefits of Geos.

Note that in order to create a GeoBuilder that you can create via the Geo Create menu in the Editor, you will need to create an implementation of Editor.ToolCreateGeo.

Details

class Editor.GeoBuilder : Editor.Node
Object Type: class (Copy by Reference)
Inherits From: Editor.Node

Optional User-Implementable Methods

GetScaleTransform

Matrix4x4 GetScaleTransform()

Returns:

Matrix4x4 The current scale transform of the GeoBuilder.

Returns any scale that's been applied to the GeoBuilder. Most of the time this will just return the same value that was passed in to #OnTransformScale.

OnTransformScale

void OnTransformScale(Matrix4x4 scaleTransform)

Arguments:

Type Argument Description
Matrix4x4 scaleTransform The transform the GeoBuilder wants to be scaled to.

This method is used to deal with scaling GeoBuilders within the editor. If this method isn't implemented, the Scale tool will scale all of the vertices within the currently built state of the GeoBuilder, but will NOT retain that scaling if the GeoBuilder rebuilds itself at any point. To address this, you can implement OnTransformScale (And the accompanying #GetScaleTransform), save the scale transform to a variable, and then apply it to each vertex when the geometry is rebuilt.

Public Methods

GetVertexCount

int GetVertexCount()

Returns:

int The number of vertices currently in the Geo.

GetEdgeCount

int GetEdgeCount()

Returns:

int The number of edge currently in the Geo.

GetFaceCount

int GetFaceCount()

Returns:

int The number of faces currently in the Geo.

ClearAll

void ClearAll()

Arguments:

Type Argument Description
Editor.UndoItem undo The UndoItem to add any undos to. Can be null.

This removes all vertices, edges and faces currently in the Geo.

CreateVertex

GeoBuilder.Vertex CreateVertex(Vector3 position, Editor.UndoItem undo)

Returns:

GeoBuilder.Vertex The created vertex.

Arguments:

Type Argument Description
Vector3 position The position to create the vertex, in local space.
Editor.UndoItem undo The UndoItem to add any undos to. Can be null.

Creates a Vertex in the Geo. The created vertex will have an index equal to the number of vertices that were in the Geo at the time the vertex was created.

CreateFace

GeoBuilder.Face CreateFace(List<:System.Types.UInt32:> indices, Render.Material material, Editor.UndoItem undo)

Returns:

GeoBuilder.Face The created Face.

Arguments:

Type Argument Description
List<:uint:> indices The vertex indices this face should use, in clockwise order.
Render.Material material The material to apply to this face.
Editor.UndoItem undo The UndoItem to add any undos to. Can be null.

Creates a Face in the Geo using the supplied indices of vertices. Note that it is generally preferred to call #GetOrCreateFace instead of this, to avoid the possibility of creating the same face twice using the same indices.

GetOrCreateFace

GeoBuilder.Face GetOrCreateFace(List<:System.Types.UInt32:> indices, Editor.UndoItem undo)

Returns:

GeoBuilder.Face The existing or created Face.

Arguments:

Type Argument Description
List<:uint:> indices The vertex indices this face should use, in clockwise order.
Editor.UndoItem undo The UndoItem to add any undos to. Can be null.

If a Face already exists in the Geo with the same indices, will return that face. Otherwise, it will be created.

GetVertex

GeoBuilder.Vertex GetVertex(int i)

Returns:

GeoBuilder.Vertex The vertex at index i

Arguments:

Type Argument Description
int i The index of the vertex you wish to retrieve.

Retrieves an existing vertex from the Geo. If i is less than zero, or greater than or equal to the number of vertices currently in the geo, an exception will be thrown. It's recommend to check GetVertexCount() first in order to avoid this.

GetEdge

GeoBuilder.Edge GetEdge(int i)

Returns:

GeoBuilder.Edge The edge at index i

Arguments:

Type Argument Description
int i The index of the edge you wish to retrieve.

Retrieves an existing edge from the Geo. If i is less than zero, or greater than or equal to the number of edges currently in the geo, an exception will be thrown. It's recommend to check GetEdgeCount() first in order to avoid this.

FindEdge

GeoBuilder.Edge FindEdge(int v1, int v2)

Returns:

GeoBuilder.Edge The existing edge that's made up of vertices v1 and v2, or null if such an edge isn't found.

Arguments:

Type Argument Description
int v1 The first vertex index of the edge
int v2 The second vertex index of the edge

Retrieves an existing edge from the Geo, made up of the vertices v1 and v2. If such an edge isn't found in the Geo, returns null.

GetFace

GeoBuilder.Face GetFace(int i)

Returns:

GeoBuilder.Face The face at index i

Arguments:

Type Argument Description
int i The index of the face you wish to retrieve.

Retrieves an existing face from the Geo. If i is less than zero, or greater than or equal to the number of faces currently in the geo, an exception will be thrown. It's recommend to check GetFaceCount() first in order to avoid this.

RenderEdges

virtual void RenderEdges(Render.Renderer renderer, Color color)

Arguments:

Type Argument Description
Render.Renderer renderer The renderer to use.
Color color The color to render the edges with.

Renders all of the edges currently in the Geo. Can be overridden.

CalculateBoundsLocal

Math.AABB CalculateBoundsLocal()

Returns:

Math.AABB The bounding box of the Geo in local space.

Gets the bounding box/extents of the Geos vertices in local space, relative to the Geos pivot point.

CalculateBoundsWorld

Math.AABB CalculateBoundsWorld()

Returns:

Math.AABB The bounding box of the Geo in world space.

Gets the bounding box/extents of the Geos vertices in world space, relative to the Geos pivot point. Note that this bounding box is axis-aligned, so if the Geo is rotated or scaled, the bounding box will remain axis-aligned to the worldspace, expanding to include the rotated/scaled position of all vertices.

ClearLightmaps

Math.AABB CalculateBoundsWorld()

Clears all current lightmaps on the Geo.

GetEditorGeo

Editor.Geo GetEditorGeo()

Returns:

Editor.Geo The Geo this GeoBuilder is currently operating on.

This category currently contains no pages or media.