Commit 3b9ebbff authored by 魔大农's avatar 魔大农 🍀

Implemented mouse camera movement, resolves #4

parent 332fc42b
No preview for this file type
## Quatter
### Menu
Carved in the sides of the table with elements glowing on selection.
\ No newline at end of file
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
<?xml version="1.0"?>
<material>
<technique name="Techniques/DiffNormalEnvCube.xml" quality="1" loddistance="0" />
<texture unit="diffuse" name="Textures/BoardDiffuse.dds" />
<texture unit="normal" name="Textures/BoardNormal.dds" />
<texture unit="diffuse" name="Textures/BoardDiffuse.png" />
<texture unit="normal" name="Textures/BoardNormal.png" />
<texture unit="specular" name="Textures/BoardSpecular.dds" />
<texture unit="environment" name="Textures/LeafyKnoll.xml" />
<parameter name="UOffset" value="1 0 0 0" />
......
This image diff could not be displayed because it is too large. You can view the blob instead.
This diff is collapsed.
......@@ -34,6 +34,8 @@ Board::Board(): Object(MC->GetContext()),
lastSelectedSquare_{nullptr}
{
rootNode_ = MC->world_.scene_->CreateChild("Board");
StringVector tag{}; tag.Push(String("Board"));
rootNode_->SetTags(tag);
model_ = rootNode_->CreateComponent<StaticModel>();
model_->SetModel(MC->GetModel("Board"));
model_->SetMaterial(MC->GetMaterial("Board"));
......
This diff is collapsed.
......@@ -29,6 +29,7 @@
#define YAD_FULLBRIGHT 0.5f
#define YAD_DIMMED 0.1f
#define DRAG_THRESHOLD 0.023f
class Square;
......@@ -41,6 +42,7 @@ public:
SharedPtr<Material> material_;
SharedPtr<Light> light_;
bool hidden_{true};
bool dimmed_{false};
}Yad;
class InputMaster : public Master
......@@ -48,29 +50,27 @@ class InputMaster : public Master
URHO3D_OBJECT(InputMaster, Master);
public:
InputMaster();
WeakPtr<Node> firstHit_;
bool IsIdle() const noexcept { return idle_; }
void ResetIdle();
void SetIdle();
JoystickState* GetActiveJoystick();
bool MultipleJoysticks();
Ray MouseRay();
void ConstructYad();
void HideYad();
void RevealYad();
private:
Input* input_;
Vector2 mousePos_;
float idleTime_;
bool idle_;
Vector2 mousePos_;
Vector2 mouseMoveSinceClick_;
bool drag_;
float mouseIdleTime_;
bool boardClick_;
bool tableClick_;
void ResetIdle();
void SetIdle();
Ray MouseRay();
void HideYad();
void RevealYad();
Vector2 smoothCamRotate_;
float smoothCamZoom_;
......@@ -82,10 +82,12 @@ private:
bool actionDone_;
Yad* yad_;
Piece* RaycastToPiece();
Square* RaycastToSquare();
Piece* rayPiece_;
Square* raySquare_;
Piece* RaycastToPiece();
Square* RaycastToSquare();
bool RaycastToBoard();
bool RaycastToTable();
void HandleUpdate(StringHash eventType, VariantMap &eventData);
void UpdateMousePos(bool delta);
......@@ -99,7 +101,10 @@ private:
void HandleMouseMove(StringHash eventType, VariantMap& eventData);
void HandleMouseButtonDown(StringHash eventType, VariantMap &eventData);
void HandleMouseButtonUp(StringHash eventType, VariantMap &eventData);
void HandleMouseWheel(StringHash eventType, VariantMap& eventData);
JoystickState* GetActiveJoystick();
bool MultipleJoysticks();
void HandleJoystickButtonDown(StringHash eventType, VariantMap &eventData);
void HandleJoystickButtonUp(StringHash eventType, VariantMap &eventData);
void HandleJoystickButtons();
......
......@@ -115,6 +115,8 @@ void MasterControl::CreateScene()
//Create table
Node* tableNode{world_.scene_->CreateChild("Table")};
StringVector tag{}; tag.Push(String("Table"));
tableNode->SetTags(tag);
tableNode->SetRotation(Quaternion(23.5f, Vector3::UP));
StaticModel* tableModel = tableNode->CreateComponent<StaticModel>();
tableModel->SetModel(GetModel("Table"));
......
......@@ -22,6 +22,7 @@
QuatterCam::QuatterCam():
Object(MC->GetContext()),
distance_{12.0f},
targetDistance_{distance_},
targetPosition_{Vector3::UP * 0.42f},
smoothTargetPosition_{targetPosition_}
{
......@@ -76,6 +77,10 @@ void QuatterCam::HandleSceneUpdate(StringHash eventType, VariantMap& eventData)
{
float t{eventData[SceneUpdate::P_TIMESTEP].GetFloat()};
//Update distance
if (targetDistance_ != distance_){
distance_ = 0.1f * (9.0f * distance_ + targetDistance_);
}
Vector3 relativeToTarget{(rootNode_->GetPosition() - targetPosition_).Normalized()};
if (relativeToTarget.Length() != distance_){
rootNode_->SetPosition(distance_ * relativeToTarget + targetPosition_);
......@@ -104,7 +109,8 @@ void QuatterCam::Rotate(Vector2 rotation)
rootNode_->RotateAround(targetPosition_,
Quaternion(-GetPitch() + PITCH_MIN, rootNode_->GetRight()), TS_WORLD);
}
void QuatterCam::Zoom(float distance)
void QuatterCam::Zoom(float delta)
{
distance_ = Clamp(distance_ - distance, ZOOM_MIN, ZOOM_MAX);
targetDistance_ = Clamp(targetDistance_ - delta, ZOOM_MIN, ZOOM_MAX);
}
......@@ -55,9 +55,12 @@ public:
float GetPitch() const { return rootNode_->GetRotation().EulerAngles().x_; }
float GetYaw() const { return rootNode_->GetRotation().EulerAngles().y_; }
void SetDistance(float distance) { targetDistance_ = Clamp(distance, ZOOM_MIN, ZOOM_MAX); }
float GetDistance() const { return distance_; }
Vector3 GetPosition() const { return rootNode_->GetPosition(); }
void Zoom(float distance);
void Zoom(float delta);
void ZoomToBoard() { SetDistance(7.0f); }
void ZoomToTable() { SetDistance(13.0f); }
Node* GetPocket(bool right) const { return right ? pockets_.second_ : pockets_.first_; }
private:
SharedPtr<Node> rootNode_;
......@@ -65,6 +68,7 @@ private:
SharedPtr<Node>> pockets_;
float distance_;
float targetDistance_;
Vector3 targetPosition_;
Vector3 smoothTargetPosition_;
......
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