Description

Base class for a visualization asset for rendering (run-time or post processing).

Encapsulates basic information about the shape position, materials, and visibility.

#include <ChVisualShape.h>

Inheritance diagram for chrono::ChVisualShape:

Public Types

enum  Type {
  BARREL, BOX, CAPSULE, CONE,
  CYLINDER, DIE, ELLIPSOID, GLYPH,
  LINE, MODELFILE, PATH, ROUNDEDBOX,
  ROUNDEDCYL, SPHERE, SURFACE, TRIANGLEMESH,
  UNKNOWN_SHAPE
}
 Supported collision shape types.
 

Public Member Functions

Type GetType () const
 Return the shape type.
 
void SetVisible (bool mv)
 Set this visualization asset as visible.
 
bool IsVisible () const
 Return true if the asset is set as visible.
 
void SetColor (const ChColor &col)
 Set the diffuse color for this shape. More...
 
ChColor GetColor () const
 Return the diffuse color of the first material in the list of materials for this shape. More...
 
void SetOpacity (float val)
 Set opacity for this shape (0: fully transparent; 1: fully opaque). More...
 
float GetOpacity () const
 Get opacity of the first material in the list of materials for this shape. More...
 
void SetTexture (const std::string &filename, float scale_x=1, float scale_y=1)
 Set the diffuse texture map for this shape. More...
 
std::string GetTexture () const
 Return the diffuse texture map of the first material in the list of materials for this shape. More...
 
void SetMutable (bool val)
 Set this visualization shape as modifiable (default: false). More...
 
bool IsMutable () const
 Return true if the visualization shape is marked as modifiable.
 
void SetDoubleFaced (bool val)
 Set shape rendering as double-faced (default: false).
 
bool IsDoubleFaced () const
 Return true if the visualization shape must be rendered double-faced.
 
int AddMaterial (std::shared_ptr< ChVisualMaterial > material)
 Add a visualization material and return its index in the list of materials.
 
void SetMaterial (int i, std::shared_ptr< ChVisualMaterial > material)
 Replace the material with specified index. More...
 
std::vector< std::shared_ptr< ChVisualMaterial > > & GetMaterials ()
 Get the list of visualization materials.
 
std::shared_ptr< ChVisualMaterialGetMaterial (int i) const
 Get the specified material in the list.
 
unsigned int GetNumMaterials () const
 Get the number of visualization materials.
 
virtual ChAABB GetBoundingBox () const
 Get the shape bounding box. More...
 
virtual void ArchiveOut (ChArchiveOut &archive_out)
 Method to allow serialization of transient data to archives.
 
virtual void ArchiveIn (ChArchiveIn &archive_in)
 Method to allow de-serialization of transient data from archives.
 

Static Public Member Functions

static std::string GetTypeAsString (Type type)
 Return a string with the name of the given shape type (mainly for diagnostic messages).
 
static void ReportUnsupported (Type type, const std::string &backend)
 Report that a run-time visualization system cannot render the shape of given type. More...
 

Protected Member Functions

 ChVisualShape (Type type=Type::UNKNOWN_SHAPE)
 
virtual void Update (ChObj *updater, const ChFrame<> &frame)
 Update this visual shape with information for the owning object. More...
 

Protected Attributes

Type m_type
 type of the visual shape
 
bool is_visible
 shape visibility flag
 
bool is_mutable
 flag indicating whether the shape is rigid or deformable
 
bool is_double_faced
 flag indicating that the shape should be rendered double-faced
 
std::vector< std::shared_ptr< ChVisualMaterial > > material_list
 list of visualization materials
 

Friends

class ChVisualModel
 

Member Function Documentation

◆ GetBoundingBox()

◆ GetColor()

ChColor chrono::ChVisualShape::GetColor ( ) const

Return the diffuse color of the first material in the list of materials for this shape.

If no materials are defined, return the color of the default material.

◆ GetOpacity()

float chrono::ChVisualShape::GetOpacity ( ) const

Get opacity of the first material in the list of materials for this shape.

If no materials are defined, return the color of the default material.

◆ GetTexture()

std::string chrono::ChVisualShape::GetTexture ( ) const

Return the diffuse texture map of the first material in the list of materials for this shape.

If no materials are defined, return an empty string (no texture for the default material).

◆ ReportUnsupported()

void chrono::ChVisualShape::ReportUnsupported ( Type  type,
const std::string &  backend 
)
static

Report that a run-time visualization system cannot render the shape of given type.

The message is emitted only once per combination of shape type and rendering backend, so calling this from a per-shape dispatch loop does not flood the console.

◆ SetColor()

void chrono::ChVisualShape::SetColor ( const ChColor col)

Set the diffuse color for this shape.

This changes the color of the first material in the list of materials for this shape. If no materials are defined for a shape, one is first created by duplicating the default material.

◆ SetMaterial()

void chrono::ChVisualShape::SetMaterial ( int  i,
std::shared_ptr< ChVisualMaterial material 
)

Replace the material with specified index.

No-op if there is no material with given index.

◆ SetMutable()

void chrono::ChVisualShape::SetMutable ( bool  val)
inline

Set this visualization shape as modifiable (default: false).

Set to true to indicate that the asset may change and therefore requires updates (e.g. for a deformable triangular mesh). Note that this also includes changes in materials. A visualization system may take advantage of this setting to accelerate rendering.

◆ SetOpacity()

void chrono::ChVisualShape::SetOpacity ( float  val)

Set opacity for this shape (0: fully transparent; 1: fully opaque).

This changes the first material in the list of materials for this shape. If no materials are defined for a shape, one is first created by duplicating the default material.

◆ SetTexture()

void chrono::ChVisualShape::SetTexture ( const std::string &  filename,
float  scale_x = 1,
float  scale_y = 1 
)

Set the diffuse texture map for this shape.

This changes the texture of the first material in the list of materials for this shape. If no materials are defined for a shape, one is first created by duplicating the default material.

◆ Update()

virtual void chrono::ChVisualShape::Update ( ChObj updater,
const ChFrame<> &  frame 
)
inlineprotectedvirtual

The documentation for this class was generated from the following files:
  • /builds/uwsbel/chrono/src/chrono/assets/ChVisualShape.h
  • /builds/uwsbel/chrono/src/chrono/assets/ChVisualShape.cpp