Commit 4bbe8bfc authored by 魔大农's avatar 魔大农

Added screenshot to readme

parent 061768ba
No preview for this file type
......@@ -20,12 +20,10 @@ SOURCES += \
luckey.cpp \
mastercontrol.cpp \
inputmaster.cpp \
templatecam.cpp \
urho.cpp
quartocam.cpp
HEADERS += \
luckey.h \
mastercontrol.h \
inputmaster.h \
templatecam.h \
urho.h
quartocam.h
# Quarto
A digital version of the boardgame by Blaise Müller
A digital version of the boardgame of the same name by Blaise Müller
![A rendered image of the board](https://raw.githubusercontent.com/Modanung/Quarto/master/Blends/Render/1.png)
\ No newline at end of file
<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.
......@@ -27,7 +27,7 @@
*/
#include "inputmaster.h"
#include "templatecam.h"
#include "quartocam.h"
InputMaster::InputMaster(Context* context, MasterControl* masterControl) : Object(context),
masterControl_{masterControl},
......
......@@ -27,9 +27,8 @@
*/
#include "mastercontrol.h"
#include "templatecam.h"
#include "quartocam.h"
#include "inputmaster.h"
#include "urho.h"
URHO3D_DEFINE_APPLICATION_MAIN(MasterControl);
......@@ -55,7 +54,7 @@ void MasterControl::Start()
//Play music
Sound* music = cache_->GetResource<Sound>("Resources/Music/Urho - Disciples of Urho.ogg");
Sound* music = cache_->GetResource<Sound>("Resources/Music/Angelight - The Knowledge River.ogg");
music->SetLooped(true);
Node* musicNode = world.scene->CreateChild("Music");
SoundSource* musicSource = musicNode->CreateComponent<SoundSource>();
......@@ -76,9 +75,8 @@ void MasterControl::CreateScene()
{
world.scene = new Scene(context_);
world.scene->CreateComponent<Octree>();
world.camera = new TemplateCam(context_, this);
world.camera = new QuartoCam(context_, this);
CreateLights();
new Urho(context_, this);
}
void MasterControl::CreateLights()
......
......@@ -41,12 +41,12 @@ class Sprite;
using namespace Urho3D;
class TemplateCam;
class QuartoCam;
class InputMaster;
typedef struct GameWorld
{
SharedPtr<TemplateCam> camera;
SharedPtr<QuartoCam> camera;
SharedPtr<Scene> scene;
struct {
SharedPtr<Node> sceneCursor;
......
......@@ -26,31 +26,52 @@
// For more information, please refer to <http://unlicense.org/>
*/
#ifndef URHO_H
#define URHO_H
#include "quartocam.h"
#include <Urho3D/Urho3D.h>
#include "mastercontrol.h"
QuartoCam::QuartoCam(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 QuartoCam::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 QuartoCam::GetWorldPosition()
{
return rootNode_->GetWorldPosition();
}
class Urho : public Object
Quaternion QuartoCam::GetRotation()
{
URHO3D_OBJECT(Urho, Object);
public:
Urho(Context* context, MasterControl* masterControl);
void Swim(float timeStep);
private:
MasterControl* masterControl_;
Node* rootNode_;
AnimatedModel* animatedModel_;
AnimationController* animCtrl_;
Vector3 velocity_;
float maxVelocity_;
Vector3 target_;
bool seenTarget_;
Vector3 SwimTarget();
void HandleUpdate(StringHash eventType, VariantMap &eventData);
};
#endif // URHO_H
return rootNode_->GetRotation();
}
......@@ -44,13 +44,13 @@ class Camera;
using namespace Urho3D;
class TemplateCam : public Object
class QuartoCam : public Object
{
URHO3D_OBJECT(TemplateCam, Object);
URHO3D_OBJECT(QuartoCam, Object);
friend class MasterControl;
friend class InputMaster;
public:
TemplateCam(Context *context, MasterControl* masterControl);
QuartoCam(Context *context, MasterControl* masterControl);
SharedPtr<Camera> camera_;
SharedPtr<Viewport> viewport_;
......
No preview for this file type
/* 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 "urho.h"
Urho::Urho(Context* context, MasterControl* masterControl):
Object(context),
masterControl_{masterControl},
velocity_{Vector3::ZERO},
maxVelocity_{23.0f},
target_{Vector3::LEFT},
seenTarget_{false}
{
rootNode_ = masterControl_->world.scene->CreateChild("Urho");
rootNode_->SetPosition(Vector3(2.0f, -3.0f, 16.0f));
rootNode_->SetRotation(Quaternion(0.0f, 90.0f, 0.0f));
rootNode_->SetScale(1.0f);
animatedModel_ = rootNode_->CreateComponent<AnimatedModel>();
animatedModel_->SetModel(masterControl_->cache_->GetResource<Model>("Resources/Models/Urho.mdl"));
animatedModel_->SetMaterial(masterControl_->cache_->GetResource<Material>("Resources/Materials/VCol.xml"));
animatedModel_->SetCastShadows(true);
animCtrl_ = rootNode_->CreateComponent<AnimationController>();
animCtrl_->PlayExclusive("Resources/Models/Swim.ani", 0, true, 0.23f);
SubscribeToEvent(E_UPDATE, URHO3D_HANDLER(Urho, HandleUpdate));
}
void Urho::HandleUpdate(StringHash eventType, VariantMap &eventData)
{
float timeStep{eventData[Update::P_TIMESTEP].GetFloat()};
Swim(timeStep);
}
void Urho::Swim(float timeStep)
{
Vector3 targetDelta = target_ - rootNode_->GetPosition();
//Accellerate
float angleFactor = rootNode_->GetDirection().Angle(targetDelta)*0.0023f;
bool limit = velocity_.Angle(targetDelta) < 90.0f && velocity_.Length() > maxVelocity_;
if (!limit) {
float swimFactor = pow( sin(0.42 * masterControl_->world.scene->GetElapsedTime()), 2.0 );
swimFactor *= swimFactor;
swimFactor = 7.5f * Clamp(5.0f * swimFactor - angleFactor + 0.23f * targetDelta.Length(), 0.5f, 2.0f);
velocity_ += swimFactor * timeStep * targetDelta.Normalized();
}
//Check target visibility and distance
if (targetDelta.Angle(rootNode_->GetDirection()) > 90.0f && seenTarget_ || targetDelta.Length() < 0.5f){
target_ = SwimTarget();
seenTarget_ = false;
}
else if (targetDelta.Angle(rootNode_->GetDirection()) < 90.0f){
seenTarget_ = true;
}
velocity_ *= 0.96f;
rootNode_->Translate(velocity_*timeStep, TS_WORLD);
//Update rotation in accordance with Urho's movement.
if (velocity_.Length() > 0.01f){
Quaternion rotation = rootNode_->GetWorldRotation();
Quaternion aimRotation = rotation;
aimRotation.FromLookRotation(velocity_);
rootNode_->SetRotation(rotation.Slerp(aimRotation, 0.23f * timeStep * velocity_.Length()));
}
//Update animation speed
animCtrl_->SetSpeed("Resources/Models/Swim.ani",
(animCtrl_->GetSpeed("Resources/Models/Swim.ani")+
(4.2f*velocity_.Length()/maxVelocity_)+angleFactor)*0.5f);
}
Vector3 Urho::SwimTarget()
{
float extraAngle = rootNode_->GetPosition().Length();
extraAngle *= extraAngle;
float randomAngle = LucKey::RandomSign() * Random(extraAngle);
Vector3 planarDirection = (rootNode_->GetDirection() * (Vector3::ONE-Vector3::UP)).Normalized();
Vector3 newTarget = rootNode_->GetPosition() + (Random(2.0f, 3.0f) * (Quaternion(randomAngle, Vector3::UP) * planarDirection));
newTarget.y_ = Clamp(target_.y_ + Random(-0.23f, 0.23f), -1.0, 1.0f);
newTarget *= 0.8f;
return newTarget;
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment