Let's add the myEntity subscriber object.
It will be called after each myEntity object that publish on the Federation.
In the panel Declaration, let's define the two local variables that will hold the values coming from the RTI.
Then, for each Attribute, let's make the copy:
X and Y must be copied to local variables x and y, then myEntity Object code will be called.
There, we will update the entity position.
First time the Object is found (new handle), the Discover part is called.
If the option is checked, an entity will be created first and paired with the handle.
If you do not want to create a default entity, the correct typed one must be created in the Discover panel.
entity = new Entity("myEntityType", objectInstanceName);
add(entity); // in the subscriber object list
store(entity); // and associate it with handle
|
When the Entity is created or retrieved at next updates, setting is done:
entity->pos.x = x;
entity->pos.y = y;
|
The myCreate interaction will receive the mouse position.
We will declare the two variables that will keep the data coming from the RTI, using the Declaration panel:
We will now copy the posX parameter into the x local variable (and do the same with posY).
Now, in the myCreate Interaction code, let's use the (x,y) map coordinates to draw a red circle for 3 seconds.
// create the circle at x,y
WCoord pos(x, y, 0);
R:gui_map.drawCircle(pos, 10, clRed, 3);
|