Add warning if normal or tangents are missing
This commit is contained in:
@@ -18,7 +18,7 @@ void Camera::updateVPM()
|
||||
|
||||
void Camera::updateAspectRatio(float aspectRatio)
|
||||
{
|
||||
m_projectionMatrix = glm::perspective(m_fov / 2.F, aspectRatio, .1F, 1000.F);
|
||||
m_projectionMatrix = glm::perspective(m_fov / 2.F, aspectRatio, .01F, 1000.F);
|
||||
updateVPM();
|
||||
}
|
||||
|
||||
|
||||
@@ -26,11 +26,11 @@ Controller::Controller()
|
||||
|
||||
std::string err;
|
||||
std::string warn;
|
||||
bool ret = loader.LoadASCIIFromFile(&m_model, &err, &warn, "WaterBottle/glTF/WaterBottle.gltf");
|
||||
// bool ret = loader.LoadASCIIFromFile(&m_model, &err, &warn, "WaterBottle/glTF/WaterBottle.gltf");
|
||||
// bool ret = loader.LoadASCIIFromFile(&m_model, &err, &warn, "Duck/glTF/Duck.gltf");
|
||||
// bool ret = loader.LoadASCIIFromFile(&m_model, &err, &warn, "Lantern/glTF/Lantern.gltf");
|
||||
// bool ret = loader.LoadBinaryFromFile(&m_model, &err, &warn, "Camera.glb");
|
||||
// bool ret = loader.LoadBinaryFromFile(&m_model, &err, &warn, "ABeautifulGame/ABeautifulGame.glb");
|
||||
bool ret = loader.LoadBinaryFromFile(&m_model, &err, &warn, "ABeautifulGame/ABeautifulGame.glb");
|
||||
|
||||
if (!warn.empty()) {
|
||||
Log::logger().warn("{}", warn);
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
#include "VertexArray.h"
|
||||
#include "definitions/models.h"
|
||||
#include "util/Log.h"
|
||||
|
||||
#include <cstddef>
|
||||
#include <vector>
|
||||
@@ -11,12 +12,18 @@ VertexArray::VertexArray(tinygltf::Primitive const &primitive, tinygltf::Model c
|
||||
glGenVertexArrays(1, &vao);
|
||||
glBindVertexArray(vao);
|
||||
|
||||
if (!primitive.attributes.contains("TANGENT") || !primitive.attributes.contains("NORMAL")) {
|
||||
Log::logger().critical("glTF scene has to include tangent and normal components!");
|
||||
exit(-1);
|
||||
}
|
||||
|
||||
int position_accessor_id = primitive.attributes.at("POSITION");
|
||||
int normal_accessor_id = primitive.attributes.at("NORMAL");
|
||||
int uv_accessor_id = primitive.attributes.at("TEXCOORD_0");
|
||||
int tangent_accessor_id = primitive.attributes.at("TANGENT");
|
||||
int indices_accessor_id = primitive.indices;
|
||||
|
||||
|
||||
auto const &position_accessor = model.accessors.at(position_accessor_id);
|
||||
auto const &normal_accessor = model.accessors.at(normal_accessor_id);
|
||||
auto const &uv_accessor = model.accessors.at(uv_accessor_id);
|
||||
@@ -126,8 +133,8 @@ VertexArray::VertexArray(tinygltf::Primitive const &primitive, tinygltf::Model c
|
||||
{
|
||||
glGenBuffers(1, &tangentVbo);
|
||||
glBindBuffer(GL_ARRAY_BUFFER, tangentVbo);
|
||||
glBufferData(GL_ARRAY_BUFFER, tangent_buffer_view.byteLength, tangent_buffer.data.data() + tangent_buffer_view.byteOffset,
|
||||
GL_STATIC_DRAW);
|
||||
glBufferData(GL_ARRAY_BUFFER, tangent_buffer_view.byteLength,
|
||||
tangent_buffer.data.data() + tangent_buffer_view.byteOffset, GL_STATIC_DRAW);
|
||||
|
||||
int size = 1;
|
||||
if (tangent_accessor.type == TINYGLTF_TYPE_SCALAR) {
|
||||
|
||||
Reference in New Issue
Block a user