libcootapi
 
Loading...
Searching...
No Matches
simple-mesh.hh
1/*
2 * coot-utils/simple-mesh.hh
3 *
4 * Copyright 2022 by Medical Research Council
5 * Author: Paul Emsley
6 *
7 * This file is part of Coot
8 *
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU Lesser General Public License as published
11 * by the Free Software Foundation; either version 3 of the License, or (at
12 * your option) any later version.
13 *
14 * This program is distributed in the hope that it will be useful, but
15 * WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 * Lesser General Public License for more details.
18 *
19 * You should have received a copies of the GNU General Public License and
20 * the GNU Lesser General Public License along with this program; if not,
21 * write to the Free Software Foundation, Inc., 51 Franklin Street,
22 * Fifth Floor, Boston, MA, 02110-1301, USA.
23 * See http://www.gnu.org/licenses/
24 *
25 */
26#ifndef SIMPLE_MESH_HH
27#define SIMPLE_MESH_HH
28
29#include <vector>
30#include <map>
31#include "vertex.hh"
32#include "g_triangle.hh"
33#include "cylinder.hh"
34
35namespace coot {
36
39 public:
41 int status;
43 std::vector<api::vnc_vertex> vertices;
45 std::vector<g_triangle> triangles;
47 std::string name;
51 explicit simple_mesh_t(const std::string &name_in) : status(1), name(name_in) {}
52 simple_mesh_t(const std::vector<api::vnc_vertex> &vertices_in,
53 const std::vector<g_triangle> &triangles_in) : status(1), vertices(vertices_in), triangles(triangles_in) {}
54 explicit simple_mesh_t(const cylinder &cyl) : vertices(cyl.vertices), triangles(cyl.triangles) {
55 status = 1;
56 }
57 void translate(const glm::vec3 &t);
58 // 20221101-PE blender uses colours/materials for faces. So let's store those too.
59 // Now each face (each g_triangle) can have a colour_index (default is -1 (unset)).
60 // Maybe a std::vector would be a better/faster container.
61 std::map<int, glm::vec4> colour_index_to_colour_map;
62
64 void add_submesh(const simple_mesh_t &submesh);
65
70
72 void export_to_gltf(const std::string &file_name,
73 float roughness_factor, float smoothness_factor,
74 bool use_binary_format) const;
75
76 void set_name(const std::string &n) { name = n; }
77
78 static simple_mesh_t make_sphere();
79 void scale(float scale_factor);
80 void change_colour(const glm::vec4 &c);
81 void clear();
82 // for debugging - the string for the number of vertices and triangles
83 std::string vandt() const;
84
85 };
86}
87
88#endif // SIMPLE_MESH_HH
The basic mesh for transfering mesh geometry and colours.
Definition simple-mesh.hh:38
std::vector< api::vnc_vertex > vertices
vertices
Definition simple-mesh.hh:43
std::string name
mesh name
Definition simple-mesh.hh:47
simple_mesh_t()
constructor (for vectors)
Definition simple-mesh.hh:49
simple_mesh_t(const std::string &name_in)
constructor with name
Definition simple-mesh.hh:51
void export_to_gltf(const std::string &file_name, float roughness_factor, float smoothness_factor, bool use_binary_format) const
export to glTF
int status
check this status before using a simple_mesh_t. 1 is good, 0 is bad (0 is set when when we get a bad_...
Definition simple-mesh.hh:41
std::vector< g_triangle > triangles
vertex index triples
Definition simple-mesh.hh:45
void add_submesh(const simple_mesh_t &submesh)
utilty function