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

Table of Contents

Overview

This example show how to extend the state model visualizer and turn all the entities in XR mode to red.

Expected Result

exampleExtendVisualizer.png
Extend Visualizer Result

Example details

In this example we derived from the class DtVrlinkEntityArticulatedStateModelVisualizer to create a new class MyVrlinkEntityArticulatedStateModelVisualizer. The only thing this class does in the constructor is to force the entity's id for colorization. This will just to prove it is overriding the original visualizer. To see the effect switch to XR mode to see all the entities in red.

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/exampleExtendVisualizer<protocol>_stealth.bat (on Windows) or ./bin64/exampleExtendVisualizer<protocol>_stealth.sh (on Linux). Load MakLand terrain, once Vantage is started, connect with the selected <protocol>. Swicth the observer to "XR" and all the entities will be red. For more information about running examples, please see Running Applications and Examples.

Example Source Files


exampleExtendVisualizerPlugin.cxx

/******************************************************************************
** Copyright (c) 2019 MAK Technologies, Inc.
** All rights reserved.
******************************************************************************/
#include <vrvCore/DtDe.h>
#include <iostream>
//------------------------------------------------------------------------------------------------------
// This section here sets up the protocol-specific definitions needed (in protocolSpecificNamespace.h,
// and then includes the protocol-specific headers/inlines that use them (in this case, only our new
// "MyVrlinkEntityArticulatedStateModelVisualizer.h" and, of course, some of the files *it* includes
//------------------------------------------------------------------------------------------------------
using namespace makVrv;
namespace exampleExtendVisualizer
{
{
void postInitializeWork(DtDe* de)
{
// We're done with the signal, so disconnect from it
de->signal_postInitialize.disconnect(boost::bind(&postInitializeWork, de));
// Added this to override the DtVrlinkEntityArticulatedStateModelVisualizer
}
void init(DtDe& de)
{
// Ensure that init only gets called once
// (not strictly necessary here, but this is good practice in general)
if (de.isInMasterMode())
{
// The custom state visualizer must be registered after the DE's initialization
// is finished, to make sure the default state visualizers have been registered.
de.signal_postInitialize.connect(boost::bind(&postInitializeWork, &de));
}
}
}
}
{
// Setup the plug-in. Normally, the init function and functionality
// should be in its own library.
return true;
}

exampleExtendVisualizerPlugin.h

/******************************************************************************
** Copyright (c) 2019 MAK Technologies, Inc.
** All rights reserved.
******************************************************************************/
#pragma once
// Get proper local export symbol
// Setup proper plugin export symbol
#define DT_DE_PLUGIN_EXPORT_MACRO DT_DLL_EXAMPLEEXTENDVISUALIZER
// Declare & export the plugin initialization function (bool initDeModule(DtDe* de))
namespace makVrv { class DtDe; }

MyVrlinkEntityArticulatedStateModelVisualizer.h

/******************************************************************************
** Copyright (c) 2019 MAK Technologies, Inc.
** All rights reserved.
******************************************************************************/
#pragma once
namespace makVrv
{
{
class DT_DLL_EXAMPLEEXTENDVISUALIZER MyVrlinkEntityArticulatedStateModelVisualizer :
public DtVrlinkEntityArticulatedStateModelVisualizer
{
public:
MyVrlinkEntityArticulatedStateModelVisualizer(DtBaseConnection& simulation,
DtStateListener& listener, int modelSet);
virtual ~MyVrlinkEntityArticulatedStateModelVisualizer();
protected:
};
typedef DtStateVisualizerCreatorTemplate<MyVrlinkEntityArticulatedStateModelVisualizer>
}
}
#define MyVrlinkEntityArticulatedStateModelVisualizer_INL_
#undef MyVrlinkEntityArticulatedStateModelVisualizer_INL_

MyVrlinkEntityArticulatedStateModelVisualizer.inl

/******************************************************************************
** Copyright (c) 2019 MAK Technologies, Inc.
** All rights reserved.
******************************************************************************/
#ifndef MyVrlinkEntityArticulatedStateModelVisualizer_INL_
#error This file may only be included by MyVrlinkEntityArticulatedStateModelVisualizer.h
#endif
namespace makVrv
{
{
DtBaseConnection& simulation, DtStateListener& listener, int modelSet)
: DtVrlinkEntityArticulatedStateModelVisualizer(simulation, listener, modelSet)
{
std::cout << "MyVrlinkEntityArticulatedStateModelVisualizer created" << std::endl;
setForceId( 2 );
}
MyVrlinkEntityArticulatedStateModelVisualizer::~MyVrlinkEntityArticulatedStateModelVisualizer()
{
}
}
}

protocolSpecificNamespace.h

/******************************************************************************
** Copyright (c) 2019 MAK Technologies, Inc.
** All rights reserved.
******************************************************************************/
#pragma once
#ifdef _WIN32
#define DL_DLL_IGCONVRLINK __declspec ( dllimport )
#else
#define DL_DLL_IGCONVRLINK
#endif
#ifdef DtDIS
# define DT_PROTOCOL_NAMESPACE vrvDis
#else
# ifdef DtHLA_1516
# ifdef DtHLA_1516_EVOLVED
# define DT_PROTOCOL_NAMESPACE vrvHla1516e
# else
# define DT_PROTOCOL_NAMESPACE vrvHla1516
# endif
# else
# define DT_PROTOCOL_NAMESPACE vrvHla13
# endif
#endif
namespace exampleExtendVisualizer
{
{
// Work function for the plugin initialization
}
}

[<< Examples] [Home] [Top of Page]



Copyright © 2005-2021 MAK Technologies. All Rights Reserved (www.mak.com)