MengeCrowdSim / Menge

The source code for the Menge crowd simulation framework
Apache License 2.0
138 stars 64 forks source link

Change agent colour during execution #148

Open douglasbandeiraivo opened 4 years ago

douglasbandeiraivo commented 4 years ago

I've seen that I can change some agent attributes like velocity and radius using actions and events, but I didn't find out how to change the agent colour after something happens, for example because of a change of state or because of being in some region of the environment. I tryed to do it changing the agent class inside an event, but it didn't work. Could you tell me how could I do it?

curds01 commented 4 years ago

Short answer: I've got nothing for you.

Long answer: visualization is a layer on top of agent visualization. In fact, all of the visualization artifacts are in a different library than the core Menge simulation code. Currently, the visualization of agents is hard-coded.

It's been long an intention of mine to make the visualization configurable akin to how the simulation is configured. That's one of the reason that there's a sceneV.xml file. However, currently, the only thing you can configure is camera, lighting, and the like.

However, if you want to hack some code, you can do the following:

  1. The class you want is VisAgent. It draws the little cylinders. Right now the logic for picking a color simply looks at the class id and maps it to a color (in a really, truly, horrible way). If you gut that function you can define an (r, g, b) triple based on any logic you like.
douglasbandeiraivo commented 4 years ago

Ok, I understand. Thank you for the reply.

Em ter, 3 de mar de 2020 21:34, curds01 notifications@github.com escreveu:

Short answer: I've got nothing for you.

Long answer: visualization is a layer on top of agent visualization. In fact, all of the visualization artifacts are in a different library https://github.com/MengeCrowdSim/Menge/tree/master/src/Menge/MengeVis than the core Menge simulation code. Currently, the visualization of agents is hard-coded.

It's been long an intention of mine to make the visualization configurable akin to how the simulation is configured. That's one of the reason that there's a sceneV.xml file. However, currently, the only thing you can configure is camera, lighting, and the like.

However, if you want to hack some code, you can do the following:

  1. The class you want is VisAgent https://github.com/MengeCrowdSim/Menge/blob/master/src/Menge/MengeVis/Runtime/VisAgent/VisAgent.cpp. It draws the little cylinders. Right now the logic for picking a color https://github.com/MengeCrowdSim/Menge/blob/master/src/Menge/MengeVis/Runtime/VisAgent/VisAgent.cpp#L121-L169 simply looks at the class id and maps it to a color (in a really, truly, horrible way). If you gut that function you can define an (r, g, b) triple based on any logic you like.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/MengeCrowdSim/Menge/issues/148?email_source=notifications&email_token=ADF43U6MHHSY5NOW5YCRFZLRFWOY3A5CNFSM4LAWCUC2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOENVXA4Q#issuecomment-594243698, or unsubscribe https://github.com/notifications/unsubscribe-auth/ADF43U6J67XRDUMIVYX5FRLRFWOY3ANCNFSM4LAWCUCQ .