Starting implementation of UI framework
This commit is contained in:
@@ -1,5 +1,7 @@
|
||||
#include "CameraComponent.h"
|
||||
#include "Scene/Actor/Actor.h"
|
||||
#include <algorithm>
|
||||
#include <iostream>
|
||||
|
||||
using namespace Seele;
|
||||
|
||||
@@ -11,7 +13,7 @@ CameraComponent::CameraComponent()
|
||||
{
|
||||
distance = 50;
|
||||
rotationX = 0;
|
||||
rotationY = -0.5f;
|
||||
rotationY = -1.f;
|
||||
}
|
||||
|
||||
CameraComponent::~CameraComponent()
|
||||
@@ -21,25 +23,26 @@ CameraComponent::~CameraComponent()
|
||||
void CameraComponent::mouseMove(float deltaX, float deltaY)
|
||||
{
|
||||
//0.01 mouse sensitivity
|
||||
rotationX += deltaX/100.f;
|
||||
rotationY += deltaY/100.f;
|
||||
rotationX += deltaX/500.f;
|
||||
rotationY += deltaY/500.f;
|
||||
rotationY = std::clamp(rotationY, -1.5f, 1.5f);
|
||||
addWorldRotation(Vector(rotationX, rotationY, 0));
|
||||
getParent()->setWorldRotation(glm::rotate(glm::quat(), rotationX, Vector(0, 1, 0)));
|
||||
getParent()->setWorldRotation(glm::rotate(glm::quat(), rotationY, Vector(1, 0, 0)));
|
||||
bNeedsViewBuild = true;
|
||||
}
|
||||
|
||||
void CameraComponent::mouseScroll(double x)
|
||||
{
|
||||
distance += static_cast<float>(x);
|
||||
distance -= static_cast<float>(x);
|
||||
distance = std::max(distance, 1.f);
|
||||
addWorldTranslation(Vector(0, 0, x));
|
||||
getParent()->addWorldTranslation(Vector(0, 0, x));
|
||||
bNeedsViewBuild = true;
|
||||
}
|
||||
|
||||
void CameraComponent::moveOrigin(float up)
|
||||
{
|
||||
originPoint.y += up;
|
||||
addWorldTranslation(Vector(0, up, 0));
|
||||
getParent()->addWorldTranslation(Vector(0, up, 0));
|
||||
bNeedsViewBuild = true;
|
||||
}
|
||||
|
||||
|
||||
@@ -26,6 +26,14 @@ public:
|
||||
}
|
||||
return projectionMatrix;
|
||||
}
|
||||
Vector getCameraPosition()
|
||||
{
|
||||
if(bNeedsViewBuild)
|
||||
{
|
||||
buildViewMatrix();
|
||||
}
|
||||
return cameraPosition;
|
||||
}
|
||||
void mouseMove(float deltaX, float deltaY);
|
||||
void mouseScroll(double x);
|
||||
void moveOrigin(float up);
|
||||
|
||||
@@ -6,6 +6,9 @@ using namespace Seele;
|
||||
|
||||
Component::Component()
|
||||
{
|
||||
relativeLocation = Vector(0);
|
||||
relativeRotation = Vector(0);
|
||||
relativeScale = Vector(1, 1, 1);
|
||||
}
|
||||
Component::~Component()
|
||||
{
|
||||
@@ -101,17 +104,17 @@ void Component::setRelativeScale(Vector scale)
|
||||
}
|
||||
void Component::addWorldTranslation(Vector translation)
|
||||
{
|
||||
const Vector newWorldLocation = translation + transform.getPosition();
|
||||
const Vector newWorldLocation = translation + getTransform().getPosition();
|
||||
setWorldLocation(newWorldLocation);
|
||||
}
|
||||
void Component::addWorldRotation(Vector rotation)
|
||||
{
|
||||
const Quaternion newWorldRotation = toQuaternion(rotation) * transform.getRotation();
|
||||
const Quaternion newWorldRotation = toQuaternion(rotation) * getTransform().getRotation();
|
||||
setWorldRotation(newWorldRotation);
|
||||
}
|
||||
void Component::addWorldRotation(Quaternion rotation)
|
||||
{
|
||||
const Quaternion newWorldRotation = rotation * transform.getRotation();
|
||||
const Quaternion newWorldRotation = rotation * getTransform().getRotation();
|
||||
setWorldRotation(newWorldRotation);
|
||||
}
|
||||
Transform Component::getTransform() const
|
||||
@@ -169,9 +172,13 @@ void Component::updateComponentTransform(Quaternion relativeRotationQuat)
|
||||
bComponentTransformClean = true;
|
||||
Transform newTransform;
|
||||
const Transform relTransform(relativeLocation, relativeRotationQuat, relativeScale);
|
||||
if (parent != nullptr)
|
||||
if(parent != nullptr)
|
||||
{
|
||||
newTransform = parent->getTransform() * relTransform;
|
||||
newTransform = relTransform * parent->getTransform();
|
||||
}
|
||||
else
|
||||
{
|
||||
newTransform = relTransform;
|
||||
}
|
||||
bool bHasChanged = !getTransform().equals(newTransform);
|
||||
if (bHasChanged)
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
#include "Material/MaterialInstance.h"
|
||||
#include "Asset/MeshAsset.h"
|
||||
#include "Graphics/VertexShaderInput.h"
|
||||
#include <iostream>
|
||||
|
||||
using namespace Seele;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user