AGL  0
3D graphics library
SharedEntity Class Reference

A SharedEntity shares its data off another Entity. More...

Inheritance diagram for SharedEntity:
Collaboration diagram for SharedEntity:

Public Member Functions

 SharedEntity (Entity &src)
 Create a SharedEntity from src. More...
 
virtual void mergeData ()
 Does nothing. Everything is done by source's Entity::mergeData. More...
 
virtual void createBuffers ()
 Does nothing. Copies the buffers created by source's Entity::createBuffers. More...
 
- Public Member Functions inherited from Entity
 Entity (const glm::vec3 &pos=glm::vec3(0))
 Create an entity centered at pos. More...
 
 Entity (const Entity &other)
 Create an entity from data copied from other. More...
 
 ~Entity ()
 
void translate (const glm::vec3 &d=glm::vec3(0))
 Translate (move,shift) the entity. More...
 
void translate (float dx=0, float dy=0, float dz=0)
 Translate (move, shift) the entity. More...
 
void rotate (float rad=0, glm::vec3 axis=glm::vec3(0))
 Rotate the entity. More...
 
void scale (const glm::vec3 &s=glm::vec3(1))
 Scale the entity. More...
 
void scale (float sx=1, float sy=std::nanf(""), float sz=std::nanf(""))
 Scale the entity. More...
 
void transform (const glm::mat4 &m)
 Transform the entity. More...
 
void applyTransform ()
 Transform the vertices permanently. More...
 
void add (BaseEntity &e)
 Add an Entity or Light as a child of the entity. More...
 
glm::mat4 getMatM ()
 Get the model matrix. More...
 
- Public Member Functions inherited from BaseEntity
virtual ~BaseEntity ()
 

Public Attributes

Entitysource = nullptr
 The source Entity whose data and buffers are used. More...
 
- Public Attributes inherited from Entity
GLuint VAO = 0
 Vertex array. More...
 
GLuint VBO = 0
 Vertex buffer. More...
 
GLuint EBO = 0
 Index buffer. More...
 
bool dynamic = false
 If true, the material is dynamic, ie. vertices might change during runtime. More...
 
std::vector< GLfloat > vertices
 Vertices. More...
 
std::vector< GLfloat > normals
 Normals. More...
 
std::vector< GLfloat > uvs
 Texture coordinates. More...
 
std::vector< GLfloat > merged
 The final combination of vertices, normals, and uvs. More...
 
std::vector< GLuint > indices
 Indices. More...
 
glm::vec3 position
 Position of the entity, the entity is centered here. More...
 
glm::mat4 model
 The model matrix for the entity. This is the M part of the MVP matrix. This is responsible for all the transformations of this entity. More...
 
Material material
 Material for shading this entity. More...
 
std::vector< BaseEntity * > children
 Children of this entity. More...
 
- Public Attributes inherited from BaseEntity
Entityparent = nullptr
 Parent of the entity, whose child this is. All transformations of the parent is also applied to the child. More...
 

Detailed Description

A SharedEntity shares its data off another Entity.

Since all entities need their separate data, they also create their separate buffers. Say, you've two cubes, they'll have the same vertex data, but will be loaded twice. SharedEntity intends to optimize this by using the buffers from another Entity whose data has already been loaded. The source entity's buffers must have been created before they can be used.

Warning
This class is unstable and might be removed in future.

Constructor & Destructor Documentation

◆ SharedEntity()

SharedEntity ( Entity src)

Create a SharedEntity from src.

Parameters
srcThe Entity to share from.

Member Function Documentation

◆ createBuffers()

void createBuffers ( )
virtual

Does nothing. Copies the buffers created by source's Entity::createBuffers.

For this to work, the source's buffer must have been create before this is called. This must either be done manually, or the Entity tree must be arranged in such a way that the DFS traversal in Scene::prepare gets to the source before itself.

Reimplemented from Entity.

◆ mergeData()

void mergeData ( )
virtual

Does nothing. Everything is done by source's Entity::mergeData.

Reimplemented from Entity.

Member Data Documentation

◆ source

Entity* source = nullptr

The source Entity whose data and buffers are used.


The documentation for this class was generated from the following files: