Class ContactForceVisualizer#

Inheritance Relationships#

Base Type#

Class Documentation#

class ContactForceVisualizer : public Karana::Core::Base#

Visualize the contact forces created by a PenaltyContact KModel.

The frame provided is the frame the vectors will be drawn in.

Public Functions

ContactForceVisualizer(std::string_view name, const kc::ks_ptr<kf::Frame> &frame, const kc::ks_ptr<ks::ProxyScene> &scene, const kc::ks_ptr<kmo::PenaltyContact> &penalty_contact)#

ContactForceVisualizer constructor. The constructor is not meant to be called directly. Please use the create(…) method instead to create an instance.

Parameters:
  • name – Name of the visualizer.

  • frame – The Frame where the vectors will be drawn in.

  • scene – The ProxyScene to add the vectors to.

  • penalty_contact – The PenaltyContact model to get the contact vectors from.

float getRadius()#

Get the radius of the vectors.

Returns:

The radius of the vectors.

void setRadius(float radius)#

Set the radius of the vectors.

Parameters:

radius – The new radius of the vectors.

ks::Color getColor()#

Get the color of the vectors.

Returns:

The color of the vectors.

void setColor(ks::Color color)#

Set the color of the vectors.

Parameters:

color – The new color of the vectors.

double getScale()#

Get the current scale.

Returns:

The current scale.

void setScale(double scale)#

Set the current scale.

Parameters:

scale – The current scale.

void registerCallback()#

Register the callback with the scene.

void unregisterCallback()#

Unregister the callback with the scene.

Public Static Functions

static kc::ks_ptr<ContactForceVisualizer> create(std::string_view name, const kc::ks_ptr<kf::Frame> &frame, const kc::ks_ptr<ks::ProxyScene> &scene, const kc::ks_ptr<kmo::PenaltyContact> &penalty_contact)#

Create a new instance of ContactForceVisualizer.

Parameters:
  • name – Name of the visualizer.

  • frame – The Frame where the vectors will be drawn in.

  • scene – The ProxyScene to add the vectors to.

  • penalty_contact – The PenaltyContact model to get the contact vectors from.

Returns:

A pointer to the newly created ContactForceVisualizer.

Protected Functions

arrow &_lookupOrCreateArrow()#

Get an arrow from the inactive pool, or create a new one if all arrows are currently active.

Returns:

An arrow to use for visualizing.

Protected Attributes

ks::Color _color = ks::Color::RED#

The color of the vector.

float _radius = 0.075f#

The radius of the vector.

double _radius_ratio = 1.0#

The scalar to use when setting the scale of the vector.

km::Vec3 _start_offset = {0.0, 0.0, 0.0}#

The starting offset of the vector.

std::vector<arrow> _arrows#

A vector of arrows.

Each consists of the ProxyScene node the arrow is attached to, the rod of the arrow, and the tip of the arrow.

size_t _active_arrow_index = 0#

In _arrows, values to the left of this (from begin() to begin() + index) are inactive and values to the right are active. Another way to say this is this index points to a node that is active, and it is the first active node in the list. Everything at this index and later is active.

bool _callback_registered = false#

Whether or not the callback has been registered with the scene.

std::string _callback_name#

The name of the scene callback.

std::weak_ptr<ks::ProxyScene> _scene#

A pointer to the ProxyScene.

double _scale = 1.0#

The scale to use for the vector.

kc::ks_ptr<kf::Frame> _frame#

The Frame used to draw arrows from.

kc::ks_ptr<kmo::PenaltyContact> _penalty_contact#

The PenaltyContact model use to get the contact node pairs.