Apertus
  • Documentation
  • Introduction
    • Definitions
      • Coordinate systems
      • Primitives
    • Features
      • Basic
        • Nodes
        • Light sources
        • Geometries
        • Primitives
        • Texts
      • Environment simulation
        • Water
        • Sky
        • Terrain
      • Browser
      • UI technologies
        • HTML UI
        • Presentation
        • Gallery
      • PointCloud
      • 360
        • 360 Images
        • 360 Videos
      • 3D Model Formats
      • Scene Sharing
        • Multiplayer
      • Video and Voice Chat
      • Hand Tarcking
        • Leap Motion
      • Head Tracking
        • Fob
      • Displays
        • Multi Display
        • Cave System
        • HMDs
      • Industry
        • IoT, and Sensors
        • Robot monitoring
        • Robot calibration
  • Developers
    • Development Cycle
    • Architecture
      • Project folders
      • Configuration ecosystem
    • API
      • C++ API
      • JavaScript API
      • HTTP REST API
    • Getting Started
      • Creating a plugin
      • Creating a sample
  • Contribute
    • Report a Bug
    • Suggest a Feature
  • Tutorial - How to visualize CAD models in VR
    • Introduction
    • Import CAD Models
    • Convert CAD Models
    • Create Low-poly from CAD Models
    • Create Photorealistic CAD Models
  • Plugins - Photorealistic Render
  • Plugins - Physics
  • Tutorial - How to visualize Tensorflow training in VR
  • Tutorial - Virtual Learning Factory Toolkit Gamification
  • Overview
    • Introduction
    • Architecture
    • Use Cases
  • Installation
    • Windows
    • Android
      • How to use
      • Writing an application
    • MacOS
  • Build
    • Windows
      • How to build the source on Windows
    • Android
    • MacOS
  • Plugins on Windows
    • Photorealistic Render
      • How to use
      • How to configure
      • Features
      • Sample
    • Physics
      • How to use
      • How to configure
      • Features
      • Samples
      • Demo video
  • Plugins on Android
    • Java Native Interface
      • How to use
      • Extending the API
    • Filament render
      • How to use
      • How to configure
      • Developers
  • Plugins on MacOS
    • Untitled
  • Samples on Windows
    • Deep learning
      • Untitled
      • Use the Fastai-PythorchVR Sample
      • Use the HTTP API
      • Create HTTP Requests from Python
      • Demo video
    • Virtual Learning Factory Toolkit Gamification
      • Installation
      • Lobby - User Interface
      • Local - User Interface
      • Student - User Interface
      • Teacher - User Interface
      • VLFT Gamification Session
      • VR Mode
  • Virtual Learning Factory Application
    • Installation on Windows
    • Installation on Apple
    • Lobby
    • Single Player
    • Multi Player - Student
    • Multi Player - Teacher
Powered by GitBook
On this page
  • C++ Plugin interface
  • Constructor
  • Init
  • Run
  1. Developers
  2. API

C++ API

The C++ headers for ApertusVR are located in ApertusVR/common/include/ folder.

C++ Plugin interface

A C++ Plugin has to implement the IPlugin interface:

class IPlugin
{
public:
	virtual void Init() = 0;
	virtual void Run() = 0;
	virtual void Step() = 0;
	virtual void Stop() = 0;
	virtual void Suspend() = 0;
	virtual void Restart() = 0;
};

Constructor

The constructor takes care of member initializations.

Ape::ApeTesterPlugin::ApeTesterPlugin()
{
	mpSceneManager = Ape::ISceneManager::getSingletonPtr();
	mpEventManager = Ape::IEventManager::getSingletonPtr();
	
	mpEventManager->connectEvent(Ape::Event::Group::NODE, std::bind(&ApeTesterPlugin::eventCallBack, this, std::placeholders::_1));
	mInterpolators = std::vector<std::unique_ptr<Ape::Interpolator>>();
	mDemoObjectNode = Ape::NodeWeakPtr();
}

Init

This method is for initializing geometries, nodes, etc. for your plugin. The following example uses Init() to create lights and the skybox:

void Ape::ApeTesterPlugin::createLights()
{
	if (auto light = std::static_pointer_cast<Ape::ILight>(mpScene->createEntity("light1", Ape::Entity::LIGHT).lock()))
	{
		light->setLightType(Ape::Light::Type::DIRECTIONAL);
		light->setLightDirection(Ape::Vector3(0, -1, -1));
		light->setDiffuseColor(Ape::Color(0.35f, 0.35f, 0.35f));
		light->setSpecularColor(Ape::Color(0.35f, 0.35f, 0.35f));
	}
	if (auto light = std::static_pointer_cast<Ape::ILight>(mpScene->createEntity("light2", Ape::Entity::LIGHT).lock()))
	{
		light->setLightType(Ape::Light::Type::DIRECTIONAL);
		light->setLightDirection(Ape::Vector3(0, -1, 1));
		light->setDiffuseColor(Ape::Color(0.35f, 0.35f, 0.35f));
		light->setSpecularColor(Ape::Color(0.35f, 0.35f, 0.35f));
	}
}

void Ape::ApeTesterPlugin::createSkyBox()
{
	if (auto skyBoxMaterial = std::static_pointer_cast<Ape::IFileMaterial>(mpScene->createEntity("skyBox", Ape::Entity::MATERIAL_FILE).lock()))
	{
		skyBoxMaterial->setFileName("skyBox.material");
		skyBoxMaterial->setAsSkyBox();
	}
}

void Ape::ApeTesterPlugin::Init()
{
	createSkyBox();
	createLights();
}

Run

The Run() method can be used to implement loops until the Stop of the plugin. It is the place where animations, and other interactions can be used.

void Ape::ApeTesterPlugin::Run()
{
	while (true)
	{	
		if (!mInterpolators.empty())
		{
			for (std::vector<std::unique_ptr<Ape::Interpolator>>::iterator it = mInterpolators.begin(); it != mInterpolators.end();)
			{
				(*it)->iterateTopSection();
				if ((*it)->isQueueEmpty())
					it = mInterpolators.erase(it);
				else 
					it++;
			}
		}
		std::this_thread::sleep_for(std::chrono::milliseconds(40));
	}
}
PreviousAPINextJavaScript API

Last updated 6 years ago