BlankMat 0.1.0
Free open-source 3D texture creation application
Loading...
Searching...
No Matches
MeshContainer Class Reference
Inheritance diagram for MeshContainer:
Collaboration diagram for MeshContainer:

Public Member Functions

void LoadMaterials (MaterialContainer *materials)
 Loads the materials of meshes in this container.
 
void Draw (Shader *shader, State *state, Material *defaultMat, const glm::mat4 &viewProj, bool drawMats=false)
 Draws the contents of the container.
 
- Public Member Functions inherited from IContainer< Mesh >
void Read (const std::string &scope, std::ifstream &file, bool clear) override
 Reads this container from the file.
 
void Write (std::ofstream &file) override
 Writes this container to the file.
 
void Clear () override
 Clears the container of all items, deleting them.
 
void ClearData ()
 Clears the data of the container without deleting it. Only use this if pointers to the data exist elsewhere.
 
unsigned int WriteCount () override
 Returns the number of items that will be written from the container.
 
unsigned int Count ()
 Returns the number of elements in the container.
 
bool Empty ()
 Returns whether the container is empty or not.
 
virtual std::string GetUniqueName (const std::string &name)
 Returns a unique name, incrementing the existing name until it is unique.
 
virtual bool Select (const std::string &name)
 Selects the given item. Does nothing if the item is not part of the container.
 
virtual bool Select (Mesh *item)
 Selects the given item. Does nothing if the item is not part of the container.
 
virtual bool IsDeleteable (Mesh *item)
 Returns whether the given item is deletable (ie. not a default element or internal)
 
virtual void Deselect ()
 Deselects the currently selected item.
 
virtual const std::string GetSelectedName ()
 Returns the currently selected item.
 
virtual MeshGetSelectedItem ()
 Returns the currently selected item.
 
virtual MeshAdd (const std::string &name, Mesh *item, bool replace, bool select=false)
 Adds the given item to the container, or if it already exists, updates the item to the given one.
 
virtual bool TryDelete (Mesh *item)
 Attempts to delete the given item. Does nothing if the item is not deleteable or is null.
 
virtual bool Remove (const std::string &name)
 Removes the given item from the container.
 
virtual bool Remove (Mesh *item)
 Removes the given item from the container.
 
virtual MeshGetItem (const std::string &name)
 Returns the item with the given key, or nullptr if not found.
 
virtual const std::string GetKey (Mesh *item)
 Returns the key of the item given, or an empty string if not found.
 
virtual bool Contains (const std::string &name)
 Returns whether the container contains an item with the given name.
 
virtual bool Rename (const std::string &name, const std::string &newName)
 Renames the given item to the new name, or the new name with appended numbers.
 
virtual const std::unordered_map< std::string, Mesh * > & Data ()
 Returns a reference to the data stored in the container.
 
 ~IContainer ()
 Clears all of the container, deleting its elements.
 

Protected Member Functions

void RenameItem (Mesh *item, const std::string &name) override
 Renames the given item to the given name.
 
const std::pair< std::string, Mesh * > ReadItem (const std::string &scope, std::ifstream &file) override
 Reads the next item from the input file stream.
 
void WriteItem (const std::string &key, Mesh *item, std::ofstream &file) override
 Writes the given item into the output file stream.
 
- Protected Member Functions inherited from IContainer< Mesh >
virtual bool SkipItem (Mesh *item)
 Returns whether the item should be skipped or not.
 

Static Protected Member Functions

static void ReadVertices (std::vector< Vertex > &outVerts, std::ifstream &file)
 Reads the vertices for the current mesh in the input file.
 
static void ReadIndices (std::vector< unsigned int > &outInds, std::ifstream &file)
 Reads the indices for the current mesh in the input file.
 

Additional Inherited Members

- Protected Attributes inherited from IContainer< Mesh >
std::unordered_map< std::string, Mesh * > mData
 Data of the container.
 
std::string mCurSelectedName
 Currently selected item's name.
 
MeshmCurSelectedItem
 Currently selected item.
 

Member Function Documentation

◆ Draw()

void MeshContainer::Draw ( Shader shader,
State state,
Material defaultMat,
const glm::mat4 &  viewProj,
bool  drawMats = false 
)
inline

Draws the contents of the container.

Parameters
shaderShader to draw with
stateGlobal state
defaultMatDefault material
viewProjView Projection matrix
drawMatsWhether to draw materials

◆ LoadMaterials()

void MeshContainer::LoadMaterials ( MaterialContainer materials)
inline

Loads the materials of meshes in this container.

Parameters
materialsMaterial list of the scene

◆ ReadIndices()

static void MeshContainer::ReadIndices ( std::vector< unsigned int > &  outInds,
std::ifstream &  file 
)
inlinestaticprotected

Reads the indices for the current mesh in the input file.

Parameters
outIndsIndices list to add to
fileFile to read from

◆ ReadItem()

const std::pair< std::string, Mesh * > MeshContainer::ReadItem ( const std::string &  scope,
std::ifstream &  file 
)
inlineoverrideprotectedvirtual

Reads the next item from the input file stream.

Parameters
scopeScope to read item in
fileFile to read
Returns
Newly constructed item from file

Implements IContainer< Mesh >.

◆ ReadVertices()

static void MeshContainer::ReadVertices ( std::vector< Vertex > &  outVerts,
std::ifstream &  file 
)
inlinestaticprotected

Reads the vertices for the current mesh in the input file.

Parameters
outVertsIndices list to add to
fileFile to read from

◆ RenameItem()

void MeshContainer::RenameItem ( Mesh item,
const std::string &  name 
)
inlineoverrideprotectedvirtual

Renames the given item to the given name.

Parameters
itemItem to rename

Implements IContainer< Mesh >.

◆ WriteItem()

void MeshContainer::WriteItem ( const std::string &  key,
Mesh item,
std::ofstream &  file 
)
inlineoverrideprotectedvirtual

Writes the given item into the output file stream.

Parameters
keyKey of item
itemItem to write
fileFile to write to

Implements IContainer< Mesh >.