Added Gorrilla-Audio and Tinygltf Library
Started laying out a assetManager / ModelImporter
This commit is contained in:
22
MyGraphicsEngine/Camera.cpp
Normal file
22
MyGraphicsEngine/Camera.cpp
Normal file
@ -0,0 +1,22 @@
|
||||
#include <MyGraphicsEngine/Camera.h>
|
||||
|
||||
Camera::Camera(glm::vec3 position, glm::vec3 rotation, float zoom)
|
||||
: Position(position), Rotation(rotation), Zoom(zoom) {
|
||||
|
||||
Front = glm::vec3(-1.0f, 0.0f, 0.0f);
|
||||
Right = glm::vec3(0.0f, 0.0f, 1.0f);
|
||||
Up = glm::vec3(0.0f, 1.0f, 0.0f);
|
||||
|
||||
}
|
||||
|
||||
Camera::~Camera() {
|
||||
|
||||
}
|
||||
|
||||
glm::mat4 Camera::GetViewMatrix() {
|
||||
return glm::lookAt(
|
||||
Position,
|
||||
Position + Front,
|
||||
Up
|
||||
);
|
||||
}
|
47
MyGraphicsEngine/ModelImporter.cpp
Normal file
47
MyGraphicsEngine/ModelImporter.cpp
Normal file
@ -0,0 +1,47 @@
|
||||
#include "include/AssetManager/ModelImporter.h"
|
||||
|
||||
void ModelImporter::ImportFBX(std::string path)
|
||||
{
|
||||
spdlog::warn("ImportFBX not implemented!");
|
||||
}
|
||||
|
||||
void ModelImporter::ImportBlend(std::string path)
|
||||
{
|
||||
spdlog::warn("ImportBlend not implemented!");
|
||||
}
|
||||
|
||||
void ModelImporter::ImportGLTF(std::string path)
|
||||
{
|
||||
spdlog::warn("ImportGLTF not implemented!");
|
||||
}
|
||||
|
||||
void ModelImporter::ImportOBJ(std::string path)
|
||||
{
|
||||
spdlog::warn("ImportOBJ not implemented!");
|
||||
}
|
||||
|
||||
void ModelImporter::Import(std::string path)
|
||||
{
|
||||
spdlog::warn("Import not implemented!");
|
||||
}
|
||||
|
||||
void ModelImporter::Test() {
|
||||
tinygltf::Model loadedModel;
|
||||
tinygltf::TinyGLTF loader;
|
||||
std::string error;
|
||||
std::string warn;
|
||||
bool ret = loader.LoadASCIIFromFile(&loadedModel, &error, &warn, "./Build/SandboxApplication/Debug/sponza.gltf");
|
||||
|
||||
if (!warn.empty())
|
||||
spdlog::warn("TinyGLTF Warning: {}", warn);
|
||||
if (!error.empty())
|
||||
spdlog::error("TinyGLTF Error: {}", error);
|
||||
if (!ret) {
|
||||
spdlog::error("TinyGLTF Error: Failed to parse glTF");
|
||||
exit(-1);
|
||||
}
|
||||
|
||||
spdlog::info("Meshes in model: {}", loadedModel.meshes.size());
|
||||
spdlog::info("Primitives in mesh: {}", loadedModel.meshes[0].primitives.size());
|
||||
|
||||
}
|
@ -6,6 +6,7 @@ Shader::Shader(const std::string vertexShaderPath, const std::string fragmentSha
|
||||
int succes;
|
||||
|
||||
char* vertexCode = readFile(vertexShaderPath.c_str());
|
||||
spdlog::info(vertexCode);
|
||||
unsigned int vertId = glCreateShader(GL_VERTEX_SHADER);
|
||||
|
||||
glShaderSource(vertId, 1, &vertexCode, NULL);
|
||||
@ -20,7 +21,7 @@ Shader::Shader(const std::string vertexShaderPath, const std::string fragmentSha
|
||||
|
||||
|
||||
char* fragmentCode = readFile(fragmentShaderPath.c_str());
|
||||
|
||||
spdlog::info(fragmentCode);
|
||||
unsigned int fragId = glCreateShader(GL_FRAGMENT_SHADER);
|
||||
|
||||
|
||||
@ -92,4 +93,32 @@ char* Shader::readFile (const char* filePath){
|
||||
void Shader::Use()
|
||||
{
|
||||
glUseProgram(id);
|
||||
}
|
||||
|
||||
|
||||
void Shader::setUniformMat4(std::string uniformName, glm::mat4 matrix4)
|
||||
{
|
||||
glUniformMatrix4fv(glGetUniformLocation(id, uniformName.c_str()), 1, GL_FALSE, glm::value_ptr(matrix4));
|
||||
}
|
||||
void Shader::setUniformVec4(std::string uniformName, glm::vec4 vector4)
|
||||
{
|
||||
glUniform4fv(glGetUniformLocation(id, uniformName.c_str()), 1, glm::value_ptr(vector4));
|
||||
}
|
||||
void Shader::setUniformVec3(std::string uniformName, glm::vec3 vector3)
|
||||
{
|
||||
glUniform3fv(glGetUniformLocation(id, uniformName.c_str()), 1, glm::value_ptr(vector3));
|
||||
}
|
||||
void Shader::setUniformVec2(std::string uniformName, glm::vec2 vector2)
|
||||
{
|
||||
glUniform2fv(glGetUniformLocation(id, uniformName.c_str()),1, glm::value_ptr(vector2));
|
||||
}
|
||||
|
||||
void Shader::setUniformFloat(std::string uniformName, float value)
|
||||
{
|
||||
glUniform1f(glGetUniformLocation(id, uniformName.c_str()), value);
|
||||
}
|
||||
|
||||
void Shader::setUniformInt(std::string uniformName, int value)
|
||||
{
|
||||
glUniform1i(glGetUniformLocation(id, uniformName.c_str()), value);
|
||||
}
|
22
MyGraphicsEngine/include/AssetManager/ModelImporter.h
Normal file
22
MyGraphicsEngine/include/AssetManager/ModelImporter.h
Normal file
@ -0,0 +1,22 @@
|
||||
#pragma once
|
||||
#define TINYGLTF_IMPLEMENTATION
|
||||
#define STB_IMAGE_IMPLEMENTATION
|
||||
#define STB_IMAGE_WRITE_IMPLEMENTATION
|
||||
#define TINYGLTF_NO_EXTERNAL_IMAGE
|
||||
|
||||
#include <tiny_gltf.h>
|
||||
#include <spdlog/spdlog.h>
|
||||
#include <string>
|
||||
|
||||
class ModelImporter {
|
||||
private:
|
||||
void ImportFBX(std::string path);
|
||||
void ImportBlend(std::string path);
|
||||
void ImportGLTF(std::string path);
|
||||
void ImportOBJ(std::string path);
|
||||
|
||||
public:
|
||||
void Import(std::string path);
|
||||
|
||||
static void Test();
|
||||
};
|
@ -1,13 +1,22 @@
|
||||
#pragma once
|
||||
#include <glm/glm.hpp>
|
||||
#include <glm/gtc/matrix_transform.hpp>
|
||||
|
||||
class Camera {
|
||||
public:
|
||||
glm::vec3 Position;
|
||||
glm::vec3 Rotation;
|
||||
float Zoom;
|
||||
|
||||
Camera(glm::vec3 position, glm::vec3 rotation, float zoom );
|
||||
~Camera();
|
||||
|
||||
glm::mat4 GetViewMatrix();
|
||||
|
||||
|
||||
struct Camera {
|
||||
glm::vec3 Position;
|
||||
glm::mat4 ViewMat;
|
||||
float Zoom;
|
||||
private:
|
||||
glm::vec3 Front;
|
||||
glm::vec3 Right;
|
||||
glm::vec3 Up;
|
||||
glm::vec3 Front;
|
||||
glm::vec3 Right;
|
||||
glm::vec3 Up;
|
||||
|
||||
};
|
@ -1,10 +1,10 @@
|
||||
#pragma once
|
||||
#include <vector>
|
||||
#include <glm/glm.hpp>
|
||||
|
||||
class Mesh {
|
||||
public:
|
||||
std::vector<float> vertices;
|
||||
std::vector<int> elements;
|
||||
std::vector<float> uv;
|
||||
|
||||
std::vector<glm::vec3> vertices;
|
||||
std::vector<GLushort> elements;
|
||||
std::vector<glm::vec2> uv;
|
||||
};
|
@ -4,15 +4,23 @@
|
||||
#include <iostream>
|
||||
#include <fstream>
|
||||
#include <spdlog/spdlog.h>
|
||||
#include <glm/glm.hpp>
|
||||
#include <glm/gtc/type_ptr.hpp>
|
||||
|
||||
|
||||
class Shader {
|
||||
private:
|
||||
int id;
|
||||
const size_t CHUNK_SIZE = 10;
|
||||
char* readFile (const char* filePath);
|
||||
public:
|
||||
Shader(const std::string vertexShaderPath, const std::string fragmentShaderPath);
|
||||
void Use();
|
||||
void setUniformMat4(std::string uniformName, glm::mat4 matrix4);
|
||||
void setUniformVec4(std::string uniformName, glm::vec4 vector4);
|
||||
void setUniformVec3(std::string uniformName, glm::vec3 vector3);
|
||||
void setUniformVec2(std::string uniformName, glm::vec2 vector2);
|
||||
void setUniformFloat(std::string uniformName, float value);
|
||||
void setUniformInt(std::string uniformName, int value);
|
||||
|
||||
|
||||
};
|
Reference in New Issue
Block a user