Support excluding 2D functionality from the build (CMake option URHO3D_URHO2D=0). Removed empty scene creation from the UIDrag example. Make compiling Civetweb conditional of URHO3D_NETWORK. Exclude samples depending on the Controls structure when URHO3D_NETWORK is disabled.
This commit is contained in:
Родитель
16c05ee6cf
Коммит
b325ba5195
|
@ -13,41 +13,14 @@ function Start()
|
|||
-- Execute base class startup
|
||||
SampleStart()
|
||||
|
||||
-- Create the scene content
|
||||
CreateScene()
|
||||
|
||||
-- Create the UI content
|
||||
CreateGUI()
|
||||
CreateInstructions()
|
||||
|
||||
-- Setup the viewport for displaying the scene
|
||||
SetupViewport()
|
||||
|
||||
-- Hook up to the frame update events
|
||||
SubscribeToEvents()
|
||||
end
|
||||
|
||||
function CreateScene()
|
||||
scene_ = Scene()
|
||||
|
||||
-- Create the Octree component to the scene. This is required before adding any drawable components, or else nothing will
|
||||
-- show up. The default octree volume will be from (-1000, -1000, -1000) to (1000, 1000, 1000) in world coordinates it
|
||||
-- is also legal to place objects outside the volume but their visibility can then not be checked in a hierarchically
|
||||
-- optimizing manner
|
||||
scene_:CreateComponent("Octree")
|
||||
|
||||
-- Create a scene node for the camera, which we will move around
|
||||
-- The camera will use default settings (1000 far clip distance, 45 degrees FOV, set aspect ratio automatically)
|
||||
cameraNode = scene_:CreateChild("Camera")
|
||||
-- Set an initial position for the camera scene node above the plane
|
||||
cameraNode.position = Vector3(0.0, 0.0, -10.0)
|
||||
local camera = cameraNode:CreateComponent("Camera")
|
||||
camera.orthographic = true
|
||||
camera.orthoSize = graphics.height * PIXEL_SIZE
|
||||
|
||||
input:SetMouseVisible(true)
|
||||
end
|
||||
|
||||
function CreateInstructions()
|
||||
-- Construct new Text object, set string to display and font to use
|
||||
local instructionText = ui.root:CreateChild("Text")
|
||||
|
@ -107,20 +80,9 @@ function CreateGUI()
|
|||
end
|
||||
end
|
||||
|
||||
function SetupViewport()
|
||||
-- Set up a viewport to the Renderer subsystem so that the 3D scene can be seen. We need to define the scene and the camera
|
||||
-- at minimum. Additionally we could configure the viewport screen size and the rendering path (eg. forward / deferred) to
|
||||
-- use, but now we just use full screen and default render path configured in the engine command line options
|
||||
local viewport = Viewport:new(scene_, cameraNode:GetComponent("Camera"))
|
||||
renderer:SetViewport(0, viewport)
|
||||
end
|
||||
|
||||
function SubscribeToEvents()
|
||||
-- Subscribe HandleUpdate() function for processing update events
|
||||
SubscribeToEvent("Update", "HandleUpdate")
|
||||
|
||||
-- Unsubscribe the SceneUpdate event from base class to prevent camera pitch and yaw in 2D sample
|
||||
UnsubscribeFromEvent("SceneUpdate")
|
||||
end
|
||||
|
||||
function HandleDragBegin(eventType, eventData)
|
||||
|
|
|
@ -14,43 +14,14 @@ void Start()
|
|||
// Execute base class startup
|
||||
SampleStart();
|
||||
|
||||
// Create the scene content
|
||||
CreateScene();
|
||||
|
||||
// Create the UI content
|
||||
CreateGUI();
|
||||
CreateInstructions();
|
||||
|
||||
// Setup the viewport for displaying the scene
|
||||
SetupViewport();
|
||||
|
||||
// Hook up to the frame update events
|
||||
SubscribeToEvents();
|
||||
}
|
||||
|
||||
void CreateScene()
|
||||
{
|
||||
scene_ = Scene();
|
||||
|
||||
// Create the Octree component to the scene. This is required before adding any drawable components, or else nothing will
|
||||
// show up. The default octree volume will be from (-1000, -1000, -1000) to (1000, 1000, 1000) in world coordinates; it
|
||||
// is also legal to place objects outside the volume but their visibility can then not be checked in a hierarchically
|
||||
// optimizing manner
|
||||
scene_.CreateComponent("Octree");
|
||||
|
||||
// Create a scene node for the camera, which we will move around
|
||||
// The camera will use default settings (1000 far clip distance, 45 degrees FOV, set aspect ratio automatically)
|
||||
cameraNode = scene_.CreateChild("Camera");
|
||||
// Set an initial position for the camera scene node above the plane
|
||||
cameraNode.position = Vector3(0.0f, 0.0f, -10.0f);
|
||||
|
||||
Camera@ camera = cameraNode.CreateComponent("Camera");
|
||||
camera.orthographic = true;
|
||||
camera.orthoSize = graphics.height * PIXEL_SIZE;
|
||||
|
||||
input.mouseVisible = true;
|
||||
}
|
||||
|
||||
void CreateGUI()
|
||||
{
|
||||
UIElement@ root = ui.root;
|
||||
|
@ -121,22 +92,10 @@ void CreateInstructions()
|
|||
instructionText.SetPosition(0, ui.root.height / 4);
|
||||
}
|
||||
|
||||
void SetupViewport()
|
||||
{
|
||||
// Set up a viewport to the Renderer subsystem so that the 3D scene can be seen. We need to define the scene and the camera
|
||||
// at minimum. Additionally we could configure the viewport screen size and the rendering path (eg. forward / deferred) to
|
||||
// use, but now we just use full screen and default render path configured in the engine command line options
|
||||
Viewport@ viewport = Viewport(scene_, cameraNode.GetComponent("Camera"));
|
||||
renderer.viewports[0] = viewport;
|
||||
}
|
||||
|
||||
void SubscribeToEvents()
|
||||
{
|
||||
// Subscribe HandleUpdate() function for processing update events
|
||||
SubscribeToEvent("Update", "HandleUpdate");
|
||||
|
||||
// Unsubscribe the SceneUpdate event from base class to prevent camera pitch and yaw in 2D sample
|
||||
UnsubscribeFromEvent("SceneUpdate");
|
||||
}
|
||||
|
||||
void HandleDragBegin(StringHash eventType, VariantMap& eventData)
|
||||
|
|
|
@ -154,6 +154,7 @@ A number of build options can be defined explicitly when invoking the above cmak
|
|||
|URHO3D_NETWORK |1|Enable Networking support|
|
||||
|URHO3D_PHYSICS |1|Enable Physics support|
|
||||
|URHO3D_NAVIGATION |1|Enable Navigation support|
|
||||
|URHO3D_URHO2D |1|Enable 2D rendering & physics support|
|
||||
|URHO3D_SAMPLES |0|Build sample applications|
|
||||
|URHO3D_TOOLS |1|Build standalone tools (Desktop and RPI only; on Android only build Lua standalone tools)|
|
||||
|URHO3D_EXTRAS |0|Build extras (Desktop and RPI only)|
|
||||
|
|
|
@ -458,6 +458,7 @@ cmake_xxxx batch files or shell scripts.
|
|||
|URHO3D_NETWORK |1|Enable Networking support |
|
||||
|URHO3D_PHYSICS |1|Enable Physics support |
|
||||
|URHO3D_NAVIGATION |1|Enable Navigation support |
|
||||
|URHO3D_URHO2D |1|Enable 2D rendering & physics support |
|
||||
|URHO3D_SAMPLES |0|Build sample applications |
|
||||
|URHO3D_TOOLS |1|Build standalone tools (Desktop and RPI only; |
|
||||
| | | on Android only build Lua standalone tools) |
|
||||
|
|
|
@ -66,12 +66,18 @@ if (URHO3D_HOME)
|
|||
foreach (DIR Audio Container Core Engine Graphics Input IO LuaScript Math Navigation Network Physics Resource Scene Script UI Urho2D)
|
||||
list (APPEND URHO3D_INCLUDE_DIRS ${URHO3D_SOURCE_TREE}/${DIR}) # Note: variable change to list context after this
|
||||
endforeach ()
|
||||
set (DIRS Box2D Bullet/src SDL/include)
|
||||
set (DIRS SDL/include)
|
||||
if (URHO3D_ANGELSCRIPT)
|
||||
list (APPEND DIRS AngelScript/include)
|
||||
endif ()
|
||||
if (URHO3D_NETWORK)
|
||||
list (APPEND DIRS kNet/include)
|
||||
endif ()
|
||||
if (URHO3D_ANGELSCRIPT)
|
||||
list (APPEND DIRS AngelScript/include)
|
||||
if (URHO3D_PHYSICS)
|
||||
list (APPEND DIRS Bullet/src)
|
||||
endif ()
|
||||
if (URHO3D_URHO2D)
|
||||
list (APPEND DIRS Box2D)
|
||||
endif ()
|
||||
foreach (DIR ${DIRS})
|
||||
list (APPEND URHO3D_INCLUDE_DIRS ${URHO3D_HOME}/Source/ThirdParty/${DIR})
|
||||
|
@ -128,12 +134,18 @@ else ()
|
|||
|
||||
if (URHO3D_INCLUDE_DIRS)
|
||||
set (BASE_DIR ${URHO3D_INCLUDE_DIRS})
|
||||
set (DIRS Bullet SDL)
|
||||
set (DIRS SDL)
|
||||
if (URHO3D_ANGELSCRIPT)
|
||||
list (APPEND DIRS AngelScript)
|
||||
endif ()
|
||||
if (URHO3D_NETWORK)
|
||||
list (APPEND DIRS kNet)
|
||||
endif ()
|
||||
if (URHO3D_ANGELSCRIPT)
|
||||
list (APPEND DIRS AngelScript)
|
||||
if (URHO3D_PHYSICS)
|
||||
list (APPEND DIRS Bullet)
|
||||
endif ()
|
||||
if (URHO3D_URHO2D)
|
||||
list (APPEND DIRS Box2D)
|
||||
endif ()
|
||||
foreach (DIR ${DIRS})
|
||||
list (APPEND URHO3D_INCLUDE_DIRS ${BASE_DIR}/${DIR}) # Note: variable change to list context after this, so we need BASE_DIR to remain the same
|
||||
|
|
|
@ -40,6 +40,7 @@ option (URHO3D_LUAJIT "Enable Lua scripting support using LuaJIT (check LuaJIT's
|
|||
option (URHO3D_NAVIGATION "Enable navigation support" TRUE)
|
||||
option (URHO3D_NETWORK "Enable networking support" TRUE)
|
||||
option (URHO3D_PHYSICS "Enable physics support" TRUE)
|
||||
option (URHO3D_URHO2D "Enable 2D graphics and physics support" TRUE)
|
||||
if (MINGW AND NOT DEFINED URHO3D_SSE)
|
||||
# Certain MinGW versions fail to compile SSE code. This is the initial guess for known "bad" version range, and can be tightened later
|
||||
execute_process (COMMAND ${CMAKE_C_COMPILER} -dumpversion OUTPUT_VARIABLE GCC_VERSION ERROR_QUIET)
|
||||
|
@ -199,6 +200,11 @@ if (URHO3D_PHYSICS)
|
|||
add_definitions (-DURHO3D_PHYSICS)
|
||||
endif ()
|
||||
|
||||
# Add definition for Urho2D
|
||||
if (URHO3D_URHO2D)
|
||||
add_definitions (-DURHO3D_URHO2D)
|
||||
endif ()
|
||||
|
||||
# Default library type is STATIC
|
||||
if (URHO3D_LIB_TYPE)
|
||||
string (TOUPPER ${URHO3D_LIB_TYPE} URHO3D_LIB_TYPE)
|
||||
|
|
|
@ -153,7 +153,7 @@ if (NOT WIN32)
|
|||
endif ()
|
||||
|
||||
# Add targets
|
||||
foreach (TARGET Box2D Civetweb FreeType JO LZ4 PugiXml SDL StanHull STB)
|
||||
foreach (TARGET FreeType JO LZ4 PugiXml SDL StanHull STB)
|
||||
add_subdirectory (ThirdParty/${TARGET})
|
||||
endforeach ()
|
||||
|
||||
|
@ -168,6 +168,7 @@ if (URHO3D_LUA)
|
|||
endif ()
|
||||
|
||||
if (URHO3D_NETWORK)
|
||||
add_subdirectory (ThirdParty/Civetweb)
|
||||
add_subdirectory (ThirdParty/kNet)
|
||||
endif ()
|
||||
|
||||
|
@ -180,6 +181,10 @@ if (URHO3D_PHYSICS)
|
|||
add_subdirectory (ThirdParty/Bullet)
|
||||
endif ()
|
||||
|
||||
if (URHO3D_URHO2D)
|
||||
add_subdirectory (ThirdParty/Box2D)
|
||||
endif ()
|
||||
|
||||
if (NOT IOS AND NOT ANDROID AND NOT RASPI)
|
||||
if (URHO3D_OPENGL)
|
||||
add_subdirectory (ThirdParty/GLEW)
|
||||
|
|
|
@ -62,7 +62,7 @@ if (MSVC AND URHO3D_LIB_TYPE STREQUAL SHARED) # MSVC linker does not have forc
|
|||
endif ()
|
||||
|
||||
# Define source files
|
||||
set (SOURCES Audio Container Core Engine Graphics Input IO Math Resource Scene UI Urho2D)
|
||||
set (SOURCES Audio Container Core Engine Graphics Input IO Math Resource Scene UI)
|
||||
if (URHO3D_ANGELSCRIPT)
|
||||
list (APPEND SOURCES Script)
|
||||
endif ()
|
||||
|
@ -79,6 +79,10 @@ if (URHO3D_PHYSICS)
|
|||
list (APPEND SOURCES Physics)
|
||||
endif ()
|
||||
|
||||
if (URHO3D_URHO2D)
|
||||
list (APPEND SOURCES Urho2D)
|
||||
endif ()
|
||||
|
||||
foreach (SOURCE ${SOURCES})
|
||||
add_subdirectory (${SOURCE})
|
||||
install (DIRECTORY ${SOURCE}/ DESTINATION ${DEST_INCLUDE_DIR} ${DEST_PERMISSIONS} FILES_MATCHING PATTERN *.h) # Note: the trailing slash is significant
|
||||
|
|
|
@ -49,7 +49,9 @@
|
|||
#include "Scene.h"
|
||||
#include "SceneEvents.h"
|
||||
#include "UI.h"
|
||||
#ifdef URHO3D_URHO2D
|
||||
#include "Urho2D.h"
|
||||
#endif
|
||||
#include "WorkQueue.h"
|
||||
#include "XMLFile.h"
|
||||
|
||||
|
@ -161,8 +163,10 @@ bool Engine::Initialize(const VariantMap& parameters)
|
|||
RegisterGraphicsLibrary(context_);
|
||||
}
|
||||
|
||||
#ifdef URHO3D_URHO2D
|
||||
// 2D graphics library is dependent on 3D graphics library
|
||||
RegisterUrho2DLibrary(context_);
|
||||
#endif
|
||||
|
||||
// Start logging
|
||||
Log* log = GetSubsystem<Log>();
|
||||
|
|
|
@ -58,6 +58,11 @@ if (NOT URHO3D_PHYSICS)
|
|||
list (REMOVE_ITEM API_PKG_FILES ${CMAKE_CURRENT_SOURCE_DIR}/pkgs/PhysicsLuaAPI.pkg)
|
||||
endif ()
|
||||
|
||||
# Remove Urho2DLuaAPI.pkg
|
||||
if (NOT URHO3D_URHO2D)
|
||||
list (REMOVE_ITEM API_PKG_FILES ${CMAKE_CURRENT_SOURCE_DIR}/pkgs/Urho2DLuaAPI.pkg)
|
||||
endif ()
|
||||
|
||||
foreach (API_PKG_FILE ${API_PKG_FILES})
|
||||
get_filename_component (NAME ${API_PKG_FILE} NAME)
|
||||
string (REGEX REPLACE LuaAPI\\.pkg$ "" API ${NAME})
|
||||
|
@ -78,8 +83,8 @@ install (FILES ${H_FILES} DESTINATION ${DEST_INCLUDE_DIR})
|
|||
# Define dependency libs
|
||||
set (LIBS ../../ThirdParty/Lua${JIT}/src)
|
||||
set (LINK_LIBS_ONLY toluapp)
|
||||
set (INCLUDE_DIRS_ONLY . .. ../Audio ../Container ../Core ../Engine ../Graphics ../Input ../IO ../Math ../Navigation ../Resource ../Scene ../UI ../Urho2D
|
||||
../../ThirdParty/Box2D ../../ThirdParty/SDL/include ../../ThirdParty/toluapp/include ${CMAKE_BINARY_DIR}/Engine)
|
||||
set (INCLUDE_DIRS_ONLY . .. ../Audio ../Container ../Core ../Engine ../Graphics ../Input ../IO ../Math ../Navigation ../Resource ../Scene ../UI
|
||||
../../ThirdParty/SDL/include ../../ThirdParty/toluapp/include ${CMAKE_BINARY_DIR}/Engine)
|
||||
|
||||
if (URHO3D_NAVIGATION)
|
||||
set (INCLUDE_DIRS_ONLY ${INCLUDE_DIRS_ONLY} ../Navigation)
|
||||
|
@ -93,5 +98,9 @@ if (URHO3D_PHYSICS)
|
|||
set (INCLUDE_DIRS_ONLY ${INCLUDE_DIRS_ONLY} ../Physics ../../ThirdParty/Bullet/src)
|
||||
endif ()
|
||||
|
||||
if (URHO3D_URHO2D)
|
||||
set (INCLUDE_DIRS_ONLY ${INCLUDE_DIRS_ONLY} ../Urho2D ../../ThirdParty/Box2D)
|
||||
endif ()
|
||||
|
||||
# Setup target
|
||||
setup_library ()
|
||||
|
|
|
@ -64,7 +64,9 @@ extern int tolua_PhysicsLuaAPI_open(lua_State*);
|
|||
extern int tolua_ResourceLuaAPI_open(lua_State*);
|
||||
extern int tolua_SceneLuaAPI_open(lua_State*);
|
||||
extern int tolua_UILuaAPI_open(lua_State*);
|
||||
#ifdef URHO3D_URHO2D
|
||||
extern int tolua_Urho2DLuaAPI_open(lua_State*);
|
||||
#endif
|
||||
extern int tolua_LuaScriptLuaAPI_open(lua_State*);
|
||||
|
||||
namespace Urho3D
|
||||
|
@ -115,7 +117,11 @@ LuaScript::LuaScript(Context* context) :
|
|||
#endif
|
||||
|
||||
tolua_UILuaAPI_open(luaState_);
|
||||
|
||||
#ifdef URHO3D_URHO2D
|
||||
tolua_Urho2DLuaAPI_open(luaState_);
|
||||
#endif
|
||||
|
||||
tolua_LuaScriptLuaAPI_open(luaState_);
|
||||
|
||||
coroutineUpdate_ = GetFunction("coroutine.update");
|
||||
|
|
|
@ -328,6 +328,7 @@ template<> int ToluaPushPODVector<RigidBody*>(lua_State* L, void* data, const ch
|
|||
}
|
||||
#endif
|
||||
|
||||
#ifdef URHO3D_URHO2D
|
||||
template<> int ToluaPushPODVector<RigidBody2D*>(lua_State* L, void* data, const char*)
|
||||
{
|
||||
const PODVector<RigidBody2D*>& vector = *((const PODVector<RigidBody2D*>*)data);
|
||||
|
@ -339,6 +340,7 @@ template<> int ToluaPushPODVector<RigidBody2D*>(lua_State* L, void* data, const
|
|||
}
|
||||
return 1;
|
||||
}
|
||||
#endif
|
||||
|
||||
template<typename T> int tolua_pushurho3dpodvectorusertype(lua_State* L, const PODVector<T>& vector, const char* typeName)
|
||||
{
|
||||
|
@ -377,10 +379,12 @@ template<> int ToluaPushPODVector<PhysicsRaycastResult>(lua_State* L, void* data
|
|||
}
|
||||
#endif
|
||||
|
||||
#ifdef URHO3D_URHO2D
|
||||
template<> int ToluaPushPODVector<PhysicsRaycastResult2D>(lua_State* L, void* data, const char*)
|
||||
{
|
||||
return tolua_pushurho3dpodvectorusertype(L, *((const PODVector<PhysicsRaycastResult2D>*)data), "PhysicsRaycastResult2D");
|
||||
}
|
||||
#endif
|
||||
|
||||
template<> int ToluaPushPODVector<RayQueryResult>(lua_State* L, void* data, const char*)
|
||||
{
|
||||
|
|
|
@ -27,7 +27,9 @@
|
|||
#ifdef URHO3D_PHYSICS
|
||||
#include "PhysicsWorld.h"
|
||||
#endif
|
||||
#ifdef URHO3D_URHO2D
|
||||
#include "PhysicsWorld2D.h"
|
||||
#endif
|
||||
#include "Vector2.h"
|
||||
#include "Vector3.h"
|
||||
|
||||
|
@ -126,8 +128,10 @@ template<> int ToluaPushPODVector<UIElement*>(lua_State* L, void* data, const ch
|
|||
/// Push PODVector<RigidBody*> to Lua as a table.
|
||||
template<> int ToluaPushPODVector<RigidBody*>(lua_State* L, void* data, const char* type);
|
||||
#endif
|
||||
#ifdef URHO3D_URHO2D
|
||||
/// Push PODVector<RigidBody2D*> to Lua as a table.
|
||||
template<> int ToluaPushPODVector<RigidBody2D*>(lua_State* L, void* data, const char* type);
|
||||
#endif
|
||||
/// Push PODVector<Vector3> to Lua as a table.
|
||||
template<> int ToluaPushPODVector<Vector3>(lua_State* L, void* data, const char* type);
|
||||
/// Push PODVector<IntVector2> to Lua as a table.
|
||||
|
@ -138,8 +142,10 @@ template<> int ToluaPushPODVector<OctreeQueryResult>(lua_State* L, void* data, c
|
|||
/// Push PODVector<PhysicsRaycastResult> to Lua as a table.
|
||||
template<> int ToluaPushPODVector<PhysicsRaycastResult>(lua_State* L, void* data, const char* type);
|
||||
#endif
|
||||
#ifdef URHO3D_URHO2D
|
||||
/// Push PODVector<PhysicsRaycastResult2D> to Lua as a table.
|
||||
template<> int ToluaPushPODVector<PhysicsRaycastResult2D>(lua_State* L, void* data, const char* type);
|
||||
#endif
|
||||
/// Push PODVector<RayQueryResult> to Lua as a table.
|
||||
template<> int ToluaPushPODVector<RayQueryResult>(lua_State* L, void* data, const char* type);
|
||||
/// Push PODVector<Pass*> to Lua as a table.
|
||||
|
|
|
@ -90,7 +90,9 @@ Script::Script(Context* context) :
|
|||
#ifdef URHO3D_NAVIGATION
|
||||
RegisterNavigationAPI(scriptEngine_);
|
||||
#endif
|
||||
#ifdef URHO3D_URHO2D
|
||||
RegisterUrho2DAPI(scriptEngine_);
|
||||
#endif
|
||||
RegisterScriptAPI(scriptEngine_);
|
||||
RegisterEngineAPI(scriptEngine_);
|
||||
|
||||
|
|
|
@ -21,6 +21,7 @@
|
|||
//
|
||||
|
||||
#include "Precompiled.h"
|
||||
#ifdef URHO3D_URHO2D
|
||||
#include "AnimatedSprite2D.h"
|
||||
#include "Animation2D.h"
|
||||
#include "AnimationSet2D.h"
|
||||
|
@ -767,3 +768,4 @@ void RegisterUrho2DAPI(asIScriptEngine* engine)
|
|||
}
|
||||
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -56,39 +56,14 @@ void UIDrag::Start()
|
|||
// Execute base class startup
|
||||
Sample::Start();
|
||||
|
||||
// Create the scene content
|
||||
CreateScene();
|
||||
|
||||
// Create the UI content
|
||||
CreateGUI();
|
||||
CreateInstructions();
|
||||
|
||||
// Setup the viewport for displaying the scene
|
||||
SetupViewport();
|
||||
|
||||
// Hook up to the frame update events
|
||||
SubscribeToEvents();
|
||||
}
|
||||
|
||||
void UIDrag::CreateScene()
|
||||
{
|
||||
scene_ = new Scene(context_);
|
||||
scene_->CreateComponent<Octree>();
|
||||
|
||||
// Create camera node
|
||||
cameraNode_ = scene_->CreateChild("Camera");
|
||||
// Set camera's position
|
||||
cameraNode_->SetPosition(Vector3(0.0f, 0.0f, -10.0f));
|
||||
|
||||
Camera* camera = cameraNode_->CreateComponent<Camera>();
|
||||
camera->SetOrthographic(true);
|
||||
|
||||
Graphics* graphics = GetSubsystem<Graphics>();
|
||||
camera->SetOrthoSize((float)graphics->GetHeight() * PIXEL_SIZE);
|
||||
|
||||
GetSubsystem<Input>()->SetMouseVisible(true);
|
||||
}
|
||||
|
||||
void UIDrag::CreateGUI()
|
||||
{
|
||||
ResourceCache* cache = GetSubsystem<ResourceCache>();
|
||||
|
@ -166,20 +141,9 @@ void UIDrag::CreateInstructions()
|
|||
instructionText->SetPosition(0, ui->GetRoot()->GetHeight() / 4);
|
||||
}
|
||||
|
||||
void UIDrag::SetupViewport()
|
||||
{
|
||||
Renderer* renderer = GetSubsystem<Renderer>();
|
||||
|
||||
// Set up a viewport to the Renderer subsystem so that the 3D scene can be seen
|
||||
SharedPtr<Viewport> viewport(new Viewport(context_, scene_, cameraNode_->GetComponent<Camera>()));
|
||||
renderer->SetViewport(0, viewport);
|
||||
}
|
||||
|
||||
void UIDrag::SubscribeToEvents()
|
||||
{
|
||||
SubscribeToEvent(E_UPDATE, HANDLER(UIDrag, HandleUpdate));
|
||||
// Unsubscribe the SceneUpdate event from base class to prevent camera pitch and yaw in 2D sample
|
||||
UnsubscribeFromEvent(E_SCENEUPDATE);
|
||||
}
|
||||
|
||||
void UIDrag::HandleDragBegin(StringHash eventType, VariantMap& eventData)
|
||||
|
|
|
@ -57,14 +57,10 @@ protected:
|
|||
}
|
||||
|
||||
private:
|
||||
/// Construct the scene content.
|
||||
void CreateScene();
|
||||
/// Construct the GUI
|
||||
/// Construct the GUI.
|
||||
void CreateGUI();
|
||||
/// Construct an instruction text to the UI.
|
||||
void CreateInstructions();
|
||||
/// Set up a viewport for displaying the scene.
|
||||
void SetupViewport();
|
||||
/// Subscribe to application-wide logic update events.
|
||||
void SubscribeToEvents();
|
||||
|
||||
|
|
|
@ -58,8 +58,6 @@ if (URHO3D_NETWORK)
|
|||
endif ()
|
||||
if (URHO3D_NETWORK AND URHO3D_PHYSICS)
|
||||
add_subdirectory (17_SceneReplication)
|
||||
endif ()
|
||||
IF (URHO3D_PHYSICS)
|
||||
add_subdirectory (18_CharacterDemo)
|
||||
add_subdirectory (19_VehicleDemo)
|
||||
endif ()
|
||||
|
@ -71,17 +69,19 @@ if (URHO3D_LUA)
|
|||
add_subdirectory (22_LuaIntegration)
|
||||
endif ()
|
||||
add_subdirectory (23_Water)
|
||||
add_subdirectory (24_Urho2DSprite)
|
||||
add_subdirectory (25_Urho2DParticle)
|
||||
if (URHO3D_URHO2D)
|
||||
add_subdirectory (24_Urho2DSprite)
|
||||
add_subdirectory (25_Urho2DParticle)
|
||||
add_subdirectory (27_Urho2DPhysics)
|
||||
add_subdirectory (28_Urho2DPhysicsRope)
|
||||
add_subdirectory (32_Urho2DConstraints)
|
||||
add_subdirectory (33_Urho2DSpriterAnimation)
|
||||
add_subdirectory (36_Urho2DTileMap)
|
||||
endif ()
|
||||
add_subdirectory (26_ConsoleInput)
|
||||
add_subdirectory (27_Urho2DPhysics)
|
||||
add_subdirectory (28_Urho2DPhysicsRope)
|
||||
add_subdirectory (29_SoundSynthesis)
|
||||
add_subdirectory (30_LightAnimation)
|
||||
add_subdirectory (31_MaterialAnimation)
|
||||
add_subdirectory (32_Urho2DConstraints)
|
||||
add_subdirectory (33_Urho2DSpriterAnimation)
|
||||
add_subdirectory (34_DynamicGeometry)
|
||||
add_subdirectory (35_SignedDistanceFieldText)
|
||||
add_subdirectory (36_Urho2DTileMap)
|
||||
add_subdirectory (37_UIDrag)
|
||||
|
|
Загрузка…
Ссылка в новой задаче