VR-Forces 4.10 Class Documentation
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties 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 DtEntityArticulatedStateModelVisualizer to create a new class MyEntityArticulatedStateModelVisualizer. 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_stealth.bat (on Windows) or ./bin64/exampleExtendVisualizer_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) 2021 MAK Technologies, Inc.
** All rights reserved.
******************************************************************************/
#include <vrvCore/DtDe.h>
#include <iostream>
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) 2021 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; }

MyEntityArticulatedStateModelVisualizer.h

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

MyEntityArticulatedStateModelVisualizer.cxx

/******************************************************************************
** Copyright (c) 2021 MAK Technologies, Inc.
** All rights reserved.
******************************************************************************/
namespace makVrv
{
DtBaseConnection& simulation, DtStateListener& listener, int modelSet)
: DtEntityArticulatedStateModelVisualizer(simulation, listener, modelSet)
{
std::cout << "MyEntityArticulatedStateModelVisualizer created" << std::endl;
DtEntityArticulatedStateModelVisualizer::setColorizedColor( 1.0, 0.0, 0.0, 1.0 );
}
MyEntityArticulatedStateModelVisualizer::~MyEntityArticulatedStateModelVisualizer()
{
}
}

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


Document ID: Generated on Tue Sep 21 17:42:52 EDT 2021 from SVN revision 234861
Copyright © 2005-2021 MAK Technologies. All Rights Reserved (www.mak.com)