Skip to content

Commit

Permalink
Use sample plugin.
Browse files Browse the repository at this point in the history
  • Loading branch information
eugeneko committed Feb 13, 2024
1 parent 5de3d23 commit fe7ddd2
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 4 deletions.
1 change: 1 addition & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ jobs:
with:
path: ${{ env.ci_source_dir }}
fetch-depth: 1
submodules: recursive

- name: Download SDK
uses: robinraju/[email protected]
Expand Down
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[submodule "Plugins/Core.SamplePlugin"]
path = Plugins/Core.SamplePlugin
url = https://github.com/rbfx/Core.SamplePlugin.git
7 changes: 7 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,17 @@ if ("${REBELFORK_SDK}" STREQUAL "")
# Include the Framework to build.
add_subdirectory (../rbfx ${CMAKE_BINARY_DIR}/3rdParty/rbfx)
else ()
# Include common build scripts.
include (${REBELFORK_SDK}/share/CMake/Modules/UrhoCommon.cmake)

# Include pre-built SDK
set (CMAKE_PREFIX_PATH ${REBELFORK_SDK}/share)
find_package(Urho3D REQUIRED)
endif ()

# Add plugins (optional).
include_directories (${CMAKE_SOURCE_DIR}/Plugins)
add_subdirectory (${CMAKE_SOURCE_DIR}/Plugins/Core.SamplePlugin)

# Add project source files.
add_subdirectory (${CMAKE_SOURCE_DIR}/Source)
1 change: 1 addition & 0 deletions Plugins/Core.SamplePlugin
Submodule Core.SamplePlugin added at c4547b
7 changes: 6 additions & 1 deletion Source/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,9 @@ endif ()
# Add executable.
set (TARGET_NAME ${CMAKE_PROJECT_NAME})
add_executable(${TARGET_NAME} ${PLATFORM} ${SOURCE_FILES})
target_link_libraries (${TARGET_NAME} PRIVATE Urho3D)

# Link the engine and plugins.
target_link_libraries (${TARGET_NAME} PRIVATE
Urho3D
Plugin.Core.SamplePlugin
)
10 changes: 7 additions & 3 deletions Source/Main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
#include <Urho3D/Resource/ResourceCache.h>
#include <Urho3D/Scene/Scene.h>

#include <Core.SamplePlugin/SampleComponent.h>

using namespace Urho3D;

class MyApplication : public Application
Expand Down Expand Up @@ -70,6 +72,8 @@ void MyApplication::Setup()

void MyApplication::Start()
{
SampleComponent::RegisterObject(context_);

auto cache = GetSubsystem<ResourceCache>();
auto renderer = GetSubsystem<Renderer>();

Expand All @@ -92,6 +96,9 @@ void MyApplication::Start()
StaticModel* geometry = geometryNode_->CreateComponent<StaticModel>();
geometry->SetModel(cache->GetResource<Model>("Models/Box.mdl"));
geometry->SetMaterial(cache->GetResource<Material>("Materials/DefaultGrey.xml"));
SampleComponent* sampleComponent = geometryNode_->CreateComponent<SampleComponent>();
sampleComponent->SetAxis(Vector3::UP);
sampleComponent->SetRotationSpeed(10.0f);

// Create light.
Node* lightNode = scene_->CreateChild("Light");
Expand All @@ -113,9 +120,6 @@ void MyApplication::Stop()

void MyApplication::Update(VariantMap& eventData)
{
const float timeStep = eventData[Update::P_TIMESTEP].GetFloat();
geometryNode_->Rotate(Quaternion{10 * timeStep, Vector3::UP}, TS_WORLD);

auto input = GetSubsystem<Input>();
if (input->GetKeyPress(KEY_ESCAPE))
SendEvent(E_EXITREQUESTED);
Expand Down

0 comments on commit fe7ddd2

Please sign in to comment.