Rigs of Rods 2026.01
Soft-body Physics Simulation
Loading...
Searching...
No Matches
ProceduralRoadAngelscriptWrappers.h
Go to the documentation of this file.
1/*
2 This source file is part of Rigs of Rods
3 Copyright 2022 - 2026 Petr Ohlidal
4
5 For more information, see http://www.rigsofrods.org/
6
7 Rigs of Rods is free software: you can redistribute it and/or modify
8 it under the terms of the GNU General Public License version 3, as
9 published by the Free Software Foundation.
10
11 Rigs of Rods is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
15
16 You should have received a copy of the GNU General Public License
17 along with Rigs of Rods. If not, see <http://www.gnu.org/licenses/>.
18*/
19
25
26#pragma once
27
28#include "Application.h"
29#include "GameContext.h"
30#include "ProceduralManager.h"
31#include "ProceduralRoad.h"
32#include "ScriptEngine.h"
33#include "Terrain.h"
34
36
37using namespace RoR;
38
39// Factories
40
42{
43 return new ProceduralPoint();
44}
45
50
51static ProceduralRoad* ProceduralRoadFactory(const std::string& groundmodelName = "")
52{
53 return new ProceduralRoad(groundmodelName);
54}
55
56// struct ProceduralPoint - property accessors
57// NOTE: Using property-accessors because `offsetof()` cannot be used with derived classes (see https://stackoverflow.com/q/1129894)
58// NOTE: for compound data types like vector3 we must return non-const references so that expressions like `ppoint.position.y = 100.f` still compile and work
59
60static Ogre::Vector3& ProceduralPoint_get_position(ProceduralPoint* self) { return self->position; }
61static Ogre::Quaternion& ProceduralPoint_get_rotation(ProceduralPoint* self) { return self->rotation; }
62static float ProceduralPoint_get_width(ProceduralPoint* self) { return self->width; }
63static float ProceduralPoint_get_border_width(ProceduralPoint* self) { return self->bwidth; }
64static float ProceduralPoint_get_border_height(ProceduralPoint* self) { return self->bheight; }
67
68static void ProceduralPoint_set_position(ProceduralPoint* self, const Ogre::Vector3& pos) { self->position = pos; }
69static void ProceduralPoint_set_rotation(ProceduralPoint* self, const Ogre::Quaternion& rot) { self->rotation = rot; }
70static void ProceduralPoint_set_width(ProceduralPoint* self, float width) { self->width = width; }
71static void ProceduralPoint_set_border_width(ProceduralPoint* self, float bwidth) { self->bwidth = bwidth; }
72static void ProceduralPoint_set_border_height(ProceduralPoint* self, float bheight) { self->bheight = bheight; }
73static void ProceduralPoint_set_type(ProceduralPoint* self, RoadType type) { self->type = type; }
74static void ProceduralPoint_set_pillar_type(ProceduralPoint* self, int type) { self->pillartype = type; }
75
76// class ProceduralRoad
77
81{
82 if (!App::GetGameContext()->GetTerrain())
83 {
84 App::GetScriptEngine()->SLOG("ProceduralRoad::finish(): no terrain loaded, cannot attach the road mesh.");
85 return;
86 }
87 self->finish(App::GetGameContext()->GetTerrain()->getProceduralManager()->getGroupingSceneNode());
88}
89
90// class ProceduralObject - property accessors
91
96
98static void ProceduralObject_set_custom_material(ProceduralObject* self, const std::string& n) { self->custom_material = n; }
100static void ProceduralObject_set_custom_groundmodel(ProceduralObject* self, const std::string& n) { self->custom_groundmodel = n; }
101
102} // namespace ProceduralRoadAngelscriptWrappers
Central state/object manager and communications hub.
Game state manager and message-queue provider.
void finish(Ogre::SceneNode *snode, const std::string &materialName="")
If materialName is empty, the default material will be used.
void SLOG(const char *msg)
Replacement of macro.
static Ogre::Vector3 & ProceduralPoint_get_position(ProceduralPoint *self)
static void ProceduralPoint_set_position(ProceduralPoint *self, const Ogre::Vector3 &pos)
static void ProceduralPoint_set_width(ProceduralPoint *self, float width)
static void ProceduralPoint_set_type(ProceduralPoint *self, RoadType type)
static void ProceduralPoint_set_rotation(ProceduralPoint *self, const Ogre::Quaternion &rot)
static void ProceduralRoad_finish(ProceduralRoad *self)
The script API has no scene node parameter - the road mesh is attached under the grouping scene node ...
static void ProceduralPoint_set_border_height(ProceduralPoint *self, float bheight)
static float ProceduralPoint_get_width(ProceduralPoint *self)
static int ProceduralPoint_get_pillar_type(ProceduralPoint *self)
static void ProceduralObject_set_custom_groundmodel(ProceduralObject *self, const std::string &n)
static std::string ProceduralObject_get_custom_material(ProceduralObject *self)
static bool ProceduralObject_get_collision_enabled(ProceduralObject *self)
static void ProceduralObject_set_custom_material(ProceduralObject *self, const std::string &n)
static void ProceduralPoint_set_pillar_type(ProceduralPoint *self, int type)
static void ProceduralObject_set_smoothing_num_splits(ProceduralObject *self, int n)
static ProceduralRoad * ProceduralRoadFactory(const std::string &groundmodelName="")
static std::string ProceduralObject_get_custom_groundmodel(ProceduralObject *self)
static void ProceduralPoint_set_border_width(ProceduralPoint *self, float bwidth)
static Ogre::Quaternion & ProceduralPoint_get_rotation(ProceduralPoint *self)
static RoadType ProceduralPoint_get_type(ProceduralPoint *self)
static float ProceduralPoint_get_border_height(ProceduralPoint *self)
static void ProceduralObject_set_collision_enabled(ProceduralObject *self, bool n)
static float ProceduralPoint_get_border_width(ProceduralPoint *self)
static int ProceduralObject_get_smoothing_num_splits(ProceduralObject *self)
GameContext * GetGameContext()
ScriptEngine * GetScriptEngine()
std::string custom_groundmodel
If empty, the default ground model ("asphalt" for roads, "concrete" for others) is used for collision...
bool collision_enabled
Generate collision triangles?
std::string custom_material
If empty, the default material is used.
Ogre::Quaternion rotation