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

Create alpha channel for shapes #358

Closed
mxgrey opened this issue Mar 18, 2015 · 3 comments
Closed

Create alpha channel for shapes #358

mxgrey opened this issue Mar 18, 2015 · 3 comments
Assignees
Labels
priority: low no timeline yet
Milestone

Comments

@mxgrey
Copy link
Member

mxgrey commented Mar 18, 2015

I'd like to make an alpha channel for visualization shapes. Is there a particular reason that colors in DART are limited to three components?

I can either implement the alpha channel as something independent of the three other channels, for example:

void Shape::setAlpha(double);
double Shape::getAlpha() const;

Or I could remake the color functions:

void Shape::setColor(const Eigen::Vector4d&);
const Eigen::Vector4d& Shape::getColor() const;

For setColor, this is not an issue, because we can just overload the function. getColor(), however, will not permit such simple overloading. Instead, we could have:

Eigen::Vector3d Shape::getColor() const;
const Eigen::Vector4d& Shape::getColor4() const;

So what I'm inclined to do have this API for enabling alpha:

void Shape::setColor(const Eigen::Vector3d&); // alpha gets set to 1.0
void Shape::setColor(const Eigen::Vector4d&);
Eigen::Vector3d Shape::getColor() const;
const Eigen::Vector4d& Shape::getColor4() const;

If people want, we could also have setAlpha() and getAlpha() functions.

@mxgrey mxgrey self-assigned this Mar 18, 2015
@mxgrey mxgrey added priority: low no timeline yet Comp: API labels Mar 18, 2015
@jslee02
Copy link
Member

jslee02 commented Mar 18, 2015

Is there a particular reason that colors in DART are limited to three components?

As I known, there is no. I think this feature is good to have.

getColor(), however, will not permit such simple overloading. Instead, we could have:

We could use more concrete name like:

void Shape::setRGB(const Eigen::Vector3d&); // alpha gets set to 1.0
void Shape::setRGBA(const Eigen::Vector4d&);
const Eigen::Vector3d& Shape::getRGB() const;  // I'm not sure we can return segment of a Eigen vector as reference variable for getRGB().
const Eigen::Vector4d& Shape::getRGBA() const;

I'm also thinking that creating Color class that provides some useful features like:

  • predefined color sets such as red, blue, and so on
  • random color generation
  • color operations

@mxgrey
Copy link
Member Author

mxgrey commented Mar 18, 2015

That all sounds good to me. Although I'm inclined to still offer overloaded versions of setColor.

The only question I would have is ... what namespace would a Color class belong in? common? math? It could be defined in MathTypes, although it really has more to do with rendering/visualization than it has to do with math. It could possibly go in the renderer namespace.

In response to whether a const Eigen::Vector3d& return is possible, I'm pretty sure it's not. If we care about efficiency, we could return a Block type, but for the sake of API clarity, I think returning an Eigen::Vector3d by value will be just fine. Return value optimization will probably eliminate any difference in efficiency anyway.

@mxgrey
Copy link
Member Author

mxgrey commented Mar 22, 2015

Finished by #359

@mxgrey mxgrey closed this as completed Mar 22, 2015
@jslee02 jslee02 added this to the Release DART 5.0 milestone May 13, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
priority: low no timeline yet
Projects
None yet
Development

No branches or pull requests

2 participants