Skip to content

Primitives

JC Luna edited this page Mar 27, 2026 · 3 revisions

Up to date for Platform 0.46.2

Written by JC Luna.


Primitives

Primitives are simple shapes which can be used in Space Teams PRO to create various volumetric visualizations. When created, they exist in the simulation as an entity and are able to be manipulated through the typical entity-specific means.

Contents

Primitive Types

  1. Boxes
  2. Spheres
  3. Cones
  4. Cylinders

Primitive Parameters

Note that the specific names vary by implementation language.

Common

  • Color
    • DoubleV4
    • The color of the primitive, in RGBA space.
    • Defaults to opaque red: (255, 0, 0, 1).
  • Fidelity
    • Integer
    • Unitless number that affects the quality of the primitive. Affects the smoothness of curved objects, for example.
    • Defaults to 32.

Shape-Specific

  • Length, Width, and Depth
    • Double
    • Boxes: This size of the box is along its x, y, or z-axis, respectively.
    • Defaults to one kilometer.
  • Radius
    • Double
    • Spheres: The radius of sphere.
    • Cones: The radius of the flat circle of the cone.
    • Cylinders: The radius of the flat circle of the cone.
    • Defaults to one kilometer.
  • Height
    • Double
    • Cones: The height of the cone. This is along its z-axis.
    • Cylinders: The height of the cylinder. This is along its z-axis.
  • Cone Closedness
    • Boolean
    • Cones: Whether or not the flat circle of the cone is rendered.
    • Defaults to true.

C++

At a Glance

  • Header File: Visualization/Primitives.h
  • Namespace: spaceteams::vis::primitives
    • Key Members of This Namespace
      • params::InitParams and its subclasses
      • PrimitiveType
      • CreatePrimitive()

Detailed Explanation

Visualization/Primitives.h is the easiest way to gain access to primitives alone. To create a primitive, use one of the overloads of CreatePrimitive() that use:

  1. A primitive-specific parameters struct
  2. A spaceteams::SimGlobals::AddEntityFromConfig()-like interface

Once created, the standard parameter modification operations for entities can be performed on primitives. Specific parameter keys are found as members of the spaceteams::vis::primitives::params.

Example

The following example produces a translucent green sphere roughly encompassing the Moon, with implementation details regarding the acquisition of a reference to the Moon abstracted away.

using namespace spaceteams;

vis::primitives::params::SphereParams inits;
inits.Color = SC_DoubleV4(0.0, 1.0, 0.0, 0.5);
inits.Radius = 1.2 * constants::MoonMeanRadius;

SC_EntityRef sphereRef = vis::primitives::CreatePrimitive(inits);
Entity::owned sphere = sphereRef.lock<Entity>();

frames::Frame::owned mci = Entity::GetBodyFixedFrame(moonCenteredInertial)
sphere->setResidentFrame(mci);
sphere->setLocation(Eigen::Vector3d::Zero(), mci);

Python

At a Glance

  • Module: spaceteams.vis.primitives
  • Key Members of This Module:
    • PrimitiveType
    • CreatePrimitive()

Detailed Explanation

A convenient interface with out of order keyword arguments is the method for creating primitives in Python. The return type of CreatePrimitive() is an entity that can be manipulated by the typical means.

Example

The following example produces a translucent green sphere roughly encompassing the Moon, with implementation details regarding the acquisition of a reference to the Moon abstracted away, again.

primit = st.vis.primitives

# sphere passed as 1.2 times the Moon's mean radius, in kilometers
sphere = primit.CreatePrimitive(primit.PrimitiveType.Sphere,
    color = [0.0, 1.0, 0.0, 0.5],
    radius = 1.2 * 1737.1)

mci = moonCenteredInertial.GetBodyFixedFrame()
sphere.setResidentFrame(mci)
sphere.setLocation(st.frames.FramedLoc([0, 0, 0], mci))

Example Result

Translucent green sphere enveloping the Moon

Clone this wiki locally