Each slot is assigned a local transformation, in relation to its parent. This allows for offsetting the slot geometry from the entity it is attached to, and is especially useful when dealing with multiple slots in one entity.
|IEntity::GetSlotWorldTM||Gets the transformation of the slot in world coordinates.|
|IEntity::GetSlotLocalTM||Gets the transformation of the slot in relation to its parent.|
|IEntity::SetSlotLocalTM||Sets the relative transformation of the slot.|
Camera space rendering allows for drawing an entity slot in the Camera's local space - always making it relative to the camera, and avoiding that other objects are on top. This is most commonly used for first person shooter weaponry and hands.
This is achieved by setting the ENTITY_SLOT_RENDER_NEAREST flag instead of ENTITY_SLOT_RENDER, and then setting the camera-space relative position of the object:
|IEntity::SetSlotCameraSpacePos||Sets the camera space position of the slot, used when the ENTITY_SLOT_RENDER_NEAREST is applied to the slot.|
|IEntity::GetSlotCameraSpacePos||Gets the camera space position of the slot, used when the ENTITY_SLOT_RENDER_NEAREST is applied to the slot.|
By default, a slot contains a null material - resulting in the rendered form of a slot using the default material for the object assigned to it. However, it is often useful to override the material of the slot, allowing custom effects on individual entity geometry.
This can be achieved with the IEntity::GetSlotMaterial and IEntity::SetSlotMaterial functions.
The EEntitySlotFlags enum can be used to change the behavior of individual slots, for example to disable rendering entirely - something that can be useful when a slot is only meant for physical interaction.
|IEntity:;SetSlotFlags||Used to set the flags for this slot, note that this completely overrides the flags.|
|IEntity::GetSlotFlags||Retrieves the specified slot's flags.|
The currently available slot flags are:
|ENTITY_SLOT_RENDER||Set by default. If cleared, the entity will no longer be rendered to the screen.|
|ENTITY_SLOT_RENDER_NEAREST||If set, the entity will be rendered in camera space. See IEntity::SetSlotCameraSpacePos and IEntity::GetSlotCameraSpacePos.|
|ENTITY_SLOT_CAST_SHADOW||If set, the entity slot will cast a shadow.|
There are several types of objects that can be applied to an entity slot:
Character instances commonly represent character definitions (CDF), created via the Character Tool to create a complex character out of multiple objects. Alternatively, this can also be a single object as part of a CGA of CHR file. Characters are represented by the ICharacterInstance interface.
Interaction with characters on an entity is limited to:
|IEntity::GetCharacter||Retrieves the character instance at the specified slot, if any.|
|IEntity::SetCharacter||Applies an existing character instance (.CDF, .CHR, .CGA) to the specified slot.|
|IEntity::LoadCharacter||Loads specified character from disk and applies it to the specified slot.|
For more information on characters, and how to approach animating them, see Characters and Animations.
Static geometry is represented by the CGF format, and is known in code as IStatObj.
Interaction with static geometry on an entity is limited to:
|IEntity::GetStatObj||Retrieves the static geometry at the specified slot, if any.|
|IEntity::SetStatObj||Applies the specified static geometry (.CGF) to the specified slot.|
|IEntity::LoadGeometry||Loads specified static geometry (.CGF) from disk and applies it to the specified slot.|
Particles can be loaded into emitters, a construct that will continuously emit effects from a point. When assigned to an entity, a particle emitter will follow an entity and thus allow creating very complex effects with ease. Emitters are represented in code by the IParticleEmitter interface, while the underlying particle effect (.pfx, .pfx2) is known in code as IParticleEffect.
Interaction with particle emitters on an entity is limited to:
|IEntity::GetParticleEmitter||Retrieves the particle emitter at the specified slot, if any.|
|IEntity::SetParticleEmitter||Applies the specified particle emitter to the specified slot.|
|IEntity::LoadParticleEmitter||Creates an emitter in the specified slot out of the specified effect.|
Very often useful, lights can be loaded into entities to create dynamic light sources that can move around the level at run-time. This is useful to create entities that provide point lights, projected lights or even environment probes.
Lights are loaded into entity slots using the IEntity::LoadLight function, with the accompanying CDLight structure defining the behavior of the light. This allows for creating point lights, projector lights and environment probes. An example is available here.
Entities can also load fog volumes into slots, allowing the use of dynamic fog effects around logical entities.
Fog volumes can be loaded into entity slots using the IEntity::LoadFogVolume function, with the accompanying SFogVolumeProperties structure defining the behavior of the volume.
Geom Cache / Alembic
Geom Caches can be loaded into entities, allowing the playback of arbitrarily animated geometry. This can allow for complex destruction, complicated cloth motion and other special effects that would otherwise be too expensive to calculate in real-time.
Geom Cache can be loaded into entity slots using the IEntity::LoadGeomCache function, and can subsequently be manipulated by calling IEntity::GetGeomCacheRenderNode.
Low-level Render nodes can be added directly to entities, allowing the dynamic rendering of effects on entities. Keep in mind that all the constructs above are also render nodes, but direct helpers for creating the render node are available to simplify ease of use.
Examples of render nodes that could be attached to entities are: IRoadRenderNode, IDecalRenderNode and IWaterVolumeRenderNode, IRopeRenderNode. It is also possible to directly query the render node attached to a slot, even in the case of using the helpers above, using IEntity::GetSlotRenderNode.
Otherwise, render nodes can be applied directly to a specific slot using the IEntity::SetSlotRenderNode function.
That concludes this article on Entity Slots. You may be interested in: