17 #ifndef AGXMODEL_WINDANDWATERCONTROLLER_H
18 #define AGXMODEL_WINDANDWATERCONTROLLER_H
330 void lock()
const { m_mutex.lock(); };
335 void unLock()
const { m_mutex.unlock(); };
354 mutable std::mutex m_mutex;
363 : node1( nullptr ), node2( nullptr ), water( nullptr ), gravity(
agx::
Vec3() )
367 : node1( node1 ), node2( node2 ), water( water ), gravity( gravity )
389 : rb( rb ), point1( point1 ), point2( point2 ), velocity( velocity ), velocityOfFluid( velocityOfFluid ),
390 fluidDensity( fluidDensity ), gravity( gravity ), volume(volume)
488 size_t numWaterSegments{0};
489 size_t numAirSegments{0};
765 : shape( shapeIn ), mesh( meshIn )
769 virtual void checkSize(
agx::Real resolution ) = 0;
775 virtual ~PrimitiveData() {}
778 struct CapsuleData : PrimitiveData
781 : PrimitiveData( shapeIn, meshIn ), radius( radiusIn ), height( heightIn )
785 virtual void checkSize(
agx::Real resolution )
override;
791 virtual ~CapsuleData() {}
794 struct ConeData : PrimitiveData
797 : PrimitiveData( shapeIn, meshIn ), topRadius( topRadiusIn ), bottomRadius( bottomRadiusIn ),
802 virtual void checkSize(
agx::Real resolution )
override;
809 virtual ~ConeData() {}
812 struct HollowConeData : PrimitiveData
817 : PrimitiveData( shapeIn, meshIn ), topOuterRadius( topOuterRadiusIn ),
818 bottomInnerRadius( bottomInnerRadiusIn ), height( heightIn ), thickness( thicknessIn )
822 virtual void checkSize(
agx::Real resolution )
override;
830 virtual ~HollowConeData() {}
833 struct HollowCylinderData : PrimitiveData
836 : PrimitiveData( shapeIn, meshIn ), innerRadius( innerRadiusIn ), height( heightIn ),
837 thickness( thicknessIn )
841 virtual void checkSize(
agx::Real resolution )
override;
848 virtual ~HollowCylinderData() {}
861 mutable MeshContainer m_cache;
862 mutable PrimitiveContainer m_primitives;
864 mutable std::mutex meshCreationMutex;
1150 void setWaterGeometry(
agxCollide::Geometry* waterGeometry );
1157 return m_aeroParams;
1162 return m_hydroParams;
#define AGX_DECLARE_POINTER_TYPES(type)
#define AGXSTREAM_DECLARE_ABSTRACT_SERIALIZABLE(T)
Use this in a pure abstract Serializable class to add the required methods Important: Use full namesp...
#define AGXSTREAM_DECLARE_SERIALIZABLE(T)
Use this in a Serializable class to add the required methods Important: Use full namespace in the dec...
The geometry representation used by the collision detection engine.
Mesh is a common base class for triangle meshes, such as Mesh or HeightField.
Type
Define the type of a Shape.
This class contains all Geometries and performs Broad Phase and Narrow Phase collision detection to c...
Class to generate constant water flow in a scene.
void setVelocity(const agx::Vec3 &velocity)
Assign new water flow velocity.
virtual ~ConstantWaterFlowGenerator()
ConstantWaterFlowGenerator(const agx::Vec3 &velocity)
Construct given flow velocity.
ConstantWaterFlowGenerator()
const agx::Vec3 & getVelocity() const
Class to generate constant wind in a scene.
void setVelocity(const agx::Vec3 &velocity)
Assign new wind velocity.
ConstantWindGenerator(const agx::Vec3 &velocity)
Construct given wind velocity.
virtual ~ConstantWindGenerator()
const agx::Vec3 & getVelocity() const
Water wrapper that can be inherited to create custom made wrappers.
agx::Vec3 project(const agx::Vec3 &localPoint, const agx::Vec3 &localUpVector) const
Projects a point in local coordinate system onto the surface in local up direction.
const agxCollide::Geometry * getGeometry() const
const agxCollide::Shape * m_shape
virtual agx::Real findHeightFromSurface(const agx::Vec3 &worldPoint, const agx::Vec3 &upVector, const agx::TimeStamp &t) const
Finds height from surface given point in world.
const WindAndWaterController::WaterFlowGenerator * m_flowGenerator
const agxModel::WindAndWaterController::WaterFlowGenerator * getWaterFlowGenerator() const
agxCollide::GeometryConstObserver m_geometry
virtual agx::Bool isValid() const
agx::AffineMatrix4x4 m_worldToShape
virtual agx::Vec3 getVelocity(const agx::Vec3 &worldPoint) const
virtual agx::Real getDensity() const
WaterWrapper()
Default constructor.
agx::Real getDensity(agx::Bool belowSurface) const
agx::Real getDensity(const agxModel::VertexData &vData) const
agx::Bool & containsAddedMass()
Set to/is true if this data contains added mass and/or inertia.
agx::Vec3 & force()
Access force vector (in world coordinate system).
agx::Vec3 & torque()
Access torque vector (in world coordinate system).
void lock() const
Perform a mutex lock for this ObjectData.
agx::Real getDensityAir() const
const agx::RigidBody * getRigidBody() const
const agx::Vec3 & getTorque() const
const agxCollide::Shape * getShape() const
const agx::Matrix3x3 & getAddedMass() const
agx::UInt getStartIndexT() const
agxModel::PressureFieldRenderer * getPressureFieldRenderer() const
agx::Matrix3x3 & addedMass()
Access added mass matrix.
agx::Matrix3x3 & addedInertia()
Access added inertia matrix.
const WaterWrapper * getWater() const
const agx::Bool & containsAddedMass() const
ObjectData(const agxCollide::Shape *shape, const agxModel::AerodynamicsParameters *aeroParams, const agxModel::HydrodynamicsParameters *hydroParams, const agxModel::WaterWrapper *water, const agxModel::WindAndWaterController::WindWrapper *wind, const agx::Vec3 &gravity, agxModel::PressureFieldRenderer *pressureFieldRenderer, const agx::UInt numTriangles, const agx::UInt startIndexT, const agx::UInt startIndexV)
Construct given shape, parameters, wind and water definitions and gravity.
const agxCollide::Geometry * getGeometry() const
const agx::Vec3 & getGravity() const
const agx::Matrix3x3 & getAddedInertia() const
void unLock() const
Perform a mutex unlock for this ObjectData.
const agx::Vec3 & getForce() const
agx::Real getDensityWater() const
agx::RigidBody * getRigidBodySerial()
This method is unsafe to use if this object is used during parallel execution.
agx::UInt getNumTriangles() const
agx::Real getDensity(const agxModel::TriangleData &tData) const
const agxCollide::Mesh * getOrCreateMesh(const agxCollide::Shape *shape, agx::Vec3 &scale, agxModel::WindAndWaterParameters::ShapeTessellation tessellationLevel) const
static agx::Vec3 findScale(const agxCollide::Shape *shape)
Interface for generating water flow.
WaterFlowGenerator()
Default constructor disables serialization.
virtual ~WaterFlowGenerator()
Data for different objects.
const agxModel::HydrodynamicsParameters * getHydrodynamicsParameters() const
const HydrodynamicsParameters * m_hydroParams
WindAndWaterData(const agxModel::AerodynamicsParameters *aeroParams, const agxModel::HydrodynamicsParameters *hydroParams)
Constructor.
virtual ~WindAndWaterData()
const AerodynamicsParameters * m_aeroParams
Interface for generating water flow and wind.
virtual agx::Vec3 getVelocity(const agx::Vec3 &worldPoint) const
Calculate and return wind at a given position in world.
WindAndWaterFlowGenerator()
Default constructor disables serialization.
virtual ~WindAndWaterFlowGenerator()
Interface for generating wind effects.
virtual void prepare(const agxCollide::Geometry *geometry)
Called before update of geometry.
WindGenerator()
Default constructor disables serialization.
Wraps wind related things.
agx::Vec3 getVelocity(const agx::Vec3 &worldPoint) const
WindWrapper(agx::Bool enable, const agxModel::WindAndWaterController::WindGenerator *windGenerator, agx::Real airDensity)
Default constructor.
const WindGenerator * m_windGenerator
agx::Bool getEnable() const
agx::Real getDensity() const
Data for a wire or a linked structure.
WireLinkedStructureData(agx::Real radius, const AerodynamicsParameters *aeroParams, const HydrodynamicsParameters *hydroParams)
Constructor.
SegmentContainer & getWaterSegments()
virtual ~WireLinkedStructureData()
SegmentContainer & getAirSegments()
void addAirSegment(const Segment &segment)
Adds a segment of the wire that is affected by aerodynamics.
void addWaterSegment(const Segment &segment)
Adds a segment of the wire that is affected by hydrodynamics.
Controller that collects relevant data and executes algorithms (probably mostly aero- and hydrodynami...
agx::HashVector< const agxWire::Wire *, HydrodynamicsParametersRef > HydrodynamicsParametersWireContainer
agxModel::WindAndWaterController::DynamicsWireData calculateWireDynamicsData(const agxCollide::Geometry *waterGeometry, agxWire::Wire *wire)
Calculates forces for hydro- and aerodynamics acting on a wire.
AddedMassDbRef m_addedMassDb
agx::HashVector< const agxCollide::Geometry *, AerodynamicsDataRef > AerodynamicsDataContainer
agx::HashVector< const agxCollide::Shape *, PressureFieldRendererDataRef > PressureFieldRendererDataContainer
agx::Vector< WireLinkedStructureDataRef > WireLinkedStructureDataContainer
void setAirDensity(agx::Real airDensity)
Set the density of air.
virtual agxModel::WindAndWaterController::ObjectDataContainer calculateObjectData(const agxCollide::Geometry *waterGeometry, const agxCollide::Geometry *geometry, const agx::Vec3 &gravity, agx::Bool aeroEnabled, agx::Bool hydroEnabled, agx::Bool updateRenderers, agx::UInt &numProcessedTriangles, const agx::UIntVector startIndexT, const agx::UIntVector startIndexV, const agx::TimeStamp &t=0)
Calculate object data (for each shape) in a geometry.
agx::HashVector< const agxSDK::LinkedStructure *, HydrodynamicsParametersRef > HydrodynamicsParametersLinkedStructureContainer
agx::HashVector< const agxCollide::Geometry *, WaterFlowGeneratorRef > WaterFlowGeneratorContainer
agx::Vector< agxWire::WireObserver > WireObserverVector
agxModel::HydrodynamicsParameters * getOrCreateHydrodynamicsParameters(const agxWire::Wire *wire) const
Creates new or returns an already created parameter storage for a given wire.
virtual agx::Bool setEnableAerodynamics(agxWire::Wire *wire, agx::Bool enable)
Enable/disable a wire for aerodynamics calculations.
virtual void post(agxModel::WindAndWaterController *)
Called during normal post.
agx::Vector< Segment > SegmentContainer
agxModel::AerodynamicsParameters * getOrCreateAerodynamicsParameters(const agxWire::Wire *wire) const
Creates new or returns an already created parameter storage for a given wire.
GeometryConstObserverVector m_waterGeometries
AerodynamicsDataContainer m_aeroGeometries
virtual agx::Bool setWaterFlowGenerator(const agxCollide::Geometry *waterGeometry, agxModel::WindAndWaterController::WaterFlowGenerator *flowGenerator)
Assign unique water flow generator to a water geometry.
static agxModel::WindAndWaterControllerPtrVector findAll(const agxSDK::Simulation *simulation, const agx::Name &name)
Find all WindAndWaterControllers with given name.
virtual agx::Bool setEnableAerodynamics(agx::RigidBody *rb, agx::Bool enable)
Enable/disable all geometries in rb for aerodynamics calculations.
agxModel::HydrodynamicsParameters * getOrCreateHydrodynamicsParameters(const agxSDK::LinkedStructure *linkedStructure) const
Creates new or returns an already created parameter storage for a given linked structure.
AerodynamicsParametersRef m_globalAerodynamicsParameters
agx::Vector< ObjectDataRef > ObjectDataContainer
virtual agx::Bool addWater(agxCollide::Geometry *geometry)
Flag a geometry as water.
void configureDefaultAlgorithms()
Configure the default algorithms.
UnitPrimitiveCache m_unitPrimitiveCache
void getSizeOfGeometry(const agxCollide::Geometry *geometry, agx::UIntVector &numTriangles, agx::UIntVector &numVertices)
AlgorithmContainer m_algorithms
HydrodynamicsParametersWireContainer m_hydrodynamicsParametersWires
virtual void post(const agx::TimeStamp &) override
Internal method.
virtual agxModel::HydrodynamicsParameters * getOrCreateHydrodynamicsParameters(const agxCollide::Shape *shape) const
Creates new or returns an already created parameter storage for a given shape.
virtual ~WindAndWaterController()
Reference counted object, protected destructor.
static agxModel::WindAndWaterControllerPtrVector findAll(const agxSDK::Simulation *simulation)
Finds all WindAndWaterControllers in the given simulation.
agx::Vector< agxCollide::GeometryConstObserver > GeometryConstObserverVector
virtual agxModel::WindAndWaterController::DynamicsData calculateDynamicsData(const agxCollide::Geometry *waterGeometry, const agx::RigidBody *rb, const agx::Vec3 &gravity, const agxCollide::Space *space=nullptr, agx::Bool updateRenderers=false)
Calculates forces given water geometry (may be null) acting on a rigid body.
virtual void pre(agxModel::WindAndWaterController *)
Called before all data is collected and before updateInteraction is called.
agx::ref_ptr< WireLinkedStructureData > WireLinkedStructureDataRef
GlobalTriangleData::Container m_trianglePool
void garbageCollect()
Collects garbage (e.g., due to deleted shapes).
agxModel::WindAndWaterController::WireLinkedStructureData * calculateWireData(agxWire::Wire *wire, WirePairContainer wirePairs, WindAndWaterController::WindWrapper wind, agx::Bool aeroEnable, const agx::TimeStamp &t=0)
Calculate wire data for all segments.
agx::HashVector< const agxSDK::LinkedStructure *, AerodynamicsParametersRef > AerodynamicsParametersLinkedStructureContainer
virtual void setEnableAerodynamics(agx::Bool enable)
Enable/disable aerodynamics for all objects in the simulation.
virtual agx::Bool registerPressureFieldRenderer(agxModel::PressureFieldRenderer *pressureFieldRenderer, const agxCollide::Shape *shape)
Pressure field renderer for a given shape.
virtual agx::Bool setWaterWrapper(agxCollide::Geometry *geometry, agxModel::WaterWrapper *waterWrapper)
Assign a water wrapper to a water geometry;.
agxModel::WindAndWaterController::DynamicsLinkedStructureData calculateLinkedStructureDynamicsData(const agxCollide::Geometry *waterGeometry, agxSDK::LinkedStructure *linkedStructure, const agxCollide::Space *space)
Calculates forces for hydro- and aerodynamics acting on a linked structure.
agx::ref_ptr< PressureFieldRendererData > PressureFieldRendererDataRef
virtual void pre(const agx::TimeStamp &) override
Internal method.
static agxCollide::TrimeshRef createPrimitiveMesh(const agxCollide::Shape *shape, agxModel::WindAndWaterParameters::ShapeTessellation tessellation)
Create a mesh from a primitive shape given a tessellation level.
agxModel::WindAndWaterController::WaterFlowGenerator * getWaterFlowGenerator(const agxCollide::Geometry *waterGeometry) const
agx::HashVector< const agxCollide::Geometry *, WaterWrapperRef > WaterWrapperContainer
agx::ref_ptr< AerodynamicsData > AerodynamicsDataRef
agx::HashVector< const agxCollide::Shape *, HydrodynamicsParametersRef > HydrodynamicsParametersContainer
agx::HashVector< const agxWire::Wire *, AerodynamicsParametersRef > AerodynamicsParametersWireContainer
virtual void preCollide(const agx::TimeStamp &) override
Internal method.
WindAndWaterController()
Construct wind and water controller.
agxModel::WindAndWaterController::ObjectData ObjectData
static agxModel::WindAndWaterController * find(agxSDK::Simulation *simulation, const agx::Uuid &uuid)
Search the given simulation for a WindAndWaterController with the given Uuid.
virtual agxModel::AerodynamicsParameters * getOrCreateAerodynamicsParameters(const agxCollide::Shape *shape) const
Creates new or returns an already created parameter storage for a given shape.
agx::Bool setEnableAerodynamics(agxSDK::LinkedStructure *linkedStructure, agx::Bool enable)
Enable/disable a linked structure for aerodynamics calculations.
agx::Vector< WirePair > WirePairContainer
HydrodynamicsParametersLinkedStructureContainer m_hydrodynamicsParametersLinkedStructures
virtual void updateInteraction(agxModel::WindAndWaterController::ObjectData &, const GlobalTriangleData::Container &)
Called when it's time to update interaction.
WireObserverVector m_aeroWires
AerodynamicsParametersLinkedStructureContainer m_aerodynamicsParametersLinkedStructures
agx::ref_ptr< ObjectData > ObjectDataRef
PressureFieldRendererDataContainer m_pressureFieldRenderers
agx::HashVector< const agxCollide::Shape *, AerodynamicsParametersRef > AerodynamicsParametersContainer
agxModel::WindAndWaterController::PressureFieldRendererData * getPressureFieldRenderData(const agxCollide::Shape *shape) const
agxModel::WaterWrapper * getWaterWrapper(const agxCollide::Geometry *waterGeometry)
virtual agxModel::WindAndWaterController::WindGenerator * getWindGenerator() const
HydrodynamicsParametersRef m_globalHydrodynamicsParameters
agx::Vector< agxModel::WindAndWaterController::AlgorithmRef > AlgorithmContainer
VertexData::Container m_vertexPool
AerodynamicsParametersContainer m_aerodynamicsParameters
agxModel::AerodynamicsParameters * getOrCreateAerodynamicsParameters(const agxSDK::LinkedStructure *linkedStructure) const
Creates new or returns an already created parameter storage for a given linked structure.
agxModel::WindAndWaterController::WireLinkedStructureData * calculateLinkedStructureData(const agxCollide::Geometry *waterGeometry, const agxCollide::Geometry *geometry, const agx::Vec3 &gravity, const AerodynamicsParameters *aeroParams, const HydrodynamicsParameters *hydroParams, agx::Bool aeroEnabled, agx::Bool hydroEnabled, const agx::TimeStamp &t=0)
Calculate linked structure data for all segments.
WaterFlowGeneratorContainer m_flowGenerators
AerodynamicsParametersWireContainer m_aerodynamicsParametersWires
WindGeneratorRef m_windGenerator
WaterWrapperContainer m_waterWrappers
virtual agx::Bool setEnableAerodynamics(agxCollide::Geometry *geometry, agx::Bool enable)
Enable/disable a geometry for aerodynamics calculations.
virtual void setWindGenerator(agxModel::WindAndWaterController::WindGenerator *windGenerator)
Assign unique wind generator.
virtual void preCollide(agxModel::WindAndWaterController *)
Called during normal preCollide events.
HydrodynamicsParametersContainer m_hydrodynamicsParameters
agxModel::PressureFieldRenderer * getPressureFieldRender(const agxCollide::Shape *shape) const
ShapeTessellation
Tessellation levels of native, non-mesh shapes, e.g, sphere, capsule and cylinder.
Basic implementation of any structure where bodies are linked/constrained together in a well defined ...
Simulation is a class that bridges the collision space agxCollide::Space and the dynamic simulation s...
Derive from this class to implement a listener for simulation step events.
This class is an abstract base class for all classes that can be stored and retrieved from an Archive...
Class defining a node that is part of a wire.
Interface and placeholder of controllers/helpers for wires.
Inheritance with partial specialization due to bug with ref_ptr containers.
Representation of a name string.
Base class providing referencing counted objects.
The rigid body class, combining a geometric model and a frame of reference.
A UUID, or Universally unique identifier, is intended to uniquely identify information in a distribut...
Vector containing 'raw' data.
Smart pointer for handling referenced counted objects.
#define DOXYGEN_END_INTERNAL_BLOCK()
#define DOXYGEN_START_INTERNAL_BLOCK()
This namespace consists of a set of classes for handling geometric intersection tests including boole...
Contain classes for higher level modeling primitives, such as Tree, Terrain etc.
agx::Vector< WindAndWaterController * > WindAndWaterControllerPtrVector
agx::ref_ptr< WindAndWaterController > WindAndWaterControllerRef
The agx namespace contains the dynamics/math part of the AGX Dynamics API.
Vec3T< Real > Vec3
The object holding 3 dimensional vectors and providing basic arithmetic.
Triangle data for a normal or a clipped triangle.
Vertex data for all global vertices in a mesh.
agxCollide::GeometryConstObserver geometry
AerodynamicsData(const agxCollide::Geometry *geometryIn)
virtual ~AerodynamicsData()
Data for rigid body with aero/hydro static/dynamic forces and added mass and inertia matrices.
agx::Matrix3x3 bodyFrameAddedInertia
agx::Matrix3x3 bodyFrameAddedMass
void getAddedMassAndInertiaDiagonalCoefficients(const agx::RigidBody *rb, agx::Vec3 &addedMassDiagonalCoefficients, agx::Vec3 &addedInertiaDiagonalCoefficients) const
Calculate the diagonal coefficients given the added mass/inertia matrices have been calculated given ...
Hydro- and aerodynamic results for a linked structure.
DynamicsLinkedStructureData()
Hydro- and aerodynamic results for a wire.
agxModel::PressureFieldRendererRef pressureField
agxCollide::ShapeConstObserver shape
virtual ~PressureFieldRendererData()
Segment(agx::RigidBody *rb, agx::Vec3 point1, agx::Vec3 point2, agx::Vec3 velocity, agx::Vec3 velocityOfFluid, agx::Real fluidDensity, agx::Vec3 gravity, agx::Real volume)
agx::Vec3 velocityOfFluid
WirePair(agxWire::Node *node1, agxWire::Node *node2, const agxCollide::Geometry *water, agx::Vec3 gravity)
const agxCollide::Geometry * water