First render

This commit is contained in:
Dynamitos
2020-10-23 01:47:56 +02:00
parent 8d4c43361b
commit b4fc5df74e
21 changed files with 128 additions and 43 deletions
+16 -3
View File
@@ -51,7 +51,12 @@ void Actor::setWorldLocation(Vector location)
{
rootComponent->setWorldLocation(location);
}
void Actor::setWorldRotation(Vector4 rotation)
void Actor::setWorldRotation(Quaternion rotation)
{
rootComponent->setWorldRotation(rotation);
}
void Actor::setWorldRotation(Vector rotation)
{
rootComponent->setWorldRotation(rotation);
}
@@ -63,7 +68,11 @@ void Actor::setRelativeLocation(Vector location)
{
rootComponent->setRelativeLocation(location);
}
void Actor::setRelativeRotation(Vector4 rotation)
void Actor::setRelativeRotation(Quaternion rotation)
{
rootComponent->setRelativeRotation(rotation);
}
void Actor::setRelativeRotation(Vector rotation)
{
rootComponent->setRelativeRotation(rotation);
}
@@ -75,7 +84,11 @@ void Actor::addWorldTranslation(Vector translation)
{
rootComponent->addWorldTranslation(translation);
}
void Actor::addWorldRotation(Vector4 rotation)
void Actor::addWorldRotation(Quaternion rotation)
{
rootComponent->addWorldRotation(rotation);
}
void Actor::addWorldRotation(Vector rotation)
{
rootComponent->addWorldRotation(rotation);
}
+6 -3
View File
@@ -22,15 +22,18 @@ public:
void detachChild(PActor child);
Array<PActor> getChildren();
void setWorldLocation(Vector location);
void setWorldRotation(Vector4 rotation);
void setWorldRotation(Quaternion rotation);
void setWorldRotation(Vector rotation);
void setWorldScale(Vector scale);
void setRelativeLocation(Vector location);
void setRelativeRotation(Vector4 rotation);
void setRelativeRotation(Quaternion rotation);
void setRelativeRotation(Vector rotation);
void setRelativeScale(Vector scale);
void addWorldTranslation(Vector translation);
void addWorldRotation(Vector4 rotation);
void addWorldRotation(Quaternion rotation);
void addWorldRotation(Vector rotation);
PComponent getRootComponent();
void setRootComponent(PComponent newRoot);
+2
View File
@@ -14,6 +14,8 @@ CameraActor::CameraActor()
cameraComponent->aspectRatio = 1.777778f;
cameraComponent->setParent(sceneComponent);
cameraComponent->setOwner(this);
addWorldTranslation(Vector(0, 0, 50));
addWorldRotation(Vector(0, -1, 0));
}
CameraActor::~CameraActor()
@@ -24,6 +24,7 @@ void CameraComponent::mouseMove(float deltaX, float deltaY)
rotationX += deltaX/100.f;
rotationY += deltaY/100.f;
rotationY = std::clamp(rotationY, -1.5f, 1.5f);
addWorldRotation(Vector(rotationX, rotationY, 0));
bNeedsViewBuild = true;
}
@@ -31,18 +32,20 @@ void CameraComponent::mouseScroll(double x)
{
distance += static_cast<float>(x);
distance = std::max(distance, 1.f);
addWorldTranslation(Vector(0, 0, x));
bNeedsViewBuild = true;
}
void CameraComponent::moveOrigin(float up)
{
originPoint.y += up;
addWorldTranslation(Vector(0, up, 0));
bNeedsViewBuild = true;
}
void CameraComponent::buildViewMatrix()
{
Matrix4 rotation = glm::rotate(Matrix4(), rotationX, Vector(0, 1, 0));
Matrix4 rotation = glm::rotate(Matrix4(1.0f), rotationX, Vector(0, 1, 0));
rotation = glm::rotate(rotation, rotationY, Vector(1, 0, 0));
Vector4 translation(0, 0, distance, 1);
translation = rotation * translation;
+1 -1
View File
@@ -203,7 +203,7 @@ void Component::setRelativeLocationAndRotation(Vector newLocation, Quaternion ne
}
const Transform desiredRelTransform(newLocation, newRotation);
const Transform desiredWorldTransform = parent->getTransform() * desiredRelTransform;
const Transform desiredWorldTransform = desiredRelTransform; // Check for absolutes etc
internalSetTransform(desiredWorldTransform.getPosition(), desiredWorldTransform.getRotation());
}