-
Notifications
You must be signed in to change notification settings - Fork 285
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
Material colours assigned to primitives in UI are not saved correctly #2730
Comments
Ah yes, the materials are just being copied from the original SDF. Lines 450 to 460 in c72be04
We need to add logic there to update the generated SDF from the @joshnewans would you be interested in helping out? Thanks for the other PR you created btw. |
Thanks yes I'd tracked it to that spot and then got a bit stuck but I'm happy to have a crack at it when I get a chance. |
Awesome! I'll assign the task to you then for tracking purposes. Let us know if you have any questions. |
Ok I had a look at things and have some questions already. First I noted that I think I need to dive into the Once in there I added the following snippet (not sure about code style yet, just trying to get it to run). auto visuals = gz::sim::Link(_entity).Visuals(_ecm); // Looks to be the same as _ecm.EntitiesByComponents(_entity,components::Visual());
for (const auto &v : visuals)
{
auto *matComp = _ecm.Component<components::Material>(v);
auto matElem = _elem->GetElement("visual")->GetElement("material");
auto diffuseElem = matElem->GetElement("diffuse");
diffuseElem->Set(matComp->Data().Diffuse());
// Todo - Repeat for specular, ambient, and emmissive as they are all configurable from the GUI
gzdbg << "Link " << nameComp->Data() << " has visual element with diffuse " << matComp->Data().Diffuse() << std::endl;
} My understanding is that this should:
My issue is that it seems like before I even get to worrying about saving it into the SDF, just printing the live diffuse value out of the material component seems to be incorrect? My secondary issue/question is that it seems a little onerous to do each of these characteristics manually but perhaps that is preferred since there are many more in the spec that aren't in the GUI? It seems like someone has ran into this before, and there is a class called Thanks |
I tried your code and was also stumped for a while. I updated one of the systems (SceneBroadcaster) to print the diffuse values for visuals on every step and noticed that the values weren't changing when I updated the color on the GUI. Then it dawned on me that there are the So this is going to be a bit more involved than I had originally thought. We'll need think a little bit more about how to extract the logic that updates the |
Ooh that's sneaky. I did come across the |
hmm I think we'll need to process the VisualCmd, LightCmd, etc (the code responsible for updating the ECM) outside of RenderUtil in a separate system. options:
None of these options are ideal. I'm currently leaning towards option 1 but can be convinced otherwise. |
An extra comment that may or may not be relevant - I don't know if this has been discussed in the past or if there is a feature request but it would be great to increase the number of parameters adjustable in the GUI, two in particular I am thinking are the geometry primitives (e.g. box dimensions, sphere radius) and scale (which gets messy but can be handy for imported meshes). I'm sure there are many considerations in the actual implementation of this, but if one of your options is more suited for generalising this problem of mapping the live parameters into the SDF that might be preferable for future-proofing? |
Environment
Description
Steps to reproduce
Output
World before saving:
Snippet from saved SDF:
The text was updated successfully, but these errors were encountered: