Skip to content

Commit c4547ba

Browse files
committed
Initial commit.
0 parents  commit c4547ba

9 files changed

Lines changed: 316 additions & 0 deletions

File tree

.clang-format

Lines changed: 178 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,178 @@
1+
#
2+
# Copyright (c) 2008-2022 the Urho3D project.
3+
#
4+
# Permission is hereby granted, free of charge, to any person obtaining a copy
5+
# of this software and associated documentation files (the "Software"), to deal
6+
# in the Software without restriction, including without limitation the rights
7+
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8+
# copies of the Software, and to permit persons to whom the Software is
9+
# furnished to do so, subject to the following conditions:
10+
#
11+
# The above copyright notice and this permission notice shall be included in
12+
# all copies or substantial portions of the Software.
13+
#
14+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
20+
# THE SOFTWARE.
21+
#
22+
23+
---
24+
Language: Cpp
25+
26+
AccessModifierOffset: -4
27+
AlignAfterOpenBracket: DontAlign
28+
AlignConsecutiveAssignments: false
29+
AlignConsecutiveDeclarations: false
30+
AlignConsecutiveMacros: false
31+
AlignEscapedNewlines: DontAlign
32+
AlignOperands: DontAlign
33+
AlignTrailingComments: false
34+
AllowAllArgumentsOnNextLine: true
35+
AllowAllConstructorInitializersOnNextLine: true
36+
AllowAllParametersOfDeclarationOnNextLine: true
37+
AllowShortBlocksOnASingleLine: Never
38+
AllowShortCaseLabelsOnASingleLine: true
39+
AllowShortEnumsOnASingleLine: true
40+
AllowShortFunctionsOnASingleLine: InlineOnly
41+
AllowShortIfStatementsOnASingleLine: Never
42+
AllowShortLambdasOnASingleLine: All
43+
AllowShortLoopsOnASingleLine: false
44+
AlwaysBreakAfterDefinitionReturnType: None
45+
AlwaysBreakAfterReturnType: None
46+
AlwaysBreakBeforeMultilineStrings: true
47+
AlwaysBreakTemplateDeclarations: MultiLine
48+
BinPackArguments: true
49+
BinPackParameters: true
50+
BraceWrapping:
51+
AfterCaseLabel: true
52+
AfterClass: true
53+
AfterControlStatement: Always
54+
AfterEnum: true
55+
AfterFunction: true
56+
AfterNamespace: true
57+
AfterObjCDeclaration: true
58+
AfterStruct: true
59+
AfterUnion: true
60+
AfterExternBlock: true
61+
BeforeCatch: true
62+
BeforeElse: true
63+
BeforeLambdaBody: true
64+
IndentBraces: false
65+
SplitEmptyFunction: true
66+
SplitEmptyRecord: true
67+
SplitEmptyNamespace: true
68+
BreakAfterJavaFieldAnnotations: false
69+
BreakBeforeBinaryOperators: NonAssignment
70+
BreakBeforeBraces: Custom
71+
BreakBeforeInheritanceComma: false
72+
BreakBeforeTernaryOperators: true
73+
BreakConstructorInitializers: BeforeComma
74+
BreakInheritanceList: BeforeComma
75+
BreakStringLiterals: true
76+
ColumnLimit: 120
77+
CommentPragmas: '^ IWYU pragma:'
78+
CompactNamespaces: false
79+
ConstructorInitializerAllOnOneLineOrOnePerLine: false
80+
ConstructorInitializerIndentWidth: 4
81+
ContinuationIndentWidth: 4
82+
Cpp11BracedListStyle: true
83+
DeriveLineEnding: true
84+
DerivePointerAlignment: false
85+
DisableFormat: false
86+
ExperimentalAutoDetectBinPacking: false
87+
FixNamespaceComments: true
88+
ForEachMacros:
89+
- foreach
90+
- Q_FOREACH
91+
- BOOST_FOREACH
92+
IncludeBlocks: Regroup
93+
IncludeCategories:
94+
# 2. Main header
95+
# 1. Precompiled header
96+
- Regex: '".*\/Precompiled\..*"'
97+
Priority: -1
98+
- Regex: '<Urho3D\/Precompiled\..*>'
99+
Priority: -1
100+
# 3. <Urho3D/Urho3D.h> before anything else.
101+
- Regex: '<Urho3D\/Urho3D\.h>'
102+
Priority: 10
103+
# 7. DebugNew goes last
104+
- Regex: '.*\/DebugNew\.h.*'
105+
Priority: 10000
106+
# 5. Includes for our libraries
107+
- Regex: '<Urho3D\/.*>'
108+
Priority: 100
109+
# 6. Includes for 3rd-party libraries
110+
- Regex: '<EASTL\/.*>'
111+
Priority: 301
112+
- Regex: '<.*\/.*>'
113+
Priority: 299
114+
- Regex: '<.*>'
115+
Priority: 302
116+
# 4. Includes for this target
117+
- Regex: '".*"'
118+
Priority: 11
119+
IncludeIsMainRegex: '$'
120+
IncludeIsMainSourceRegex: ''
121+
IndentCaseLabels: false
122+
IndentGotoLabels: true
123+
IndentPPDirectives: BeforeHash
124+
IndentWidth: 4
125+
IndentWrappedFunctionNames: false
126+
JavaScriptQuotes: Leave
127+
JavaScriptWrapImports: true
128+
KeepEmptyLinesAtTheStartOfBlocks: true
129+
LambdaBodyIndentation: OuterScope
130+
MacroBlockBegin: ''
131+
MacroBlockEnd: ''
132+
MaxEmptyLinesToKeep: 1
133+
NamespaceIndentation: None
134+
ObjCBinPackProtocolList: Auto
135+
ObjCBlockIndentWidth: 2
136+
ObjCSpaceAfterProperty: false
137+
ObjCSpaceBeforeProtocolList: true
138+
PenaltyBreakAssignment: 2
139+
PenaltyBreakBeforeFirstCallParameter: 19
140+
PenaltyBreakComment: 300
141+
PenaltyBreakFirstLessLess: 120
142+
PenaltyBreakString: 1000
143+
PenaltyBreakTemplateDeclaration: 10
144+
PenaltyExcessCharacter: 1000000
145+
PenaltyReturnTypeOnItsOwnLine: 60
146+
PointerAlignment: Left
147+
ReflowComments: true
148+
SortIncludes: true
149+
SortUsingDeclarations: true
150+
SpaceAfterCStyleCast: false
151+
SpaceAfterLogicalNot: false
152+
SpaceAfterTemplateKeyword: true
153+
SpaceBeforeAssignmentOperators: true
154+
SpaceBeforeCpp11BracedList: false
155+
SpaceBeforeCtorInitializerColon: true
156+
SpaceBeforeInheritanceColon: true
157+
SpaceBeforeParens: ControlStatements
158+
SpaceBeforeRangeBasedForLoopColon: true
159+
SpaceBeforeSquareBrackets: false
160+
SpaceInEmptyBlock: false
161+
SpaceInEmptyParentheses: false
162+
SpacesBeforeTrailingComments: 1
163+
SpacesInAngles: false
164+
SpacesInConditionalStatement: false
165+
SpacesInContainerLiterals: true
166+
SpacesInCStyleCastParentheses: false
167+
SpacesInParentheses: false
168+
SpacesInSquareBrackets: false
169+
Standard: c++17
170+
StatementMacros:
171+
- Q_UNUSED
172+
- QT_REQUIRE_VERSION
173+
TabWidth: 4
174+
UseCRLF: true
175+
UseTab: Never
176+
...
177+
178+
# vi: set ts=2 sw=2 expandtab:

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# Ignore generated projects
2+
build/
3+
.vscode/

CMakeLists.txt

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
cmake_minimum_required(VERSION 3.21)
2+
project (Plugin.Core.SamplePlugin)
3+
4+
if (PROJECT_IS_TOP_LEVEL)
5+
set (CMAKE_CXX_STANDARD 17)
6+
set (REBELFORK_SDK "" CACHE STRING "Path to pre-built SDK")
7+
set (CMAKE_PREFIX_PATH ${REBELFORK_SDK}/share)
8+
find_package(Urho3D REQUIRED)
9+
include (${REBELFORK_SDK}/share/CMake/Modules/UrhoCommon.cmake)
10+
endif ()
11+
12+
file (GLOB_RECURSE SOURCE_FILES *.h *.cpp)
13+
add_library(${PROJECT_NAME} ${SOURCE_FILES})
14+
define_static_plugin (${PROJECT_NAME} "${PROJECT_NAME}")
15+
target_link_libraries (${PROJECT_NAME} PRIVATE Urho3D)

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2024-2024 the rbfx project.
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# Core.SamplePlugin
2+
3+
(WIP) Example of engine plugin

SampleComponent.cpp

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
#include "SampleComponent.h"
2+
3+
#include <Urho3D/Core/Context.h>
4+
#include <Urho3D/Scene/Node.h>
5+
6+
namespace Urho3D
7+
{
8+
9+
SampleComponent::SampleComponent(Context* context)
10+
: LogicComponent(context)
11+
{
12+
}
13+
14+
void SampleComponent::RegisterObject(Context* context)
15+
{
16+
context->AddFactoryReflection<SampleComponent>(Category_User);
17+
18+
URHO3D_ATTRIBUTE("Axis", Vector3, axis_, Vector3::FORWARD, AM_DEFAULT);
19+
URHO3D_ATTRIBUTE("Rotation Speed", float, rotationSpeed_, 0.0f, AM_DEFAULT);
20+
}
21+
22+
void SampleComponent::Update(float timeStep)
23+
{
24+
node_->Rotate(Quaternion{rotationSpeed_ * timeStep, axis_}, TS_WORLD);
25+
}
26+
27+
} // namespace Urho3D

SampleComponent.h

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
#pragma once
2+
3+
#include "_Plugin.h"
4+
5+
#include <Urho3D/Scene/LogicComponent.h>
6+
7+
namespace Urho3D
8+
{
9+
10+
class PLUGIN_CORE_SAMPLEPLUGIN_API SampleComponent : public LogicComponent
11+
{
12+
URHO3D_OBJECT(SampleComponent, LogicComponent);
13+
14+
public:
15+
SampleComponent(Context* context);
16+
static void RegisterObject(Context* context);
17+
18+
void Update(float timeStep) override;
19+
20+
/// Attributes.
21+
/// @{
22+
void SetAxis(const Vector3& axis) { axis_ = axis; }
23+
const Vector3& GetAxis() const { return axis_; }
24+
void SetRotationSpeed(float rotationSpeed) { rotationSpeed_ = rotationSpeed; }
25+
float GetRotationSpeed() const { return rotationSpeed_; }
26+
/// @}
27+
28+
private:
29+
Vector3 axis_;
30+
float rotationSpeed_{};
31+
};
32+
33+
} // namespace Urho3D

_Plugin.cpp

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
#include "_Plugin.h"
2+
3+
#include "SampleComponent.h"
4+
5+
#include <Urho3D/Plugins/PluginApplication.h>
6+
7+
using namespace Urho3D;
8+
9+
namespace
10+
{
11+
12+
void RegisterPluginObjects(PluginApplication& plugin)
13+
{
14+
plugin.RegisterObject<SampleComponent>();
15+
}
16+
17+
void UnregisterPluginObjects(PluginApplication& plugin)
18+
{
19+
}
20+
21+
} // namespace
22+
23+
URHO3D_DEFINE_PLUGIN_MAIN_SIMPLE(RegisterPluginObjects, UnregisterPluginObjects);

_Plugin.h

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#pragma once
2+
3+
#include <Urho3D/Urho3D.h>
4+
5+
#ifdef URHO3D_STATIC
6+
#define PLUGIN_CORE_SAMPLEPLUGIN_API
7+
#else
8+
#if Plugin_Core_SamplePlugin_EXPORT
9+
#define PLUGIN_CORE_SAMPLEPLUGIN_API URHO3D_EXPORT_API
10+
#else
11+
#define PLUGIN_CORE_SAMPLEPLUGIN_API URHO3D_IMPORT_API
12+
#endif
13+
#endif

0 commit comments

Comments
 (0)