google-deepmind / mujoco

Multi-Joint dynamics with Contact. A general purpose physics simulator.
https://mujoco.org
Apache License 2.0
7.84k stars 783 forks source link

[Ask] How to change geom's rgba value in runtime code (C#) like a python example ? #1734

Closed kshfire closed 3 months ago

kshfire commented 3 months ago

Hi,

I'm an engineer and I'm trying to use MuJoCo for motion simulator.

I'm looking for some help with : how to change geom's rgba value in C# (not tested in C)code.

Referring the official Google Collab (Python): model.geom('red_box').rgba[:3] = np.random.rand(3)

I've tried to check(get) mjModel's geom_rgba float pointer values, but the values are not same with MJMODEL.TXT values.

I'd appreciate it if anyone could tell me a solution. : how to get Geom's RGBA values and change it by C# codes.

kshfire commented 3 months ago

I don't know what the problem was, but it's solved now. Simply, tried again and it works now (C#: unsafe and fixed)

float rgba = m_->geom_rgba + 4 (geom_id); rgba[0] = xx; rgba[1] = xx; rgba[2] = xx; rgba[3] = xx;

Thanks!!