Spinning Topp Logo BlackTopp Studios
inc
submesh.h
1 // © Copyright 2010 - 2016 BlackTopp Studios Inc.
2 /* This file is part of The Mezzanine Engine.
3 
4  The Mezzanine Engine is free software: you can redistribute it and/or modify
5  it under the terms of the GNU General Public License as published by
6  the Free Software Foundation, either version 3 of the License, or
7  (at your option) any later version.
8 
9  The Mezzanine Engine is distributed in the hope that it will be useful,
10  but WITHOUT ANY WARRANTY; without even the implied warranty of
11  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  GNU General Public License for more details.
13 
14  You should have received a copy of the GNU General Public License
15  along with The Mezzanine Engine. If not, see <http://www.gnu.org/licenses/>.
16 */
17 /* The original authors have included a copy of the license specified above in the
18  'Docs' folder. See 'gpl.txt'
19 */
20 /* We welcome the use of the Mezzanine engine to anyone, including companies who wish to
21  Build professional software and charge for their product.
22 
23  However there are some practical restrictions, so if your project involves
24  any of the following you should contact us and we will try to work something
25  out:
26  - DRM or Copy Protection of any kind(except Copyrights)
27  - Software Patents You Do Not Wish to Freely License
28  - Any Kind of Linking to Non-GPL licensed Works
29  - Are Currently In Violation of Another Copyright Holder's GPL License
30  - If You want to change our code and not add a few hundred MB of stuff to
31  your distribution
32 
33  These and other limitations could cause serious legal problems if you ignore
34  them, so it is best to simply contact us or the Free Software Foundation, if
35  you have any questions.
36 
37  Joseph Toppi - toppij@gmail.com
38  John Blackwood - makoenergy02@gmail.com
39 */
40 
41 #ifndef _graphicssubmesh_h
42 #define _graphicssubmesh_h
43 
44 #include "Graphics/meshinfo.h"
45 
46 namespace Ogre
47 {
48  class SubMesh;
49 }//Ogre
50 
51 namespace Mezzanine
52 {
53  namespace Graphics
54  {
55  ///////////////////////////////////////////////////////////////////////////////
56  /// @brief This class represents a sub-section of an overall mesh.
57  /// @details Every mesh has at least one SubMesh. Most meshes have only 1 or 2. SubMeshes are often
58  /// implemented in cases where one portion of the mesh needs to be animated or given a different
59  /// material then another portion.
60  ///////////////////////////////////////
62  {
63  protected:
64  /// @internal
65  /// @brief A pointer to the internal SubMesh this is based on.
66  Ogre::SubMesh* InternalSubMesh;
67  public:
68  /// @internal
69  /// @brief Internal Constructor.
70  /// @param Internal The internal SubMesh this SubMesh class is based on.
71  SubMesh(Ogre::SubMesh* Internal);
72  /// @brief Class Destructor.
73  ~SubMesh();
74 
75  ///////////////////////////////////////////////////////////////////////////////
76  // Utility Methods
77 
78  /// @brief Sets the name of the Material to be used by this SubMesh.
79  /// @param MatName The name of the Material to be applied to this SubMesh.
80  void SetMaterialName(const String& MatName);
81  /// @brief Gets the name of the Material being used by this SubMesh.
82  /// @return Returns a const reference to a String containing the name of the Material to be used with this SubMesh.
83  const String& GetMaterialName() const;
84 
85  /// @brief Gets whether or not this SubMesh shares a Vertex Buffer with other SubMeshes.
86  /// @remarks A Mesh can only have a single shared buffer across all SubMeshes. So if any SubMesh does use a shared buffer,
87  /// all of the SubMeshes that do share one, share the same buffer.
88  /// @return Returns true if this SubMesh uses a shared Vertex Buffer with other SubMeshes.
89  Boole UsesSharedVertices() const;
90  /// @brief Gets the number of Vertices in this SubMesh.
91  /// @return Returns the number of Vertices that make up this SubMesh.
92  Whole GetVertexCount() const;
93  /// @brief Gets the number of Indices in this SubMesh.
94  /// @return Returns the number of Indices used to assemble the vertices in this SubMesh.
95  Whole GetIndexCount() const;
96 
97  ///////////////////////////////////////////////////////////////////////////////
98  // SubMesh Information Methods
99 
100  /// @brief Gets the information used to render this SubMesh.
101  /// @remarks This method makes no attempt to clear any pre-existing data on the MeshInfo struct before use. Relevant data will be overwritten.
102  /// @param ToFill The MeshInfo struct to be populated with data from this SubMesh.
103  void GetInfo(MeshInfo& ToFill) const;
104  /// @brief Gets the vertex information of this SubMesh and appends it to the VertexInfo provided.
105  /// @param ToFill The VertexInfo struct to have this SubMesh vertex information added to.
106  void AppendVertexInfo(VertexInfo& ToFill) const;
107 
108  /// @brief Gets the vertex position information of this SubMesh and appends it to the container provided.
109  /// @param ToFill The container to append this SubMeshes vertex position info to.
110  void AppendVertexPositionInfo(Vector3Vec& ToFill) const;
111  /// @brief Gets the vertex texture coordinate information of this SubMesh and appends it to the container provided.
112  /// @param ToFill The container to append this SubMeshes vertex texture coordinate info to.
113  void AppendVertexTexCoordInfo(Vector2Vec& ToFill) const;
114  /// @brief Gets the vertex normal information of this SubMesh and appends it to the container provided.
115  /// @param ToFill The container to append this SubMeshes vertex normal info to.
116  void AppendVertexNormalInfo(Vector3Vec& ToFill) const;
117  /// @brief Gets the vertex tangent information of this SubMesh and appends it to the container provided.
118  /// @param ToFill The container to append this SubMeshes vertex tangent info to.
119  void AppendVertexTangentInfo(Vector3Vec& ToFill) const;
120  /// @brief Gets the Index information of this SubMesh and appends it to the container provided.
121  /// @param ToFill The container to append this SubMeshes Index info to.
122  void AppendIndexInfo(IntVec& ToFill) const;
123 
124  ///////////////////////////////////////////////////////////////////////////////
125  // Internal Methods
126 
127  /// @internal
128  /// @brief Gets the internal SubMesh pointer.
129  /// @return Returns a pointer pointing to the internal SubMesh.
130  Ogre::SubMesh* _GetInternalSubMesh() const;
131  };//SubMesh
132  }//Graphics
133 }//Mezzanine
134 
135 #endif
bool Boole
Generally acts a single bit, true or false.
Definition: datatypes.h:173
A convenience class for the storage of Vertex data in a Mesh/SubMesh.
Definition: meshinfo.h:62
Ogre::SubMesh * InternalSubMesh
A pointer to the internal SubMesh this is based on.
Definition: submesh.h:66
This class represents a sub-section of an overall mesh.
Definition: submesh.h:61
std::vector< Vector2 > Vector2Vec
Convenience type for a container of Vector2s.
Definition: meshinfo.h:54
A convenience class for the storage of rendering data in a Mesh/SubMesh.
Definition: meshinfo.h:97
std::vector< Integer > IntVec
Convenience type for a container of Integers.
Definition: meshinfo.h:56
#define MEZZ_LIB
Some platforms require special decorations to denote what is exported/imported in a share library...
The bulk of the engine components go in this namspace.
Definition: actor.cpp:56
std::vector< Vector3 > Vector3Vec
Convenience type for a container of Vector3s.
Definition: meshinfo.h:52
unsigned long Whole
Whole is an unsigned integer, it will be at least 32bits in size.
Definition: datatypes.h:151
std::string String
A datatype used to a series of characters.
Definition: datatypes.h:159