![]() |
VR-Link API Documentation for HLA 1.3
|
The code to manipulate articulated parts was re-written for VR-Link 3.12.
All classes were written to maintain backwards compatibility, while at the same time providing a robust and intuitive interface to access articulated parts.
Articulated parts are implemented in three classes:
Other examples which use articulated parts include:
A typical usage of articulated parts may look like this:
// Required header for all entities #include <vl/entitySR.h> // The following headers are actually already included // in entitySR.h, but are included here for reference. #include <vlpi/articulatedPartCollection.h> #include <vlpi/articulatedPart.h> // Used for DtInfo in this example #include <vlutil/vlPrint.h> // This function passes the classes which are needed for Articulated Parts... void artPartsExample(DtEntityStateRepository *anEntity) { DtArticulatedPartCollection* artPartCol = anEntity->artPartList(); // Here we set some Articulated Parts: A gun with elevation and a turrent with azimuth and rate. // The Articulated part collection is a map of DtArticulatedParts keyed to the PartType. // Note that the part type is in fact an integer, but normally under DIS // you would want the value to be one of the defined enumerations // DtArtPartType and DtArtParamType. // Note that the getPart() method of DtArticulatedPartCollection will create // an articulated part of the specified part type, if it does not exist. DtArticulatedPart& turret = artPartCol->getPart(DtPrimaryTurret1); DtArticulatedPart& gun = artPartCol->getPart(DtPrimaryGun1); turret.setParameter(DtApAzimuth, 3.14f); turret.setParameter(DtApAzimuthRate, 3.14f); gun.setParameter(DtApElevation, 3.14f); // Now, we attach the gun to the turret. By default, parts are attached to the // entity when created. artPartCol->attachPart(&gun, &turret); // Read and print all of the articulated parts and parameters. // The first loop iterates through the known collections of articulated parts. for(DtArticulatedPartCollection::const_iterator artPartIter = artPartCol->begin(); artPartIter != artPartCol->end(); ++artPartIter) { int currentPartType = artPartIter->first; DtArticulatedPart* currentPart = artPartIter->second; DtInfo << "Part Type: " << DtString(currentPartType) << "\n"; // Once we have a chosen a DtArticulatedPart, we can retrieve a vector // of the parameter metrics set, and iterate through it. std::vector<DtArticulatedPart::ParameterMetric> parameterMetrics; currentPart->getParameterMetrics(parameterMetrics); std::vector<DtArticulatedPart::ParameterMetric>::const_iterator paramMetricIter = parameterMetrics.begin(); std::vector<DtArticulatedPart::ParameterMetric>::const_iterator paramMetricEnd = parameterMetrics.end(); for(;paramMetricIter != paramMetricEnd; ++paramMetricIter) { int paramMetric = *paramMetricIter; DtArticulatedPart::Parameter parameter; currentPart->getParameter(paramMetric, parameter); DtInfo << " Param: " << DtString(paramMetric) << " Value: " << parameter.value << "\n"; } } }