vsTASKER 7 Tutorial
×
Menu
Index

Detections

  
Add a sensor on STK aircraft
 
 
Update vsTasker scenario by importing the Sensor definition.
On the Includes section of the STK Importer window, select Sensors for Entities.
Make sure that Catalog is correctly mapped with Category.
Then, Import.
 
 
vsTASKER will add the StkSensor Model Component to every Entity having a Sensor defined in STK.
Name and some parameters will also be automatically set.
After Import, you can select any Entity with Sensors and check into the Models pane that StkSensor is loaded.
There is as many Component as Sensors.
 
 
Now we can add a logic on vsTASKER that will react on anything detected by the STK Sensor.
Here, in case of event STK_Detect that is raised by the StkSensor whenever its counterpart in STK detects something, Fire_Missile Action will be triggered.
 
 
Fire_Missile Action will create a vsTASKER missile that will target whatever has been detected.
 
L:target = (Entity*) edata();
 
if (L:target) { // fire missile at
   StkMissile* missile = new StkMissile("xMissile");
 
   IAgMissilePtr miss=(IAgMissilePtr) missile->stkObject;
   IAgVOModelPtr model=(IAgVOModelPtr) miss->VO->Model;
   model->ModelType = AgEModelType::eModelFile;
   IAgVOModelFilePtr modelFile =(IAgVOModelFilePtr) model->ModelData;
 
   modelFile->Filename = strAdd(vsTaskerDir(), "\\Runtime\\3D-models\\harpoon\\harpoon.mdl");
 
   BasicMissile* missile_ctrl = missile->findBasicMissile();
   missile_ctrl->launch(ent(), L:target);
}
 
 
In case of destruction of the target (belonging to STK), both entities will be removed (or marked dead or wreck).
 
sprintf(cmdString,"Graphics %s SetAttrType Basic",L:target->db->getProfile());
sendCommandToStk(cmdString);
 
sprintf(cmdString,"Graphics %s Basic Show Off", L:target->db->getProfile(), getEpochStk());
sendCommandToStk(cmdString);
 
Now, we can compile and run the scenario.