VR-Vantage 2.3 API Documentation
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
exampleViewControl

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.

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. The exampleSendControl is a good starting point for this.

Please review the comments in the files for details.

Example Source Files


MyLightScaleCommand.cxx

/*******************************************************************************
** Copyright (c) 2015 MAK Technologies, Inc.
** All rights reserved.
*******************************************************************************/
#include <vrvCore/DtDe.h>
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() )
{
de.sharedState().setLightingDiffuseScale(diffuseLightScale());
}
if ( ambientLightScaleSet() )
{
de.sharedState().setLightingAmbientScale(ambientLightScale());
}
}
MyLightScaleCommandCreator::MyLightScaleCommandCreator(GlobalIdConvertFunc func)
{
}
MyLightScaleCommandCreator::~MyLightScaleCommandCreator()
{
}
DtVrvCommand* MyLightScaleCommandCreator::create(
{
MyLightScaleCommand* retCmd = 0;
if ( control->myVersion == 1 )
{
if( control->mySize == sizeof( MyControlToolkit::MyLightScale_v1 ) )
{
retCmd = new MyLightScaleCommand();
MyControlToolkit::MyLightScale_v1* lightScaleControl =
if ( lightScaleControl->myValuesSetFlags &
{
retCmd->setDiffuseLightScale( lightScaleControl->myDiffuseLightScale );
}
if ( lightScaleControl->myValuesSetFlags &
{
retCmd->setAmbientLightScale( lightScaleControl->myAmbientLightScale);
}
}
}
return retCmd;
}
}

MyLightScaleCommand.h

/*******************************************************************************
** Copyright (c) 2015 MAK Technologies, Inc.
** All rights reserved.
*******************************************************************************/
#pragma once
using namespace makVrv;
namespace MyViewControl
{
class DT_DLL_EXAMPLEVIEWCONTROL MyLightScaleCommand : public DtVrvCommand
{
public:
MyLightScaleCommand();
virtual ~MyLightScaleCommand();
virtual bool diffuseLightScaleSet() const;
virtual int diffuseLightScale() const;
// effect of setting diffuseLightScaleSet() to true
virtual void setDiffuseLightScale( int scale );
virtual bool ambientLightScaleSet() const;
virtual int ambientLightScale() const;
// effect of setting ambientLightScaleSet() to true
virtual void setAmbientLightScale( int scale );
virtual void execute(DtDe& de);
protected:
int myDiffuseLightScale;
int myAmbientLightScale;
bool myDiffuseLightScaleSet;
bool myAmbientLightScaleSet;
};
class DT_DLL_EXAMPLEVIEWCONTROL MyLightScaleCommandCreator
{
public:
MyLightScaleCommandCreator(GlobalIdConvertFunc func);
virtual ~MyLightScaleCommandCreator();
};
}

MyViewControlDataTypes.h

/*******************************************************************************
** Copyright (c) 2015 MAK Technologies, Inc.
** All rights reserved.
*******************************************************************************/
#pragma once
namespace MyControlToolkit
{
// Declare the enumerants to use for you custom view control messages. This
// could be added directly to vrvControlToolkitDataTypes.h, but then you
// would need to re-merge with each new release. It makes more sense to
// manage your own packets this way.
{
};
// Declare the packet(s) that will contain your view control message(s).
// This message will set a scale factor for the diffuse and/or ambient light
// values in the scene
struct MyLightScale_v1 : public vrvControlToolkit::DtVrvControl_v1
{
inline MyLightScale_v1();
inline ~MyLightScale_v1();
// Similar to VR-Link net types, the The vrvControlToolkit types will
// manage byte-swapping if needed.
// This enumeration describes bit values set in the myValuesSetFlags
// member to indicate which of the messages members should be processed
{
};
// Bit-encoded integer that indicates which values are set
};
}

MyViewControlDataTypes.inl

/*******************************************************************************
** Copyright (c) 2015 MAK Technologies, Inc.
** All rights reserved.
*******************************************************************************/
#pragma once
namespace MyControlToolkit
{
//----------------------Light Scale Command ----------------------
: vrvControlToolkit::DtVrvControl_v1()
{
// Base struct setup
myVersion = 1;
mySize = sizeof(MyLightScale_v1);
// Initial Values
myDiffuseLightScale = 0;
myAmbientLightScale = 0;
myValuesSetFlags = 0;
}
MyLightScale_v1::~MyLightScale_v1()
{
}
}


Copyright © 2005-2018 VT MAK. All Rights Reserved (www.mak.com)