raisim::InstancedVisuals
struct · #include <raisim/server/Visuals.hpp>
Many visual-only instances of one shape, drawn with per-instance pose, scale and a color interpolated between color1 and color2. Create with RaisimServer::addInstancedVisuals(); the server owns it. Instance ids are indices into the instance array (0 .. count()-1); ids are not checked.
Constructors & destructor
InstancedVisuals
InstancedVisuals(
Shape::Type type,
std::string name,
const Vec<3> &size,
const Vec<4> &color1,
const Vec<4> &color2)Normally called by RaisimServer::addInstancedVisuals().
Parameters
| Parameter | Description |
|---|---|
type (in) | shape of every instance |
name (in) | name used by the server |
size (in) | base size of an instance (same convention as Visuals::size) |
color1 (in) | color at weight 0 |
color2 (in) | color at weight 1 |
Public member functions
count
size_t count()Returns the number of instances
clearInstances
void clearInstances()clear the instances
resize
void resize(size_t numberOfObjects)Resize the instance array. Every instance (including existing ones) is reset to identity orientation and the base size; new instances start at the origin with color weight 0.
Parameters
| Parameter | Description |
|---|---|
numberOfObjects (in) | new number of instances |
addInstance
void addInstance(
const Eigen::Vector3d &pos,
const Eigen::Vector4d &ori,
const Eigen::Vector3d &scale,
float colorWeight=0.f)Parameters
| Parameter | Description |
|---|---|
pos (in) | position of the visual object in Eigen::Vector3d. |
ori (in) | quaternion of the visual object in Eigen::Vector4d. |
scale (in) | per-axis multiplier applied to the base size. |
colorWeight (in) | the final color is an weighted average of color1 and color2 add a new instance of the specified pose |
void addInstance(
const Eigen::Vector3d &pos,
const Eigen::Vector4d &ori,
float colorWeight=0.f)Parameters
| Parameter | Description |
|---|---|
pos (in) | position of the visual object in Eigen::Vector3d. |
ori (in) | quaternion of the visual object in Eigen::Vector4d. |
colorWeight (in) | the final color is an weighted average of color1 and color2 add a new instance of the specified pose |
void addInstance(const Eigen::Vector3d &pos, float colorWeight=0.f)Parameters
| Parameter | Description |
|---|---|
pos (in) | position of the visual object in Eigen::Vector3d. |
colorWeight (in) | the final color is a weighted average of color1 and color2 add a new instance of the specified position and an identity rotation |
removeInstance
void removeInstance(size_t id)Remove a single instance by moving the last instance into its slot (the order is not preserved; the former last instance now has this id).
Parameters
| Parameter | Description |
|---|---|
id (in) | instance id |
setPosition
void setPosition(size_t id, const Eigen::Vector3d &pos)Parameters
| Parameter | Description |
|---|---|
id (in) | instance id. |
pos (in) | position of the visual object in Eigen::Vector3d. set the position of the specified instance of the visual object. |
setOrientation
void setOrientation(size_t id, const Eigen::Vector4d &ori)Parameters
| Parameter | Description |
|---|---|
id (in) | instance id. |
ori (in) | quaternion of the visual object in Eigen::Vector4d. set the orientation of the specified instance of the visual object. |
setScale
void setScale(size_t id, const Eigen::Vector3d &scale)Parameters
| Parameter | Description |
|---|---|
id (in) | instance id. |
scale (in) | absolute per-axis size of the instance (not multiplied by the base size). set the scale of the specified instance of the visual object. |
setColor
void setColor(const Vec<4> &color1, const Vec<4> &color2)Parameters
| Parameter | Description |
|---|---|
color1 (in) | first color. |
color2 (in) | second color. The color of the instance is interpolated between the two colors. 100% color1 when weight is 0. |
setColorWeight
void setColorWeight(size_t id, float weight)Parameters
| Parameter | Description |
|---|---|
id (in) | instance id |
weight (in) | the color weight The actual color is linearly interpolated between color1 and color2 which are set by setColor method. 100% color1 when weight is 0. |
getPosition
Eigen::Vector3d getPosition(size_t id)Parameters
| Parameter | Description |
|---|---|
id (in) | instance id. |
Returns the position of the specified instance.
getOrientation
Eigen::Vector4d getOrientation(size_t id)Parameters
| Parameter | Description |
|---|---|
id (in) | instance id. |
Returns the orientation of the specified instance as a quaternion (w, x, y, z).
getScale
Eigen::Vector3d getScale(size_t id)Parameters
| Parameter | Description |
|---|---|
id (in) | instance id. |
Returns the absolute per-axis size of the specified instance.
lockMutex
void lockMutex()Lock this instanced visual's mutex. The server holds it while serializing this instanced visual, so lock it while modifying the instanced visual from another thread. Same as lock().
lock
void lock()Lock the mutex (BasicLockable interface for std::lock_guard / std::unique_lock).
try_lock
bool try_lock()Returns true if the mutex was acquired without blocking (Lockable interface).
unlockMutex
void unlockMutex()Unlock the mutex locked by lockMutex(). Same as unlock().
unlock
void unlock()Unlock the mutex (BasicLockable interface).