Skip to main content

History: -Entity

Source of version: 5

Copy to clipboard
            {INCLUDE(page="ogrelex ext tpl")/}
---
__Entity__ - An entity is an instance of a ((-MovableObject|MovableObject)) in the ((-scene|scene)). It could be a car, a person, a dog, a shuriken, whatever. The only assumption is that it does not necessarily have a fixed position in the world.

Entities are based on discrete meshes, i.e. collections of geometry which are self-contained and typically fairly small on a world scale, which are represented by the ((-Mesh|Mesh)) object. Multiple entities can be based on the same mesh, since often you want to create multiple copies of the same type of object in a scene.

You create an entity by calling the ''((-SceneManager))::createEntity()'' method, giving it a name and specifying the name of the mesh object which it will be based on (e.g. 'muscleboundhero.mesh'). The -SceneManager will ensure that the mesh is loaded by calling the ((MeshManager)) resource manager for you. Only one copy of the -Mesh will be loaded.

Entities are not deemed to be a part of the scene until you attach them to a ((-SceneNode|SceneNode)) (see the section below). By attaching entities to SceneNodes, you can create complex hierarchical relationships between the positions and orientations of entities. You then modify the positions of the nodes to indirectly affect the entity positions.

When a ((-Mesh|Mesh)) is loaded, it automatically comes with a number of materials defined. It is possible to have more than one material attached to a mesh - different parts of the mesh may use different materials. Any entity created from the mesh will automatically use the default materials. However, you can change this on a per-entity basis if you like so you can create a number of entities based on the same mesh but with different ((-Texture|texture))s etc.

To understand how this works, you have to know that all Mesh objects are actually composed of ((-Submesh Names|SubMesh)) objects, each of which represents a part of the mesh using one ((-Material|Material)). If a Mesh uses only one Material, it will only have one SubMesh.

When an Entity is created based on this Mesh, it is composed of (possibly) multiple SubEntity objects, each matching 1 for 1 with the ((-Submesh Names|SubMesh)) objects from the original Mesh. You can access the SubEntity objects using the ''Entity::getSubEntity()'' method. Once you have a reference to a SubEntity, you can change the material it uses by calling it's ''setMaterialName()'' method. In this way you can make an Entity deviate from the default materials and thus create an individual looking version of it.

%%%
__Short description__ by user ((user:madmarx|MadMarx)):

An Entity is an instance of a ((-Mesh|mesh)), and allow different ((-Material|material)) information for each entity.
Entities are often the most common object in a Ogre application.
Different Entities can have different materials, while sharing the same mesh.
It is possible to create Entities with different meshes too.
In order to move an Entity, attach it to a ((-SceneNode|SceneNode)), and move this SceneNode. 


!!See also

* [http://www.ogre3d.org/docs/api/html/classOgre_1_1Entity.html|Ogre::Entity Class Reference]
* ((-Mesh|Mesh))
* ((ManualObject)) - useful class for creation of 3D objects by code
* ((-Material|Material))

---
{INCLUDE(page="ogrelex ext tpl")/}
---

        

History

Information Version
Fri 16 of Aug, 2013 11:24 GMT-0000 spacegaier 7
Wed 26 of Oct, 2011 12:54 GMT-0000 Beauty move short description to top 6
Sun 06 of Mar, 2011 17:14 GMT-0000 Beauty added short description by MadMarx 5
Sat 05 of Mar, 2011 17:56 GMT-0000 Beauty several corrections + added links 4
Thu 07 of Jan, 2010 23:53 GMT-0000 jacmoe 3
Tue 29 of Dec, 2009 09:30 GMT-0000 jacmoe 2
Sat 28 of Nov, 2009 17:29 GMT-0000 Spacegaier 1