change spiarl color, remove 5 degree roll of the camera
This commit is contained in:
@@ -1,8 +1,8 @@
|
||||
#include <GLFW/glfw3.h>
|
||||
#include <camera/camera.hpp>
|
||||
#include <glm/ext/scalar_constants.hpp>
|
||||
#include <glm/geometric.hpp>
|
||||
#include <glm/gtc/matrix_transform.hpp>
|
||||
#include <iostream>
|
||||
|
||||
Camera::Camera(
|
||||
CameraType type, glm::vec3 pos, glm::vec3 up, float yaw,
|
||||
@@ -49,11 +49,11 @@ void Camera::processKeyboardInput(CameraMovement direction) {
|
||||
switch (direction) {
|
||||
case CameraMovement::LEFT:
|
||||
radialAngle += angularVelocity;
|
||||
pos = glm::vec3(1.2 * coilCenter * cos(radialAngle), glm::degrees(radialAngle)/360. * segmentHeight + 3, 1.2*coilCenter * sin(radialAngle));
|
||||
pos = glm::vec3(1.2 * coilCenter * cos(radialAngle), radialAngle/(2*glm::pi<float>()) * segmentHeight + 3, 1.2*coilCenter * sin(radialAngle));
|
||||
break;
|
||||
case CameraMovement::RIGHT:
|
||||
radialAngle -= angularVelocity;
|
||||
pos = glm::vec3(1.2 * coilCenter * cos(radialAngle), glm::degrees(radialAngle)/360. * segmentHeight + 3, 1.2*coilCenter * sin(radialAngle));
|
||||
pos = glm::vec3(1.2 * coilCenter * cos(radialAngle), radialAngle/(2*glm::pi<float>()) * segmentHeight + 3, 1.2*coilCenter * sin(radialAngle));
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
@@ -115,9 +115,10 @@ void Camera::updateCameraVectors() {
|
||||
}
|
||||
case CameraType::SPINNING: {
|
||||
float x = coilCenter * cos(radialAngle);
|
||||
float y = radialAngle/(2*glm::pi<float>()) * segmentHeight;
|
||||
float z = coilCenter * sin(radialAngle);
|
||||
|
||||
front = -glm::vec3(x, glm::degrees(radialAngle)/360. * segmentHeight, z);
|
||||
front = -glm::vec3(x, y, z);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -68,21 +68,13 @@ void CoilSegment::printVertices() {
|
||||
float *CoilSegment::calculateSlice() {
|
||||
uint32_t size = slicePointsAmount * 3 * sizeof(float);
|
||||
float *slice = (float *)malloc(size);
|
||||
mat4 transform = mat4(1.);
|
||||
transform = glm::scale(
|
||||
transform,
|
||||
vec3(
|
||||
coil->getWidth(),
|
||||
10,
|
||||
1
|
||||
)
|
||||
);
|
||||
|
||||
// Start of a slice
|
||||
slice[0] = cos(0);
|
||||
slice[1] = sin(0);
|
||||
slice[2] = 0;
|
||||
|
||||
float degreeByPoint = -180. / (sliceDetailization + 1);
|
||||
float degreeByPoint = 180. / (sliceDetailization + 1);
|
||||
|
||||
for (uint32_t i = 1; i <= sliceDetailization; i ++) {
|
||||
uint32_t offset = 3 * i;
|
||||
@@ -108,7 +100,7 @@ void CoilSegment::constructSegment(float *slice) {
|
||||
float daysDegree = day * degreesPerDay;
|
||||
vec3 daysPosition = vec3(
|
||||
cos(radians(daysDegree)) * coil->getRadius(),
|
||||
height * (float)day/getDaysAmount() + shift * height,
|
||||
height * daysDegree/360. + shift * height,
|
||||
sin(radians(daysDegree)) * coil->getRadius()
|
||||
);
|
||||
|
||||
@@ -144,9 +136,9 @@ void CoilSegment::constructSegment(float *slice) {
|
||||
vertices[currentPointOffset + 1] = point.y;
|
||||
vertices[currentPointOffset + 2] = point.z;
|
||||
|
||||
vertices[currentPointOffset + 3] = (float)slicePoint / slicePointsAmount;
|
||||
vertices[currentPointOffset + 4] = 0;
|
||||
vertices[currentPointOffset + 5] = 0;
|
||||
vertices[currentPointOffset + 3] = daysDegree/360.;
|
||||
vertices[currentPointOffset + 4] = daysDegree/360.;
|
||||
vertices[currentPointOffset + 5] = daysDegree/360.;
|
||||
}
|
||||
}
|
||||
free(slice);
|
||||
|
||||
@@ -25,7 +25,7 @@ void framebufferSizeCallback(GLFWwindow *window, int width, int height) {
|
||||
glViewport(10, 10, width-10, height-10);
|
||||
}
|
||||
|
||||
float coilRadius = 50;
|
||||
float coilRadius = 100;
|
||||
float coilWidth = 10;
|
||||
float segmentHeight = 10;
|
||||
|
||||
@@ -66,7 +66,7 @@ void processMousePosCallback(GLFWwindow *window, double deltaX, double deltaY) {
|
||||
}
|
||||
|
||||
int main () {
|
||||
Coil coil = Coil(2024, 1, segmentHeight, 8, coilRadius, coilWidth);
|
||||
Coil coil = Coil(2024, 500, segmentHeight, 8, coilRadius, coilWidth);
|
||||
|
||||
srand(time(0));
|
||||
glfwInit();
|
||||
@@ -114,7 +114,7 @@ int main () {
|
||||
|
||||
glm::mat4 model = glm::mat4(1.0f);
|
||||
glm::mat4 view = glm::mat4(1.0f);
|
||||
model = glm::rotate(model, glm::radians(5.0f), glm::vec3(1.0f, 0.0f, 0.0f));
|
||||
model = glm::rotate(model, glm::radians(0.0f), glm::vec3(1.0f, 0.0f, 0.0f));
|
||||
view = cam.getViewMatrix();
|
||||
unsigned int modelLoc = glGetUniformLocation(shaderProgram, "model");
|
||||
unsigned int viewLoc = glGetUniformLocation(shaderProgram, "view");
|
||||
|
||||
Reference in New Issue
Block a user