AGXDynamics
2.35.0.2
agxSDK/PickHandler.h
Go to the documentation of this file.
1
/*
2
Copyright 2007-2022. Algoryx Simulation AB.
3
4
All AGX source code, intellectual property, documentation, sample code,
5
tutorials, scene files and technical white papers, are copyrighted, proprietary
6
and confidential material of Algoryx Simulation AB. You may not download, read,
7
store, distribute, publish, copy or otherwise disseminate, use or expose this
8
material unless having a written signed agreement with Algoryx Simulation AB, or having been
9
advised so by Algoryx Simulation AB for a time limited evaluation, or having purchased a
10
valid commercial license from Algoryx Simulation AB.
11
12
Algoryx Simulation AB disclaims all responsibilities for loss or damage caused
13
from using this software, unless otherwise stated in written agreements with
14
Algoryx Simulation AB.
15
*/
16
17
#pragma once
18
19
#include <
agx/agxPhysics_export.h
>
20
#include <
agxSDK/GuiEventListener.h
>
21
22
#include <
agxCollide/Geometry.h
>
23
#include <
agx/Constraint.h
>
24
#include <
agxCollide/LocalContactPoint.h
>
25
26
namespace
agx
27
{
28
class
DistanceJoint;
29
class
BallJoint;
30
class
LockJoint;
31
}
32
33
namespace
agxSDK
34
{
35
// class to handle events with a pick
36
class
AGXPHYSICS_EXPORT
PickHandler
:
public
agxSDK::GuiEventListener
37
{
38
public
:
39
// Old interface
40
virtual
PickResult
pick
(
float
/*screenX*/
,
float
/*screenY*/
) {
return
PickResult
(); };
41
42
public
:
43
PickHandler
();
44
45
virtual
void
addNotification();
46
virtual
void
removeNotification();
47
56
virtual
bool
attachBody(
const
agx::Vec3
& worldPoint,
agx::RigidBody
*body,
bool
useLock =
false
,
bool
updateRotation =
false
);
57
58
bool
attachGeometry(
const
agx::Vec3
& worldPoint,
agxCollide::Geometry
*geometry,
bool
useLock =
false
);
59
64
virtual
bool
updateAttachment(
const
agx::Vec3
& mousePositionWorld);
65
67
bool
playbackMode()
const
;
68
70
virtual
void
reset();
71
73
agx::RigidBody
*getRigidBody();
74
75
agxCollide::Geometry
*getAttachedGeometry();
76
77
79
agx::Vec3
getCurrentWorldMousePoint()
const
;
80
82
agx::Vec3
getWorldAttachmentPoint()
const
;
83
84
85
bool
isActive()
const
;
86
87
protected
:
88
virtual
~
PickHandler
();
89
91
bool
validate(
agx::RigidBody
*body);
92
94
agx::Vec3
getLocalAttachmentPoint()
const
;
95
96
void
calculateComplianceAndDamping(
agx::DistanceJoint
* constraint,
agx::RigidBody
* rb );
97
void
calculateComplianceAndDamping(
agx::BallJoint
* constraint,
agx::RigidBody
* rb );
98
void
calculateComplianceAndDamping(
agx::LockJoint
* constraint,
agx::RigidBody
* rb );
99
100
protected
:
101
102
agx::RigidBodyRef
m_rigidBody
;
103
agxCollide::GeometryRef
m_geometry
;
104
agx::ConstraintRef
m_constraint
;
105
106
bool
m_updateRotation
;
107
108
109
struct
PickedParticle
110
{
111
PickedParticle
() {}
112
PickedParticle
(
agx::Physics::ParticlePtr
p) : particle(p), material(p.material()), color(p.color()) {}
113
114
agx::Physics::ParticlePtr
particle
;
115
agx::Physics::MaterialPtr
material
;
116
agx::Vec4f
color
;
117
};
118
agx::Physics::ParticlePtr
m_particle
;
119
120
agx::Vector<PickedParticle>
m_particleSet
;
121
agx::MaterialRef
m_particleMaterial
;
122
123
private
:
124
125
126
agx::Vec3
m_initialMousePointWorld;
127
agx::Vec3
m_currentMousePointWorld;
128
agx::Vec3
m_worldAttachmentPoint;
129
agx::Vec3
m_localAttachmentPoint;
130
agx::Quat
m_oldBodyRotation;
131
132
agx::FrameRef
m_constraintWorldFrame;
133
agx::FrameRef
m_constraintBodyFrame;
134
135
agx::ComponentRef
m_mouseComponent;
136
agxData::ValueRef
m_pickAttachmentPoint;
137
agxData::ValueRef
m_pickHandlePoint;
138
agxData::ValueRef
m_isPicking;
139
};
140
141
typedef
agx::ref_ptr<PickHandler>
PickHandlerRef
;
142
143
}
144
agxPhysics_export.h
agxSDK::PickResult
Definition:
agxSDK/GuiEventListener.h:31
agxSDK::GuiEventListener
Derive from this class to implement a listener for simulation GuiEvents.
Definition:
agxSDK/GuiEventListener.h:51
agx::Vector
Templated vector class.
Definition:
Vector.h:52
agx::RigidBody
The rigid body class, combining a geometric model and a frame of reference.
Definition:
RigidBody.h:54
agxSDK::PickHandler::PickedParticle::particle
agx::Physics::ParticlePtr particle
Definition:
agxSDK/PickHandler.h:114
agxSDK::PickHandler::PickedParticle::color
agx::Vec4f color
Definition:
agxSDK/PickHandler.h:116
Constraint.h
Geometry.h
agxSDK::PickHandler::PickedParticle::PickedParticle
PickedParticle(agx::Physics::ParticlePtr p)
Definition:
agxSDK/PickHandler.h:112
agx::Physics::MaterialPtr
Pointer to a entity instance of type Physics.Material.
Definition:
MaterialEntity.h:190
agx::Vec4T
A class holding 4 dimensional vectors and providing basic arithmetic.
Definition:
Vec4Template.h:34
agxSDK::PickHandler::m_particleMaterial
agx::MaterialRef m_particleMaterial
Definition:
agxSDK/PickHandler.h:121
agx
The agx namespace contains the dynamics/math part of the AGX Dynamics API.
Definition:
AddedMassInteraction.h:22
AGXPHYSICS_EXPORT
#define AGXPHYSICS_EXPORT
agxSDK::PickHandler::pick
virtual PickResult pick(float, float)
Definition:
agxSDK/PickHandler.h:40
agxSDK::PickHandler::PickedParticle::PickedParticle
PickedParticle()
Definition:
agxSDK/PickHandler.h:111
agxSDK::PickHandler::m_rigidBody
agx::RigidBodyRef m_rigidBody
Definition:
agxSDK/PickHandler.h:102
agxSDK::PickHandler::m_particle
agx::Physics::ParticlePtr m_particle
Definition:
agxSDK/PickHandler.h:118
agx::Physics::ParticlePtr
Pointer to a entity instance of type Physics.Particle.
Definition:
ParticleEntity.h:292
agx::ref_ptr< RigidBody >
agxSDK::PickHandler
Definition:
agxSDK/PickHandler.h:36
LocalContactPoint.h
GuiEventListener.h
agxSDK::PickHandler::m_updateRotation
bool m_updateRotation
Definition:
agxSDK/PickHandler.h:106
agxCollide::Geometry
The geometry representation used by the collision detection engine.
Definition:
Geometry.h:92
agx::LockJoint
Constraint that removes all 6 DOF between two bodies, or one body and the world.
Definition:
LockJoint.h:28
agx::QuatT< Real >
agx::BallJoint
Constraint that removes the three translation DOF between two bodies (or one and the world).
Definition:
BallJoint.h:47
agxSDK::PickHandler::PickedParticle
Definition:
agxSDK/PickHandler.h:109
agxSDK::PickHandler::m_constraint
agx::ConstraintRef m_constraint
Definition:
agxSDK/PickHandler.h:104
agxSDK::PickHandler::PickedParticle::material
agx::Physics::MaterialPtr material
Definition:
agxSDK/PickHandler.h:115
agxSDK::PickHandlerRef
agx::ref_ptr< PickHandler > PickHandlerRef
Definition:
agxSDK/PickHandler.h:141
agxSDK
The agxSDK namespace contain classes to bridge the collision detection system and the dynamical simul...
Definition:
Constraint.h:30
agx::DistanceJoint
This joint will preserve the initial distance between a body and a point in world coordinate or betwe...
Definition:
DistanceJoint.h:27
agx::Vec3T< Real >
agxSDK::PickHandler::m_particleSet
agx::Vector< PickedParticle > m_particleSet
Definition:
agxSDK/PickHandler.h:120
agxSDK::PickHandler::m_geometry
agxCollide::GeometryRef m_geometry
Definition:
agxSDK/PickHandler.h:103
include
agxSDK
PickHandler.h
Generated on Mon Jan 30 2023 15:44:18 for AGXDynamics by
1.8.17