rigComponent 0.1.1
RigKit pack API - rigComponent
Loading...
Searching...
No Matches
create.h File Reference

Creators an artist calls to make entities - makeRect and friends. More...

#include <glm/glm.hpp>
#include <glm/gtc/matrix_transform.hpp>
#include <glm/gtc/quaternion.hpp>
#include <cstdint>
#include <string>
#include <vector>
#include "ecs/MEcs.h"
#include "CArc.h"
#include "CCamera.h"
#include "CDrawStyle.h"
#include "CEllipse.h"
#include "CGroup.h"
#include "CIndexedAtlas.h"
#include "CLight.h"
#include "CLine.h"
#include "CMesh.h"
#include "COrbitDrive.h"
#include "COrthoView.h"
#include "CPalette.h"
#include "CPath.h"
#include "CPolygon.h"
#include "CRectangle.h"
#include "CRegularPolygon.h"
#include "CRing.h"
#include "CSphere.h"
#include "CStar.h"
#include "CTransform.h"
#include "CUiPanel.h"
Include dependency graph for create.h:

Functions

void rig::setEcs (rigkit::MEcs *ecs)
 Bind the ECS that the bare creators write to.
rigkit::MEcs * rig::currentEcs ()
 ECS the bare creators write to, or nullptr when nothing is bound.
entt::entity rig::makeRect (float x, float y, float w, float h, const rigkit::ecs::CDrawStyle &style=fill(1, 1, 1), const std::string &name={})
 Create a rectangle entity (transform + shape + draw style).
entt::entity rig::makeEllipse (float x, float y, float w, float h, const rigkit::ecs::CDrawStyle &style=fill(1, 1, 1), const std::string &name={})
entt::entity rig::makeCircle (float x, float y, float radius, const rigkit::ecs::CDrawStyle &style=fill(1, 1, 1), const std::string &name={})
entt::entity rig::makeRegularPolygon (float x, float y, float radius, int sides, float rotation=0.0f, const rigkit::ecs::CDrawStyle &style=fill(1, 1, 1), const std::string &name={})
 Equilateral n-gon entity.
entt::entity rig::makeStar (float x, float y, float radius, float innerRadius, int points=5, float rotation=0.0f, const rigkit::ecs::CDrawStyle &style=fill(1, 1, 1), const std::string &name={})
 Star entity.
entt::entity rig::makePolygon (std::vector< glm::vec2 > points, bool closed=true, const rigkit::ecs::CDrawStyle &style=fill(1, 1, 1), const std::string &name={})
 Freeform outline from a vertex list (needs three or more points).
entt::entity rig::makePath (rigkit::ecs::CPath path, const rigkit::ecs::CDrawStyle &style=stroke(1, 1, 1), const std::string &name={})
 Vector path from command list (rig.geometry.path) - true curves.
entt::entity rig::makeArc (float x, float y, float radius, float startAngle, float endAngle, bool pie=false, const rigkit::ecs::CDrawStyle &style=stroke(1, 1, 1), const std::string &name={})
 Circular arc.
entt::entity rig::makeRing (float x, float y, float outerRadius, float innerRadius, const rigkit::ecs::CDrawStyle &style=fill(1, 1, 1), const std::string &name={})
 Annulus with a real hole, not a stroked ellipse.
entt::entity rig::makeMesh (std::vector< glm::vec3 > positions, std::vector< uint32_t > indices={}, rigkit::ecs::CMesh::Mode mode=rigkit::ecs::CMesh::Mode::Triangles, const rigkit::ecs::CDrawStyle &style=fill(1, 1, 1), const std::string &name={})
 Mesh entity from positions (+ optional indices).
entt::entity rig::makeMeshTriangle (glm::vec3 a, glm::vec3 b, glm::vec3 c, const rigkit::ecs::CDrawStyle &style=fill(1, 1, 1), const std::string &name={})
 Triangle a,b,c in that index order (CCW => outward / +facing normal).
entt::entity rig::makeMeshQuad (float x, float y, float w, float h, const rigkit::ecs::CDrawStyle &style=fill(1, 1, 1), const std::string &name={})
 Axis-aligned quad on z = 0 (CCW in XY => +Z normal).
entt::entity rig::makeMeshBox (float size=1.0f, const rigkit::ecs::CDrawStyle &style=fill(1, 1, 1), const std::string &name={})
 Axis-aligned box at origin (size = full extents).
entt::entity rig::makeMeshGrid (int half=6, float y=0.f, const rigkit::ecs::CDrawStyle &style=fill(0.32f, 0.34f, 0.38f), const std::string &name={})
 XZ line grid (construction plane).
entt::entity rig::makeSphere (float radius=1.0f, int subdivisions=1, const rigkit::ecs::CDrawStyle &style=fill(1, 1, 1), const std::string &name={})
 Icosphere entity (CSphere), radius / subdivisions stay live data.
void rig::lookAt (rigkit::ecs::CTransform &xf, const glm::vec3 &eye, const glm::vec3 &target, const glm::vec3 &up={0.f, 1.f, 0.f})
 Aim a transform at a world point (writes position + rotation quat).
void rig::poseOrthoView (rigkit::ecs::CTransform &xf, const rigkit::ecs::COrthoView &view, float distance)
 Aim a transform for a locked ortho face (Y-up).
entt::entity rig::makeCamera (glm::vec3 position, bool active=true, const std::string &name={})
 Camera entity (CTransform + CCamera).
entt::entity rig::makeOrbitCamera (glm::vec3 target={0.f, 0.f, 0.f}, float radius=5.6f, float pitch=0.36f, bool active=true, const std::string &name={})
 Active camera with COrbitDrive, posed at yaw 0 looking at target.
entt::entity rig::makeOrthoCamera (rigkit::ecs::COrthoView::Face face, glm::vec3 target={0.f, 0.f, 0.f}, float orthoHeight=4.f, const std::string &name={})
 Inactive ortho camera locked to a face (COrthoView + CCamera).
entt::entity rig::makeLight (glm::vec3 position, rigkit::ecs::CLight::Type type=rigkit::ecs::CLight::Type::Directional, const std::string &name={})
 Light entity (CTransform + CLight).
entt::entity rig::makePalette (rigkit::ecs::CPalette palette=rigkit::ecs::CPalette::default16(), const std::string &name={})
 Scene palette entity (CPalette).
entt::entity rig::makeIndexedAtlas (int width=128, int height=128, uint8_t fillIndex=0, const std::string &name={})
 Indexed atlas entity (CIndexedAtlas).
entt::entity rig::makeGroup (glm::vec3 position={0, 0, 0}, const std::string &name={})
 Scene group root (CTransform + CGroup).
void rig::parentTo (entt::entity child, entt::entity parent)
 Parent one entity to another (CRelationship).
void rig::select (entt::entity entity, bool selected=true)
 Mark an entity selected (CSelection).
entt::entity rig::makeUiPanel (const std::string &role={}, int surface=rigkit::ecs::kUiSurfaceTool, const std::string &name={})
 Portable tool or HUD surface (CUiPanel).
entt::entity rig::makeUiGroup (entt::entity panel, int order=0, int orientation=rigkit::ecs::kUiOrientVertical, const std::string &name={})
 Section inside a panel (CUiGroup).
entt::entity rig::makeUiControl (entt::entity panel, entt::entity target, const std::string &propertyKey, int order=0, int widget=rigkit::ecs::kUiWidgetAuto, const std::string &name={})
 Control bound to one field on target (CUiControl).
entt::entity rig::makeUiAction (entt::entity panel, const std::string &actionId, int order=0, const std::string &name={})
 Command button on a panel (CUiAction).

Detailed Description

Creators an artist calls to make entities - makeRect and friends.

NO CODE JUST DATA: creators write POD components only. Present via rigSystems (2D) or rigRender3D (active camera).

Every creator comes in two forms. The bare form writes to the ECS bound by setEcs, which registering rigComponent already does, so a sketch reads:

rig::makeRect(40.f, 40.f, 220.f, 170.f, rig::fill(0.2f, 0.56f, 0.96f));
entt::entity makeRect(float x, float y, float w, float h, const rigkit::ecs::CDrawStyle &style=fill(1, 1, 1), const std::string &name={})
Create a rectangle entity (transform + shape + draw style).

The form taking an explicit MEcs& stays for packs, tools, and tests that target a specific registry.

Function Documentation

◆ lookAt()

void rig::lookAt ( rigkit::ecs::CTransform & xf,
const glm::vec3 & eye,
const glm::vec3 & target,
const glm::vec3 & up = {0.f, 1.f, 0.f} )
inline

Aim a transform at a world point (writes position + rotation quat).

Builds camera-to-world from inverse(lookAt) so CCamera::viewMatrix (inverse world) matches the usual OpenGL eye. Syncs euler cache.

◆ makeArc()

entt::entity rig::makeArc ( float x,
float y,
float radius,
float startAngle,
float endAngle,
bool pie = false,
const rigkit::ecs::CDrawStyle & style = stroke(1, 1, 1),
const std::string & name = {} )

Circular arc.

Parameters
pieClose through the centre. Angles in degrees.

◆ makeCamera()

entt::entity rig::makeCamera ( glm::vec3 position,
bool active = true,
const std::string & name = {} )

Camera entity (CTransform + CCamera).

Present via rigRender3D when CCamera::active. Pose is transform.

◆ makeCircle()

entt::entity rig::makeCircle ( float x,
float y,
float radius,
const rigkit::ecs::CDrawStyle & style = fill(1, 1, 1),
const std::string & name = {} )
Parameters
xCentre x.
yCentre y.

◆ makeEllipse()

entt::entity rig::makeEllipse ( float x,
float y,
float w,
float h,
const rigkit::ecs::CDrawStyle & style = fill(1, 1, 1),
const std::string & name = {} )
Parameters
xCentre x.
yCentre y.

◆ makeGroup()

entt::entity rig::makeGroup ( glm::vec3 position = {0, 0, 0},
const std::string & name = {} )

Scene group root (CTransform + CGroup).

Children use CRelationship::parent.

◆ makeIndexedAtlas()

entt::entity rig::makeIndexedAtlas ( int width = 128,
int height = 128,
uint8_t fillIndex = 0,
const std::string & name = {} )

Indexed atlas entity (CIndexedAtlas).

Default 128x128 filled with index 0.

◆ makeLight()

entt::entity rig::makeLight ( glm::vec3 position,
rigkit::ecs::CLight::Type type = rigkit::ecs::CLight::Type::Directional,
const std::string & name = {} )

Light entity (CTransform + CLight).

Directional: shines along local -Z. Point: emits from transform position.

◆ makeMesh()

entt::entity rig::makeMesh ( std::vector< glm::vec3 > positions,
std::vector< uint32_t > indices = {},
rigkit::ecs::CMesh::Mode mode = rigkit::ecs::CMesh::Mode::Triangles,
const rigkit::ecs::CDrawStyle & style = fill(1, 1, 1),
const std::string & name = {} )

Mesh entity from positions (+ optional indices).

Present path draws triangles or lines per CMesh::Mode. Triangle winding is caller-owned: CCW when viewed along the intended outward normal (same rule as makeMeshBox / makeMeshQuad).

◆ makeMeshBox()

entt::entity rig::makeMeshBox ( float size = 1.0f,
const rigkit::ecs::CDrawStyle & style = fill(1, 1, 1),
const std::string & name = {} )

Axis-aligned box at origin (size = full extents).

Faces CCW from outside.

◆ makeMeshGrid()

entt::entity rig::makeMeshGrid ( int half = 6,
float y = 0.f,
const rigkit::ecs::CDrawStyle & style = fill(0.32f, 0.34f, 0.38f),
const std::string & name = {} )

XZ line grid (construction plane).

Skipped by triangle pick.

Parameters
halfCells from origin to each edge.
yPlane height.

◆ makeOrbitCamera()

entt::entity rig::makeOrbitCamera ( glm::vec3 target = {0.f, 0.f, 0.f},
float radius = 5.6f,
float pitch = 0.36f,
bool active = true,
const std::string & name = {} )

Active camera with COrbitDrive, posed at yaw 0 looking at target.

Writes CTransform + CCamera + COrbitDrive. Auto-orbit starts off (enabled false); set it true for a show-mode spin. SOrbitDrive yaws when enabled. Mouse orbit / pan / dolly: rig::orbitNavigate in rigSystems.

Parameters
pitchRadians; ~0.36 is a slight downward look.

◆ makeOrthoCamera()

entt::entity rig::makeOrthoCamera ( rigkit::ecs::COrthoView::Face face,
glm::vec3 target = {0.f, 0.f, 0.f},
float orthoHeight = 4.f,
const std::string & name = {} )

Inactive ortho camera locked to a face (COrthoView + CCamera).

CCamera::active stays false so rigRender3D keeps the main bed. Open a dockable panel with rigkit::openOrthoView / OrthoViewWindow.

◆ makePalette()

entt::entity rig::makePalette ( rigkit::ecs::CPalette palette = rigkit::ecs::CPalette::default16(),
const std::string & name = {} )

Scene palette entity (CPalette).

Default = CPalette::default16().

◆ makePath()

entt::entity rig::makePath ( rigkit::ecs::CPath path,
const rigkit::ecs::CDrawStyle & style = stroke(1, 1, 1),
const std::string & name = {} )

Vector path from command list (rig.geometry.path) - true curves.

Cubics / quads / arcs stay commands; renderers flatten for display only. Points are local; pose lives on the entity's CTransform.

◆ makeRect()

entt::entity rig::makeRect ( float x,
float y,
float w,
float h,
const rigkit::ecs::CDrawStyle & style = fill(1, 1, 1),
const std::string & name = {} )

Create a rectangle entity (transform + shape + draw style).

Parameters
xTop-left x.
yTop-left y.
wWidth.
hHeight.
Returns
New entity id, or entt::null when no ECS is bound.

◆ makeRegularPolygon()

entt::entity rig::makeRegularPolygon ( float x,
float y,
float radius,
int sides,
float rotation = 0.0f,
const rigkit::ecs::CDrawStyle & style = fill(1, 1, 1),
const std::string & name = {} )

Equilateral n-gon entity.

Parameters
xCentre x.
yCentre y.
radiusCentre to vertex.
rotationDegrees from +X.

◆ makeSphere()

entt::entity rig::makeSphere ( float radius = 1.0f,
int subdivisions = 1,
const rigkit::ecs::CDrawStyle & style = fill(1, 1, 1),
const std::string & name = {} )

Icosphere entity (CSphere), radius / subdivisions stay live data.

Present rebuilds triangles from CSphere each frame - same parametric deal as makeRegularPolygon / makeStar, just in 3D. Want per-face colors or a one-off hand-authored form instead? Build a CMesh directly (see makeMesh).

◆ makeStar()

entt::entity rig::makeStar ( float x,
float y,
float radius,
float innerRadius,
int points = 5,
float rotation = 0.0f,
const rigkit::ecs::CDrawStyle & style = fill(1, 1, 1),
const std::string & name = {} )

Star entity.

Parameters
xCentre x.
yCentre y.
radiusCentre to outer point.
innerRadiusAbsolute, not a ratio.

◆ makeUiAction()

entt::entity rig::makeUiAction ( entt::entity panel,
const std::string & actionId,
int order = 0,
const std::string & name = {} )

Command button on a panel (CUiAction).

Fires SEvent ids from IApp::registerUIActions. Unknown ids stay hidden.

◆ makeUiControl()

entt::entity rig::makeUiControl ( entt::entity panel,
entt::entity target,
const std::string & propertyKey,
int order = 0,
int widget = rigkit::ecs::kUiWidgetAuto,
const std::string & name = {} )

Control bound to one field on target (CUiControl).

propertyKey matches GetProperties / dotted aliases (position.y).

◆ makeUiPanel()

entt::entity rig::makeUiPanel ( const std::string & role = {},
int surface = rigkit::ecs::kUiSurfaceTool,
const std::string & name = {} )

Portable tool or HUD surface (CUiPanel).

rigImGui presents visible panels. surface is kUiSurfaceTool or kUiSurfaceHud.

◆ parentTo()

void rig::parentTo ( entt::entity child,
entt::entity parent )

Parent one entity to another (CRelationship).

Child keeps its local TRS; SHierarchy folds parent world before Draw.

◆ poseOrthoView()

void rig::poseOrthoView ( rigkit::ecs::CTransform & xf,
const rigkit::ecs::COrthoView & view,
float distance )
inline

Aim a transform for a locked ortho face (Y-up).

Top looks down -Y with +X right. Left / Right keep world +Y up.

◆ select()

void rig::select ( entt::entity entity,
bool selected = true )

Mark an entity selected (CSelection).

The present path strokes a bounds overlay around selected entities.

◆ setEcs()

void rig::setEcs ( rigkit::MEcs * ecs)

Bind the ECS that the bare creators write to.

rigComponent::setup() binds the host ECS, so apps rarely call this. Pass nullptr to unbind.

See also
currentEcs