VR-Link API Documentation for HLA 1.3
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Articulated Parts Example

Table of Contents

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.

Implementing Articulated Parts

Articulated parts are implemented in two classes:

Other examples which use articulated parts include:

Example Code

A typical usage of articulated parts may look like this:

// Required header for all entities
// The following headers are actually already included
// in entitySR.h, but are included here for reference.
// 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);
turret.setParameter(DtApAzimuth, 3.14f);
turret.setParameter(DtApAzimuthRate, 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;
currentPart->getParameter(paramMetric, parameter);
DtInfo << " Param: " << DtString(paramMetric)
<< " Value: " << parameter.value << "\n";
}
}
}

Document ID: Generated on Thu Sep 19 02:12:35 EDT 2024 from SVN revision 269601
Copyright © 2005-2024 MAK Technologies. All Rights Reserved (www.mak.com)