Commit 518625f3 authored by 魔大农's avatar 魔大农

Initial commit

parent 40877db1
File added
LIBS += ../Urho3DQtemplate/Urho3D/lib/libUrho3D.a \
-lpthread \
-ldl \
-lGL
DEFINES += URHO3D_COMPILE_QT
QMAKE_CXXFLAGS += -std=c++1y
INCLUDEPATH += \
../Urho3DQtemplate/Urho3D/include \
../Urho3DQtemplate/Urho3D/include/Urho3D/ThirdParty \
TEMPLATE = app
CONFIG += console
CONFIG -= app_bundle
CONFIG -= qt
SOURCES += \
luckey.cpp \
mastercontrol.cpp \
inputmaster.cpp \
templatecam.cpp \
urho.cpp
HEADERS += \
luckey.h \
mastercontrol.h \
inputmaster.h \
templatecam.h \
urho.h
<material>
<technique name="CoreData/Techniques/DiffNormalAlpha.xml" quality="1" loddistance="0"/>
<texture name="Resources/Textures/UrhoDiffuse.png" unit="diffuse"/>
<texture name="Resources/Textures/UrhoNormals.png" unit="normal"/>
</material>
<?xml version="1.0"?>
<material>
<technique name="Resources/Techniques/NoTextureVColAlpha.xml" quality="0" loddistance="0" />
<texture name="Resources/Textures/UrhoDiffuse.png" unit="diffuse"/>
<texture name="Resources/Textures/UrhoNormals.png" unit="normal"/>
<parameter name="UOffset" value="1 0 0 0" />
<parameter name="VOffset" value="0 1 0 0" />
<parameter name="MatDiffColor" value="1 1 1 1" />
<parameter name="MatEmissiveColor" value="0 0 0" />
<parameter name="MatSpecColor" value="1 1 1 23" />
<cull value="ccw" />
<shadowcull value="ccw" />
<fill value="solid" />
<depthbias constant="0" slopescaled="0" />
</material>
<technique vs="LitSolid" ps="LitSolid" vsdefines="NOUV VERTEXCOLOR" psdefines="VERTEXCOLOR" >
<pass name="base" psdefines="AMBIENT"/>
<pass name="litbase" vsdefines="NORMALMAP" psdefines="VERTEXCOLOR" blend="alpha"/>
<pass name="light" vsdefines="VERTEXCOLOR" depthtest="equal" depthwrite="false" blend="addalpha" />
<pass name="prepass" psdefines="PREPASS" />
<pass name="material" psdefines="MATERIAL" depthtest="equal" depthwrite="false" />
<pass name="deferred" psdefines="DEFERRED" />
<pass name="depth" vs="Depth" ps="Depth" />
<pass name="shadow" vs="Shadow" ps="Shadow" />
</technique>
This diff is collapsed.
This diff is collapsed.
/home/frode/Git/Urho3D
\ No newline at end of file
/* LucKey Productions Urho3D Project Template
//
// This is free and unencumbered software released into the public domain.
//
// Anyone is free to copy, modify, publish, use, compile, sell, or
// distribute this software, either in source code form or as a compiled
// binary, for any purpose, commercial or non-commercial, and by any
// means.
//
// In jurisdictions that recognize copyright laws, the author or authors
// of this software dedicate any and all copyright interest in the
// software to the public domain. We make this dedication for the benefit
// of the public at large and to the detriment of our heirs and
// successors. We intend this dedication to be an overt act of
// relinquishment in perpetuity of all present and future rights to this
// software under copyright law.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
// IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
// OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
// OTHER DEALINGS IN THE SOFTWARE.
//
// For more information, please refer to <http://unlicense.org/>
*/
#include "inputmaster.h"
#include "templatecam.h"
InputMaster::InputMaster(Context* context, MasterControl* masterControl) : Object(context),
masterControl_{masterControl},
input_{GetSubsystem<Input>()}
{
SubscribeToEvent(E_MOUSEBUTTONDOWN, URHO3D_HANDLER(InputMaster, HandleMouseButtonDown));
SubscribeToEvent(E_MOUSEBUTTONUP, URHO3D_HANDLER(InputMaster, HandleMouseButtonUp));
SubscribeToEvent(E_KEYDOWN, URHO3D_HANDLER(InputMaster, HandleKeyDown));
SubscribeToEvent(E_KEYUP, URHO3D_HANDLER(InputMaster, HandleKeyUp));
SubscribeToEvent(E_JOYSTICKBUTTONDOWN, URHO3D_HANDLER(InputMaster, HandleJoystickButtonDown));
SubscribeToEvent(E_JOYSTICKBUTTONUP, URHO3D_HANDLER(InputMaster, HandleJoystickButtonUp));
}
void InputMaster::HandleKeyDown(StringHash eventType, VariantMap &eventData)
{
using namespace KeyDown;
int key = eventData[P_KEY].GetInt();
pressedKeys_.Insert(key);
switch (key){
//Exit when ESC is pressed
case KEY_ESC:{
masterControl_->Exit();
} break;
//Take screenshot
case KEY_9:{
Graphics* graphics = GetSubsystem<Graphics>();
Image screenshot(context_);
graphics->TakeScreenShot(screenshot);
//Here we save in the Data folder with date and time appended
String fileName = GetSubsystem<FileSystem>()->GetProgramDir() + "Screenshots/Screenshot_" +
Time::GetTimeStamp().Replaced(':', '_').Replaced('.', '_').Replaced(' ', '_')+".png";
Log::Write(1, fileName);
screenshot.SavePNG(fileName);
} break;
default: break;
}
}
void InputMaster::HandleKeyUp(StringHash eventType, VariantMap &eventData)
{
using namespace KeyUp;
int key = eventData[P_KEY].GetInt();
if (pressedKeys_.Contains(key)) pressedKeys_.Erase(key);
}
void InputMaster::HandleMouseButtonDown(StringHash eventType, VariantMap &eventData)
{
using namespace MouseButtonDown;
int button = eventData[P_BUTTON].GetInt();
pressedMouseButtons_.Insert(button);
}
void InputMaster::HandleMouseButtonUp(StringHash eventType, VariantMap &eventData)
{
using namespace MouseButtonUp;
int button = eventData[P_BUTTON].GetInt();
if (pressedMouseButtons_.Contains(button)) pressedMouseButtons_.Erase(button);
}
void InputMaster::HandleJoystickButtonDown(StringHash eventType, VariantMap &eventData)
{
using namespace JoystickButtonDown;
int joystickId = eventData[P_JOYSTICKID].GetInt();
int button = eventData[P_BUTTON].GetInt();
pressedJoystickButtons_.Insert(button);
}
void InputMaster::HandleJoystickButtonUp(StringHash eventType, VariantMap &eventData)
{
using namespace JoystickButtonUp;
int joystickId = eventData[P_JOYSTICKID].GetInt();
int button = eventData[P_BUTTON].GetInt();
if (pressedJoystickButtons_.Contains(button)) pressedJoystickButtons_.Erase(button);
}
/* LucKey Productions Urho3D Project Template
//
// This is free and unencumbered software released into the public domain.
//
// Anyone is free to copy, modify, publish, use, compile, sell, or
// distribute this software, either in source code form or as a compiled
// binary, for any purpose, commercial or non-commercial, and by any
// means.
//
// In jurisdictions that recognize copyright laws, the author or authors
// of this software dedicate any and all copyright interest in the
// software to the public domain. We make this dedication for the benefit
// of the public at large and to the detriment of our heirs and
// successors. We intend this dedication to be an overt act of
// relinquishment in perpetuity of all present and future rights to this
// software under copyright law.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
// IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
// OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
// OTHER DEALINGS IN THE SOFTWARE.
//
// For more information, please refer to <http://unlicense.org/>
*/
#ifndef INPUTMASTER_H
#define INPUTMASTER_H
#include <Urho3D/Urho3D.h>
#include "mastercontrol.h"
namespace Urho3D {
class Drawable;
class Node;
class Scene;
class Sprite;
}
using namespace Urho3D;
enum class JoystickButton {SELECT, LEFTSTICK, RIGHTSTICK, START, DPAD_UP, DPAD_RIGHT, DPAD_DOWN, DPAD_LEFT, L2, R2, L1, R1, TRIANGLE, CIRCLE, CROSS, SQUARE};
class InputMaster : public Object
{
URHO3D_OBJECT(InputMaster, Object);
public:
InputMaster(Context* context, MasterControl* masterControl);
WeakPtr<Node> firstHit_;
private:
MasterControl* masterControl_;
Input* input_;
HashSet<int> pressedKeys_;
HashSet<int> pressedMouseButtons_;
HashSet<int> pressedJoystickButtons_;
void HandleKeyDown(StringHash eventType, VariantMap &eventData);
void HandleKeyUp(StringHash eventType, VariantMap &eventData);
void HandleMouseButtonDown(StringHash eventType, VariantMap &eventData);
void HandleMouseButtonUp(StringHash eventType, VariantMap &eventData);
void HandleJoystickButtonDown(StringHash eventType, VariantMap &eventData);
void HandleJoystickButtonUp(StringHash eventType, VariantMap &eventData);
};
#endif // INPUTMASTER_H
/*
// Copyright (C) 2015 LucKey Productions (luckeyproductions.nl)
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License along
// with this program; if not, write to the Free Software Foundation, Inc.,
// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#include "luckey.h"
float LucKey::Distance(const Vector3 from, const Vector3 to){
return (to - from).Length();
}
unsigned LucKey::IntVector2ToHash(IntVector2 vec) { return (MakeHash(vec.x_) & 0xffff) | (MakeHash(vec.y_) << 16); }
Vector3 LucKey::Scale(const Vector3 lhs, const Vector3 rhs) {
return Vector3(lhs.x_ * rhs.x_, lhs.y_ * rhs.y_, lhs.z_ * rhs.z_);
}
Urho3D::IntVector2 LucKey::Scale(const Urho3D::IntVector2 lhs, const Urho3D::IntVector2 rhs) {
return Urho3D::IntVector2(lhs.x_ * rhs.x_, lhs.y_ * rhs.y_);
}
Vector2 LucKey::Rotate(const Vector2 vec2, const float angle){
float x = vec2.x_;
float y = vec2.y_;
float theta = M_DEGTORAD * angle;
float cs = cos(theta);
float sn = sin(theta);
return Vector2(x * cs - y * sn, x * sn + y * cs);
}
float LucKey::RandomSign()
{
return Random(2)*2-1;
}
Color LucKey::RandomHairColor()
{
Color hairColor{};
hairColor.FromHSV(Random(0.1666f), Random(0.05f, 0.7f), Random(0.9f));
return hairColor;
}
Color LucKey::RandomSkinColor()
{
Color skinColor{};
skinColor.FromHSV(Random(0.05f, 0.18f), Random(0.5f, 0.75f), Random(0.23f, 0.8f));
return skinColor;
}
Color LucKey::RandomColor()
{
Color color{};
color.FromHSV(Random(), Random(), Random());
return color;
}
/*
// Copyright (C) 2015 LucKey Productions (luckeyproductions.nl)
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License along
// with this program; if not, write to the Free Software Foundation, Inc.,
// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#ifndef LUCKEY_H
#define LUCKEY_H
#include <Urho3D/Urho3D.h>
#include <Urho3D/Audio/Sound.h>
#include <Urho3D/Audio/SoundSource.h>
#include <Urho3D/Container/HashBase.h>
#include <Urho3D/Container/HashMap.h>
#include <Urho3D/Container/Vector.h>
#include <Urho3D/Core/CoreEvents.h>
#include <Urho3D/Engine/Application.h>
#include <Urho3D/Engine/Console.h>
#include <Urho3D/Engine/DebugHud.h>
#include <Urho3D/Engine/Engine.h>
#include <Urho3D/Graphics/AnimatedModel.h>
#include <Urho3D/Graphics/AnimationController.h>
#include <Urho3D/Graphics/Animation.h>
#include <Urho3D/Graphics/AnimationState.h>
#include <Urho3D/Graphics/Camera.h>
#include <Urho3D/Graphics/DebugRenderer.h>
#include <Urho3D/Graphics/DecalSet.h>
#include <Urho3D/Graphics/Graphics.h>
#include <Urho3D/Graphics/Light.h>
#include <Urho3D/Graphics/Material.h>
#include <Urho3D/Graphics/Model.h>
#include <Urho3D/Graphics/Octree.h>
#include <Urho3D/Graphics/OctreeQuery.h>
#include <Urho3D/Graphics/ParticleEffect.h>
#include <Urho3D/Graphics/ParticleEmitter.h>
#include <Urho3D/Graphics/Renderer.h>
#include <Urho3D/Graphics/RenderPath.h>
#include <Urho3D/Graphics/Skybox.h>
#include <Urho3D/Graphics/StaticModel.h>
#include <Urho3D/Graphics/Viewport.h>
#include <Urho3D/Graphics/Zone.h>
#include <Urho3D/Input/InputEvents.h>
#include <Urho3D/Input/Input.h>
#include <Urho3D/IO/FileSystem.h>
#include <Urho3D/IO/Log.h>
#include <Urho3D/Math/MathDefs.h>
#include <Urho3D/Math/Plane.h>
#include <Urho3D/Math/Sphere.h>
#include <Urho3D/Math/Vector2.h>
#include <Urho3D/Math/Vector3.h>
#include <Urho3D/Physics/CollisionShape.h>
#include <Urho3D/Physics/PhysicsEvents.h>
#include <Urho3D/Physics/PhysicsWorld.h>
#include <Urho3D/Physics/RigidBody.h>
#include <Urho3D/Resource/ResourceCache.h>
#include <Urho3D/Resource/XMLFile.h>
#include <Urho3D/Scene/LogicComponent.h>
#include <Urho3D/Scene/Node.h>
#include <Urho3D/Scene/SceneEvents.h>
#include <Urho3D/Scene/Scene.h>
#include <Urho3D/UI/Font.h>
#include <Urho3D/UI/Text.h>
#include <Urho3D/UI/UI.h>
#include <Urho3D/DebugNew.h>
namespace Urho3D {
class Drawable;
class Node;
class Scene;
class Sprite;
class Viewport;
class RenderPath;
class Camera;
}
using namespace Urho3D;
namespace LucKey {
enum class SixaxisButton { SELECT, LEFTSTICK, RIGHTSTICK, START,
DPAD_UP, DPAD_RIGHT, DPAD_DOWN, DPAD_LEFT,
L2, R2, L1, R1, TRIANGLE, CIRCLE, CROSS, SQUARE,
PS
};
template <class T>
T Cycle(T x, T min, T max){
return (x < min) ?
x + (max - min) * abs(ceil((min - x) / (max - min)))
: (x > max) ?
x - (max - min) * abs(ceil((x - max) / (max - min)))
: x;
}
float Distance(const Vector3 from, const Vector3 to);
unsigned IntVector2ToHash(IntVector2 vec);
Vector3 Scale(const Vector3 lhs, const Vector3 rhs);
IntVector2 Scale(const IntVector2 lhs, const IntVector2 rhs);
Vector2 Rotate(const Vector2 vec2, const float angle);
float RandomSign();
Color RandomColor();
Color RandomSkinColor();
Color RandomHairColor();
}
#endif // LUCKEY_H
/* LucKey Productions Urho3D Project Template
// This is free and unencumbered software released into the public domain.
// Anyone is free to copy, modify, publish, use, compile, sell, or
// distribute this software, either in source code form or as a compiled
// binary, for any purpose, commercial or non-commercial, and by any
// means.
// In jurisdictions that recognize copyright laws, the author or authors
// of this software dedicate any and all copyright interest in the
// software to the public domain. We make this dedication for the benefit
// of the public at large and to the detriment of our heirs and
// successors. We intend this dedication to be an overt act of
// relinquishment in perpetuity of all present and future rights to this
// software under copyright law.
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
// IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
// OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
// OTHER DEALINGS IN THE SOFTWARE.
// For more information, please refer to <http://unlicense.org/>
*/
#include "mastercontrol.h"
#include "templatecam.h"
#include "inputmaster.h"
#include "urho.h"
URHO3D_DEFINE_APPLICATION_MAIN(MasterControl);
MasterControl::MasterControl(Context *context):
Application(context)
{
}
void MasterControl::Setup()
{
engineParameters_["WindowTitle"] = "LucKey Productions Urho3D Project Template";
engineParameters_["LogName"] = GetSubsystem<FileSystem>()->GetAppPreferencesDir("urho3d", "logs")+"LucKeyTemplate.log";
// engineParameters_["FullScreen"] = false;
// engineParameters_["WindowWidth"] = 960;
// engineParameters_["WindowHeight"] = 540;
}
void MasterControl::Start()
{
new InputMaster(context_, this);
cache_ = GetSubsystem<ResourceCache>();
CreateScene();
//Play music
Sound* music = cache_->GetResource<Sound>("Resources/Music/Urho - Disciples of Urho.ogg");
music->SetLooped(true);
Node* musicNode = world.scene->CreateChild("Music");
SoundSource* musicSource = musicNode->CreateComponent<SoundSource>();
musicSource->SetSoundType(SOUND_MUSIC);
musicSource->Play(music);
}
void MasterControl::Stop()
{
engine_->DumpResources(true);
}
void MasterControl::Exit()
{
engine_->Exit();
}
void MasterControl::CreateScene()
{
world.scene = new Scene(context_);
world.scene->CreateComponent<Octree>();
world.camera = new TemplateCam(context_, this);
CreateLights();
new Urho(context_, this);
}
void MasterControl::CreateLights()
{
//Add a directional light to the world. Enable cascaded shadows on it
Node* downardsLightNode = world.scene->CreateChild("DirectionalLight");
downardsLightNode->SetPosition(Vector3(-2.0f, 10.0f, -5.0f));
downardsLightNode->LookAt(Vector3(0.0f, 0.0f, 0.0f));
Light* downwardsLight = downardsLightNode->CreateComponent<Light>();
downwardsLight->SetLightType(LIGHT_DIRECTIONAL);
downwardsLight->SetBrightness(0.666f);
downwardsLight->SetColor(Color(0.8f, 0.9f, 0.95f));
downwardsLight->SetCastShadows(true);
downwardsLight->SetShadowIntensity(0.23f);
downwardsLight->SetShadowBias(BiasParameters(0.000025f, 0.5f));
downwardsLight->SetShadowCascade(CascadeParameters(1.0f, 5.0f, 23.0f, 100.0f, 0.8f));
//Add a directional light to the world. Enable cascaded shadows on it
Node* upwardsLightNode = world.scene->CreateChild("DirectionalLight");
upwardsLightNode->SetPosition(Vector3(3.0f, -10.0f, -5.0f));
upwardsLightNode->LookAt(Vector3(0.0f, 0.0f, 0.0f));
Light* upwardsLight = upwardsLightNode->CreateComponent<Light>();
upwardsLight->SetLightType(LIGHT_DIRECTIONAL);
upwardsLight->SetBrightness(0.5);
upwardsLight->SetColor(Color(0.23f, 0.666f, 1.0f));
//Create a point light. Enable cascaded shadows on it
Node* pointLightNode_ = world.scene->CreateChild("MovingLight");
pointLightNode_->SetPosition(Vector3(0.0f, -1.0f, -13.0f));
Light* pointLight = pointLightNode_->CreateComponent<Light>();
pointLight->SetLightType(LIGHT_POINT);
pointLight->SetBrightness(0.1f);
pointLight->SetRange(23.0f);
pointLight->SetColor(Color(0.5f, 1.23f, 0.75f));
}
/* LucKey Productions Urho3D Project Template
//
// This is free and unencumbered software released into the public domain.
//
// Anyone is free to copy, modify, publish, use, compile, sell, or
// distribute this software, either in source code form or as a compiled
// binary, for any purpose, commercial or non-commercial, and by any
// means.
//
// In jurisdictions that recognize copyright laws, the author or authors
// of this software dedicate any and all copyright interest in the
// software to the public domain. We make this dedication for the benefit
// of the public at large and to the detriment of our heirs and
// successors. We intend this dedication to be an overt act of
// relinquishment in perpetuity of all present and future rights to this
// software under copyright law.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
// IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
// OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
// OTHER DEALINGS IN THE SOFTWARE.
//
// For more information, please refer to <http://unlicense.org/>
*/
#ifndef MASTERCONTROL_H
#define MASTERCONTROL_H
#include <Urho3D/Urho3D.h>
#include "luckey.h"
namespace Urho3D {
class Drawable;
class Node;
class Scene;
class Sprite;
}
using namespace Urho3D;
class TemplateCam;
class InputMaster;
typedef struct GameWorld
{
SharedPtr<TemplateCam> camera;
SharedPtr<Scene> scene;
struct {
SharedPtr<Node> sceneCursor;
SharedPtr<Cursor> uiCursor;
PODVector<RayQueryResult> hitResults;
} cursor;
} GameWorld;
class MasterControl : public Application
{
URHO3D_OBJECT(MasterControl, Application);
friend class InputMaster;
public:
MasterControl(Context* context);
GameWorld world;
SharedPtr<ResourceCache> cache_;
SharedPtr<Graphics> graphics_;
/// Setup before engine initialization. Modifies the engine paramaters.
virtual void Setup();
/// Setup after engine initialization.
virtual void Start();
/// Cleanup after the main loop. Called by Application.
virtual void Stop();
void Exit();
void CreateLights();
private:
Node* movingLightNode_;
void CreateScene();
void HandleUpdate(StringHash eventType, VariantMap& eventData);
};
#endif // MASTERCONTROL_H
/* LucKey Productions Urho3D Project Template
//
// This is free and unencumbered software released into the public domain.
//
// Anyone is free to copy, modify, publish, use, compile, sell, or
// distribute this software, either in source code form or as a compiled
// binary, for any purpose, commercial or non-commercial, and by any
// means.
//
// In jurisdictions that recognize copyright laws, the author or authors
// of this software dedicate any and all copyright interest in the
// software to the public domain. We make this dedication for the benefit
// of the public at large and to the detriment of our heirs and
// successors. We intend this dedication to be an overt act of
// relinquishment in perpetuity of all present and future rights to this
// software under copyright law.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
// IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
// OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
// OTHER DEALINGS IN THE SOFTWARE.
//
// For more information, please refer to <http://unlicense.org/>
*/
#include "templatecam.h"
TemplateCam::TemplateCam(Context *context, MasterControl *masterControl):
Object(context)
{
masterControl_ = masterControl;
rootNode_ = masterControl_->world.scene->CreateChild("Camera");
camera_ = rootNode_->CreateComponent<Camera>();
camera_->SetFarClip(1024.0f);
rootNode_->SetPosition(Vector3(0.0f, 1.0f, -13.0f));
rootNode_->SetRotation(Quaternion(10.0f, 0.0f, 0.0f));
// Zone* zone = rootNode_->CreateComponent<Zone>();
// zone->SetFogStart(13.0f);
// zone->SetFogEnd(23.0f);
SetupViewport();
}
void TemplateCam::SetupViewport()
{
//Set up a viewport to the Renderer subsystem so that the 3D scene can be seen
SharedPtr<Viewport> viewport(new Viewport(context_, masterControl_->world.scene, camera_));
viewport_ = viewport;
//Add anti-asliasing and bloom
effectRenderPath_ = viewport_->GetRenderPath()->Clone();
effectRenderPath_->Append(masterControl_->cache_->GetResource<XMLFile>("PostProcess/FXAA3.xml"));
effectRenderPath_->SetEnabled("FXAA3", true);
effectRenderPath_->Append(masterControl_->cache_->GetResource<XMLFile>("PostProcess/Bloom.xml"));
effectRenderPath_->SetShaderParameter("BloomThreshold", 0.23f);
effectRenderPath_->SetShaderParameter("BloomMix", Vector2(1.75f, 1.25f));
effectRenderPath_->SetEnabled("Bloom", true);
Renderer* renderer = GetSubsystem<Renderer>();
viewport_->SetRenderPath(effectRenderPath_);
renderer->SetViewport(0, viewport_);
}
Vector3 TemplateCam::GetWorldPosition()
{
return rootNode_->GetWorldPosition();
}
Quaternion TemplateCam::GetRotation()
{
return rootNode_->GetRotation();
}
/* LucKey Productions Urho3D Project Template
//
// This is free and unencumbered software released into the public domain.
//
// Anyone is free to copy, modify, publish, use, compile, sell, or
// distribute this software, either in source code form or as a compiled
// binary, for any purpose, commercial or non-commercial, and by any
// means.
//
// In jurisdictions that recognize copyright laws, the author or authors
// of this software dedicate any and all copyright interest in the
// software to the public domain. We make this dedication for the benefit
// of the public at large and to the detriment of our heirs and
// successors. We intend this dedication to be an overt act of
// relinquishment in perpetuity of all present and future rights to this
// software under copyright law.