Commit 0edb6bbb authored by 魔大农's avatar 魔大农

Clover in readme is now link

parent eed5c245
# Quatter
# [:four_leaf_clover:] (http://www.luckeyproductions.nl/) Quatter
A digital version of [the Quarto boardgame](https://en.wikipedia.org/wiki/Quarto_%28board_game%29) by Blaise Müller, made using the Urho3D game engine.
![A rendered image of the board](https://raw.githubusercontent.com/Modanung/Quatter/master/Blends/Render/2.png)
\ No newline at end of file
This diff is collapsed.
......@@ -7,9 +7,4 @@
<parameter name="MatEmissiveColor" value="0 0 0" />
<parameter name="MatEnvMapColor" value="1 1 1" />
<parameter name="MatSpecColor" value="1 1 0.9 5" />
<cull value="ccw" />
<shadowcull value="ccw" />
<fill value="solid" />
<depthbias constant="0" slopescaled="0" />
<renderorder value="128" />
</material>
<?xml version="1.0"?>
<material>
<technique name="Techniques/DiffNormalSpec.xml" quality="1" loddistance="0" />
<texture unit="diffuse" name="Resources/Textures/BoardDiffuse.png" />
<texture unit="normal" name="Resources/Textures/BoardNormal.png" />
<texture unit="specular" name="Resources/Textures/BoardSpecular.png" />
<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="MatEnvMapColor" value="1 1 1" />
<parameter name="MatSpecColor" value="0.666 0.666 0.666 23" />
<cull value="ccw" />
<shadowcull value="ccw" />
<fill value="solid" />
<depthbias constant="0" slopescaled="0" />
<renderorder value="128" />
</material>
......@@ -7,9 +7,4 @@
<parameter name="MatEmissiveColor" value="0 0 0" />
<parameter name="MatEnvMapColor" value="0.4 0.5 0.4" />
<parameter name="MatSpecColor" value="1 1 0.9 5" />
<cull value="ccw" />
<shadowcull value="ccw" />
<fill value="solid" />
<depthbias constant="0" slopescaled="0" />
<renderorder value="128" />
</material>
......@@ -7,9 +7,4 @@
<parameter name="MatEmissiveColor" value="0 0 0" />
<parameter name="MatEnvMapColor" value="1 1 1" />
<parameter name="MatSpecColor" value="0.32 0.35 0.3 5" />
<cull value="ccw" />
<shadowcull value="ccw" />
<fill value="solid" />
<depthbias constant="0" slopescaled="0" />
<renderorder value="128" />
</material>
......@@ -7,9 +7,4 @@
<parameter name="MatEmissiveColor" value="0 0 0" />
<parameter name="MatEnvMapColor" value="0.4 0.5 0.4" />
<parameter name="MatSpecColor" value="0.5 0.5 0.5 5" />
<cull value="ccw" />
<shadowcull value="ccw" />
<fill value="solid" />
<depthbias constant="0" slopescaled="0" />
<renderorder value="128" />
</material>
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
......@@ -6,6 +6,6 @@ Board::Board(Context* context, MasterControl *masterControl): Object(context),
Node* rootNode = masterControl_->world.scene->CreateChild("Board");
model_ = rootNode->CreateComponent<StaticModel>();
model_->SetModel(masterControl_->cache_->GetResource<Model>("Resources/Models/Board.mdl"));
model_->SetMaterial(masterControl_->cache_->GetResource<Material>("Resources/Materials/Wood_board.xml"));
model_->SetMaterial(masterControl_->cache_->GetResource<Material>("Resources/Materials/Board.xml"));
model_->SetCastShadows(true);
}
......@@ -16,6 +16,7 @@ class Board : public Object
URHO3D_OBJECT(Board, Object);
public:
Board(Context *context, MasterControl* masterControl);
float GetHeight() const { return model_->GetBoundingBox().Size().y_; }
private:
MasterControl* masterControl_;
StaticModel* model_;
......
......@@ -10,6 +10,7 @@ InputMaster::InputMaster(Context* context, MasterControl* masterControl) : Maste
SubscribeToEvent(E_KEYUP, URHO3D_HANDLER(InputMaster, HandleKeyUp));
SubscribeToEvent(E_JOYSTICKBUTTONDOWN, URHO3D_HANDLER(InputMaster, HandleJoystickButtonDown));
SubscribeToEvent(E_JOYSTICKBUTTONUP, URHO3D_HANDLER(InputMaster, HandleJoystickButtonUp));
SubscribeToEvent(E_UPDATE, URHO3D_HANDLER(InputMaster, HandleUpdate));
}
void InputMaster::HandleKeyDown(StringHash eventType, VariantMap &eventData)
......@@ -77,5 +78,9 @@ void InputMaster::HandleJoystickButtonUp(StringHash eventType, VariantMap &event
void InputMaster::HandleUpdate(StringHash eventType, VariantMap &eventData)
{
if (input_->GetMouseButtonDown(2)){
IntVector2 mouseMove = input_->GetMouseMove();
Vector2 rotation = Vector2(mouseMove.x_, mouseMove.y_) * 0.23f;
masterControl_->world.camera->Rotate(rotation);
}
}
......@@ -50,20 +50,24 @@ void MasterControl::CreateScene()
world.camera = new QuatterCam(context_, this);
CreateLights();
//Create table
Node* tableNode = world.scene->CreateChild("Table");
tableNode->SetPosition(Vector3::DOWN * 0.4f);
tableNode->SetRotation(Quaternion(23.5f, Vector3::UP));
tableNode->SetScale(23.0f);
tableNode->SetScale(19.0f);
StaticModel* tableModel = tableNode->CreateComponent<StaticModel>();
tableModel->SetModel(cache_->GetResource<Model>("Models/Plane.mdl"));
tableModel->SetMaterial(cache_->GetResource<Material>("Resources/Materials/Basic.xml"));
tableModel->SetMaterial(cache_->GetResource<Material>("Materials/Stone.xml"));
tableModel->GetMaterial()->SetShaderParameter("MatDiffColor", Vector4(0.32f, 0.40f, 0.42f, 1.0f));
//Create board and pieces
new Board(context_, this);
world.board_ = new Board(context_, this);
tableNode->SetPosition(Vector3::DOWN * world.board_->GetHeight());
for (int p = 0; p < 16; ++p){
Piece* newPiece = new Piece(context_, this, std::bitset<4>(p));
newPiece->SetPosition(Quaternion(360.0f/16 * p, Vector3::UP) * Vector3::RIGHT * 9.0f +
Vector3::DOWN * 0.4f);
world.pieces_.Push(SharedPtr<Piece>(newPiece));
newPiece->SetPosition(Quaternion(360.0f/16 * p, Vector3::UP) * Vector3::RIGHT * 6.66f +
Vector3::DOWN * world.board_->GetHeight());
}
}
......@@ -76,19 +80,19 @@ void MasterControl::CreateLights()
downardsLightNode->LookAt(Vector3(0.0f, 0.0f, 0.0f));
Light* downwardsLight = downardsLightNode->CreateComponent<Light>();
downwardsLight->SetLightType(LIGHT_DIRECTIONAL);
downwardsLight->SetBrightness(1.0f);
downwardsLight->SetBrightness(0.88f);
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));
//Create a point light. Enable cascaded shadows on it
//Create a point light.
Node* pointLightNode_ = world.scene->CreateChild("PointLight");
pointLightNode_->SetPosition(Vector3(0.0f, -1.0f, -13.0f));
Light* pointLight = pointLightNode_->CreateComponent<Light>();
pointLight->SetLightType(LIGHT_POINT);
pointLight->SetBrightness(0.5f);
pointLight->SetBrightness(0.23f);
pointLight->SetRange(42.0f);
pointLight->SetColor(Color(0.75f, 1.0f, 0.75f));
}
......
......@@ -15,6 +15,8 @@ using namespace Urho3D;
class QuatterCam;
class InputMaster;
class Board;
class Piece;
enum class GamePhase{PLAYER1PICKS, PLAYER2PUTS, PLAYER2PICKS, PLAYER1PUTS};
......@@ -22,6 +24,8 @@ typedef struct GameWorld
{
SharedPtr<QuatterCam> camera;
SharedPtr<Scene> scene;
SharedPtr<Board> board_;
Vector< SharedPtr<Piece> > pieces_;
struct {
SharedPtr<Node> sceneCursor;
SharedPtr<Cursor> uiCursor;
......
#include "quattercam.h"
QuatterCam::QuatterCam(Context *context, MasterControl *masterControl):
Object(context)
Object(context),
distance_{23.0f},
dollyRotation_{Vector2::ZERO},
targetPosition_{Vector3::ZERO},
lastTargetPosition_{Vector3::ZERO}
{
masterControl_ = masterControl;
rootNode_ = masterControl_->world.scene->CreateChild("Camera");
camera_ = rootNode_->CreateComponent<Camera>();
camera_->SetFarClip(1024.0f);
rootNode_->SetPosition(Vector3(0.0f, 5.0f, -13.0f));
rootNode_->SetPosition(Vector3(3.0f, 5.0f, -11.0f));
rootNode_->LookAt(Vector3::UP);
Zone* zone = rootNode_->CreateComponent<Zone>();
......@@ -38,11 +43,22 @@ void QuatterCam::SetupViewport()
renderer->SetViewport(0, viewport_);
}
Vector3 QuatterCam::GetWorldPosition()
void QuatterCam::Rotate(Vector2 rotation)
{
return rootNode_->GetWorldPosition();
rootNode_->RotateAround(targetPosition_,
Quaternion(rotation.x_, Vector3::UP) * Quaternion(rotation.y_, rootNode_->GetRight()), TS_WORLD);
}
//void QuatterCam::Focus(Vector3 targetPosition, float distance, float duration)
//{
/////Focus on targetposition for duration from distance
//}
//Vector3 QuatterCam::GetWorldPosition()
//{
// return rootNode_->GetWorldPosition();
//}
Quaternion QuatterCam::GetRotation()
{
return rootNode_->GetRotation();
......
......@@ -30,11 +30,22 @@ public:
Vector3 GetWorldPosition();
Quaternion GetRotation();
Vector2 GetDollyRotation();
private:
MasterControl* masterControl_;
SharedPtr<Node> rootNode_;
float distance_;
Vector2 dollyRotation_;
Vector3 targetPosition_;
Vector3 lastTargetPosition_;
void SetupViewport();
void Rotate(Vector2 rotation);
// void SetDollyRotation(Vector2 dollyRotation){ dollyRotation_ = dollyRotation;}
// void Rotate(Vector2 rotation){ SetDollyRotation(GetDollyRotation() + rotation);
// void Focus(Vector3 targetPosition, float distance, float duration);
};
#endif // TEMPLATECAM_H
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