Skyscraper 2.0
dynamicmesh.h
Go to the documentation of this file.
1/*
2 Scalable Building Simulator - Dynamic Mesh
3 The Skyscraper Project - Version 2.0
4 Copyright (C)2004-2024 Ryan Thoryk
5 https://www.skyscrapersim.net
6 https://sourceforge.net/projects/skyscraper/
7 Contact - ryan@skyscrapersim.net
8
9 This program is free software; you can redistribute it and/or
10 modify it under the terms of the GNU General Public License
11 as published by the Free Software Foundation; either version 2
12 of the License, or (at your option) any later version.
13
14 This program is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 GNU General Public License for more details.
18
19 You should have received a copy of the GNU General Public License
20 along with this program; if not, write to the Free Software
21 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
22*/
23
24#ifndef _SBS_DYNAMICMESH_H
25#define _SBS_DYNAMICMESH_H
26
27namespace SBS {
28
30{
31public:
32
33 bool force_combine; //if set to true, forces combined meshes
34
35 DynamicMesh(Object *parent, SceneNode *node, const std::string &name, Real max_render_distance = 0, bool dynamic_buffers = false);
37 void Enabled(bool value, MeshObject *client = 0);
38 bool ChangeTexture(const std::string &old_texture, const std::string &new_texture, MeshObject *client = 0);
39 void EnableDebugView(bool value, MeshObject *client = 0);
40 bool IsVisible(MeshObject *client = 0);
41 bool IsVisible(Ogre::Camera *camera, MeshObject *client = 0);
42 bool IsVisible(Ogre::Camera *camera, int mesh_index);
43 void Prepare(MeshObject *client = 0);
44 bool LoadFromFile(const std::string &filename, const std::string &path);
45 bool LoadFromMesh(const std::string &meshname);
46 void AddClient(MeshObject *mesh);
47 void RemoveClient(MeshObject *mesh);
48 MeshObject* GetClient(int number);
49 int GetClientIndex(MeshObject *client);
50 int GetClientCount() { return (int)clients.size(); }
51 void NeedsUpdate(MeshObject *client = 0);
52 int GetMaterials(std::vector<std::string> &materials, int client = -1);
53 int GetMaterialCount(int client = -1);
54 unsigned int GetVertexCount(const std::string &material = "", int client = -1);
55 unsigned int GetTriangleCount(const std::string &material, int &client_count, int client = -1);
56 unsigned int GetIndexOffset(MeshObject *client);
57 bool UseDynamicBuffers() { return dynamic_buffers; }
58 void UpdateVertices(MeshObject *client, const std::string &material = "", Polygon *polygon = 0, bool single = false);
59 void DetachClient(MeshObject *client);
60 int GetMeshCount() { return (int)meshes.size(); }
61 int GetSubMeshCount(int mesh_index);
62 std::string GetMeshName(int mesh_index);
63 Ogre::AxisAlignedBox GetBounds(MeshObject *client = 0);
64 void EnableShadows(bool value);
65 void SetMaterial(const std::string& material);
66
67private:
68
69 //raw mesh wrapper
70 struct Mesh
71 {
72 struct Submesh;
73
74 Mesh(DynamicMesh *parent, const std::string &name, SceneNode *node, Real max_render_distance, const std::string &filename = "", const std::string &meshname = "", const std::string & path = "");
75 ~Mesh();
76 void Enabled(bool value);
77 bool ChangeTexture(const std::string &old_texture, const std::string &new_texture);
78 int FindMatchingSubMesh(const std::string &material);
79 Submesh* CreateSubMesh(const std::string &material);
80 void DeleteSubMesh(int client, int index);
81 void Prepare(bool process_vertices = true, int client = -1);
82 void EnableDebugView(bool value);
83 bool IsVisible();
84 bool IsVisible(Ogre::Camera *camera);
85 int GetSubMeshCount();
86 void UpdateVertices(int client, const std::string &material, Polygon *polygon = 0, bool single = false);
87 void Detach();
88 void UpdateBoundingBox();
89 void EnableShadows(bool value);
90 void SetMaterial(const std::string& material);
91
93 {
94 unsigned int vertex_offset;
95 unsigned int vertex_count;
96 Ogre::AxisAlignedBox* bounds;
98 };
99
100 struct Submesh
101 {
102 Ogre::SubMesh* object;
104 std::string material;
105 };
106
107 std::string name;
108 Ogre::MeshPtr MeshWrapper; //mesh
109 std::vector<Submesh> Submeshes; //submeshes (per-material mesh)
110 std::vector<ClientEntry> client_entries; //per-client information
111 Ogre::Entity *Movable;
119 };
120
121 std::vector<Mesh*> meshes;
125 std::vector<MeshObject*> clients;
126 std::vector<bool> client_enable;
130};
131
132}
133
134#endif
std::vector< Mesh * > meshes
SceneNode * node
std::vector< bool > client_enable
std::vector< MeshObject * > clients
bool UseDynamicBuffers()
Definition dynamicmesh.h:57
Ogre::Real Real
Definition globals.h:57
#define SBSIMPEXP
Definition globals.h:53
Ogre::AxisAlignedBox * bounds
Definition dynamicmesh.h:96
Ogre::MeshPtr MeshWrapper
std::vector< Submesh > Submeshes
Ogre::Entity * Movable
std::vector< ClientEntry > client_entries