Assets represent optional objects that can be attached to rigid bodies to provide access to information/data such as:

  • Visualization shapes
  • Custom user-defined data such as electric charge, costs, sounds, etc.


The ChAsset class is the base class for all types of assets. See chrono::ChAsset for API details.

Example: a custom-defined asset is introduced below to illustrate a case in which a user attaches 'electrical charge' to a rigid body.

// First declare a class inherited from ChAsset:
class ElectricParticleProperty: public ChAsset
// Data for this type of asset
double charge;
// Default constructor with initialization
charge = 0;
// Create an asset object of ElectricParticleProperty type
ChSharedPtr<ElectricParticleProperty> electric_asset(new ElectricParticleProperty);
electric_asset->charge = 100;
// ..and attach it to a body:

Example: selecting all the assets of a certain type.

for (unsigned int na= 0; na<abody->GetAssets().size(); na++)
auto myasset = abody->GetAssetN(na);
if (std::shared_ptr<ElectricParticleProperty> electricasset = std::dynamic_pointer_cast<ElectricParticleProperty>(myasset))
// Do things with the electricasset, for instance

Visualization shapes

There are many ready-to-use assets that define visualization shapes. Note that multiple visualization shapes can be attached to one body.

Chrono is rendering engine agnostic. Indeed, if the IRRLICHT module is used, it is up to the Irrlicht module to convert the visualization assets into something that can be rendered in the OpenGL view of Irrlicht. Likewise, if the POSTPROCESSING module is used instead, this unit is expected to convert the visualization assets into scripts with shapes for the POVray or some other rendering tool.

Visualization assets are inherited from a base class called ChVisualization. See chrono::ChVisualization for API details.

Each shape has a translation and a rotation defined with respect to the REF reference of the owner body. Note that this is not the COG frame, as shown in the figure below.

Examples of visualization assets:

  • ChSphereShape
  • ChBoxShape
  • ChCylinderShape
  • ChEllipsoidShape
  • ChConeShape
  • ChCapsuleShape

A special type of visualization asset is the ChAssetLevel. An object of this type does not represent a shape. Rather, it can contain other visualization assets as a group. This allows the creation of hierarchical models. When rotating or translating a ChAssetLevel object, all the shapes associated with that object are moved/rotated.

Other special assets are:

  • ChColorAsset
  • ChTexture

They affect all the assets belonging to the same level by coloring/texturing them.


// Assume that a body_b is already available at this point. Demonstrate how to add a box.
auto mbox = std::make_shared<ChBoxShape>();
mbox->GetBoxGeometry().Pos = ChVector<>(0,-1,0);
mbox->GetBoxGeometry().Size = ChVector<>(10,0.5,10);
//Example: add a texture
auto mtexture = std::make_shared<ChTexture>;
// Example: add a mesh via an .obj file
auto mobjmeshfile = std::make_shared<ChObjShapeFile>();
// Example: add a mesh with triangle data
auto mobjmesh = std::make_shared<ChTriangleMeshShape>();


See also:

  • demo_irr_assets.cpp