...
 
Commits (2)
cmake_minimum_required(VERSION 2.8)
include(${CMAKE_MODULE_PATH}/DefaultExecutable.cmake)
\ No newline at end of file
#include "ShaderSkybox.h"
ShaderSkybox::ShaderSkybox(GLuint shader_mask, const char** shaderPaths)
: CVK::ShaderMinimal(shader_mask, shaderPaths) {
init();
}
ShaderSkybox::ShaderSkybox(GLuint shader_mask,
const std::vector<std::string>& shaderNames)
: CVK::ShaderMinimal(shader_mask, shaderNames) {
init();
}
void ShaderSkybox::update() {
CVK::ShaderMinimal::update();
glUniform1i(m_colorTextureID, 0);
glActiveTexture(GL_TEXTURE0);
}
void ShaderSkybox::init() {
m_colorTextureID = glGetUniformLocation(m_ProgramID, "colortexture");
}
\ No newline at end of file
#ifndef __SHADER_SKYBOX_H
#define __SHADER_SKYBOX_H
#include <CVK_2/CVK_Framework.h>
class ShaderSkybox : public CVK::ShaderMinimal {
public:
ShaderSkybox(GLuint shader_mask, const char** shaderPaths);
ShaderSkybox(GLuint shader_mask,
const std::vector<std::string>& shaderNames);
virtual void update();
private:
void init();
GLuint m_colorTextureID;
};
#endif /*__SHADER_SIMPLE_TEXTURE_H*/
\ No newline at end of file
#include "Skybox.h"
Skybox::Skybox(const float size) {
GLfloat vertices[] = {
// Front face
-size,
-size,
-size,
size,
-size,
-size,
size,
size,
-size,
size,
size,
-size,
-size,
size,
-size,
-size,
-size,
-size,
// Right face
size,
-size,
-size,
size,
-size,
size,
size,
size,
size,
size,
size,
size,
size,
size,
-size,
size,
-size,
-size,
// Back face
size,
-size,
size,
-size,
-size,
size,
-size,
size,
size,
-size,
size,
size,
size,
size,
size,
size,
-size,
size,
// Left face
-size,
-size,
size,
-size,
-size,
-size,
-size,
size,
-size,
-size,
size,
-size,
-size,
size,
size,
-size,
-size,
size,
// Bottom face
-size,
-size,
size,
size,
-size,
size,
size,
-size,
-size,
size,
-size,
-size,
-size,
-size,
-size,
-size,
-size,
size,
// Top Face
-size,
size,
-size,
size,
size,
-size,
size,
size,
size,
size,
size,
size,
-size,
size,
size,
-size,
size,
-size,
};
GLfloat uvCoordinates[] = {
// Front face
1.0f / 4.0f, 1.0f / 3.0f, 2.0f / 4.0f, 1.0f / 3.0f, 2.0f / 4.0f,
2.0f / 3.0f, 2.0f / 4.0f, 2.0f / 3.0f, 1.0f / 4.0f, 2.0f / 3.0f,
1.0f / 4.0f, 1.0f / 3.0f,
// Right face
2.0f / 4.0f, 1.0f / 3.0f, 3.0f / 4.0f, 1.0f / 3.0f, 3.0f / 4.0f,
2.0f / 3.0f, 3.0f / 4.0f, 2.0f / 3.0f, 2.0f / 4.0f, 2.0f / 3.0f,
2.0f / 4.0f, 1.0f / 3.0f,
// Back face
3.0f / 4.0f, 1.0f / 3.0f, 1.0f, 1.0f / 3.0f, 1.0f, 2.0f / 3.0f, 1.0f,
2.0f / 3.0f, 3.0f / 4.0f, 2.0f / 3.0f, 3.0f / 4.0f, 1.0f / 3.0f,
// Left face
0.0f, 1.0f / 3.0f, 1.0f / 4.0f, 1.0f / 3.0f, 1.0f / 4.0f, 2.0f / 3.0f,
1.0f / 4.0f, 2.0f / 3.0f, 0.0f, 2.0f / 3.0f, 0.0f, 1.0f / 3.0f,
// Bottom face
1.0f / 4.0f, 0.0f, 2.0f / 4.0f, 0.0f, 2.0f / 4.0f, 1.0f / 3.0f,
2.0f / 4.0f, 1.0f / 3.0f, 1.0f / 4.0f, 1.0f / 3.0f, 1.0f / 4.0f, 0.0f,
// Top face
1.0f / 4.0f, 2.0f / 3.0f, 2.0f / 4.0f, 2.0f / 3.0f, 2.0f / 4.0f, 1.0f,
2.0f / 4.0f, 1.0f, 1.0f / 4.0f, 1.0f, 1.0f / 4.0f, 2.0f / 3.0f};
glGenVertexArrays(1, &m_vaoHandle);
glBindVertexArray(m_vaoHandle);
// we generate multiple buffers at a time
glGenBuffers(2, m_vboHandles);
// bind the first buffer and store geometry into the VBO
glBindBuffer(GL_ARRAY_BUFFER, m_vboHandles[0]);
glBufferData(GL_ARRAY_BUFFER, sizeof(vertices), vertices, GL_STATIC_DRAW);
glEnableVertexAttribArray(0);
glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 0, 0);
// uses the second buffer as the source for uv coordinates
glBindBuffer(GL_ARRAY_BUFFER, m_vboHandles[1]);
glBufferData(GL_ARRAY_BUFFER, sizeof(uvCoordinates), uvCoordinates,
GL_STATIC_DRAW);
glEnableVertexAttribArray(2);
glVertexAttribPointer(2, 2, GL_FLOAT, GL_FALSE, 0, 0);
// unbind the VBO, we don't need it anymore
glBindBuffer(GL_ARRAY_BUFFER, 0);
// load a skybox texture
m_texture = new CVK::Texture(CVK::State::getInstance()->getResourcesPath() +
"/AS/skybox_space.png");
}
Skybox::~Skybox() {
// cleanup vao, vbos and texture
glDeleteVertexArrays(1, &m_vaoHandle);
glDeleteBuffers(2, &m_vboHandles[0]);
delete m_texture;
}
void Skybox::render() {
// bind the ID texture specified by the 2nd parameter
m_texture->bind();
glBindVertexArray(m_vaoHandle);
glDrawArrays(GL_TRIANGLES, 0, 36);
}
\ No newline at end of file
#ifndef _SKYBOX_H
#define _SKYBOX_H
#include <CVK_2/CVK_Framework.h>
#include <CVK_2/CVK_Texture.h>
class Skybox {
public:
/**
* Constructor
*/
Skybox(const float size);
/**
* Destructor
*/
~Skybox();
/**
* Render the skybox.
*/
void render();
inline GLint getTextureHandle(void) { return m_textureHandle; }
private:
CVK::Texture* m_texture;
GLuint m_vaoHandle; // vao
GLuint m_vboHandles[2]; // vbo handels (vertices and uv coordinates)
GLuint m_textureHandle; // texture handle
};
#endif
\ No newline at end of file
% This file contains the internal library dependencies in src/libraries
% Lines starting with % are comments and will be ignored
% To add a dependency, simply add a new line containing the name of the library
% Example: HelloLib
CVK_2
CVK_AnSim
\ No newline at end of file
#include <CVK_2/CVK_Framework.h>
#include <CVK_AnSim/CVK_AS_MassPoint.h>
#include <CVK_AnSim/CVK_AS_ShaderSpace.h>
#include "ShaderSkybox.h"
#include "Skybox.h"
#include <glm/gtc/constants.hpp>
#include <glm/gtx/string_cast.hpp>
const int width = 640;
const int height = 480;
GLFWwindow* window;
// define Camera (Trackball)
CVK::Perspective projection(glm::radians(60.0f), width / float(height), 0.1f,
500.f);
CVK::Trackball* cam_trackball;
//*************************************************************************************************************
// space ship
CVK::MassPoint spaceShipMassPoint;
float spaceShipEngineForce = 10.0f;
float spaceShipRotAngle = 0.0f; // angle in degree
// pigs
std::vector<CVK::MassPoint> pigsMassPoints;
// fish
std::vector<glm::quat> quaternions;
//*************************************************************************************************************
void keyCallback(GLFWwindow* window, int key, int scancode, int action,
int mods) {
if (action == GLFW_RELEASE)
return;
switch (key) {
case GLFW_KEY_ESCAPE:
glfwSetWindowShouldClose(window, GL_TRUE);
break;
case GLFW_KEY_S:
spaceShipMassPoint.applyForce(
spaceShipEngineForce *
glm::vec3(glm::cos(glm::radians(spaceShipRotAngle)), 0.0f,
-glm::sin(glm::radians(spaceShipRotAngle))));
break;
case GLFW_KEY_LEFT:
spaceShipRotAngle += 10;
break;
case GLFW_KEY_RIGHT:
spaceShipRotAngle -= 10;
break;
}
}
void resizeCallback(GLFWwindow* window, int w, int h) {
cam_trackball->setWidthHeight(w, h);
cam_trackball->getProjection()->updateRatio(w / (float)h);
glViewport(0, 0, w, h);
}
void init_camera() {
// Camera
cam_trackball = new CVK::Trackball(window, width, height, &projection);
glm::vec3 center(0.0f, 0.0f, 0.0f);
cam_trackball->setCenter(&center);
cam_trackball->setRadius(5.0f);
CVK::State::getInstance()->setCamera(cam_trackball);
}
int main() {
// Init GLFW and GLAD
glfwInit();
CVK::useOpenGL33CoreProfile();
window = glfwCreateWindow(width, height, "AnSim Exercise 3", 0, 0);
glfwSetWindowPos(window, 100, 50);
glfwMakeContextCurrent(window);
glfwSetWindowSizeCallback(window, resizeCallback);
glfwSetKeyCallback(window, keyCallback);
if (!gladLoadGL()) {
printf("Something went wrong!\n");
exit(-1);
}
CVK::State::getInstance()->setBackgroundColor(WHITE);
glm::vec3 BgCol = CVK::State::getInstance()->getBackgroundColor();
glClearColor(BgCol.r, BgCol.g, BgCol.b, 0.0);
glEnable(GL_DEPTH_TEST);
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
// load, compile and link Shader
CVK::ShaderSpace spaceShader(
VERTEX_SHADER_BIT | FRAGMENT_SHADER_BIT,
{CVK::State::getInstance()->getShaderPath() + "/CVK_AnSim/Toon.vert",
CVK::State::getInstance()->getShaderPath() + "/CVK_AnSim/Toon.frag"});
ShaderSkybox skyboxShader(
VERTEX_SHADER_BIT | FRAGMENT_SHADER_BIT,
{CVK::State::getInstance()->getShaderPath() + "/CVK_AnSim/Minimal.vert",
CVK::State::getInstance()->getShaderPath() +
"/CVK_AnSim/SimpleTexture.frag"});
// Camera
init_camera();
// Light Sources
CVK::Light light = CVK::Light(glm::vec4(0.0, 10.0, 0.0, 1.0), GREY,
glm::vec3(0, 0, 0), 1.0f, 0.0f);
CVK::State::getInstance()->addLight(&light);
CVK::State::getInstance()->updateSceneSettings(DARKGREY, 0, WHITE, 1, 10,
1);
// Create skybox
Skybox* skybox = new Skybox(50.0f);
// Init scene nodes and mass points
CVK::Node spaceship("Spaceship",
CVK::State::getInstance()->getResourcesPath() +
"/AS/spaceship.obj");
CVK::Node fish("Fish", CVK::State::getInstance()->getResourcesPath() +
"/AS/fish.obj");
CVK::Node pig("Pig", CVK::State::getInstance()->getResourcesPath() +
"/AS/piggy.obj");
// First mass point for the spaceship
spaceShipMassPoint = CVK::MassPoint(glm::vec3(0.0f, 2.3f, 0.0f),
glm::vec3(0.0f, 0.0f, 0.0f), 1.0);
// Next ones for the pigs
pigsMassPoints.push_back(CVK::MassPoint(
glm::vec3(-2.0f, 2.3f, 2.0f), glm::vec3(-0.3f, 0.0f, -0.23f), 1.0));
pigsMassPoints.push_back(CVK::MassPoint(glm::vec3(2.0f, 2.3f, -2.0f),
glm::vec3(0.0f, 0.0f, 0.4f), 2.0));
pigsMassPoints.push_back(CVK::MassPoint(
glm::vec3(4.0f, 2.3f, 3.0f), glm::vec3(-0.23f, 0.0f, -0.1f), 3.0));
pigsMassPoints.push_back(CVK::MassPoint(
glm::vec3(-5.0f, 0.0f, 6.0f), glm::vec3(-0.3f, 0.0f, -0.4f), 1.0));
pigsMassPoints.push_back(CVK::MassPoint(glm::vec3(5.0f, 2.3f, -3.0f),
glm::vec3(0.2f, 0.0f, 0.2f), 2.0));
pigsMassPoints.push_back(CVK::MassPoint(
glm::vec3(4.0f, 4.3f, 2.5f), glm::vec3(-0.4f, 0.0f, -0.2f), 3.0));
// TODO 4 (b)
// Fuellen Sie den global definierten Vektor (quaternions) mit den
// gewünschten Orientierungen. Mit 4 quaternionen
/*quaternions.push_back(glm::rotate(glm::quat(1, 0, 0, 0),
glm::radians(0.0f), glm::vec3(0, 1, 0)));
quaternions.push_back(glm::rotate(glm::quat(1, 0, 0,
0),glm::radians(90.0f),glm::vec3(0,1,0)));
quaternions.push_back(glm::rotate(glm::quat(1, 0, 0, 0),
glm::radians(180.0f), glm::vec3(0, 1, 0)));
quaternions.push_back(glm::rotate(glm::quat(1, 0, 0, 0),
glm::radians(270.0f), glm::vec3(0, 1, 0)));*/
// Mit 3 Quaternionen
quaternions.push_back(glm::rotate(glm::quat(1, 0, 0, 0), glm::radians(0.0f),
glm::vec3(0, 1, 0)));
quaternions.push_back(glm::rotate(
glm::quat(1, 0, 0, 0), glm::radians(120.0f), glm::vec3(0, 1, 0)));
quaternions.push_back(glm::rotate(
glm::quat(1, 0, 0, 0), glm::radians(240.0f), glm::vec3(0, 1, 0)));
float deltaTime = 0.0f;
float oldTime = glfwGetTime();
float t = 0.0f;
// time period for rotation in s
float period = 10.0;
float timePerOrientation = period / static_cast<float>(quaternions.size());
while (!glfwWindowShouldClose(window)) {
float currentTime = glfwGetTime();
deltaTime = currentTime - oldTime;
oldTime = currentTime;
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
// Update Camera
cam_trackball->update(deltaTime);
// Use the skybox shader program
CVK::State::getInstance()->setShader(&skyboxShader);
CVK::State::getInstance()->getShader()->update();
skybox->render();
// Use phong shader to render the scene
CVK::State::getInstance()->setShader(&spaceShader);
CVK::State::getInstance()->setLight(0, &light);
spaceShader.update();
// Update and render spaceship
spaceShipMassPoint.numericIntegration(deltaTime);
glm::mat4 modelmatrix = glm::mat4(1.0f);
glm::mat4 shipS = glm::scale(glm::mat4(1.0f), glm::vec3(1.5, 1.5, 1.5));
glm::mat4 shipT =
glm::translate(glm::mat4(1.0f), spaceShipMassPoint.getPosition());
glm::mat4 shipR =
glm::rotate(glm::mat4(1.0f), glm::radians(spaceShipRotAngle),
glm::vec3(0.0f, 1.0f, 0.0f));
modelmatrix = shipT * shipS * shipR;
spaceship.setModelMatrix(modelmatrix);
spaceship.render();
// Update and render pigs
for (CVK::MassPoint& mp : pigsMassPoints) {
mp.numericIntegration(deltaTime);
modelmatrix = glm::translate(glm::mat4(1.0f), mp.getPosition());
modelmatrix = glm::scale(modelmatrix, glm::vec3(0.5, 0.5, 0.5));
pig.setModelMatrix(modelmatrix);
pig.render();
}
t += deltaTime; // speed = 0.01
// TODO 4 (b)
// Erweitern Sie die Modelmatrix um Translation und Rotation.
// Anmerkung: Verwenden Sie die Variable t.
// Zeitindex, wenn alle sich wiederholenden Orientierungen aneinander
// geschrieben werden (mit Nachkommazahl)
float timeIndex = t / timePerOrientation;
// Index der Orientierung (mit Wiederholung)
int timeBucket = static_cast<int>(timeIndex);
// Wie weit zwischen der aktuellen und der nächsten Orientierung
float mix = timeIndex - timeBucket;
// Wiederholung berücksichtigen
int index = timeBucket % quaternions.size();
// SLERP Interpolation zwischen aktueller und nächster Orientierung
glm::quat rotationQ =
glm::slerp(quaternions[index],
quaternions[(index + 1) % quaternions.size()], mix);
// Erstelle Matrix aus Interpolation
glm::mat4 rotation = glm::mat4_cast(rotationQ);
glm::mat4 fishT =
glm::translate(glm::mat4(1.0f), spaceShipMassPoint.getPosition() -
glm::vec3(0.0f, 0.0f, 6.0f));
// Gesamtfischmatrix
modelmatrix = rotation * fishT *
glm::scale(glm::mat4(1.0f), glm::vec3(0.1f, 0.1f, 0.1f));
fish.setModelMatrix(modelmatrix);
fish.render();
glfwSwapBuffers(window);
glfwPollEvents();
}
glfwDestroyWindow(window);
glfwTerminate();
return 0;
}
......@@ -38,31 +38,31 @@ void CVK::Geometry::createBuffers() {
glGenBuffers(1, &m_vertexbuffer);
glBindBuffer(GL_ARRAY_BUFFER, m_vertexbuffer);
glBufferData(GL_ARRAY_BUFFER, m_points * sizeof(glm::vec4),
&m_vertices[0], GL_STATIC_DRAW);
m_vertices.data(), GL_STATIC_DRAW);
}
if (m_normalbuffer == INVALID_GL_VALUE && m_normals.size() > 0) {
if (m_normalbuffer == INVALID_GL_VALUE && !m_normals.empty()) {
glGenBuffers(1, &m_normalbuffer);
glBindBuffer(GL_ARRAY_BUFFER, m_normalbuffer);
glBufferData(GL_ARRAY_BUFFER, m_points * sizeof(glm::vec3),
&m_normals[0], GL_STATIC_DRAW);
m_normals.data(), GL_STATIC_DRAW);
}
if (m_uvbuffer == INVALID_GL_VALUE && m_uvs.size() > 0) {
if (m_uvbuffer == INVALID_GL_VALUE && !m_uvs.empty()) {
glGenBuffers(1, &m_uvbuffer);
glBindBuffer(GL_ARRAY_BUFFER, m_uvbuffer);
glBufferData(GL_ARRAY_BUFFER, m_points * sizeof(glm::vec2), &m_uvs[0],
GL_STATIC_DRAW);
glBufferData(GL_ARRAY_BUFFER, m_points * sizeof(glm::vec2),
m_uvs.data(), GL_STATIC_DRAW);
}
if (m_tangentbuffer == INVALID_GL_VALUE && m_uvs.size() > 0) {
if (m_tangentbuffer == INVALID_GL_VALUE && !m_uvs.empty()) {
if (m_tangents.empty()) {
computeTangents();
}
glGenBuffers(1, &m_tangentbuffer);
glBindBuffer(GL_ARRAY_BUFFER, m_tangentbuffer);
glBufferData(GL_ARRAY_BUFFER, m_tangents.size() * sizeof(glm::vec3),
&m_tangents[0], GL_STATIC_DRAW);
m_tangents.data(), GL_STATIC_DRAW);
}
// Generate a buffer for the indices as well
......@@ -70,7 +70,7 @@ void CVK::Geometry::createBuffers() {
glGenBuffers(1, &m_indexlist);
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, m_indexlist);
glBufferData(GL_ELEMENT_ARRAY_BUFFER, m_indices * sizeof(unsigned int),
&m_index[0], GL_STATIC_DRAW);
m_index.data(), GL_STATIC_DRAW);
}
if (m_vao == INVALID_GL_VALUE)
......@@ -78,23 +78,30 @@ void CVK::Geometry::createBuffers() {
glBindVertexArray(m_vao);
glBindBuffer(GL_ARRAY_BUFFER, m_vertexbuffer);
glEnableVertexAttribArray(VERTICES);
glVertexAttribPointer(VERTICES, 4, GL_FLOAT, GL_FALSE, 0, 0);
glBindBuffer(GL_ARRAY_BUFFER, m_normalbuffer);
glEnableVertexAttribArray(NORMALS);
glVertexAttribPointer(NORMALS, 3, GL_FLOAT, GL_FALSE, 0, 0);
glBindBuffer(GL_ARRAY_BUFFER, m_uvbuffer);
glEnableVertexAttribArray(TEXTURECOORDS);
glVertexAttribPointer(TEXTURECOORDS, 2, GL_FLOAT, GL_FALSE, 0, 0);
glBindBuffer(GL_ARRAY_BUFFER, m_tangentbuffer);
glEnableVertexAttribArray(TANGENTS);
glVertexAttribPointer(TANGENTS, 3, GL_FLOAT, GL_FALSE, 0, 0);
if (m_vertexbuffer != INVALID_GL_VALUE) {
glBindBuffer(GL_ARRAY_BUFFER, m_vertexbuffer);
glEnableVertexAttribArray(VERTICES);
glVertexAttribPointer(VERTICES, 4, GL_FLOAT, GL_FALSE, 0, nullptr);
}
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, m_indexlist);
if (m_normalbuffer != INVALID_GL_VALUE) {
glBindBuffer(GL_ARRAY_BUFFER, m_normalbuffer);
glEnableVertexAttribArray(NORMALS);
glVertexAttribPointer(NORMALS, 3, GL_FLOAT, GL_FALSE, 0, nullptr);
}
if (m_uvbuffer != INVALID_GL_VALUE) {
glBindBuffer(GL_ARRAY_BUFFER, m_uvbuffer);
glEnableVertexAttribArray(TEXTURECOORDS);
glVertexAttribPointer(TEXTURECOORDS, 2, GL_FLOAT, GL_FALSE, 0, nullptr);
}
if (m_tangentbuffer != INVALID_GL_VALUE) {
glBindBuffer(GL_ARRAY_BUFFER, m_tangentbuffer);
glEnableVertexAttribArray(TANGENTS);
glVertexAttribPointer(TANGENTS, 3, GL_FLOAT, GL_FALSE, 0, nullptr);
}
if (m_indexlist != INVALID_GL_VALUE) {
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, m_indexlist);
}
glBindVertexArray(0);
......
......@@ -9,23 +9,23 @@ class MassPoint {
//---------------CONSTRUCTORS & DESTRUCTOR---------------
public:
MassPoint();
MassPoint(glm::vec3 pos, glm::vec3 vel, float m);
MassPoint(const glm::vec3& pos, const glm::vec3& vel, float m);
~MassPoint();
//---------------MEMBER VARIABLES------------------------
private:
glm::vec3 mPosition{};
glm::vec3 mVelocity{};
glm::vec3 mPosition = glm::vec3{0.0f};
glm::vec3 mVelocity = glm::vec3{0.0f};
float mMass = 1.0f;
glm::vec3 mCurrentForce{};
glm::vec3 mCurrentForce = glm::vec3{0.0f};
//---------------MEMBER FUNCTIONS------------------------
public:
void numericIntegration(float d_t);
inline void setPosition(glm::vec3& p) { mPosition = p; }
inline void setVelocity(glm::vec3& v) { mVelocity = v; }
inline void setPosition(const glm::vec3& p) { mPosition = p; }
inline void setVelocity(const glm::vec3& v) { mVelocity = v; }
inline void setMass(float m) { mMass = m; }
inline glm::vec3 getPosition() { return mPosition; }
......@@ -33,7 +33,7 @@ class MassPoint {
inline float getMass() { return mMass; }
inline glm::vec3 getCurrentForce() { return mCurrentForce; }
inline void applyForce(glm::vec3 f) { mCurrentForce += f; }
inline void applyForce(const glm::vec3& f) { mCurrentForce += f; }
inline void zeroForce() { mCurrentForce = glm::vec3(0.0f); }
};
......
......@@ -19,10 +19,10 @@ class Renderable {
inline glm::vec4 getColor() { return m_color; }
protected:
GLuint m_vertexBuffer, m_vao;
GLuint m_vertexBuffer{}, m_vao{};
private:
glm::vec4 m_color;
glm::vec4 m_color{};
void setupBuffers();
};
......
......@@ -11,12 +11,12 @@ class ShaderLineRender : public CVK::ShaderMinimal {
ShaderLineRender(GLuint shader_mask,
const std::vector<std::string>& shaderNames);
void update();
void update() override;
void update(glm::vec4& color);
private:
void init();
GLuint m_colorID;
GLuint m_colorID{};
};
} // End namespace CVK
......
......@@ -16,10 +16,10 @@ class ShaderSpace : public ShaderMinimal {
private:
void init();
GLuint m_colorID{};
glm::vec3 m_color{};
GLuint m_colorID;
glm::vec3 m_color;
GLuint m_useColorTexture{}, m_colorTextureID{};
GLuint m_useColorTexture, m_colorTextureID;
};
} // End namespace CVK
......
......@@ -116,7 +116,7 @@ void HermiteSpline::getParameterByArcLength(float length, float& u,
if (length >
mArcLengthTable.back().arcLength) { // given length exeeds path
// length, return -1 as error
// length, return -1 as error
u = -1.0;
patchNum = -1;
return;
......
......@@ -5,7 +5,7 @@ namespace CVK {
MassPoint::MassPoint() = default;
MassPoint::MassPoint(glm::vec3 pos, glm::vec3 vel, float m) {
MassPoint::MassPoint(const glm::vec3& pos, const glm::vec3& vel, float m) {
mPosition = pos;
mVelocity = vel;
mMass = m;
......@@ -16,6 +16,18 @@ MassPoint::~MassPoint() = default;
void MassPoint::numericIntegration(float d_t) {
// TODO Aufgabe 4 (a)
// Implementieren Sie das Euler Integrationsverfahren.
// Einfaches Euler Verfahren updated zuerst die Position, dann die
// Geschwindigkeit
mPosition = mPosition + mVelocity * d_t;
// F = ma -> a = F/m
// oft auch Speicherung von 1/m statt m, damit unendliche Massen dargestellt
// werden koennen
mVelocity = mVelocity + mCurrentForce / mMass * d_t;
// Kraft wieder auf 0 setzen
zeroForce();
}
} // End namespace CVK