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

--Support multi-color gradient trajectories #1550

Merged
merged 4 commits into from
Oct 26, 2021

Conversation

jturner65
Copy link
Contributor

Interpolate a list of colors (in HSV space) of any length and map them to trajectory vertices; use vertex colors to render trajectory tube.

Motivation and Context

This PR introduces the ability to generate trajectories with color gradients by interpolating a given list of colors (in HSV space) to produce per-trajectory prim ring colors that are then assigned to the vertices of the trajectory. Any number of colors are supported, not just 2.

The existing functionality is still supported, but another functional binding has been added that supports the user specifying a list of Mn::Color3ub values to be used as the color interpolants. NOTE : the existing code supported the user specifying a single Mn::Color4 (which was a float color w/alpha) even though the alpha was ignored for this construct. A discussion should be had on whether we wish to refactor the old mechanism to support Color3ub, dispose of the old method entirely, or leave the old method (to not break existing code).

How Has This Been Tested

Local c++ and python tests pass; Viewer.cpp has been expanded to enable the user to request a single random color or a random number of multiple random colors (up to 5) to illustrate the functionality.

Types of changes

  • Docs change / refactoring / dependency upgrade
  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist

  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have read the CONTRIBUTING document.
  • I have completed my CLA (see CONTRIBUTING)
  • I have added tests to cover my changes.
  • All new and existing tests passed.

Interpolate a list of colors (in HSV space) of any length and map them to trajectory vertices; use vertex colors to render trajectory tube.
@facebook-github-bot facebook-github-bot added the CLA Signed Do not delete this pull request or issue due to inactivity. label Oct 25, 2021
@jturner65
Copy link
Contributor Author

gradientTrajectory

@jturner65
Copy link
Contributor Author

multi-gradient

@jturner65 jturner65 requested a review from mosra October 25, 2021 20:40
std::vector<Mn::Vector3> trajColors;

// temp converter to vector of values in HSV space from RGB color
auto convertClrToHSVArray = [&](const Mn::Color3ub& clr) -> Mn::Vector3 {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why the [&], can't this be a pure a lambda?

vertices.slice(&Vertex::color);

// temp converter to RGB color from vector of HSV values
auto convertHSVArrayToColor = [&](const Mn::Vector3& hsvVec) -> Mn::Color3ub {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Likewise for this lambda

Copy link
Contributor

@aclegg3 aclegg3 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cool. 👍

@jturner65 jturner65 merged commit 3f7f02f into facebookresearch:main Oct 26, 2021
@jturner65 jturner65 deleted the Traj_MultiColorGradient branch October 26, 2021 08:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLA Signed Do not delete this pull request or issue due to inactivity.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants