Entity
- class nvisii.entity(*args, **kwargs)
An “Entity” is a component that is used to connect other component types together.
If you’d like to place an object in the scene, an Entity would be used to connect a Mesh component, a Transform component, and a Material component together.
Only one component of a given type can be connected to an entity at any given point in time.
Multiple entities can “share” the same component type. For example, a sphere mesh component can be referenced by many entities, with each entity having a unique material. This is essentially a form of “instancing”. Alternatively, many different entities can share the same Material component, such that any adjustments to that material component effect a collection of objects instead of just one.
- property thisown
The membership flag
- static create(name, transform=None, material=None, mesh=None, light=None, camera=None, volume=None)
Constructs an Entity with the given name.
- Parameters
transform (
Transform
, optional) – (optional) A transform component places the entity into the scene.material (
Material
, optional) – (optional) A material component describes how an entity should look when rendered.mesh (
Mesh
, optional) – (optional) A mesh component describes a surface to be rendered. Volume separating the inside and outside portion of the surface are implicitly represented using clockwise and counterclockwise triangles and corresponding surface normal. Note: Cannot be assigned if a “volume” component is also assigned.light (
Light
, optional) – (optional) A light component indicates that any connected geometry should act like a light source.camera (
Camera
, optional) – (optional) A camera component indicates that the current entity can be used to view into the scene.volume (
Volume
, optional) – (optional) A volume component describes the volumetric particles to be rendered. Surfaces within the volume are implicitly defined using extinction. Note: Cannot be assigned if a “mesh” component is also assigned.
- Return type
Entity
- Returns
a reference to an Entity
- static get(name)
- Parameters
name (string) – The name of the entity to get
- Return type
Entity
- Returns
an Entity who’s name matches the given name
- static get_count()
- Return type
int
- Returns
the number of allocated entities
- get_name()
- Return type
string
- Returns
the name of this component
- get_id()
- Return type
int
- Returns
the unique integer ID for this component
- static get_name_to_id_map()
- Return type
std::map< std::string,uint32_t,std::less< std::string >,std::allocator< std::pair< std::string const,uint32_t > > >
- Returns
A map whose key is an entity name and whose value is the ID for that entity
- static remove(name)
- Parameters
name (string) – The name of the Entity to remove
- static initialize_factory(max_components)
Allocates the tables used to store all Entity components
- is_initialized()
- Return type
boolean
- Returns
True the current entity is a valid, initialized entity, and False if the entity was cleared or removed.
- static clear_all()
Clears any existing entity components. This function can be used to reset a scene.
- to_string()
- Return type
string
- Returns
a string representation of the current component
- static are_any_dirty()
- Return type
boolean
- Returns
True if any the entities has been modified since the previous frame, and False otherwise
- static get_dirty_entities()
- Return type
std::set< nvisii::Entity * >
- Returns
a list of entities that have been modified since the previous frame
- static get_renderable_entities()
- Return type
std::set< nvisii::Entity * >
- Returns
a list of entities that are renderable (ie, can be seen) by the camera. (note, currently ignores visibility)
- set_transform(transform)
Connects a transform component to the current entity
- clear_transform()
Disconnects any transform component from the current entity
- get_transform()
- Return type
Transform
- Returns
a reference to the connected transform component, or None/nullptr if no component is connected.
- set_camera(camera)
Connects a camera component to the current entity
- clear_camera()
Disconnects any camera component from the current entity
- get_camera()
- Return type
Camera
- Returns
a reference to the connected camera component, or None/nullptr if no component is connected.
- set_material(material)
Connects a material component to the current entity
- clear_material()
Disconnects any material component from the current entity
- get_material()
- Return type
Material
- Returns
a reference to the connected material component, or None/nullptr if no component is connected.
- set_light(light)
Connects a light component to the current entity
- clear_light()
Disconnects any light component from the current entity
- get_light()
- Return type
Light
- Returns
a reference to the connected light component, or None/nullptr if no component is connected.
- set_mesh(mesh)
Connects a mesh component to the current entity. Note: a mesh component cannot be attached if a volume component is currently attached.
- clear_mesh()
Disconnects any mesh component from the current entity
- get_mesh()
- Return type
Mesh
- Returns
a reference to the connected mesh component, or None/nullptr if no component is connected.
- set_volume(volume)
Connects a volume component to the current entity. Note: a volume component cannot be attached if a mesh component is currently attached.
- clear_volume()
Disconnects any volume component from the current entity
- get_volume()
- Return type
Volume
- Returns
a reference to the connected volume component, or None/nullptr if no component is connected.
- set_visibility(camera=True, diffuse=True, glossy=True, transmission=True, volume_scatter=True, shadow=True)
Objects can be set to be invisible to particular ray types: :type camera: boolean, optional :param camera: Makes the object visible to camera rays (the first rays to be traced from the camera). :type diffuse: boolean, optional :param diffuse: Makes the object visible to diffuse rays (eg for diffuse GI) :type glossy: boolean, optional :param glossy: Makes the object visible to glossy rays (eg in reflections) :type transmission: boolean, optional :param transmission: Makes the object visible to transmission rays (eg from inside glass) :type volume_scatter: boolean, optional :param volume_scatter: Makes the object visible to volume scatter rays (eg from light simulation inside a volume) :type shadow: boolean, optional :param shadow: Enables the object to cast shadows.
- get_min_aabb_corner()
- Return type
- Returns
the minimum axis aligned bounding box position. Requires a transform and mesh component to be attached.
- get_max_aabb_corner()
- Return type
- Returns
the maximum axis aligned bounding box position. Requires a transform and mesh component to be attached.
- get_aabb_center()
- Return type
- Returns
the center of the aligned bounding box. Requires a transform and mesh component to be attached.
- get_center()
- Return type
- Returns
the average of the vertices of the mesh in world space, which will lay roughly in the center. Requires a transform and mesh component to be attached.
- compute_aabb()
For internal use.
- update_renderables()
For internal use.