leggedrobotics / raisimOgre

https://rsl.ethz.ch/partnership/spinoff/raisim.html

Home Page:https://github.com/raisimTech/raisimOgre

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Is there an easy way to change the material name or color of an object?

Atlis opened this issue · comments

commented

Hello,

I would like to change the color of a sphere (live).

I have tried few things with the 'graphic' property, but without success.

auto & list = raisim::OgreVis::get()->getVisualObjectList();
list['sphere'].graphics->...

I would need help on that one.

Thanks!

This is definitely tricky. I will try to make a simpler way. But the current way is

auto *ogreEntity = dynamic_cast<Ogre::Entity *>(list["sphere"].graphics->getAttachedObject(0));
ogreEntity->getSubEntities()[0]->setMaterialName("red");
commented

Hi Jemin,

I have tried your solution (and some variations) and I keep getting segmentation faults.
This is not critical to me though. I found an (not ideal) alternative to present the info I want.

Thanks!

It's hard to see how a segmentation fault can occur here. The only way that I can think of is when "sphere" doesn't exist. Do you use debug_app? For me, it is impossible to develop an environment with the debug_app. Clion has a built-in support for valgrind and it is a HIGHLY HIGHLY recommended way. Make sure that you get no errors with "no_render" first, then use rendering. Valgrind outputs many errors with opengl functions but these are safe ones. You can also try GDB first.

By the way, the code snippet I wrote is what I use in my environment. I just copy-pasted it here