/*********************************************************************************************************************** * * Copyright (c) 2010 - 2025 by Tech Soft 3D, Inc. * The information contained herein is confidential and proprietary to Tech Soft 3D, Inc., and considered a trade secret * as defined under civil and criminal statutes. Tech Soft 3D shall pursue its civil and criminal remedies in the event * of unauthorized use or misappropriation of its trade secrets. Use of this information by anyone other than authorized * employees of Tech Soft 3D, Inc. is granted only under a written non-disclosure agreement, expressly prescribing the * scope and manner of such use. * ***********************************************************************************************************************/ #include "mesh.h" #include #include Mesh::Mesh(const utils::geometry::BufferData& data, const glm::mat4& plnt, const utils::properties::style::Graphics& style_) { placement = plnt; style = style_; indice_count = static_cast(data.indices.size() ); box = data.mesh_box.transform(plnt); vao.Bind(); VBO vbo(data.vertices); EBO ebo(data.indices); vao.LinkAttrib(vbo, 0, 3, GL_FLOAT, sizeof(utils::geometry::Vertex), (GLvoid*) 0); vao.LinkAttrib(vbo, 1, 3, GL_FLOAT, sizeof(utils::geometry::Vertex), (GLvoid*) ( 3 * sizeof(float) )); vao.Unbind(); vbo.Unbind(); ebo.Unbind(); } void Mesh::draw() { if (indice_count == 0) return; vao.Bind(); // Draw the actual mesh glDrawElements(GL_TRIANGLES, indice_count, GL_UNSIGNED_INT, 0); vao.Unbind(); } void Mesh::sort_by_style(std::vector& models) { auto by_style = [] (const Mesh& m1, const Mesh& m2) { return m1.style.id < m2.style.id; }; std::sort(models.begin(), models.end(), by_style); }