Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow the user to hide the ellipsoid drawn by EllipsoidJoint::generateDecorations() #3445

Merged
merged 1 commit into from
May 4, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions OpenSim/Simulation/SimbodyEngine/EllipsoidJoint.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,10 @@ void EllipsoidJoint::constructProperties()
setAuthors("Ajay Seth");
SimTK::Vec3 radii(NaN);
constructProperty_radii_x_y_z(radii);

Appearance appearance;
appearance.set_visible(true);
constructProperty_Appearance(appearance);
}

//=============================================================================
Expand Down Expand Up @@ -176,6 +180,7 @@ void EllipsoidJoint::generateDecorations
// since this method is called with fixed={true, false}
if (!fixed) return;
// Construct the visible Ellipsoid
if (!get_Appearance().get_visible()) return;
SimTK::DecorativeEllipsoid ellipsoid(get_radii_x_y_z());
const OpenSim::PhysicalFrame& frame = getParentFrame();
ellipsoid.setColor(Vec3(0.0, 1.0, 1.0));
Expand Down
8 changes: 8 additions & 0 deletions OpenSim/Simulation/SimbodyEngine/EllipsoidJoint.h
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,9 @@ OpenSim_DECLARE_CONCRETE_OBJECT(EllipsoidJoint, Joint);
Rotation3Z = 2u ///< 2
};

OpenSim_DECLARE_UNNAMED_PROPERTY(Appearance,
"Default appearance attributes for this EllipsoidJoint");

private:
/** Specify the Coordinates of the EllipsoidJoint */
CoordinateIndex rx{ constructCoordinate(Coordinate::MotionType::Rotational,
Expand Down Expand Up @@ -120,6 +123,11 @@ OpenSim_DECLARE_CONCRETE_OBJECT(EllipsoidJoint, Joint);
//Set properties
void setEllipsoidRadii(const SimTK::Vec3& radii);

/** Turn on/off the ellipsoid drawn by generateDecorations(). */
void setEllipsoidVisible(bool visible) {
upd_Appearance().set_visible(visible);
};

/** Exposes getCoordinate() method defined in base class (overloaded below).
@see Joint */
using Joint::getCoordinate;
Expand Down