Terrain Processor SDK Manual: Difference between revisions

From Bohemia Interactive Community
Jump to navigation Jump to search
(Created page with "== 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 pr...")
 
No edit summary
Line 3: Line 3:


==Create New Project in Visual Studio==
==Create New Project in Visual Studio==
Start Microsoft Visual Studio and create a new Project
Start Microsoft Visual Studio and create a new Project.


[[Image:TerrainProcessor_SDK_newProject.png|400px]]
[[Image:TerrainProcessor_SDK_newProject.png|400px]]


Configure it to be an empty DLL
Configure it to be an empty DLL.


[[Image:TerrainProcessor_SDK_projectType.png|400px]]
[[Image:TerrainProcessor_SDK_projectType.png|400px]]
Line 94: Line 94:
</syntaxhighlight>
</syntaxhighlight>


And finally a new module-definitions file:
And finally a new '''module-definitions''' file:


<syntaxhighlight lang="cpp">
<syntaxhighlight lang="cpp">

Revision as of 11:16, 23 October 2015

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