glmSpatialRequest

This command is deprecated and will be removed starting with Golaem 6.2. Please check out Sensors and their channels to achieve the same results, or contact support@golaem.com for more detailed information.
 
Golaem Crowd provides a way to query its neighborhood graph when the simulation is running and a navigation mesh terrain has been defined (i.e. the positions of the crowd entities contained in a cylinder). This query can be done with the glmSpatialRequest:
string[] glmSpatialRequest [-center float float float] [-radius float] [-type string] [-count int] [-showDistance boolean] [-crowdField string]

Flags

  • -center (-ce) float float float: defines the center of the query circle;
  • -radius (-r) float: defines the radius of the query circle;
  • -type (ty) string: defines the type of returned data (count|entityIds|particleIds);
  • -count (co) integer: specifies the number of entities to return. -1 for all of them;
  • -showDistance (sd) boolean: true if the distance of entities with the center is returned as well;
  • -crowdField (cf) string : defines on which crowdField the request must be applied. This flag value is case sensitive.

Return Value

Depending on the type, count and showDistance flags, this command returns different values:
  • "count" for the flag "type": returns the number of entities contained in the query circle;
  • "entityIds" for the flag "type": returns the XX first Golaem Crowd entity ids sorted by proximity order, following this template: [entityId][crowdFieldName];
  • "particleIds" for the flag "type": returns the XX first particle ids sorted by proximity order, following this template: [particleId][particleSystemName][crowdFieldName].
With XX defined with the flag "count". The flag "showDistance" can be used to append the distance value.

MEL Examples

// get the number of entities in a 2m circle around the scene origin
glmSpatialRequest -center 0 0 0 -radius 2 -type "count" -cf "crowdField1";
// Result: 3 //
 
// get their particle ids
glmSpatialRequest -center 0 0 0 -radius 2 -type "particleIds" -cf "crowdField1";
// Result: 7 particle2 crowdField1 6 particle2 crowdField1 3 particle2 crowdField1 //
 
// just the closest
glmSpatialRequest -center 0 0 0 -radius 2 -type "particleIds" -count 1 -cf "crowdField1";
// Result: 7 particle2 crowdField1 //
 
// just the closest and its distance
glmSpatialRequest -center 0 0 0 -radius 2 -type "particleIds" -count 1 -showDistance on -cf "crowdField1";
// Result: 7 particle2 crowdField1 0.942455 //
 
// Note that being a command and not a function, you need to use ` ` when storing its result:
string $spatialResult [] = `glmSpatialRequest -center 0 0 0 -radius 2 -type "particleIds" -count 1 -showDistance on -cf "crowdField1"`;
// Result: 7 particle2 crowdField1 0.942455 //