Project Chrono: chrono::ChVisualShape Class Reference

Public Member Functions | Protected Member Functions | Protected Attributes | Friends | List of all members
chrono::ChVisualShape Class Reference
Chrono::Engine » Visual asset objects

## 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:
[legend]

## Public Member Functions
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.
ChColor | GetColor () const
| Return the diffuse color of the first material in the list of materials for this shape.
void | SetOpacity (float val)
| Set opacity for this shape (0: fully transparent; 1: fully opaque).
float | GetOpacity () const
| Get opacity of the first material in the list of materials for this shape.
void | SetTexture (const std::string &filename, float scale_x=1, float scale_y=1)
| Set the diffuse texture map for this shape.
std::string | GetTexture () const
| Return the diffuse texture map of the first material in the list of materials for this shape.
void | SetMutable (bool val)
| Set this visualization shape as modifiable (default: false for primitive shapes, true otherwise).
bool | IsMutable () const
| Return true if the visualization shape is marked as modifiable.
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.
std::vector< std::shared_ptr< ChVisualMaterial > > & | GetMaterials ()
| Get the list of visualization materials.
std::shared_ptr< ChVisualMaterial > | GetMaterial (int i)
| Get the specified material in the list.
unsigned int | GetNumMaterials () const
| Get the number of visualization materials.
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.

## Protected Member Functions
virtual void | Update (ChPhysicsItem *updater, const ChFrame<> &frame)
| Update this visual shape with information for the owning physical object.

## Protected Attributes
bool | visible
| shape visibility flag
bool | is_mutable
| flag indicating whether the shape is rigid or deformable
std::vector< std::shared_ptr< ChVisualMaterial > > | material_list
| list of visualization materials

## Friends
class | ChVisualModel

## Member Function Documentation

## ◆ ArchiveIn()

void chrono::ChVisualShape::ArchiveIn | ( | ChArchiveIn & | archive_in | ) |
| virtual

Method to allow de-serialization of transient data from archives.

Reimplemented in chrono::cascade::ChVisualShapeCascade, chrono::ChGlyphs, chrono::ChVisualShapeBarrel, chrono::ChVisualShapeBox, chrono::ChVisualShapeCapsule, chrono::ChVisualShapeCone, chrono::ChVisualShapeCylinder, chrono::ChVisualShapeEllipsoid, chrono::ChVisualShapeLine, chrono::ChVisualShapeModelFile, chrono::ChVisualShapePath, chrono::ChVisualShapeRoundedBox, chrono::ChVisualShapeRoundedCylinder, chrono::ChVisualShapeSphere, chrono::ChVisualShapeSurface, and chrono::ChVisualShapeTriangleMesh.

## ◆ ArchiveOut()

void chrono::ChVisualShape::ArchiveOut | ( | ChArchiveOut & | archive_out | ) |
| virtual

Method to allow serialization of transient data to archives.

Reimplemented in chrono::cascade::ChVisualShapeCascade, chrono::ChGlyphs, chrono::ChVisualShapeBarrel, chrono::ChVisualShapeBox, chrono::ChVisualShapeCapsule, chrono::ChVisualShapeCone, chrono::ChVisualShapeCylinder, chrono::ChVisualShapeEllipsoid, chrono::ChVisualShapeLine, chrono::ChVisualShapeModelFile, chrono::ChVisualShapePath, chrono::ChVisualShapeRoundedBox, chrono::ChVisualShapeRoundedCylinder, chrono::ChVisualShapeSphere, chrono::ChVisualShapeSurface, and chrono::ChVisualShapeTriangleMesh.

## ◆ 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).

## ◆ 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 for primitive shapes, true otherwise).

Set to false to indicate that the asset never changes and therefore does not require updates (e.g. for a non-deformable triangular mesh). Note that this also includes changes in materials. A particular 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 | ( | ChPhysicsItem * | updater,
|  | const ChFrame<> & | frame )
| inlineprotectedvirtual

Update this visual shape with information for the owning physical object.

Since a visual shape can be shared in multiple instances, this function may be called with different updaters.

Reimplemented in chrono::ChVisualShapePointPoint, and chrono::ChVisualShapeRotSpring.

The documentation for this class was generated from the following files:

- D:/W/B/src/chrono-9.0.1/src/chrono/assets/ChVisualShape.h
- D:/W/B/src/chrono-9.0.1/src/chrono/assets/ChVisualShape.cpp