@@ -91,55 +91,6 @@ SimTK::ContactGeometry ContactGeometry::createSimTKContactGeometry() const
9191 return createSimTKContactGeometryImpl ();
9292}
9393
94- // =============================================================================
95- // VISUALIZATION
96- // =============================================================================
97- void ContactGeometry::generateDecorations (
98- bool fixed,
99- const ModelDisplayHints& hints,
100- const SimTK::State& s,
101- SimTK::Array_<SimTK::DecorativeGeometry>& geometry) const {
102- Super::generateDecorations (fixed, hints, s, geometry);
103- generateDecorationsImpl (fixed, hints, s, geometry);
104- }
105-
106- void ContactGeometry::generateDecorationsImpl (
107- bool fixed,
108- const ModelDisplayHints& hints,
109- const SimTK::State& s,
110- SimTK::Array_<SimTK::DecorativeGeometry>& geometry) const {
111- // There is no fixed geometry to generate here.
112- if (fixed) { return ; }
113-
114- // Model-wide hints indicate that contact geometry shouldn't be shown.
115- if (!hints.get_show_contact_geometry ()) { return ; }
116-
117- // The decoration has been toggled off by its `Appearance` block.
118- if (!get_Appearance ().get_visible ()) { return ; }
119-
120- // Create a SimTK::DecorativeGeometry object for this ContactGeometry.
121- SimTK::DecorativeGeometry decoration =
122- createSimTKContactGeometry ().createDecorativeGeometry ();
123-
124- // B: base Frame (Body or Ground)
125- // F: PhysicalFrame that this ContactGeometry is connected to
126- // P: the frame defined (relative to F) by the location and orientation
127- // properties defined in ContactGeometry.
128- // D: the frame defined (relative to P) by the decoration's location and
129- // orientation properties defined by the SimTK::DecorativeGeometry object.
130- const auto & X_BF = getFrame ().findTransformInBaseFrame ();
131- const auto & X_FP = getTransform ();
132- const auto & X_PD = decoration.getTransform ();
133- const auto X_BD = X_BF.compose (X_FP).compose (X_PD);
134- geometry.push_back (decoration
135- .setScale (1 )
136- .setTransform (X_BD)
137- .setRepresentation (get_Appearance ().get_representation ())
138- .setBodyId (getFrame ().getMobilizedBodyIndex ())
139- .setColor (get_Appearance ().get_color ())
140- .setOpacity (get_Appearance ().get_opacity ()));
141- }
142-
14394// =============================================================================
14495// OBJECT INTERFACE
14596// =============================================================================
@@ -264,6 +215,43 @@ SimTK::ContactGeometry ContactSphere::createSimTKContactGeometryImpl() const
264215 return SimTK::ContactGeometry::Sphere (get_radius ());
265216}
266217
218+ void ContactSphere::generateDecorations (
219+ bool fixed,
220+ const ModelDisplayHints& hints,
221+ const SimTK::State& s,
222+ SimTK::Array_<SimTK::DecorativeGeometry>& geometry) const {
223+
224+ // There is no fixed geometry to generate here.
225+ if (fixed) { return ; }
226+
227+ // Model-wide hints indicate that contact geometry shouldn't be shown.
228+ if (!hints.get_show_contact_geometry ()) { return ; }
229+
230+ // The decoration has been toggled off by its `Appearance` block.
231+ if (!get_Appearance ().get_visible ()) { return ; }
232+
233+ // Create a SimTK::DecorativeSphere object for this ContactSphere.
234+ SimTK::DecorativeSphere decoration (get_radius ());
235+
236+ // B: base Frame (Body or Ground)
237+ // F: PhysicalFrame that this ContactGeometry is connected to
238+ // P: the frame defined (relative to F) by the location and orientation
239+ // properties defined in ContactGeometry.
240+ // D: the frame defined (relative to P) by the decoration's location and
241+ // orientation properties defined by the SimTK::DecorativeGeometry object.
242+ const auto & X_BF = getFrame ().findTransformInBaseFrame ();
243+ const auto & X_FP = getTransform ();
244+ const auto & X_PD = decoration.getTransform ();
245+ const auto X_BD = X_BF.compose (X_FP).compose (X_PD);
246+ geometry.push_back (decoration
247+ .setScale (1 )
248+ .setTransform (X_BD)
249+ .setRepresentation (get_Appearance ().get_representation ())
250+ .setBodyId (getFrame ().getMobilizedBodyIndex ())
251+ .setColor (get_Appearance ().get_color ())
252+ .setOpacity (get_Appearance ().get_opacity ()));
253+ }
254+
267255// =============================================================================
268256// CONTACT CYLINDER
269257// =============================================================================
@@ -303,6 +291,46 @@ SimTK::ContactGeometry ContactCylinder::createSimTKContactGeometryImpl() const
303291 return SimTK::ContactGeometry::Cylinder (get_radius ());
304292}
305293
294+ void ContactCylinder::generateDecorations (
295+ bool fixed,
296+ const ModelDisplayHints& hints,
297+ const SimTK::State& s,
298+ SimTK::Array_<SimTK::DecorativeGeometry>& geometry) const {
299+
300+ // There is no fixed geometry to generate here.
301+ if (fixed) { return ; }
302+
303+ // Model-wide hints indicate that contact geometry shouldn't be shown.
304+ if (!hints.get_show_contact_geometry ()) { return ; }
305+
306+ // The decoration has been toggled off by its `Appearance` block.
307+ if (!get_Appearance ().get_visible ()) { return ; }
308+
309+ // Create a SimTK::DecorativeCylinder object for this ContactCylinder.
310+ SimTK::DecorativeCylinder decoration (get_radius (), get_radius ()*2 );
311+ // SimTK::DecorativeCylinder's axis is defined as the y-axis,
312+ // whereas SimTK::ContactGeometry::Cylinder axis is defined as the z-axis.
313+ decoration.setTransform (SimTK::Rotation (SimTK::Pi/2 , SimTK::XAxis));
314+
315+ // B: base Frame (Body or Ground)
316+ // F: PhysicalFrame that this ContactGeometry is connected to
317+ // P: the frame defined (relative to F) by the location and orientation
318+ // properties defined in ContactGeometry.
319+ // D: the frame defined (relative to P) by the decoration's location and
320+ // orientation properties defined by the SimTK::DecorativeGeometry object.
321+ const auto & X_BF = getFrame ().findTransformInBaseFrame ();
322+ const auto & X_FP = getTransform ();
323+ const auto & X_PD = decoration.getTransform ();
324+ const auto X_BD = X_BF.compose (X_FP).compose (X_PD);
325+ geometry.push_back (decoration
326+ .setScale (1 )
327+ .setTransform (X_BD)
328+ .setRepresentation (get_Appearance ().get_representation ())
329+ .setBodyId (getFrame ().getMobilizedBodyIndex ())
330+ .setColor (get_Appearance ().get_color ())
331+ .setOpacity (get_Appearance ().get_opacity ()));
332+ }
333+
306334// =============================================================================
307335// CONTACT ELLIPSOID
308336// =============================================================================
@@ -343,6 +371,43 @@ SimTK::ContactGeometry ContactEllipsoid::createSimTKContactGeometryImpl() const
343371 return SimTK::ContactGeometry::Ellipsoid (get_radii ());
344372}
345373
374+ void ContactEllipsoid::generateDecorations (
375+ bool fixed,
376+ const ModelDisplayHints& hints,
377+ const SimTK::State& s,
378+ SimTK::Array_<SimTK::DecorativeGeometry>& geometry) const {
379+
380+ // There is no fixed geometry to generate here.
381+ if (fixed) { return ; }
382+
383+ // Model-wide hints indicate that contact geometry shouldn't be shown.
384+ if (!hints.get_show_contact_geometry ()) { return ; }
385+
386+ // The decoration has been toggled off by its `Appearance` block.
387+ if (!get_Appearance ().get_visible ()) { return ; }
388+
389+ // Create a SimTK::DecorativeEllipsoid object for this ContactEllipsoid.
390+ SimTK::DecorativeEllipsoid decoration (get_radii ());
391+
392+ // B: base Frame (Body or Ground)
393+ // F: PhysicalFrame that this ContactGeometry is connected to
394+ // P: the frame defined (relative to F) by the location and orientation
395+ // properties defined in ContactGeometry.
396+ // D: the frame defined (relative to P) by the decoration's location and
397+ // orientation properties defined by the SimTK::DecorativeGeometry object.
398+ const auto & X_BF = getFrame ().findTransformInBaseFrame ();
399+ const auto & X_FP = getTransform ();
400+ const auto & X_PD = decoration.getTransform ();
401+ const auto X_BD = X_BF.compose (X_FP).compose (X_PD);
402+ geometry.push_back (decoration
403+ .setScale (1 )
404+ .setTransform (X_BD)
405+ .setRepresentation (get_Appearance ().get_representation ())
406+ .setBodyId (getFrame ().getMobilizedBodyIndex ())
407+ .setColor (get_Appearance ().get_color ())
408+ .setOpacity (get_Appearance ().get_opacity ()));
409+ }
410+
346411// =============================================================================
347412// CONTACT TORUS
348413// =============================================================================
@@ -395,3 +460,41 @@ SimTK::ContactGeometry ContactTorus::createSimTKContactGeometryImpl() const
395460{
396461 return SimTK::ContactGeometry::Torus (get_torus_radius (), get_tube_radius ());
397462}
463+
464+ void ContactTorus::generateDecorations (
465+ bool fixed,
466+ const ModelDisplayHints& hints,
467+ const SimTK::State& s,
468+ SimTK::Array_<SimTK::DecorativeGeometry>& geometry) const {
469+
470+ // There is no fixed geometry to generate here.
471+ if (fixed) { return ; }
472+
473+ // Model-wide hints indicate that contact geometry shouldn't be shown.
474+ if (!hints.get_show_contact_geometry ()) { return ; }
475+
476+ // The decoration has been toggled off by its `Appearance` block.
477+ if (!get_Appearance ().get_visible ()) { return ; }
478+
479+ // Create a SimTK::DecorativeTorus object for this ContactTorus.
480+ SimTK::DecorativeGeometry decoration =
481+ createSimTKContactGeometry ().createDecorativeGeometry ();
482+
483+ // B: base Frame (Body or Ground)
484+ // F: PhysicalFrame that this ContactGeometry is connected to
485+ // P: the frame defined (relative to F) by the location and orientation
486+ // properties defined in ContactGeometry.
487+ // D: the frame defined (relative to P) by the decoration's location and
488+ // orientation properties defined by the SimTK::DecorativeGeometry object.
489+ const auto & X_BF = getFrame ().findTransformInBaseFrame ();
490+ const auto & X_FP = getTransform ();
491+ const auto & X_PD = decoration.getTransform ();
492+ const auto X_BD = X_BF.compose (X_FP).compose (X_PD);
493+ geometry.push_back (decoration
494+ .setScale (1 )
495+ .setTransform (X_BD)
496+ .setRepresentation (get_Appearance ().get_representation ())
497+ .setBodyId (getFrame ().getMobilizedBodyIndex ())
498+ .setColor (get_Appearance ().get_color ())
499+ .setOpacity (get_Appearance ().get_opacity ()));
500+ }
0 commit comments