Commit 8f73e75b authored by Philip Trettner's avatar Philip Trettner

added object labels to importer and generated geometry

parent 09f52dfd
......@@ -4,15 +4,15 @@
#include <glm/glm.hpp>
#include <glow/objects/VertexArray.hh>
#include <glow/objects/ArrayBuffer.hh>
#include <glow/objects/ElementArrayBuffer.hh>
#include <glow/objects/VertexArray.hh>
#include <glow/common/profiling.hh>
#include <assimp/Importer.hpp>
#include <assimp/scene.h>
#include <assimp/postprocess.h>
#include <assimp/scene.h>
#include <assimp/Importer.hpp>
static glm::vec3 aiCast(aiVector3D const& v)
{
......@@ -23,9 +23,7 @@ static glm::vec4 aiCast(aiColor4D const& v)
return {v.r, v.g, v.b, v.a};
}
glow::assimp::Importer::Importer()
{
}
glow::assimp::Importer::Importer() {}
glow::SharedVertexArray glow::assimp::Importer::load(const std::string& filename)
{
......@@ -184,6 +182,12 @@ glow::SharedVertexArray glow::assimp::Importer::load(const std::string& filename
abs.push_back(ab);
}
for (auto const& ab : abs)
ab->setObjectLabel(ab->getAttributes()[0].name + " of " + filename);
auto eab = ElementArrayBuffer::create(indices);
return VertexArray::create(abs, eab, GL_TRIANGLES);
eab->setObjectLabel(filename);
auto va = VertexArray::create(abs, eab, GL_TRIANGLES);
va->setObjectLabel(filename);
return va;
}
#pragma once
#include <glm/common.hpp>
#include <glm/geometric.hpp>
#include <glm/vec2.hpp>
#include <glm/vec3.hpp>
#include <glm/geometric.hpp>
#include <glm/common.hpp>
#include <glow/common/shared.hh>
#include <glow/objects/VertexArray.hh>
#include <glow/objects/ArrayBuffer.hh>
#include <glow/objects/ElementArrayBuffer.hh>
#include <glow/objects/VertexArray.hh>
namespace glow
{
......@@ -50,6 +50,7 @@ public:
public: // default vertex creator
static VertexT createVertex(glm::vec3 position, glm::vec3 color) { return {position, color}; }
public:
CoordFrame(std::vector<ArrayBufferAttribute> const& attrs = attributesOf((VertexT*)0)) : attributes(attrs) {}
/**
......@@ -59,6 +60,7 @@ public:
SharedVertexArray generate(VertexCreator&& gen = createVertex) const
{
auto ab = ArrayBuffer::create();
ab->setObjectLabel("CoordFrame");
ab->defineAttributes(attributes);
VertexT vertices[2 * 3] = {
......@@ -73,7 +75,9 @@ public:
};
ab->bind().setData(vertices);
return VertexArray::create(ab, nullptr, GL_LINES);
auto va = VertexArray::create(ab, nullptr, GL_LINES);
va->setObjectLabel("CoordFrame");
return va;
}
public: // Predefined attributes
......
......@@ -83,7 +83,9 @@ public:
SharedVertexArray generate(VertexCreator&& gen = createVertex) const
{
auto ab = ArrayBuffer::create();
ab->setObjectLabel("Cube");
auto eab = ElementArrayBuffer::create();
eab->setObjectLabel("Cube");
ab->defineAttributes(attributes);
auto vi = 0u;
......@@ -123,7 +125,9 @@ public:
ab->bind().setData(vertices);
eab->bind().setIndices(indices);
return VertexArray::create(ab, eab, GL_TRIANGLES);
auto va = VertexArray::create(ab, eab, GL_TRIANGLES);
va->setObjectLabel("Cube");
return va;
}
public: // Predefined attributes
......
......@@ -69,13 +69,16 @@ public:
SharedVertexArray generate(VertexCreator&& gen = createVertex) const
{
auto ab = ArrayBuffer::create();
ab->setObjectLabel("Line");
ab->defineAttributes(attributes);
VertexT data[] = {
gen(startPos), //
gen(endPos), //
};
ab->bind().setData(data);
return VertexArray::create(ab, nullptr, GL_LINES);
auto va = VertexArray::create(ab, nullptr, GL_LINES);
ab->setObjectLabel("Line");
return va;
}
public: // Predefined attributes
......
......@@ -69,6 +69,7 @@ public:
SharedVertexArray generate(VertexCreator&& gen = createVertex) const
{
auto ab = ArrayBuffer::create();
ab->setObjectLabel("Quad");
ab->defineAttributes(attributes);
VertexT data[] = {
gen(minCoord.x, minCoord.y), //
......@@ -77,7 +78,9 @@ public:
gen(maxCoord.x, maxCoord.y),
};
ab->bind().setData(data);
return VertexArray::create(ab, nullptr, GL_TRIANGLE_STRIP);
auto va = VertexArray::create(ab, nullptr, GL_TRIANGLE_STRIP);
va->setObjectLabel("Quad");
return va;
}
public: // Predefined attributes
......
#pragma once
#include <glm/vec2.hpp>
#include <glm/glm.hpp>
#include <glm/vec3.hpp>
#include <glm/geometric.hpp>
#include <glm/common.hpp>
......@@ -93,7 +93,9 @@ public:
SharedVertexArray generate(VertexCreator&& gen = createVertex) const
{
auto ab = ArrayBuffer::create();
ab->setObjectLabel("UVSphere");
auto eab = ElementArrayBuffer::create();
eab->setObjectLabel("UVSphere");
ab->defineAttributes(attributes);
......@@ -115,7 +117,7 @@ public:
glm::vec3 position = {std::cos(phi) * std::sin(theta) * radius, std::cos(theta) * radius, std::sin(phi) * std::sin(theta) * radius};
glm::vec3 normal = glm::normalize(position);
glm::vec3 tangent = {sin(phi), 0, cos(phi)};
glm::vec3 tangent = {glm::sin(phi), 0, glm::cos(phi)};
glm::vec2 texcoord = {static_cast<float>(s) / segments, static_cast<float>(r) / rings};
vertices[vi++] = gen(position, normal, tangent, texcoord);
}
......@@ -139,7 +141,9 @@ public:
ab->bind().setData(vertices);
eab->bind().setIndices(indices);
return VertexArray::create(ab, eab, GL_TRIANGLES);
auto va = VertexArray::create(ab, eab, GL_TRIANGLES);
va->setObjectLabel("UVSphere");
return va;
}
public: // Predefined attributes
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment