class SceneGizmos

Inherits: IScriptExportable, std::enable_shared_from_this<SceneGizmos>

Records commands for rendering gizmos for a particular scene.

Draws the recorded commands using a renderer extension. See GizmoDrawing.

Public

Constructors

SceneGizmos

SceneGizmos(PrivatelyConstruct, const SPtr<EditorSceneInstance> &scene)

Methods

~SceneGizmos

~SceneGizmos() noexcept override

SetColor

void SetColor(const Color &color)

Changes the color of any future recorded draw commands.

SetTransform

void SetTransform(const Matrix4 &transform)

Changes the transform of any future recorded draw commands.

AddDrawCubeCommand

void AddDrawCubeCommand(GizmoCubeData &&cubeData)

Adds a command that draws an axis aligned cuboid.

AddDrawSphereCommand

void AddDrawSphereCommand(GizmoSphereData &&sphereData)

Adds a command that draws a sphere.

AddDrawConeCommand

void AddDrawConeCommand(GizmoConeData &&coneData)

Adds a command that draws a solid cone.

AddDrawDiscCommand

void AddDrawDiscCommand(GizmoDiscData &&discData)

Adds a command that draws a solid disc.

AddDrawWireCubeCommand

void AddDrawWireCubeCommand(GizmoCubeData &&cubeData)

Adds a command that draws a wireframe axis aligned cuboid.

AddDrawWireSphereCommand

void AddDrawWireSphereCommand(GizmoSphereData &&sphereData)

Adds a command that draws a wireframe sphere represented by three discs.

AddDrawWireHemisphereCommand

void AddDrawWireHemisphereCommand(GizmoSphereData &&sphereData)

Adds a command that draws a wireframe hemisphere represented by three arcs.

AddDrawWireConeCommand

void AddDrawWireConeCommand(GizmoConeData &&coneData)

Adds a command that draws a wireframe cone.

AddDrawLineCommand

void AddDrawLineCommand(GizmoLineData &&lineData)

Adds a command that draws a line between two points.

AddDrawLineListCommand

void AddDrawLineListCommand(GizmoLineListData &&lineListData)

Adds a command that draws a list of lines.

Provided array must contain pairs of the line start point followed by an end point.

AddDrawWireDiscCommand

void AddDrawWireDiscCommand(GizmoDiscData &&gizmoDiscData)

Adds a command that draws a wireframe disc.

AddDrawWireArcCommand

void AddDrawWireArcCommand(GizmoWireArcData &&gizmoWireArcData)

Adds a command that draws a wireframe arc.

AddDrawWireMeshCommand

void AddDrawWireMeshCommand(GizmoWireMeshData &&gizmoWireMeshData)

Adds a command that draws a wireframe mesh.

AddDrawFrustumCommand

void AddDrawFrustumCommand(GizmoFrustumData &&gizmoFrustumData)

Adds a command that draws a wireframe frustum.

AddDrawIconCommand

void AddDrawIconCommand(GizmoIconData &&gizmoIconData)

Adds a command that draws an icon that always faces the camera.

AddDrawTextCommand

void AddDrawTextCommand(GizmoTextData &&textData)

Adds a command that draws a mesh representing 2D text with the specified properties.

ClearDrawCommands

void ClearDrawCommands()

Clears all draw commands, but doesn't update the render data.

This means that current gizmos will continue drawing until Draw() is called.

ClearRenderData

void ClearRenderData()

Clears gizmo render data like meshes, so anything specified by the last Draw() call stops drawing.

Does not clear the draw commands, so the following Draw() call will re-queue the previous commands for drawing and re-generate the render data.

GetSceneObject

HSceneObject GetSceneObject(u32 gizmoIdx)

Returns a scene object that was attached to a specific gizmo.

gizmoIdx
Index of the gizmo to look for.

Draw

void Draw(const HCamera &camera, const GizmoDrawSettings &drawSettings)

Sends all the draw commands since the last call to ClearRenderData() for drawing on the provided camera.

staticCreate

static SPtr<SceneGizmos> Create(const SPtr<EditorSceneInstance> &scene)

Creates a new scene gizmos object associated with the provided scene.

Internal

Methods

GeneratePickingInformation

GizmoRenderData GeneratePickingInformation(const HCamera &camera, const GizmoDrawSettings &drawSettings, std::function<Color (u32)> fnIndexToColorCallback)

Generates information required for rendering gizmos for picking purposes.

camera
Camera to draw the gizmos on.
drawSettings
Settings used to control icon drawing.
fnIndexToColorCallback
Callback that assigns a unique color to each gizmo index.

Returns: Object that can be passed to gizmo renderer.

GetGizmoRenderer

const SPtr<render::GizmoRenderer> &GetGizmoRenderer() const

Returns an object that may be used for gizmo rendering.

staticSetFactory

static void SetFactory(const SPtr<SceneGizmosFactory> &factory)

Sets the object that will be used for creating new SceneGizmos objects when Create() is called.

If null is provided, then Create() will output default SceneGizmos object types.

Protected

Methods

BuildIconMesh

SPtr<Mesh> BuildIconMesh(const HCamera &camera, const GizmoDrawSettings &drawSettings, const Vector<GizmoIconData> &iconData, bool forPicking, Vector<GizmoIconRenderData> &outRenderData)

Builds a brand new mesh that can be used for rendering all icon gizmos.

camera
Camera the mesh will be rendered to.
drawSettings
Settings used to control icon drawing.
iconData
A list of all icons and their properties.
forPicking
Whether the icons will be rendered normally, or with a special material for picking.
outRenderData
Output data that outlines the structure of the returned mesh. It tells us which portions of the mesh use which icon texture.

Returns: A mesh containing all of the visible icons.

LimitIconSize

void LimitIconSize(i32 &width, i32 &height)

Resizes the icon width/height so it is always scaled to optimal size (with preserved aspect).

CreateMeshProxyData

Vector<GizmoMeshRenderData> CreateMeshProxyData(const Vector<DrawHelper::ShapeMeshData> &meshData)

Converts mesh data from DrawHelper into mesh data usable by the gizmo renderer.

CalculateIconColors

void CalculateIconColors(const Color &tint, const HCamera &camera, const GizmoDrawSettings &drawSettings, u32 iconHeight, bool fixedScale, Color &normalColor, Color &fadedColor)

Calculates colors for an icon based on its position in the camera.

For example icons too close to too far might be faded.

tint
Primary tint for the icon.
camera
Camera in which the icon will be rendered in.
drawSettings
Settings used to control icon drawing.
iconHeight
Height of the icon in pixels.
fixedScale
Whether the icon size changes depending on distance from the camera.
normalColor
Normal color of the icon.
fadedColor
Faded color to be used when icon is occluded by geometry.

PrepareForDraw

virtual void PrepareForDraw(const HCamera &camera)

Called just before rendering gizmos.

Allows derived classes to add gizmos for drawing.

Fields

mDrawHelper

DrawHelper * mDrawHelper

mPickingDrawHelper

DrawHelper * mPickingDrawHelper

mNextIndex

u32 mNextIndex

mSolidCubeData

Vector<GizmoCubeData> mSolidCubeData

mWireCubeData

Vector<GizmoCubeData> mWireCubeData

mSolidSphereData

Vector<GizmoSphereData> mSolidSphereData

mWireSphereData

Vector<GizmoSphereData> mWireSphereData

mWireHemisphereData

Vector<GizmoSphereData> mWireHemisphereData

mSolidConeData

Vector<GizmoConeData> mSolidConeData

mWireConeData

Vector<GizmoConeData> mWireConeData

mLineData

Vector<GizmoLineData> mLineData

mLineListData

Vector<GizmoLineListData> mLineListData

mSolidDiscData

Vector<GizmoDiscData> mSolidDiscData

mWireDiscData

Vector<GizmoDiscData> mWireDiscData

mWireArcData

Vector<GizmoWireArcData> mWireArcData

mWireMeshData

Vector<GizmoWireMeshData> mWireMeshData

mFrustumData

Vector<GizmoFrustumData> mFrustumData

mIconData

Vector<GizmoIconData> mIconData

mTextData

Vector<GizmoTextData> mTextData

mIndexToSceneObjectMap

Map<u32, HSceneObject> mIndexToSceneObjectMap

mActiveMeshes

Vector<DrawHelper::ShapeMeshData> mActiveMeshes

mIconMesh

SPtr<Mesh> mIconMesh

mGizmoRenderer

SPtr<render::GizmoRenderer> mGizmoRenderer

mIconVertexDesc

SPtr<VertexDescription> mIconVertexDesc

mSortedIconData

Vector<SortedIconData> mSortedIconData