Overview
Shows how to add a new view control to the VR-Vantage Control Toolkit.
Expected Result
We use exampleSendControl to demonstrate the view control message created in this example. Using exampleSendControl, you can observe the following behavior:
Before you enter 'W'
After you enter 'W'
Note: A 3D model was added to the scene to better illustrate the change in render settings. To do this, the startup scripts for this example loads the exampleDistributedObject plugin which, among other things, places a 3D model in the scene.
Example details
The VR-Vantage Control Toolkit lets you send DIS or HLA messages that can remotely control a VR-Vantage application. It has messages for most VR-Vantage display settings. This example shows how to add new control messages by adding a viewLightScale view control message, and a custom attach observer message.
VR-Vantage does not send view controls so in order to test the receipt of this new view control a new application will need to be created to send them. We show how to send view controls in exampleSendControl but also use this example to demonstrate the view control message created in this example.
Please review the comments in the files for details.
Building the Example
VR-Vantage includes pre-built versions of the example plug-in. To build it yourself, follow the instructions at Building VR-Vantage Examples, Applications, and Plug-ins.
Running the Example
This example is a plug-in. You can run it by running ./bin64/exampleViewControl_stealth.bat (on Windows from cmd.exe) or ./bin64/exampleViewControl_stealth.sh (on Linux). For more information about running examples, please see Running Applications and Examples.
When using HLA1516e, it's important to configure the default connection using the RTI Assistant. In Windows, the RTI Assistant can be found under "MAK Technologies" from the Windows start menu. In Linux, the RTI Assistant can be started using the "./rtiAssitstant -N" script located in the RTI installed location bin folder. Using the RTI Assistant connection preferences tab, set the default connection to be "[machine name]'s predefined rtiexec loopback connection" rather than the default "Predefined lightweight loopback connection".
Example Source Files
MyLightScaleCommand.h
#pragma once
using namespace makVrv;
namespace MyViewControl
{
{
public:
MyLightScaleCommand();
virtual ~MyLightScaleCommand();
virtual bool diffuseLightScaleSet() const;
virtual int diffuseLightScale() const;
virtual void setDiffuseLightScale( int scale );
virtual bool ambientLightScaleSet() const;
virtual int ambientLightScale() const;
virtual void setAmbientLightScale( int scale );
virtual void execute(
DtDe& de);
protected:
int myDiffuseLightScale;
int myAmbientLightScale;
bool myDiffuseLightScaleSet;
bool myAmbientLightScaleSet;
};
{
public:
virtual ~MyLightScaleCommandCreator();
};
}
MyLightScaleCommand.cxx
using namespace makVrv;
namespace MyViewControl
{
MyLightScaleCommand::MyLightScaleCommand()
, myDiffuseLightScale(0)
, myAmbientLightScale(0)
, myDiffuseLightScaleSet(false)
, myAmbientLightScaleSet(false)
{
}
MyLightScaleCommand::~MyLightScaleCommand()
{
}
bool MyLightScaleCommand::diffuseLightScaleSet() const
{
return myDiffuseLightScaleSet;
}
int MyLightScaleCommand::diffuseLightScale() const
{
return myDiffuseLightScale;
}
void MyLightScaleCommand::setDiffuseLightScale( int scale )
{
myDiffuseLightScale = scale;
myDiffuseLightScaleSet = true;
}
bool MyLightScaleCommand::ambientLightScaleSet() const
{
return myAmbientLightScaleSet;
}
int MyLightScaleCommand::ambientLightScale() const
{
return myAmbientLightScale;
}
void MyLightScaleCommand::setAmbientLightScale( int scale )
{
myAmbientLightScale = scale;
myAmbientLightScaleSet = true;
}
void MyLightScaleCommand::execute(
DtDe& de)
{
if ( diffuseLightScaleSet() )
{
}
if ( ambientLightScaleSet() )
{
}
}
{
}
MyLightScaleCommandCreator::~MyLightScaleCommandCreator()
{
}
{
MyLightScaleCommand* retCmd = 0;
{
{
retCmd = new MyLightScaleCommand();
{
}
{
}
}
}
return retCmd;
}
}
MyAttachObserverCommand.h
#pragma once
using namespace makVrv;
namespace MyViewControl
{
{
public:
MyAttachObserverCommand();
virtual ~MyAttachObserverCommand();
virtual void setEntityId(
const DtUniqueID& entityId );
virtual const std::string& sensorName();
virtual void setSensorName( const std::string& sensorName );
virtual const std::string& observerName();
virtual void setObserverName( const std::string& observerName );
virtual bool createOverlay() const;
virtual void setCreateOverlay( bool );
virtual void execute(
DtDe& de );
protected:
std::string mySensorName;
std::string myObserverName;
bool myCreateOverlay;
};
{
public:
virtual ~MyAttachObserverCommandCreator();
};
}
MyAttachObserverCommand.cxx
#include <vrvCore/DtObserverObjectAgent.hpp>
using namespace makVrv;
namespace MyViewControl
{
MyAttachObserverCommand::MyAttachObserverCommand()
, myCreateOverlay( true )
, mySensorName( "" )
, myObserverName( "" )
{
}
MyAttachObserverCommand::~MyAttachObserverCommand()
{
}
const DtUniqueID& MyAttachObserverCommand::entityId()
{
return myEntityId;
}
void MyAttachObserverCommand::setEntityId(
const DtUniqueID& u )
{
myEntityId = u;
}
const std::string& MyAttachObserverCommand::sensorName()
{
return mySensorName;
}
void MyAttachObserverCommand::setSensorName( const std::string& u )
{
mySensorName = u;
}
const std::string& MyAttachObserverCommand::observerName()
{
return myObserverName;
}
void MyAttachObserverCommand::setObserverName( const std::string& u )
{
myObserverName = u;
}
bool MyAttachObserverCommand::createOverlay() const
{
return myCreateOverlay;
}
void MyAttachObserverCommand::setCreateOverlay( bool b )
{
myCreateOverlay = b;
}
void MyAttachObserverCommand::execute(
DtDe& de )
{
if( myEntityId == 0 )
{
DtWarn << "MyAttachObserverCommand element ID == 0" << std::endl;
return;
}
if( mySensorName == "" )
{
DtWarn << "MyAttachObserverCommand mySensorName string is empty" << std::endl;
return;
}
std::string obsName = myObserverName == "" ? "Observer 1" : myObserverName;
obsName );
if( observer )
{
std::vector<DtUniqueID> idVector;
idVector.push_back( myEntityId );
observer->
setAttachType( DtObserverObject::AttachType::AttachTypeMimic );
}
if( display )
{
{
{
{
if( newConfig )
{
}
}
}
}
}
if( myCreateOverlay )
{
if( oldId != 0 && oldSensorId != 0 )
{
}
if( fieldsOfView )
{
for( auto& fieldOfView : *fieldsOfView )
{
if( fieldOfView.second.sensorId() == mySensorName && !fieldOfViewMgr.
hasSensorObserver( myEntityId, fieldOfView.first ) )
{
oldId = myEntityId;
oldSensorId = fieldOfView.first;
}
}
}
}
}
{
}
MyAttachObserverCommandCreator::~MyAttachObserverCommandCreator()
{
}
{
MyAttachObserverCommand* retCmd = 0;
{
{
retCmd = new MyAttachObserverCommand();
retCmd->setEntityId( myConvertGlobablIdFunc( attachControl->
myEntity ) );
}
}
return retCmd;
}
}
MyViewControlDataTypes.h
#pragma once
namespace MyControlToolkit
{
{
};
{
inline MyLightScale_v1();
inline ~MyLightScale_v1();
enum LightScaleSettingsUsed
{
DiffuseLightScaleSet = 1,
AmbientLightScaleSet = 2,
};
};
{
inline MyAttachObserverToSensor_v1();
inline ~MyAttachObserverToSensor_v1();
bool myCreateOverlay;
};
}
#include "MyViewControlDataTypes.inl"
MyViewControlDataTypes.inl
#pragma once
namespace MyControlToolkit
{
: vrvControlToolkit::DtVrvControl_v1()
{
myVersion = 1;
mySize = sizeof(MyLightScale_v1);
myDiffuseLightScale = 0;
myAmbientLightScale = 0;
myValuesSetFlags = 0;
}
MyLightScale_v1::~MyLightScale_v1()
{
}
MyAttachObserverToSensor_v1::MyAttachObserverToSensor_v1()
: vrvControlToolkit::DtVrvControl_v1()
{
myVersion = 1;
mySize = sizeof( MyAttachObserverToSensor_v1 );
myCreateOverlay = true;
}
MyAttachObserverToSensor_v1::~MyAttachObserverToSensor_v1()
{
}
}
[<< Examples] [Home] [Top of Page]