Terrain Processor SDK Manual

From Bohemia Interactive Community
Revision as of 10:16, 23 October 2015 by Tom 48 97 (talk | contribs)
Jump to navigation Jump to search

Introduction

Terrain Processor has its own SDK which allows the creation of new tasks. Hereafter, you will find a quick introduction of the setup of the new project. All you need is the Visual Studio (an Express version is enough) and the SDK which is available in Arma 3 Samples.

Create New Project in Visual Studio

Start Microsoft Visual Studio and create a new Project.

TerrainProcessor SDK newProject.png

Configure it to be an empty DLL.

TerrainProcessor SDK projectType.png

Add include and library directories

Then, go to the configuration of the project and edit the debug configuration to include the library directory (VC++ Directories option group).

TerrainProcessor SDK configLibs.png

Add lib to dependencies

From the project configuration, go to Linker, Input and define the additional dependencies.

TerrainProcessor SDK configInput.png

Create plugin source files

Create a new header called pluginTest.h with the following content:

#pragma once 

#include "TerrainProcessorPlugin.h"

using namespace TerrainProcessorSDK;

// Test plugin.
class PluginTest : public TerrainProcessorPlugin
{
public:
	// Sample parameter
	TerrainProcessorParameterDefinition _sampleParameter;

	// Constructor.
	PluginTest();
	// Process shape.
	virtual void ProcessShape(IRunContext& context, ShapeFiles::SHPShape* shape, const ShapeParameters& shapeParameters);
};

Then a code file called pluginTest.cpp with this content:

#include "PluginTest.h"
#include <algorithm>
#include <cmath>

// Constructor.
PluginTest::PluginTest()
	: TerrainProcessorPlugin(	
	"Test",
	"Test plugin.",
	GTPolyline,
	TPPFlagsShapeFile | TPPFlagsDEM)
{
	_sampleParameter = TerrainProcessorParameterDefinition(
	"Sample parameter",
	"Sample parameter. \r\n"
	"Default value is : 10",
	"10",
	TPPT_DOUBLE);
	_parameters.push_back(_sampleParameter);
}

// Process shape.
void PluginTest::ProcessShape(IRunContext& context, ShapeFiles::SHPShape* shape, const ShapeParameters& shapeParameters)
{
	_sampleParameter = _parameters[0];
}


Create Plugin.cpp and DllExport.def

New code file named Plugin.cpp:

#include <vector>
#include <memory>
#include "TerrainProcessorPlugin.h"
#include "PluginTest.h"

using namespace TerrainProcessorSDK;

// Get plugins function.
__declspec(dllexport) bool __stdcall GetPlugins(std::reference_wrapper<std::vector<std::shared_ptr<TerrainProcessorPlugin>>> plugins)
{
	plugins.get().push_back(std::make_shared<PluginTest>());

	return true;
}

And finally a new module-definitions file:

LIBRARY PLUGIN_TEST
EXPORTS
	GetPlugins		@1