Tutorials written in the language C++

This page describes the tutorials written in C++. Each source file might contain several scenes. The different scenes can be selected with keys '1'..'0'. It is also possible to toggle scene using '-'and '+'.

The executables for each tutorial can be found in the <agx-install-path>\bin\<build-mode>\tutorial*.exe

Where <agx-install-path> is something like: c:\Program Files\Algoryx\AgX-2.0..0, and <build-mode> can be either x86 or x64 depending on which version of AGX that is installed.

Keybindings and arguments for agxViewer

Some of the tutorials might have several scenes. Remember that buttons 1..0 can be used to switch between different scenes

agxTerrain: How to model deformable terrain.

Demonstrates how to:

  • Setup and use the agxTerrain::Terrain class which is a generic deformable terrain simulating soil mechanics.

Source code: tutorial_agxTerrain.cpp

Basic simulation

Demonstrates how to create a simulation, stepping a system and choosing solver.

Source code: tutorial_basicSimulation.cpp

Creating and manipulating bodies

Demonstrates how to:

  • Add/remove bodies, geometries to a simulation.
  • Set linear/angular velocity on bodies.
  • Set mass properties: mass/inertia.
  • Demonstrates the use of model/CM coordinate systems.
  • Create bodies with multiple geometries.
  • Use agx::Frame to tranform vectors and points
  • Use ForceFields to affect bodies.

Source code: tutorial_bodies.cpp

Modelling cables using the agxCable API

Demonstrates how to:

  • Create and route a cable.
  • Attach cable to objects.
  • Set cable properties.
  • Inspect dynamic state.
  • Control initialization.
  • Detect cable collisions.
  • Attach objects on initialized cable.

Source code: tutorial_cable.cpp

Modelling cables together with Wind and Water

This tutorial illustrates how to achieve wind/water effects together with cables.

Demonstrates how to:

  • Specify wind/water properties for a cable

Source code: tutorial_cableWindAndWater.cpp

Modelling damage on a cable

Demonstrate how to use the cable damage class in the cable module to estimate damage inflicted on a cable during simulation.

Source code: tutorial_cable_damage.cpp

Modelling a basic car

Demonstrates how to model a basic car with four wheels.

Source code: tutorial_car.cpp

Demonstrates mesh collision detection

Using Constraints

Demonstrates how to:

  • Create and use various constraints available in AGX: Distance, BallJoint, CylindricalJoint, Hinge, Prismatic, LockJoint

Source code: tutorial_constraints.cpp

Reading contact forces

Demonstrates how to read contact forces

Source code: tutorial_contactForces.cpp

Creating oriented bounding volume

Demonstrates how to create oriented boxes, cylinders and capsules from a set of vertices.

Source code: tutorial_create_oriented_bounding_volume.cpp

Building Custom Constraints: Design your own constraint.

Demonstrates how to:

  • Create your own specialized constraint.

Source code: tutorial_customConstraints.cpp

Custom MergeSplitHandler : Speed up your system

Use your own code to decide when bodies should be merged/split

Demonstrates how to:

Modelling a Drivetrain

This tutorial show how to build various drive train system with shafts, gears and engines

Source code: tutorial_driveTrain.cpp

Modelling a Combustion engine

This tutorial show use the combustion engine model

Source code: tutorial_driveTrain_combustionEngine.cpp

Modelling an electric motor

This tutorial show use the electric motor model

Source code: tutorial_driveTrain_ElectricMotor.cpp

Measuring energy using the EnergyManager

This tutorial show use EnergyManager to measure energy in the system

Source code: tutorial_energyManager.cpp

Breaking objects using fracture

This tutorial show how to model fracturing objects.

Source code: tutorial_fracture.cpp

Using Friction models: Control the frictional contacts.

Demonstrates how to:

  • Specify solver type for frictional constraints
  • Calculate and specify direction for frictional constraints.

Source code: tutorial_frictionModels.cpp

Using gravity models

Demonstrates how to:

  • Create a Uniform Gravity field
  • Create a Point Gravity Field.
  • Derive from CustomGravityField in order to create a general custom made gravity field

Source code: tutorial_gravityFields.cpp

Modelling Hydraulic systems

The Hydraulics API can be used for modelling a hydraulics system.

Demonstrates how to:

  • Setup a hydraulics system
  • Connect hydraulics through a constraint
  • Connect hydraulics to a motor, clutch, gear box and external torques.

Source code: tutorial_hydraulics.cpp

Hydraulics coupling

This tutorial show a coupled simulation with an external engine and propeller connected to the hydraulics system

Demonstrates how to:

  • Setup a hydraulics system
  • Connect an external simulation to the hydraulics API

Source code: tutorial_hydraulics_coupling.cpp

Modelling Hydrodynamics

The Hydrodynamics API can be used to model both hydrodynamic and aerodynamic effects

Demonstrates how to:

  • Specify an object to be affected by hydrodynamic forces: lift, drag, buyoancy.
  • Specify wind and wind effects
  • Connect an external simulation to AGX exemplified with hydrodynamics

Source code: tutorial_hydrodynamics.cpp

Reading/writing files

Demonstrates how to:

  • Create HeightField mesh from image (.png) files.
  • Serialize/deserialize simulation data to files.

Source code: tutorial_io.cpp

EventListeners: inject user code.

Demonstrates how to:

  • Listen to Keyboard events.
  • Listen to Contact events.
  • Listen to Step events.

Source code: tutorial_listeners.cpp

Using materials

Demonstrates how to:

  • Assign material to geometries.
  • Set bulk and surface material properties to change restitution and friction.
  • Create explicit contact material to get full control over the simulation result.
  • Set surface velocity to simulate conveyor belt behaviour.

Source code: tutorial_material.cpp

MergedBody : Speed up your system

Learn how to explicitly create and handle agx::MergedBody to reduce complexity of large systems.

Demonstrates how to:

  • Create MergedBodies
  • Add/remove agx::RigidBody to reduce/expand simulation systems.
  • Source code: tutorial_mergedBody.cpp

MergeSplitHandler : Speed up your system

Learn how to use the MergeSplitHandler to automatically merge/split large systems.

Demonstrates how to:

  • Create MergedBodies
  • Register MergedBodies with the MergeSplitHandler for automatic merge/split functionality
  • Source code: tutorial_mergeSplitHandler.cpp

Using the Particle system

The particle system can collide with it self and other geometries. It can be considered to be a collection of spheres solved with an iterative solver. The scalability of a particle system is however a lot better than with ordinary 6DOF rigid bodies.

Demonstrates how to:

  • Create and manipulate particles
  • Create and control an emitter
  • Set attributes such as lifetime and velocity.

Source code: tutorial_particleSystem.cpp

Using the a RigidBodyEmitter

A RigidBodyEmitter can be used to emit rigid bodies.

Source code: tutorial_rigidBodyEmitter.cpp

How to access statistics data from simulation

agx::Statistics can be used to read various statistics data.

Source code: tutorial_statistics.cpp

How to use the terrain pager and handle load/unload events

Demonstrates how to use the terrain pager and how to catch events.

Source code: tutorial_terrainPager_tileEvents.cpp

Managing threads in AGX Dynamics

This tutorial demonstrates how to create and manage custom threads in an AGX Dynamics environment

Demonstrates how to:

  • Create custom threads
  • Register/unregister threads to AGX Dynamics

Source code: tutorial_threads.cpp

Locking threads to cores: ThreadAffinity

This tutorial demonstrates how lock threads to run onto specific cores on a multi core CPU

Source code: tutorial_threadAffinity.cpp

Modelling a vehicle with tires

This tutorial demonstrates how to create a vehicle using the various tire models available in AGX.

Source code: tutorial_tire.cpp

Trimesh: How to create and use the Triangle mesh (concave) shape.

Demonstrates how to:

  • Create a Triangle mesh from Code
  • Create a Triangle mesh from a (.obj) file
  • Traverse triangle mesh data to trace contours etc.

Source code: tutorial_trimesh.cpp

Modelling a Tracked vehicle/crawler

agxVehicle::Track, agxVehicle::TrackWheel, agxVehicle::TrackNode are classes for building a tracked vehicle aka. crawler.

Demonstrates how to:

  • Create rollers, idlers and sprockets (driving wheels)
  • Create track objects of varying shape

Source code: tutorial_trackedVehicle.cpp

Modelling Wind effects

The Hydrodynamics/Aerodynamics API can be used to model both hydrodynamic and aerodynamic effects

Demonstrates how to:

  • Specify an object to be affected by aerodynamic forces: lift, drag.
  • Specify wind and wind effects

Source code: tutorial_wind.cpp

Modelling wires

agxWire::Wire is an implementation of the lumped element model with varying resolution. It will give stable and scalable simulations for large mass ratios. Together with the wire are a set of classes for simulating wires, controlling friction etc.

Demonstrates how to:

  • Create and use the agxWire::Wire class.
  • Create and control a winch (WinchController)
  • Render an agxWire

Source code: tutorial_wire1.cpp

Connecting wires with WireLinks

WireLinks can be used to build composite wires which can be winched in and out. This allows for complex wire scenarios.

Demonstrates how to:

  • Create multiple wires and connect them with WireLinks
  • Winch in and out composite wires

Source code: tutorial_wireLink.cpp