VR-Link JAVA API Documentation
 All Classes Namespaces Files Functions Variables Enumerator Pages
9.5 - Publishing Objects

VR-Link for C# supplies publishers for objects that it defines.

In the F-18 example, we define a VehicleSim class that is used to manipulate the information we publish. To start, a publisher of the right type is required, so we define and initialize that. As you can see, it requires the exercise connection that is being used in the project.

EntityPublisher myEntityPub;
myEntityPub = new EntityPublisher(myExConn);

Our vehicle is an entity type so we define the EntityPublisher. To start to edit the values that the publisher sends, the EntityStateRepository of the publisher must be edited. The VehicleSim class stores a member for the EntityStateRepository (ESR).

EntityStateRepository myESR;
myESR = myEntityPub.esr;

The ESR information that needs to be modified is usually handled in a tick() function. Tick often refers to a defined amount of time between updates. Therefor a tick() function is called every time the threshold is reached. For this reason, the tick() functions require a time that represents the change in time since last call of this function. VehicleSim defines a simTick() function to handle modifying the ESR. Here is a small sample:

public void simTick(double dt)
{
...
//update position
myPos[i] += (myVel[i] + 0.5 * myAccel[i] * dt) * dt;
...
//Convert position to correct format
myESR.worldPosition = myCoordTrans.coordTrans(myPos);
...
//call publisher tick function
myEntityPub.tick(dt);
}

Notice that you must call the EntityPublisher.tick() function after your ESR has been modified.

[<< Using the Application Initializer Class] [Home] [Top of Page] [Reflected Objects >>]


Document ID: Generated on Mon Apr 25 03:39:01 EDT 2022 from SVN revision 242502
Copyright © 2005-2021 MAK Technologies. All Rights Reserved (www.mak.com)