...
 
Commits (2)
......@@ -4,11 +4,11 @@ This repository contains a basic project setup.
## Adding your own executables
You can add your own executable by creating a folder in *src/executables* and adding your source files. You have to copy the CMakeLists.txt from another executable. Afterwards rerun cmake.
You can add your own executable by creating a folder in *src/executables* and adding your source files. You have to copy the CMakeLists.txt from another executable or write your own. Afterwards rerun cmake.
## Adding your own libraries
You can add your own library by creating a folder in *src/libraries* and adding your source files. For libraries, all headers should be placed in a folder *libraryname/include/libraryname* and all source files in *libraryname/src* You have to copy the CMakeLists.txt from another library. Afterwards rerun cmake.
You can add your own library by creating a folder in *src/libraries* and adding your source files. For libraries, all headers should be placed in a folder *libraryname/include/libraryname* and all source files in *libraryname/src* You have to copy the CMakeLists.txt from another library or write your own. Afterwards rerun cmake.
## Dependencies
......
......@@ -80,7 +80,7 @@ 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->setCenter(center);
cam_trackball->setRadius(5.0f);
CVK::State::getInstance()->setCamera(cam_trackball);
}
......
cmake_minimum_required(VERSION 2.8)
include(${CMAKE_MODULE_PATH}/DefaultExecutable.cmake)
\ No newline at end of file
CVK_2
\ No newline at end of file
#include <CVK_2/CVK_Framework.h>
#include <glad/glad.h>
#include <memory>
const int WIDTH = 600;
const int HEIGHT = 600;
void renderMain(GLFWwindow* window) {
glClearColor(1, 1, 1, 1);
// create cone vao
// TODO Use appropriate constructor to create a cone with 45° opening angle,
// oriented along the z-axis with its apex located at (0,0,0). The height
// an be chosen to mach the camera's far value
// You can use the model matrix to move the geometry
CVK::Cone coneGeometry;
// TODO Generate random points and colors
// compile a shader program
std::vector<std::string> shadernames = {
CVK::State::getInstance()->getShaderPath() +
"/Fragezeichen/fragezeichen.vert",
CVK::State::getInstance()->getShaderPath() +
"/Fragezeichen/fragezeichen.frag"};
CVK::ShaderSet shaderProgram(VERTEX_SHADER_BIT | FRAGMENT_SHADER_BIT,
{CVK::State::getInstance()->getShaderPath() +
"/Fragezeichen/fragezeichen.vert",
CVK::State::getInstance()->getShaderPath() +
"/Fragezeichen/fragezeichen.frag"});
// use the shader program
shaderProgram.useProgram();
// get uniform handles
GLint viewMatrixHandle =
glGetUniformLocation(shaderProgram.getProgramID(), "viewMatrix");
GLint projectionMatrixHandle =
glGetUniformLocation(shaderProgram.getProgramID(), "projectionMatrix");
GLint modelMatrixHandle =
glGetUniformLocation(shaderProgram.getProgramID(), "modelMatrix");
GLint colorHandle =
glGetUniformLocation(shaderProgram.getProgramID(), "color");
// setting up the camera parameters
glm::mat4 viewMatrix =
glm::lookAt(glm::vec3(0.0f, 0.0f, 0.001f), glm::vec3(0.0f, 0.0f, 0.0f),
glm::vec3(0.0f, 1.0f, 0.0f));
glm::mat4 projectionMatrix =
glm::ortho(-1.0f, 1.0f, -1.0f, 1.0f, 0.0f, 10.0f);
glm::mat4 modelMatrix = glm::mat4(1.0);
glUniformMatrix4fv(viewMatrixHandle, 1, GL_FALSE,
glm::value_ptr(viewMatrix));
glUniformMatrix4fv(projectionMatrixHandle, 1, GL_FALSE,
glm::value_ptr(projectionMatrix));
glUniformMatrix4fv(modelMatrixHandle, 1, GL_FALSE,
glm::value_ptr(modelMatrix));
// set color of the cone
glm::vec3 color(1.0, 0.0, 0.0);
glUniform3fv(colorHandle, 1, glm::value_ptr(color));
glEnable(GL_DEPTH_TEST);
// renderloop
while (!glfwWindowShouldClose(window)) {
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
// TODO Render a cone for each point with the respective color
// render cone
coneGeometry.render();
glfwSwapBuffers(window);
glfwPollEvents();
}
}
int main() {
// initialize opengl
glfwInit();
CVK::useOpenGL33CoreProfile();
GLFWwindow* window = glfwCreateWindow(WIDTH, HEIGHT, "Was bin ich?", 0, 0);
glfwSetWindowPos(window, 600, 50);
glfwMakeContextCurrent(window);
if (!gladLoadGLLoader((GLADloadproc)glfwGetProcAddress)) {
std::cout << "Failed to initialize OpenGL context" << std::endl;
return -1;
}
renderMain(window);
glfwDestroyWindow(window);
glfwTerminate();
return 0;
}
......@@ -53,7 +53,7 @@ class Camera {
* @brief Setter for the view matrix
* @param view the new view matrix as pointer
*/
void setView(glm::mat4* view);
void setView(const glm::mat4& view);
/**
* deprecated.
......@@ -73,7 +73,8 @@ class Camera {
* @param center the center point to look at.
* @param up the tilt of the camera.
*/
void lookAt(glm::vec3 position, glm::vec3 center, glm::vec3 up);
void lookAt(const glm::vec3& position, const glm::vec3& center,
const glm::vec3& up);
/**
* Sets the projection matrix.
......
......@@ -32,8 +32,8 @@ class Cone : public CVK::Geometry {
* @param apexradius The radius of the top of the Cone
* @param resolution The resolution of the mantle
*/
Cone(glm::vec3 basepoint, glm::vec3 apexpoint, float baseradius,
float apexradius, int resolution);
Cone(const glm::vec3& basepoint, const glm::vec3& apexpoint,
float baseradius, float apexradius, int resolution);
/**
* Standard Destructor for Cone
*/
......@@ -43,30 +43,30 @@ class Cone : public CVK::Geometry {
* @brief Standard Getter for position of the base
* @return the position of the base of this object as pointer
*/
glm::vec3* getBasepoint();
const glm::vec3& getBasepoint() const;
/**
* @brief Standard Getter for position of the top
* @return the position of the top of this object as pointer
*/
glm::vec3* getApexpoint();
const glm::vec3& getApexpoint() const;
/**
* @brief Standard Getter for u Axis of the local coordinate system
* @return the u Axis of the local coordinate system of this object as
* pointer
*/
glm::vec3* get_u();
const glm::vec3& get_u() const;
/**
* @brief Standard Getter for v Axis of the local coordinate system
* @return the v Axis of the local coordinate system of this object as
* pointer
*/
glm::vec3* get_v();
const glm::vec3& get_v() const;
/**
* @brief Standard Getter for w Axis of the local coordinate system
* @return the w Axis of the local coordinate system of this object as
* pointer
*/
glm::vec3* get_w();
const glm::vec3& get_w() const;
/**
* @brief Standard Getter for radius at base
......
......@@ -23,7 +23,7 @@ class Cube : public CVK::Geometry {
/**
* Standard Destructor for Cube
*/
~Cube();
~Cube() override;
/**
* @brief Standard Setter for size
......
......@@ -51,27 +51,55 @@ class Geometry {
* @brief Standard Getter for vertices
* @return the vertices of this object
*/
std::vector<glm::vec4>* getVertices();
std::vector<glm::vec4>& getVertices();
/**
* @brief Standard Getter for vertices
* @return the vertices of this object
*/
const std::vector<glm::vec4>& getVertices() const;
/**
* @brief Standard Getter for normals
* @return the normals of this object as pointer
*/
std::vector<glm::vec3>& getNormals();
/**
* @brief Standard Getter for normals
* @return the normals of this object as pointer
*/
std::vector<glm::vec3>* getNormals();
const std::vector<glm::vec3>& getNormals() const;
/**
* @brief Standard Getter for uv coordinates
* @return the uv coordinates of this object as pointer
*/
std::vector<glm::vec2>* getUVs();
std::vector<glm::vec2>& getUVs();
/**
* @brief Standard Getter for uv coordinates
* @return the uv coordinates of this object as pointer
*/
const std::vector<glm::vec2>& getUVs() const;
/**
* @brief Standard Getter for index list
* @return the index list of this object as pointer
*/
std::vector<unsigned int>& getIndex();
/**
* @brief Standard Getter for index list
* @return the index list of this object as pointer
*/
std::vector<unsigned int>* getIndex();
const std::vector<unsigned int>& getIndex() const;
/**
* @brief Standard Getter for tangents
* @return the tangents of this object as pointer
*/
std::vector<glm::vec3>& getTangents();
/**
* @brief Standard Getter for tangents
* @return the tangents of this object as pointer
*/
std::vector<glm::vec3>* getTangents();
const std::vector<glm::vec3>& getTangents() const;
/**
* @brief Standard Getter for the vao
......
......@@ -44,7 +44,7 @@ class Light {
* @brief Standard Getter for position
* @return the position of this object as pointer
*/
glm::vec4* getPosition();
const glm::vec4& getPosition() const;
/**
* @brief Standard Setter for color
......@@ -55,7 +55,7 @@ class Light {
* @brief Standard Getter for color
* @return the color of this object as pointer
*/
glm::vec3* getColor();
const glm::vec3& getColor() const;
/**
* @brief Standard Setter for direction
......@@ -66,7 +66,7 @@ class Light {
* @brief Standard Getter for direction
* @return the direction of this object as pointer
*/
glm::vec3* getSpotDirection();
const glm::vec3& getSpotDirection() const;
/**
* @brief Standard Setter for spot exponent
......
......@@ -28,14 +28,15 @@ class Material {
* @param shininess The exponent for the angle for reflective specular
* illumination
*/
Material(glm::vec3 diffuse, glm::vec3 specular, float shininess);
Material(const glm::vec3& diffuse, const glm::vec3& specular,
float shininess);
/**
* Constructor for Material with given parameters
* @param kd The factor of diffuse illumination
* @param diffuse The color for direct illumination only dependent on angle
* between normal and light position
*/
Material(float kd, glm::vec3 diffuse);
Material(float kd, const glm::vec3& diffuse);
/**
* Constructor for Material with given parameters
* @param kd The factor of diffuse illumination
......@@ -47,15 +48,15 @@ class Material {
* @param shininess The exponent for the angle for reflective specular
* illumination
*/
Material(float kd, glm::vec3 diffuse, float ks, glm::vec3 specular,
float shininess);
Material(float kd, const glm::vec3& diffuse, float ks,
const glm::vec3& specular, float shininess);
/**
* Constructor for Material with given parameters
* @param colorTexturePath The path to the color image for this material,
* used instead of diffuse color. Image is loaded first.
* @param kd The factor of diffuse illumination
*/
Material(const std::string colorTexturePath, float kd);
Material(const std::string& colorTexturePath, float kd);
/**
* Constructor for Material with given parameters
* @param colorTextureID The OpenGL id for the already created OpenGL
......@@ -74,7 +75,7 @@ class Material {
* @param shininess The exponent for the angle for reflective specular
* illumination
*/
Material(const std::string colorTexturePath, float kd, float ks,
Material(const std::string& colorTexturePath, float kd, float ks,
glm::vec3 specular, float shininess);
/**
* Constructor for Material with given parameters
......@@ -87,8 +88,8 @@ class Material {
* @param shininess The exponent for the angle for reflective specular
* illumination
*/
Material(GLuint colorTextureID, float kd, float ks, glm::vec3 specular,
float shininess);
Material(GLuint colorTextureID, float kd, float ks,
const glm::vec3& specular, float shininess);
/**
* Standard Destructor for Material
*/
......@@ -107,7 +108,7 @@ class Material {
* @param shininess The exponent for the angle for reflective specular
* illumination
*/
void init(float kd, glm::vec3 diffuse, float ks, glm::vec3 specular,
void init(float kd, const glm::vec3& diffuse, float ks, glm::vec3 specular,
float shininess);
/**
......@@ -145,23 +146,23 @@ class Material {
* @brief Standard Setter for diffuse color
* @param col the new diffuse color of this object
*/
void setdiffColor(glm::vec3 col);
void setDiffColor(const glm::vec3& col);
/**
* @brief Standard Getter for diffuse color
* @return the diffuse color of this object
*/
glm::vec3* getdiffColor();
const glm::vec3& getDiffColor();
/**
* @brief Standard Setter for specular color
* @param col the new specular color of this object
*/
void setspecColor(glm::vec3 col);
void setSpecColor(const glm::vec3& col);
/**
* @brief Standard Getter for specular color
* @return the specular color of this object
*/
glm::vec3* getspecColor();
const glm::vec3& getSpecColor();
/**
* @brief Standard Setter for shininess
* @param shininess the new shininess of this object
......@@ -188,7 +189,7 @@ class Material {
* @param type the type of the texture
* @param fileName the type of the texture
*/
void setTexture(TextureType type, const std::string fileName);
void setTexture(TextureType type, const std::string& fileName);
/**
* @brief Setter for texture of given texture type.
* @param type the type of the texture
......
......@@ -61,13 +61,13 @@ class Node {
* Constructor for Node with given parameters
* @param name The name for this node
*/
Node(const std::string name);
Node(const std::string& name);
/**
* Constructor for Node with given parameters
* @param name The name for this node
* @param path The path to a model, which is loaded with assimp
*/
Node(const std::string name, const std::string path);
Node(const std::string& name, const std::string& path);
/**
* Standard Destructor for Node
*/
......@@ -84,7 +84,7 @@ class Node {
* @brief Loads the model with assimp
* @param path The path to the model file
*/
void load(std::string path);
void load(const std::string& path);
/**
* Main render call for a Node and all subnodes. Calls render with model
......@@ -113,12 +113,12 @@ class Node {
* @brief Standard Setter for name
* @param name The new name of this object
*/
void setName(const std::string name);
void setName(std::string name);
/**
* @brief Standard Getter for name
* @return The name of this object as pointer
*/
std::string* getName();
const std::string& getName() const;
/**
* @brief Standard Setter for geometry
......@@ -191,10 +191,10 @@ class Node {
std::string m_name; //!< The name of the Node
CVK::Geometry* m_geometry = nullptr; //!< The geometry to render of the Node
CVK::Material* m_material =
nullptr; //!< The material used in the shader of the Node
glm::mat4 m_modelMatrix; //!< The model matrix for the local coordinate
//!< system of the Node
Node* m_parent = nullptr; //!< The parent node of the Node
nullptr; //!< The material used in the shader of the Node
glm::mat4 m_modelMatrix{1.0f}; //!< The model matrix for the local
//!< coordinate system of the Node
Node* m_parent = nullptr; //!< The parent node of the Node
std::vector<Node*> m_children; //!< The list of subnodes of the Node
};
......
......@@ -10,16 +10,18 @@ namespace CVK {
*/
class Projection {
public:
virtual ~Projection();
/**
* @brief Standard Getter for projection matrix
* @return The projection matrix of this object as pointer
*/
glm::mat4* getProjMatrix();
const glm::mat4& getProjMatrix();
/**
* @brief Standard Setter for projection matrix
* @param projection The new projection matrix of this object as pointer
*/
void setProjMatrix(glm::mat4* projection);
void setProjMatrix(const glm::mat4& projection);
/**
* @brief Getter for near and far value
......
......@@ -23,13 +23,20 @@ class ShaderMinimal : public CVK::ShaderSet {
* @param shaderPaths Array of paths to shader files
*/
ShaderMinimal(GLuint shaderMask, const char** shaderPaths);
/**
* Constructor for ShaderMinimal with given parameters. Collects uniform
* locations for all used variables from Shader Program.
* @param shaderMask Describes which shader files are used
* @param shaderPaths Array of paths to shader files
*/
ShaderMinimal(GLuint shaderMask,
const std::vector<std::string>& shaderNames);
/**
* @brief Standard Setter for model matrix in shader
* @param modelmatrix The new model matrix of this object
*/
void updateModelMatrix(glm::mat4 modelmatrix) const;
void updateModelMatrix(const glm::mat4& modelmatrix);
/**
* Sets scene dependent variables in Shader. Namely view and projection
* matrix by using Camera in State.
......
......@@ -26,8 +26,14 @@ class ShaderPhong : public CVK::ShaderMinimal {
* @param shaderPaths Array of paths to shader files
*/
ShaderPhong(GLuint shaderMask, const char** shaderPaths);
ShaderPhong(GLuint shaderMask,
const std::vector<std::string>& shaderNames);
/**
* Constructor for ShaderPhong with given parameters. Collects uniform
* locations for all used variables from Shader Program.
* @param shaderMask Describes which shader files are used
* @param shaderPaths Array of paths to shader files
*/
ShaderPhong(GLuint shaderMask, const std::vector<std::string>& shaderNames);
/**
* Sets scene dependent variables in Shader. Namely light and fog
......
......@@ -22,6 +22,13 @@ class ShaderPostProcessing : public CVK::ShaderSet {
* @param shaderPaths Array of paths to shader files
*/
ShaderPostProcessing(GLuint shaderMask, const char** shaderPaths);
/**
* Constructor for ShaderPostProcessing with given parameters. Collects
* uniform locations for all used variables from Shader Program.
* @param shaderMask Describes which shader files are used
* @param shaderPaths Array of paths to shader files
*/
ShaderPostProcessing(GLuint shader_mask,
const std::vector<std::string>& shaderPaths);
......
......@@ -43,9 +43,9 @@ class ShaderSet {
* @param shader_mask Describes which shader files are used
* @param ShaderNames Array of paths to shader files
*/
void GenerateShaderProgramm(GLuint shader_mask, const char** shaderNames);
void generateShaderProgram(GLuint shader_mask, const char** shaderNames);
void GenerateShaderProgramm(GLuint shader_mask,
void generateShaderProgram(GLuint shader_mask,
const std::vector<std::string>& shaderNames);
/**
* @brief Standard Getter for OpenGL program id
......
......@@ -24,6 +24,13 @@ class ShaderSimpleTexture : public CVK::ShaderPostProcessing {
* @param shaderPaths Array of paths to shader files
*/
ShaderSimpleTexture(GLuint shaderMask, const char** shaderPaths);
/**
* Constructor for ShaderSimpleTexture with given parameters. Collects
* uniform locations for all used variables from Shader Program.
* @param shaderMask Describes which shader files are used
* @param shaderPaths Array of paths to shader files
*/
ShaderSimpleTexture(GLuint shader_mask,
const std::vector<std::string>& shaderPaths);
......
......@@ -25,7 +25,7 @@ class Sphere : public CVK::Geometry {
* @param center the center of the sphere
* @param radius the radius of the sphere
*/
Sphere(glm::vec3 center, float radius);
Sphere(const glm::vec3& center, float radius);
/**
* Constructor for Sphere with given parameters around (0/0/0)
* @param radius the radius of the sphere
......@@ -38,7 +38,7 @@ class Sphere : public CVK::Geometry {
* @param radius the radius of the sphere
* @param resolution The resolution for triangulation
*/
Sphere(glm::vec3 center, float radius, int resolution);
Sphere(const glm::vec3& center, float radius, int resolution);
/**
* Standard Destructor for Sphere
*/
......@@ -48,12 +48,12 @@ class Sphere : public CVK::Geometry {
* @brief Standard Getter for center position
* @return the center position of this object as pointer
*/
glm::vec3* get_center();
const glm::vec3& getCenter() const;
/**
* @brief Standard Getter for radius
* @return the radius of this object
*/
float get_radius() const;
float getRadius() const;
private:
/**
......@@ -63,9 +63,9 @@ class Sphere : public CVK::Geometry {
* @param radius The radius of the sphere
* @param resolution The resolution for triangulation
*/
void create(glm::vec3 center, float radius, int resolution);
void create(const glm::vec3& center, float radius, int resolution);
glm::vec3 m_Center;
glm::vec3 m_center;
float m_radius;
int m_resolution;
};
......
......@@ -15,7 +15,7 @@ class Texture {
* Constructor for Texture with given parameters. Loads Image File first.
* @param fileName The path to a file which needs to be loaded
*/
Texture(const std::string fileName);
Texture(const std::string& fileName);
/**
* Constructor for Texture with given parameters
* @param width The width of the texture
......@@ -41,7 +41,7 @@ class Texture {
* @param fileName The path to a file which needs to be loaded
* @return false, if an error occurred, true otherwise
*/
bool load(const std::string fileName);
bool load(const std::string& fileName);
/**
* Binds the OpenGL texture object to the current GL_TEXTURE_2D, so that it
* can be used in the shader
......
......@@ -43,7 +43,7 @@ class Trackball : public CVK::Camera {
* @brief Standard Setter for center point
* @param center The new center point of this object as pointer
*/
void setCenter(glm::vec3* center);
void setCenter(const glm::vec3& center);
/**
* @brief Standard Setter for radius
* @param radius The new radius of this object
......@@ -53,7 +53,7 @@ class Trackball : public CVK::Camera {
* @brief Standard Setter for up vector
* @param up The new up vector of this object
*/
void setUpvector(glm::vec3* up);
void setUpvector(const glm::vec3& up);
private:
float m_sensitivity; //!< the sensitivity of the mouse movement
......
......@@ -22,7 +22,7 @@ class Triangle : public CVK::Geometry {
* @param b 2. vertex position
* @param c 3. vertex position
*/
Triangle(glm::vec3 a, glm::vec3 b, glm::vec3 c);
Triangle(const glm::vec3& a, const glm::vec3& b, const glm::vec3& c);
/**
* Constructor for Triangle with given parameters
* @param a 1. vertex position
......@@ -32,8 +32,8 @@ class Triangle : public CVK::Geometry {
* @param nb 2. vertex normal
* @param nc 3. vertex normal
*/
Triangle(glm::vec3 a, glm::vec3 b, glm::vec3 c, glm::vec3 na, glm::vec3 nb,
glm::vec3 nc);
Triangle(const glm::vec3& a, const glm::vec3& b, const glm::vec3& c,
const glm::vec3& na, const glm::vec3& nb, const glm::vec3& nc);
/**
* Constructor for Triangle with given parameters
* @param a 1. vertex position
......@@ -43,8 +43,8 @@ class Triangle : public CVK::Geometry {
* @param tcb 2. vertex uv coordinate
* @param tcc 3. vertex uv coordinate
*/
Triangle(glm::vec3 a, glm::vec3 b, glm::vec3 c, glm::vec2 tca,
glm::vec2 tcb, glm::vec2 tcc);
Triangle(const glm::vec3& a, const glm::vec3& b, const glm::vec3& c,
const glm::vec2& tca, const glm::vec2& tcb, const glm::vec2& tcc);
/**
* Constructor for Triangle with given parameters
* @param a 1. vertex position
......@@ -57,8 +57,9 @@ class Triangle : public CVK::Geometry {
* @param tcb 2. vertex uv coordinate
* @param tcc 3. vertex uv coordinate
*/
Triangle(glm::vec3 a, glm::vec3 b, glm::vec3 c, glm::vec3 na, glm::vec3 nb,
glm::vec3 nc, glm::vec2 tca, glm::vec2 tcb, glm::vec2 tcc);
Triangle(const glm::vec3& a, const glm::vec3& b, const glm::vec3& c,
const glm::vec3& na, const glm::vec3& nb, const glm::vec3& nc,
const glm::vec2& tca, const glm::vec2& tcb, const glm::vec2& tcc);
/**
* Standard Destructor for Triangle
......@@ -71,25 +72,25 @@ class Triangle : public CVK::Geometry {
* @param b 2. vertex position
* @param c 3. vertex position
*/
void set_Points(glm::vec3 a, glm::vec3 b, glm::vec3 c);
void setPoints(const glm::vec3& a, const glm::vec3& b, const glm::vec3& c);
/**
* @brief Getter for vertex positions as pointers
* @param a 1. vertex position as pointer
* @param b 2. vertex position as pointer
* @param c 3. vertex position as pointer
*/
void get_Points(glm::vec3* a, glm::vec3* b, glm::vec3* c);
void getPoints(glm::vec3* a, glm::vec3* b, glm::vec3* c);
/**
* @brief Standard Setter for plane normal
* @param n the new normal of this object
*/
void set_Normal(glm::vec3 n);
void setNormal(const glm::vec3& n);
/**
* @brief Standard Getter for plane normal
* @param n the normal of this object as pointer
*/
void get_Normal(glm::vec3* n);
void getNormal(glm::vec3* n);
/**
* @brief Setter for vertex normals
......@@ -97,14 +98,15 @@ class Triangle : public CVK::Geometry {
* @param nb 2. vertex normal
* @param nc 3. vertex normal
*/
void set_Normals(glm::vec3 na, glm::vec3 nb, glm::vec3 nc);
void setNormals(const glm::vec3& na, const glm::vec3& nb,
const glm::vec3& nc);
/**
* @brief Getter for vertex normals as pointers
* @param na 1. vertex normal as pointer
* @param nb 2. vertex normal as pointer
* @param nc 3. vertex normal as pointer
*/
void get_Normals(glm::vec3* na, glm::vec3* nb, glm::vec3* nc);
void getNormals(glm::vec3* na, glm::vec3* nb, glm::vec3* nc);
/**
* @brief Setter for vertex uv coordinates
......@@ -112,14 +114,15 @@ class Triangle : public CVK::Geometry {
* @param tcb 2. vertex uv coordinate
* @param tcc 3. vertex uv coordinate
*/
void set_Tcoords(glm::vec2 tca, glm::vec2 tcb, glm::vec2 tcc);
void setTcoords(const glm::vec2& tca, const glm::vec2& tcb,
const glm::vec2& tcc);
/**
* @brief Getter for vertex uv coordinates as pointers
* @param tca 1. vertex uv coordinate as pointer
* @param tcb 2. vertex uv coordinate as pointer
* @param tcc 3. vertex uv coordinate as pointer
*/
void get_Tcoords(glm::vec2* tca, glm::vec2* tcb, glm::vec2* tcc);
void getTcoords(glm::vec2* tca, glm::vec2* tcb, glm::vec2* tcc);
private:
/**
......@@ -132,8 +135,9 @@ class Triangle : public CVK::Geometry {
* @param tcb 2. vertex uv coordinate
* @param tcc 3. vertex uv coordinate
*/
void create(glm::vec3 a, glm::vec3 b, glm::vec3 c, glm::vec2 tca,
glm::vec2 tcb, glm::vec2 tcc);
void create(const glm::vec3& a, const glm::vec3& b, const glm::vec3& c,
const glm::vec2& tca, const glm::vec2& tcb,
const glm::vec2& tcc);
/**
* Create the Triangle and the buffers with the given attributes
* @brief Create the Triangle and the buffers
......@@ -147,9 +151,10 @@ class Triangle : public CVK::Geometry {
* @param tcb 2. vertex uv coordinate
* @param tcc 3. vertex uv coordinate
*/
void create(glm::vec3 a, glm::vec3 b, glm::vec3 c, glm::vec3 na,
glm::vec3 nb, glm::vec3 nc, glm::vec2 tca, glm::vec2 tcb,
glm::vec2 tcc);
void create(const glm::vec3& a, const glm::vec3& b, const glm::vec3& c,
const glm::vec3& na, const glm::vec3& nb, const glm::vec3& nc,
const glm::vec2& tca, const glm::vec2& tcb,
const glm::vec2& tcc);
};
} // namespace CVK
......
......@@ -18,7 +18,7 @@ void Camera::getView(glm::vec3* x, glm::vec3* y, glm::vec3* z,
*pos = -mat_inv * *pos;
}
void Camera::setView(glm::mat4* view) { m_viewmatrix = *view; }
void Camera::setView(const glm::mat4& view) { m_viewmatrix = view; }
void Camera::setWidthHeight(int width, int height) {
m_width = width;
......@@ -30,7 +30,8 @@ void Camera::getWidthHeight(int* width, int* height) const {
*height = m_height;
}
void Camera::lookAt(glm::vec3 position, glm::vec3 center, glm::vec3 up) {
void Camera::lookAt(const glm::vec3& position, const glm::vec3& center,
const glm::vec3& up) {
m_viewmatrix = glm::lookAt(position, center, up);
}
......
......@@ -24,8 +24,8 @@ Cone::Cone(float baseradius, float apexradius, float height, int resolution) {
create();
}
Cone::Cone(glm::vec3 basepoint, glm::vec3 apexpoint, float baseradius,
float apexradius, int resolution) {
Cone::Cone(const glm::vec3& basepoint, const glm::vec3& apexpoint,
float baseradius, float apexradius, int resolution) {
m_baseradius = baseradius;
m_apexradius = apexradius;
m_basepoint = basepoint;
......@@ -38,15 +38,15 @@ Cone::Cone(glm::vec3 basepoint, glm::vec3 apexpoint, float baseradius,
Cone::~Cone() = default;
glm::vec3* Cone::getBasepoint() { return &m_basepoint; }
const glm::vec3& Cone::getBasepoint() const { return m_basepoint; }
glm::vec3* Cone::getApexpoint() { return &m_apexpoint; }
const glm::vec3& Cone::getApexpoint() const { return m_apexpoint; }
glm::vec3* Cone::get_u() { return &m_u; }
const glm::vec3& Cone::get_u() const { return m_u; }
glm::vec3* Cone::get_v() { return &m_v; }
const glm::vec3& Cone::get_v() const { return m_v; }
glm::vec3* Cone::get_w() { return &m_w; }
const glm::vec3& Cone::get_w() const { return m_w; }
float Cone::getBaseradius() const { return m_baseradius; }
......
......@@ -144,17 +144,26 @@ void Geometry::computeTangents() {
}
}
std::vector<glm::vec4>* Geometry::getVertices() { return &m_vertices; }
std::vector<glm::vec4>& Geometry::getVertices() { return m_vertices; }
std::vector<glm::vec3>* Geometry::getNormals() { return &m_normals; }
std::vector<glm::vec3>& Geometry::getNormals() { return m_normals; }
std::vector<glm::vec2>* Geometry::getUVs() { return &m_uvs; }
std::vector<glm::vec2>& Geometry::getUVs() { return m_uvs; }
std::vector<unsigned int>* Geometry::getIndex() { return &m_index; }
std::vector<unsigned int>& Geometry::getIndex() { return m_index; }
std::vector<glm::vec3>* Geometry::getTangents() { return &m_tangents; }
std::vector<glm::vec3>& Geometry::getTangents() { return m_tangents; }
GLuint Geometry::getVAO() const { return m_vao; }
int Geometry::getNumIndices() const { return m_indices; }
int Geometry::getNumVertexAttrib() const { return m_num_attribs; }
const std::vector<glm::vec4>& Geometry::getVertices() const {
return m_vertices;
}
const std::vector<glm::vec3>& Geometry::getNormals() const { return m_normals; }
const std::vector<glm::vec2>& Geometry::getUVs() const { return m_uvs; }
const std::vector<unsigned int>& Geometry::getIndex() const { return m_index; }
const std::vector<glm::vec3>& Geometry::getTangents() const {
return m_tangents;
}
} // namespace CVK
\ No newline at end of file
......@@ -25,17 +25,17 @@ Light::~Light() {}
void Light::setPosition(glm::vec4 pos) { m_position = pos; }
glm::vec4* Light::getPosition() { return &m_position; }
const glm::vec4& Light::getPosition() const { return m_position; }
void Light::setColor(glm::vec3 col) { m_color = col; }
glm::vec3* Light::getColor() { return &m_color; }
const glm::vec3& Light::getColor() const { return m_color; }
void Light::setSpotDirection(glm::vec3 direction) {
m_spotDirection = direction;
}
glm::vec3* Light::getSpotDirection() { return &m_spotDirection; }
const glm::vec3& Light::getSpotDirection() const { return m_spotDirection; }
void Light::setSpotExponent(float spotExponent) {
m_spotExponent = spotExponent;
......
......@@ -2,20 +2,21 @@
namespace CVK {
Material::Material(glm::vec3 diffuse, glm::vec3 specular, float shininess) {
Material::Material(const glm::vec3& diffuse, const glm::vec3& specular, float shininess) {
init(1.f, diffuse, 1.f, specular, shininess);
}
Material::Material(float kd, glm::vec3 diffuse) {
Material::Material(float kd, const glm::vec3& diffuse) {
init(kd, diffuse, 0.f, BLACK, 0.f);
}
Material::Material(float kd, glm::vec3 diffuse, float ks, glm::vec3 specular,
Material::Material(float kd, const glm::vec3& diffuse, float ks,
const glm::vec3& specular,
float shininess) {
init(kd, diffuse, ks, specular, shininess);
}
Material::Material(const std::string colorTexturePath, float kd) {
Material::Material(const std::string& colorTexturePath, float kd) {
init(kd, WHITE, 0.f, BLACK, 0.f);
setTexture(COLOR_TEXTURE, colorTexturePath);
}
......@@ -25,18 +26,18 @@ Material::Material(GLuint colorTextureID, float kd) {
setTexture(COLOR_TEXTURE, colorTextureID);
}
Material::Material(const std::string colorTexturePath, float kd, float ks,
Material::Material(const std::string& colorTexturePath, float kd, float ks,
glm::vec3 specular, float shininess) {
init(kd, WHITE, ks, specular, shininess);
setTexture(COLOR_TEXTURE, colorTexturePath);
}
Material::Material(GLuint colorTextureID, float kd, float ks,
glm::vec3 specular, float shininess) {
const glm::vec3& specular, float shininess) {
init(kd, WHITE, ks, specular, shininess);
setTexture(COLOR_TEXTURE, colorTextureID);
}
void Material::init(float kd, glm::vec3 diffuse, float ks, glm::vec3 specular,
void Material::init(float kd, const glm::vec3& diffuse, float ks, glm::vec3 specular,
float shininess) {
m_kd = kd;
m_ks = ks;
......@@ -61,13 +62,13 @@ void Material::setKt(float kt) { m_kt = kt; }
float Material::getKt() const { return m_kt; }
void Material::setdiffColor(glm::vec3 col) { m_diffColor = col; }
void Material::setDiffColor(const glm::vec3& col) { m_diffColor = col; }
glm::vec3* Material::getdiffColor() { return &m_diffColor; }
const glm::vec3& Material::getDiffColor() { return m_diffColor; }
void Material::setspecColor(glm::vec3 col) { m_specColor = col; }
void Material::setSpecColor(const glm::vec3& col) { m_specColor = col; }
glm::vec3* Material::getspecColor() { return &m_specColor; }
const glm::vec3& Material::getSpecColor() { return m_specColor; }
void Material::setShininess(float shininess) { m_shininess = shininess; }
......@@ -77,7 +78,7 @@ void Material::setIor(float ior) { m_ior = ior; }
float Material::getIor() const { return m_ior; }
void Material::setTexture(TextureType type, const std::string fileName) {
void Material::setTexture(TextureType type, const std::string& fileName) {
switch (type) {
case COLOR_TEXTURE:
if (m_colorTexture)
......
......@@ -2,30 +2,35 @@
#include <CVK_2/CVK_ShaderMinimal.h>
#include <iostream>
#include <utility>
namespace CVK {
Node::Node() { init(); }
Node::Node(const std::string name) {
Node::Node(const std::string& name) {
init();
m_name = name;
}
Node::Node(std::string name, std::string path) {
Node::Node(const std::string& name, const std::string& path) {
init();
m_name = name;
load(path);
}
Node::~Node() {}
Node::~Node() {
for (auto& c : m_children) {
delete c;
}
}
void Node::init() {
m_name = "";
m_modelMatrix = glm::mat4(1.0f);
}
void Node::load(std::string path) {
void Node::load(const std::string& path) {
// load a scene with ASSIMP
Assimp::Importer importer;
const aiScene* scene = importer.ReadFile(path, aiProcess_GenSmoothNormals |
......@@ -73,24 +78,24 @@ void Node::load(std::string path) {
for (unsigned int i = 0; i < scene->mNumMeshes; i++) {
aiMesh* mesh = scene->mMeshes[i];
Geometry* geometry = new Geometry();
auto* geometry = new Geometry();
// load geometry information of the current mesh
for (unsigned int vCount = 0; vCount < mesh->mNumVertices; vCount++) {
// vertices
aiVector3D v = mesh->mVertices[vCount];
geometry->getVertices()->push_back(glm::vec4(v.x, v.y, v.z, 1.0f));
geometry->getVertices().emplace_back(v.x, v.y, v.z, 1.0f);
// normals
if (mesh->HasNormals()) {
v = mesh->mNormals[vCount];
geometry->getNormals()->push_back(glm::vec3(v.x, v.y, v.z));
geometry->getNormals().emplace_back(v.x, v.y, v.z);
}
// texture coordinates
if (mesh->HasTextureCoords(0)) {
v = mesh->mTextureCoords[0][vCount];
geometry->getUVs()->push_back(glm::vec2(v.x, v.y));
geometry->getUVs().emplace_back(v.x, v.y);
}
}
......@@ -98,7 +103,7 @@ void Node::load(std::string path) {
aiFace f = mesh->mFaces[fCount];
// index numbers
for (unsigned int iCount = 0; iCount < f.mNumIndices; iCount++) {
geometry->getIndex()->push_back(f.mIndices[iCount]);
geometry->getIndex().push_back(f.mIndices[iCount]);
}
}
......@@ -148,12 +153,12 @@ Node* Node::find(std::string name) {
if (result != nullptr)
return result;
}
return 0;
return nullptr;
}
void Node::setName(std::string name) { m_name = name; }
void Node::setName(std::string name) { m_name = std::move(name); }
std::string* Node::getName() { return &m_name; }
const std::string& Node::getName() const { return m_name; }
void Node::setGeometry(Geometry* geometry) { m_geometry = geometry; }
......
......@@ -2,9 +2,9 @@
namespace CVK {
glm::mat4* Projection::getProjMatrix() { return &m_projection; }
void Projection::setProjMatrix(glm::mat4* projection) {
m_projection = *projection;
const glm::mat4& Projection::getProjMatrix() { return m_projection; }
void Projection::setProjMatrix(const glm::mat4& projection) {
m_projection = projection;
}
void Projection::getNearFar(float* near, float* far) const {
......@@ -14,4 +14,6 @@ void Projection::getNearFar(float* near, float* far) const {
float Projection::getNear() const { return m_znear; }
Projection::~Projection() {}
} // namespace CVK
\ No newline at end of file
......@@ -4,12 +4,12 @@ namespace CVK {
ShaderMinimal::ShaderMinimal(GLuint shaderMask, const char** shaderPaths) {
// generate shader program
GenerateShaderProgramm(shaderMask, shaderPaths);
generateShaderProgram(shaderMask, shaderPaths);
init();
}
void ShaderMinimal::updateModelMatrix(glm::mat4 modelmatrix) const {
void ShaderMinimal::updateModelMatrix(const glm::mat4& modelmatrix) {
glUniformMatrix4fv(m_modelMatrixID, 1, GL_FALSE,
glm::value_ptr(modelmatrix));
}
......@@ -20,7 +20,7 @@ void ShaderMinimal::update() {
if (cam != nullptr) {
viewmatrix = *cam->getView();
projection = *cam->getProjection()->getProjMatrix();
projection = cam->getProjection()->getProjMatrix();
}
glUniformMatrix4fv(m_viewMatrixID, 1, GL_FALSE, glm::value_ptr(viewmatrix));
......
......@@ -16,10 +16,10 @@ void ShaderPhong::update() {
glUniform1i(m_numLightsID, numLights);
for (auto i = 0; i < numLights; i++) {
Light* light = &State::getInstance()->getLights()->at(i);
glUniform4fv(m_lightposID[i], 1, glm::value_ptr(*light->getPosition()));
glUniform3fv(m_lightcolID[i], 1, glm::value_ptr(*light->getColor()));
glUniform4fv(m_lightposID[i], 1, glm::value_ptr(light->getPosition()));
glUniform3fv(m_lightcolID[i], 1, glm::value_ptr(light->getColor()));
glUniform3fv(m_lightsdirID[i], 1,
glm::value_ptr(*light->getSpotDirection()));
glm::value_ptr(light->getSpotDirection()));
glUniform1f(m_lightsexpID[i], light->getSpotExponent());
glUniform1f(m_lightscutID[i], light->getSpotCutoff());
}
......@@ -44,8 +44,8 @@ void ShaderPhong::update(Node* node) {
glUniform1f(m_kdID, mat->getKd());
glUniform1f(m_ksID, mat->getKs());
glUniform1f(m_ktID, mat->getKt());
glUniform3fv(m_diffuseID, 1, glm::value_ptr(*mat->getdiffColor()));
glUniform3fv(m_specularID, 1, glm::value_ptr(*mat->getspecColor()));
glUniform3fv(m_diffuseID, 1, glm::value_ptr(mat->getDiffColor()));
glUniform3fv(m_specularID, 1, glm::value_ptr(mat->getSpecColor()));
glUniform1f(m_shininessID, mat->getShininess());
bool colorTexture = mat->hasTexture(COLOR_TEXTURE);
......
......@@ -10,12 +10,12 @@ ShaderSet::ShaderSet() = default;
// ShaderNames must be in order Vertx, Tess_Control, Tess_Eval, Geometry,
// Fragment, Compute
ShaderSet::ShaderSet(GLuint shader_mask, const char** shaderPaths) {
GenerateShaderProgramm(shader_mask, shaderPaths);
generateShaderProgram(shader_mask, shaderPaths);
}
ShaderSet::ShaderSet(GLuint shader_mask,
const std::vector<std::string>& shaderNames) {
GenerateShaderProgramm(shader_mask, shaderNames);
generateShaderProgram(shader_mask, shaderNames);
}
GLuint ShaderSet::getProgramID() const { return (m_ProgramID); }
......@@ -38,7 +38,7 @@ void ShaderSet::setValue(const char* variableName, float value) const {
glUniform1f(variableID, value);
}
void ShaderSet::GenerateShaderProgramm(
void ShaderSet::generateShaderProgram(
GLuint shader_mask, const std::vector<std::string>& shaderNames) {
GLuint vertexShaderID, tessControlShaderID, tessEvalShaderID;
GLuint geometryShaderID, fragmentShaderID, computeShaderID;
......@@ -110,8 +110,8 @@ void ShaderSet::GenerateShaderProgramm(
checkProgram(m_ProgramID);
}
void ShaderSet::GenerateShaderProgramm(GLuint shader_mask,
const char** shaderPaths) {
void ShaderSet::generateShaderProgram(GLuint shader_mask,
const char** shaderNames) {
// TODO remove all old code
GLuint vertexShaderID, tessControlShaderID, tessEvalShaderID;
GLuint geometryShaderID, fragmentShaderID, computeShaderID;
......@@ -123,42 +123,42 @@ void ShaderSet::GenerateShaderProgramm(GLuint shader_mask,
if (shader_mask & VERTEX_SHADER_BIT) {
vertexShaderID = glCreateShader(GL_VERTEX_SHADER);
loadShaderSource(vertexShaderID, shaderPaths[next_name++]);
loadShaderSource(vertexShaderID, shaderNames[next_name++]);
glCompileShader(vertexShaderID);
checkShader(vertexShaderID);
}
if (shader_mask & TESS_CONTROL_BIT) {
tessControlShaderID = glCreateShader(GL_TESS_CONTROL_SHADER);
loadShaderSource(tessControlShaderID, shaderPaths[next_name++]);
loadShaderSource(tessControlShaderID, shaderNames[next_name++]);
glCompileShader(tessControlShaderID);
checkShader(tessControlShaderID);
}
if (shader_mask & TESS_EVAL_BIT) {
tessEvalShaderID = glCreateShader(GL_TESS_EVALUATION_SHADER);
loadShaderSource(tessEvalShaderID, shaderPaths[next_name++]);
loadShaderSource(tessEvalShaderID, shaderNames[next_name++]);
glCompileShader(tessEvalShaderID);
checkShader(tessEvalShaderID);
}
if (shader_mask & GEOMETRY_SHADER_BIT) {
geometryShaderID = glCreateShader(GL_GEOMETRY_SHADER);
loadShaderSource(geometryShaderID, shaderPaths[next_name++]);
loadShaderSource(geometryShaderID, shaderNames[next_name++]);
glCompileShader(geometryShaderID);
checkShader(geometryShaderID);
}
if (shader_mask & FRAGMENT_SHADER_BIT) {
fragmentShaderID = glCreateShader(GL_FRAGMENT_SHADER);
loadShaderSource(fragmentShaderID, shaderPaths[next_name++]);
loadShaderSource(fragmentShaderID, shaderNames[next_name++]);
glCompileShader(fragmentShaderID);
checkShader(fragmentShaderID);
}
if (shader_mask & COMPUTE_SHADER_BIT) {
computeShaderID = glCreateShader(GL_COMPUTE_SHADER);
loadShaderSource(computeShaderID, shaderPaths[next_name++]);
loadShaderSource(computeShaderID, shaderNames[next_name++]);
glCompileShader(computeShaderID);
checkShader(computeShaderID);
}
......
......@@ -5,50 +5,50 @@ namespace CVK {
Sphere::Sphere() {
m_radius = 1.0f;
m_resolution = 20;
m_Center = glm::vec3(0);
create(m_Center, m_radius, m_resolution);
m_center = glm::vec3(0);
create(m_center, m_radius, m_resolution);
m_geotype = CVK_SPHERE;
}
Sphere::Sphere(float radius) {
m_radius = radius;
m_resolution = 20;
m_Center = glm::vec3(0);
create(m_Center, m_radius, m_resolution);
m_center = glm::vec3(0);
create(m_center, m_radius, m_resolution);
m_geotype = CVK_SPHERE;
}
Sphere::Sphere(glm::vec3 center, float radius) {
Sphere::Sphere(const glm::vec3& center, float radius) {
m_radius = radius;
m_resolution = 20;
m_Center = center;
create(m_Center, m_radius, m_resolution);
m_center = center;
create(m_center, m_radius, m_resolution);
m_geotype = CVK_SPHERE;
}
Sphere::Sphere(float radius, int resolution) {
m_radius = radius;
m_resolution = resolution;
m_Center = glm::vec3(0);
create(m_Center, m_radius, m_resolution);
m_center = glm::vec3(0);
create(m_center, m_radius, m_resolution);
m_geotype = CVK_SPHERE;
}
Sphere::Sphere(glm::vec3 center, float radius, int resolution) {
Sphere::Sphere(const glm::vec3& center, float radius, int resolution) {
m_radius = radius;
m_resolution = resolution;
m_Center = center;
create(m_Center, m_radius, m_resolution);
m_center = center;
create(m_center, m_radius, m_resolution);
m_geotype = CVK_SPHERE;
}
Sphere::~Sphere() {}
glm::vec3* Sphere::get_center() { return &m_Center; }
const glm::vec3& Sphere::getCenter() const { return m_center; }
float Sphere::get_radius() const { return m_radius; }
float Sphere::getRadius() const { return m_radius; }
void Sphere::create(glm::vec3 center, float radius, int resolution) {
void Sphere::create(const glm::vec3& center, float radius, int resolution) {
// iniatialize the variable we are going to use
float u, v;
float phi, theta;
......@@ -64,9 +64,9 @@ void Sphere::create(glm::vec3 center, float radius, int resolution) {
v = j / (float)resolution;
theta = glm::pi<float>() * v;
x = m_Center.x + radius * sin(theta) * sin(phi);
y = m_Center.y + radius * cos(theta);
z = m_Center.z + radius * sin(theta) * cos(phi);
x = m_center.x + radius * sin(theta) * sin(phi);
y = m_center.y + radius * cos(theta);
z = m_center.z + radius * sin(theta) * cos(phi);
m_vertices.push_back(glm::vec4(x, y, z, 1.0f));
m_normals.push_back(glm::vec3(x, y, z) / radius);
......
......@@ -5,7 +5,7 @@
namespace CVK {
Texture::Texture(const std::string fileName) {
Texture::Texture(const std::string& fileName) {
m_textureID = INVALID_GL_VALUE;
createTexture();
......@@ -37,7 +37,7 @@ void Texture::createTexture() {
GL_LINEAR_MIPMAP_LINEAR);
}
bool Texture::load(const std::string fileName) {
bool Texture::load(const std::string& fileName) {
int bytesPerPixel = 0;
unsigned char* data =
......
......@@ -89,10 +89,10 @@ void Trackball::update(double deltaTime) {
m_viewmatrix = glm::lookAt(m_cameraPos, m_center, m_up);
}
void Trackball::setCenter(glm::vec3* center) { m_center = *center; }
void Trackball::setCenter(const glm::vec3& center) { m_center = center; }
void Trackball::setRadius(float radius) { m_radius = radius; }
void Trackball::setUpvector(glm::vec3* up) { m_up = *up; }
void Trackball::setUpvector(const glm::vec3& up) { m_up = up; }
} // namespace CVK
\ No newline at end of file
......@@ -21,41 +21,49 @@ CVK::Triangle::Triangle() {
m_geotype = CVK_TRIANGLE;
}
CVK::Triangle::Triangle(glm::vec3 a, glm::vec3 b, glm::vec3 c) {
CVK::Triangle::Triangle(const glm::vec3& a, const glm::vec3& b,
const glm::vec3& c) {
create(a, b, c, def_ta, def_tb, def_tc);
m_geotype = CVK_TRIANGLE;
}
CVK::Triangle::Triangle(glm::vec3 a, glm::vec3 b, glm::vec3 c, glm::vec3 na,
glm::vec3 nb, glm::vec3 nc) {
CVK::Triangle::Triangle(const glm::vec3& a, const glm::vec3& b,
const glm::vec3& c, const glm::vec3& na,
const glm::vec3& nb, const glm::vec3& nc) {
create(a, b, c, na, nb, nc, def_ta, def_tb, def_tc);
m_geotype = CVK_TRIANGLE;
}
CVK::Triangle::Triangle(glm::vec3 a, glm::vec3 b, glm::vec3 c, glm::vec2 tca,
glm::vec2 tcb, glm::vec2 tcc) {
CVK::Triangle::Triangle(const glm::vec3& a, const glm::vec3& b,
const glm::vec3& c, const glm::vec2& tca,
const glm::vec2& tcb, const glm::vec2& tcc) {
create(a, b, c, tca, tcb, tcc);
m_geotype = CVK_TRIANGLE;
}
CVK::Triangle::Triangle(glm::vec3 a, glm::vec3 b, glm::vec3 c, glm::vec3 na,
glm::vec3 nb, glm::vec3 nc, glm::vec2 tca,
glm::vec2 tcb, glm::vec2 tcc) {
CVK::Triangle::Triangle(const glm::vec3& a, const glm::vec3& b,
const glm::vec3& c, const glm::vec3& na,
const glm::vec3& nb, const glm::vec3& nc,
const glm::vec2& tca, const glm::vec2& tcb,
const glm::vec2& tcc) {
create(a, b, c, na, nb, nc, tca, tcb, tcc);
m_geotype = CVK_TRIANGLE;
}
CVK::Triangle::~Triangle() = default;
void CVK::Triangle::create(glm::vec3 a, glm::vec3 b, glm::vec3 c, glm::vec2 tca,
glm::vec2 tcb, glm::vec2 tcc) {
void CVK::Triangle::create(const glm::vec3& a, const glm::vec3& b,
const glm::vec3& c, const glm::vec2& tca,
const glm::vec2& tcb, const glm::vec2& tcc) {
glm::vec3 n = glm::normalize(glm::cross(b - a, c - a));
create(a, b, c, n, n, n, tca, tcb, tcc);
}
void CVK::Triangle::create(glm::vec3 a, glm::vec3 b, glm::vec3 c, glm::vec3 na,
glm::vec3 nb, glm::vec3 nc, glm::vec2 tca,
glm::vec2 tcb, glm