1 | #ifndef NX_COLLISION_NXUSERCONTACTREPORT
|
---|
2 | #define NX_COLLISION_NXUSERCONTACTREPORT
|
---|
3 | /*----------------------------------------------------------------------------*\
|
---|
4 | |
|
---|
5 | | Public Interface to NovodeX Technology
|
---|
6 | |
|
---|
7 | | www.novodex.com
|
---|
8 |
|
---|
9 | \*----------------------------------------------------------------------------*/
|
---|
10 | /** \addtogroup physics
|
---|
11 | @{
|
---|
12 | */
|
---|
13 |
|
---|
14 | #include "Nxp.h"
|
---|
15 | #include "NxShape.h"
|
---|
16 | #include "NxContactStreamIterator.h"
|
---|
17 |
|
---|
18 | class NxActor;
|
---|
19 |
|
---|
20 | #if NX_USE_FLUID_API
|
---|
21 | class NxFluid;
|
---|
22 | #endif
|
---|
23 |
|
---|
24 | /**
|
---|
25 | \brief Contact pair flags.
|
---|
26 |
|
---|
27 | @see NxUserContactReport.onContactNotify()
|
---|
28 | */
|
---|
29 | enum NxContactPairFlag
|
---|
30 | {
|
---|
31 | NX_IGNORE_PAIR = (1<<0), //!< Disable contact generation for this pair
|
---|
32 |
|
---|
33 | NX_NOTIFY_ON_START_TOUCH = (1<<1), //!< Pair callback will be called when the pair starts to be in contact
|
---|
34 | NX_NOTIFY_ON_END_TOUCH = (1<<2), //!< Pair callback will be called when the pair stops to be in contact
|
---|
35 | NX_NOTIFY_ON_TOUCH = (1<<3), //!< Pair callback will keep getting called while the pair is in contact
|
---|
36 | NX_NOTIFY_ON_IMPACT = (1<<4), //!< [Not yet implemented] pair callback will be called when it may be appropriate for the pair to play an impact sound
|
---|
37 | NX_NOTIFY_ON_ROLL = (1<<5), //!< [Not yet implemented] pair callback will be called when the pair is in contact and rolling.
|
---|
38 | NX_NOTIFY_ON_SLIDE = (1<<6), //!< [Not yet implemented] pair callback will be called when the pair is in contact and sliding (and not rolling).
|
---|
39 |
|
---|
40 | NX_NOTIFY_ALL = (NX_NOTIFY_ON_START_TOUCH|NX_NOTIFY_ON_END_TOUCH|NX_NOTIFY_ON_TOUCH|NX_NOTIFY_ON_IMPACT|NX_NOTIFY_ON_ROLL|NX_NOTIFY_ON_SLIDE)
|
---|
41 | };
|
---|
42 |
|
---|
43 | /**
|
---|
44 | \brief An instance of this class is passed to NxUserContactReport::onContactNotify().
|
---|
45 | It contains a contact stream which may be parsed using the class NxContactStreamIterator.
|
---|
46 |
|
---|
47 | @see NxUserContactReport.onContactNotify()
|
---|
48 | */
|
---|
49 | class NxContactPair
|
---|
50 | {
|
---|
51 | public:
|
---|
52 | NX_INLINE NxContactPair() : stream(NULL) {}
|
---|
53 |
|
---|
54 | /**
|
---|
55 | \brief the two actors that make up the pair.
|
---|
56 |
|
---|
57 | @see NxActor
|
---|
58 | */
|
---|
59 | NxActor* actors[2];
|
---|
60 |
|
---|
61 | /**
|
---|
62 | \brief use this to create stream iter. See #NxContactStreamIterator.
|
---|
63 |
|
---|
64 | @see NxConstContactStream
|
---|
65 | */
|
---|
66 | NxConstContactStream stream;
|
---|
67 |
|
---|
68 | /**
|
---|
69 | \brief the total contact normal force that was applied for this pair, to maintain nonpenetration constraints.
|
---|
70 | */
|
---|
71 | NxVec3 sumNormalForce;
|
---|
72 |
|
---|
73 | /**
|
---|
74 | \brief the total tangential force that was applied for this pair.
|
---|
75 | */
|
---|
76 | NxVec3 sumFrictionForce;
|
---|
77 | };
|
---|
78 |
|
---|
79 | /**
|
---|
80 | \brief The user needs to implement this interface class in order to be notified when
|
---|
81 | certain contact events occur.
|
---|
82 |
|
---|
83 | Once you pass an instance of this class to #NxScene::setUserContactReport(),
|
---|
84 | its #onContactNotify() method will be called for each pair of actors which comes into contact,
|
---|
85 | for which this behavior was enabled.
|
---|
86 |
|
---|
87 | You request which events are reported using NxScene::setActorPairFlags(),
|
---|
88 | #NxScene::setShapePairFlags(), or #NxScene::getActorGroupPairFlags()
|
---|
89 |
|
---|
90 | <b>Threading:</b> It is not necessary to make this class thread safe as it will only be called in the context of the
|
---|
91 | user thread.
|
---|
92 |
|
---|
93 | <h3>Example</h3>
|
---|
94 |
|
---|
95 | \include NxUserContactReport_Example.cpp
|
---|
96 |
|
---|
97 | <h3>Visulizations:</h3>
|
---|
98 | \li #NX_VISUALIZE_CONTACT_POINT
|
---|
99 | \li #NX_VISUALIZE_CONTACT_NORMAL
|
---|
100 | \li #NX_VISUALIZE_CONTACT_ERROR
|
---|
101 | \li #NX_VISUALIZE_CONTACT_FORCE
|
---|
102 |
|
---|
103 | @see NxScene.setUserContactReport() NxScene.getUserNotify()
|
---|
104 | */
|
---|
105 | class NxUserContactReport
|
---|
106 | {
|
---|
107 | public:
|
---|
108 | /**
|
---|
109 | Called for a pair in contact. The events parameter is a combination of:
|
---|
110 |
|
---|
111 | <ul>
|
---|
112 | <li>NX_NOTIFY_ON_START_TOUCH,</li>
|
---|
113 | <li>NX_NOTIFY_ON_END_TOUCH,</li>
|
---|
114 | <li>NX_NOTIFY_ON_TOUCH,</li>
|
---|
115 | <li>NX_NOTIFY_ON_IMPACT, //unimplemented!</li>
|
---|
116 | <li>NX_NOTIFY_ON_ROLL, //unimplemented!</li>
|
---|
117 | <li>NX_NOTIFY_ON_SLIDE, //unimplemented!</li>
|
---|
118 | </ul>
|
---|
119 |
|
---|
120 | See the documentation of #NxContactPairFlag for an explanation of each. You request which events
|
---|
121 | are reported using #NxScene::setActorPairFlags() or
|
---|
122 | #NxScene::setActorGroupPairFlags(). Do not keep a reference to the passed object, as it will
|
---|
123 | be invalid after this function returns.
|
---|
124 |
|
---|
125 | \param[in] pair The contact pair we are being notified of. See #NxContactPair.
|
---|
126 | \param[in] events Flags raised due to the contact. See #NxContactPairFlag.
|
---|
127 |
|
---|
128 | <b>Platform:</b>
|
---|
129 | \li PC SW: Yes
|
---|
130 | \li PPU :
|
---|
131 | \li PS3 : Yes
|
---|
132 | \li XB360: Yes
|
---|
133 |
|
---|
134 | @see NxContactPair NxContactPairFlag
|
---|
135 | */
|
---|
136 | virtual void onContactNotify(NxContactPair& pair, NxU32 events) = 0;
|
---|
137 | };
|
---|
138 |
|
---|
139 | #if NX_USE_FLUID_API
|
---|
140 |
|
---|
141 | enum NxFluidContactPairFlag
|
---|
142 | {
|
---|
143 | NX_FPF_IGNORE_PAIR = (1<<0), //!< Not available in the current release. Disable contact generation for this pair
|
---|
144 | NX_FPF_NOTIFY_ON_COLLISION = (1<<1), //!< Not available in the current release. Pair callback will be called when the pair collides
|
---|
145 | };
|
---|
146 |
|
---|
147 | /**
|
---|
148 | \warning <b>Not available in the current release. </b>
|
---|
149 | \brief An instance of this class is passed to NxUserFluidContactReport::onContactNotify().
|
---|
150 |
|
---|
151 | It contains a contact stream which may be parsed using the class NxContactStreamIterator.
|
---|
152 | */
|
---|
153 | class NxFluidContactPair
|
---|
154 | {
|
---|
155 | public:
|
---|
156 | NX_INLINE NxFluidContactPair() : stream(NULL) {}
|
---|
157 |
|
---|
158 | NxFluid* fluid;
|
---|
159 | NxActor* actor;
|
---|
160 | NxConstContactStream stream;
|
---|
161 | };
|
---|
162 |
|
---|
163 | /**
|
---|
164 | \brief The user needs to implement this interface class in order to be notified when
|
---|
165 | certain fluid actor contact events occur.
|
---|
166 |
|
---|
167 | Once you pass an instance of this class to NxScene::setUserFluidContactReport(),
|
---|
168 | its onContactNotify() method will be called for each pair of actors which comes
|
---|
169 | into contact, for which this behavior was enabled.
|
---|
170 |
|
---|
171 | You request which events are reported using NxPhysicsSDK::getFluidGroupPairFlags()
|
---|
172 |
|
---|
173 | <b>Threading:</b> It is not necessary to make this class thread safe as it will only be called in the context of the
|
---|
174 | user thread.
|
---|
175 | */
|
---|
176 | class NxUserFluidContactReport
|
---|
177 | {
|
---|
178 | public:
|
---|
179 | /**
|
---|
180 | \brief Called for a pair in contact.
|
---|
181 |
|
---|
182 | The events parameter is at the moment always NX_NOTIFY_ON_COLLISION:
|
---|
183 |
|
---|
184 | NX_NOTIFY_ON_COLLISION,
|
---|
185 |
|
---|
186 | See the documentation of NxFluidContactPairFlag for an explanation of each. You request which events
|
---|
187 | are reported using NxScene::setActorPairFlags(), NxScene::setShapePairFlags(), or
|
---|
188 | NxPhysicsSDK::getActorGroupPairFlags(). Do not keep a reference to the passed object, as it will
|
---|
189 | be invalid after this function returns.
|
---|
190 |
|
---|
191 | \param[in] pair Fluid contact pair.
|
---|
192 | \param[in] events See #NxContactPairFlag.
|
---|
193 |
|
---|
194 | <b>Platform:</b>
|
---|
195 | \li PC SW: Yes
|
---|
196 | \li PPU :
|
---|
197 | \li PS3 : No
|
---|
198 | \li XB360:
|
---|
199 | */
|
---|
200 | virtual void onContactNotify(NxFluidContactPair& pair, NxU32 events) = 0;
|
---|
201 | };
|
---|
202 |
|
---|
203 | #endif
|
---|
204 |
|
---|
205 | /**
|
---|
206 | \brief The user needs to implement this interface class in order to be notified when trigger events
|
---|
207 | occur.
|
---|
208 |
|
---|
209 | Once you pass an instance of this class to #NxScene::setUserTriggerReport(), shapes
|
---|
210 | which have been marked as triggers using NxShape::setFlag(NX_TRIGGER_ENABLE,true) will call the
|
---|
211 | #onTrigger() method when their trigger status changes.
|
---|
212 |
|
---|
213 | <b>Threading:</b> It is not necessary to make this class thread safe as it will only be called in the context of the
|
---|
214 | user thread.
|
---|
215 |
|
---|
216 | Example:
|
---|
217 |
|
---|
218 | \include NxUserTriggerReport_Usage.cpp
|
---|
219 |
|
---|
220 | <h3>Visualizations</h3>
|
---|
221 | \li NX_VISUALIZE_COLLISION_SHAPES
|
---|
222 |
|
---|
223 | @see NxScene.setUserTriggerReport() NxScene.getUserTriggerReport() NxShapeFlag NxShape.setFlag()
|
---|
224 | */
|
---|
225 | class NxUserTriggerReport
|
---|
226 | {
|
---|
227 | public:
|
---|
228 | /**
|
---|
229 | \brief Called when a trigger shape reports a trigger event.
|
---|
230 |
|
---|
231 | \param[in] triggerShape is the shape that has been marked as a trigger.
|
---|
232 | \param[in] otherShape is the shape causing the trigger event.
|
---|
233 | \param[in] status is the type of trigger event.
|
---|
234 |
|
---|
235 | <b>Platform:</b>
|
---|
236 | \li PC SW: Yes
|
---|
237 | \li PPU :
|
---|
238 | \li PS3 : Yes
|
---|
239 | \li XB360: Yes
|
---|
240 |
|
---|
241 | @see NxTriggerFlag
|
---|
242 | */
|
---|
243 | virtual void onTrigger(NxShape& triggerShape, NxShape& otherShape, NxTriggerFlag status) = 0;
|
---|
244 | };
|
---|
245 |
|
---|
246 | /** @} */
|
---|
247 | #endif
|
---|
248 |
|
---|
249 |
|
---|
250 | //AGCOPYRIGHTBEGIN
|
---|
251 | ///////////////////////////////////////////////////////////////////////////
|
---|
252 | // Copyright © 2005 AGEIA Technologies.
|
---|
253 | // All rights reserved. www.ageia.com
|
---|
254 | ///////////////////////////////////////////////////////////////////////////
|
---|
255 | //AGCOPYRIGHTEND
|
---|
256 |
|
---|