-
Notifications
You must be signed in to change notification settings - Fork 1
Primitives
Written by JC Luna.
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.
- Boxes
- Spheres
- Cones
- Cylinders
Note that the specific names vary by implementation language.
- 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.
- 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.
- Header File:
Visualization/Primitives.h - Namespace:
spaceteams::vis::primitives- Key Members of This Namespace
-
params::InitParamsand its subclasses PrimitiveTypeCreatePrimitive()
-
- Key Members of This Namespace
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:
- A primitive-specific parameters struct
- 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.
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);- Module:
spaceteams.vis.primitives - Key Members of This Module:
PrimitiveTypeCreatePrimitive()
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.
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))