Graphics::IModelWorld class

A model world is a space where models can be rendered in the game.

Model worlds keep track of all the models loaded in order to render them when the model world itself is rendered. A world can also contain multiple lighting worlds; for more information, check the ILightingWorld interface. When no lighting worlds are added a default lighting is used.

In order for the model world to render, you must add it to the render queue. This step is not necessary if the IRenderable::Render() method is called directly from another renderer. For example: RenderManager.AddRenderable(pModelWorld->ToRenderable(), Graphics::kRenderQueueMain); You might use greater render queue indices, like Graphics::kRenderQueueMain + 1. An example of this would be having a model world for translucid objects, which need to be rendered last.

Public types

enum ModelWorldFlags { kBuildDrawLists = 0x00000100, kUpdateLOD = 0x00000200, kUseOccluders = 0x00000400, kSetState = 0x00000800, kDrawOpaque = 0x00001000, kDrawAlpha = 0x00002000, kDrawDebug = 0x00004000, kNoSort = 0x00008000, kForceOpaque = 0x00010000, kRenderAll = 0x00007f00, kRenderAllNoLOD = 0x00007d00 }

Constructors, destructors, conversion operators

~IModelWorld() virtual

Public functions

auto AddRef() -> int pure virtual
auto Release() -> int pure virtual
auto LoadModel(uint32_t instanceID, uint32_t groupID, int arg_8 = 0) -> Model* pure virtual
Loads a model from the resources system with the given instance and group ID.
auto func10h() -> int pure virtual
auto func14h() -> int pure virtual
auto func18h() -> int pure virtual
auto func1Ch() -> int pure virtual
auto func20h() -> int pure virtual
auto Raycast(const Vector3& point1, const Vector3& point2, float* factorDst = nullptr, Vector3* dstIntersectionPoint = nullptr, Vector3* = nullptr, FilterSettings& settings = FilterSettings(), int* = nullptr, int* = nullptr) -> Model* pure virtual
Gets the first model that is intersected with the segment between point1 and point2.
auto func28h(const Vector3& point1, const Vector3& point2, float* factorDst, FilterSettings& settings = FilterSettings()) -> Model* pure virtual
auto GetModels(vector<Model*>& dst, FilterSettings& settings = FilterSettings()) -> bool pure virtual
Gets all the models that fit the filter.
auto RaycastAllOrdered(const Vector3& point1, const Vector3& point2, vector<pair<Model*, float>>& result, FilterSettings& settings = FilterSettings(), float = 0.0) -> bool pure virtual
Gets all the models that intersect with a segment.
auto RaycastAll(const Vector3& point1, const Vector3& point2, vector<Model*>& result, FilterSettings& settings = FilterSettings(), float = 0.0) -> bool pure virtual
Gets all the models that intersect with a segment.
auto IntersectSphere(const Vector3& center, float radius, vector<Model*> result, FilterSettings& settings = FilterSettings()) -> bool pure virtual
Finds all the models that intersect with the sphere with center and radius.
auto IntersectBBox(const BoundingBox& bbox, vector<Model*>& result, FilterSettings& settings = FilterSettings()) -> bool pure virtual
Finds all the models that intersect with the given bounding box.
auto func40h() -> int pure virtual
auto func44h(const Vector3& p1, const Vector3& p2, const Model* model, const Vector3& p3, FilterSettings& settings = FilterSettings()) -> bool pure virtual
auto ModelIntersectSphere(const Vector3& center, float radius, const Model* model, FilterSettings& settings = FilterSettings()) -> bool pure virtual
Returns true if the sphere with center and radius intersects with the model.
auto ModelIntersectBBox(const BoundingBox& bbox, const Model* model, FilterSettings& settings = FilterSettings()) -> bool pure virtual
Returns true if the given bounding box intersects with the model.
void GetResourceID(const Model* pModel, uint32_t* pDstInstanceID, uint32_t* pDstGroupID) pure virtual
Used to get the instance and group ID of the given model.
void GetRegions(const Model* pModel, vector<uint32_t>& dst) pure virtual
void UpdateModel(const Model* pModel) pure virtual
Ensures the given model is loaded and all its parameters are updated.
auto GetBoundingRadius(const Model* pModel) -> float pure virtual
Returns the model bounding radius, calling UpdateModel() if the model does not have the 'overrideBoundingRadius' property.
auto GetBoundingBox(const Model* pModel) -> const BoundingBox& pure virtual
Returns the model bounding box, calling UpdateModel() if the model does not have the 'overrideBoundingBox' property.
auto func64h() -> int pure virtual
auto GetAnimCount(const Model* pModel, int skeletonSinkIndex = 0) const -> int pure virtual
Returns the amount of animations contained in the model.
auto GetAnimIDs(const Model* pModel, uint32_t* dst, int skeletonSinkIndex = 0) const -> int pure virtual
Used to get the IDs of the animations contained in the model.
void func70h(Model* pModel, uint32_t animID, int = 3, float = 0.0, int skeletonSinkIndex = 0) pure virtual
void SetAnimTime(Model* pModel, uint32_t animID, float time, int = 0) pure virtual
Changes the current time of an animation in the model.
auto func78h(Model* pModel, uint32_t animID, float, int) -> int pure virtual
auto func7Ch(Model* pModel) const -> int pure virtual
auto GetAnimRange(const Model* pModel, uint32_t animID, float& dstStart, float& dstEnd, int = 0) const -> bool pure virtual
Used to get the start and end time of an animation in the model, in seconds.
auto func84h(const Model* pModel) const -> int pure virtual
auto GetAnimationSkin(const Model* pModel, RenderWare::Matrix3x4* dst, bool original = false) const -> int pure virtual
auto func8Ch(const Model* pModel, RenderWare::Matrix3x4* dst) -> int pure virtual
auto func90h(const Model* pModel, int* dst) -> int pure virtual
auto func94h(const Model* pModel, int* dst) -> int pure virtual
auto func98h() -> int pure virtual
auto func9Ch() -> int pure virtual
auto funcA0h() -> int pure virtual
void SetMaterialInfo(Model* pModel, cMaterialInfo* pMaterialInfo, int region = -1) const pure virtual
auto GetMaterialInfo(const Model* pModel, int region = -1) const -> cMaterialInfo* pure virtual
auto funcACh() -> int pure virtual
auto GetLodMeshCount(const Model* pModel) const -> int pure virtual
Returns how many mesh versions this model has, which depend on the level of detail (LOD).
void SetFixedLod(Model* pModel, int lod) const pure virtual
Forces the model to use a certain lod level, or restores it to the default (which is changing lod level depending on distance).
void SetEffectRange(Model* pModel, double effectRange = -1.0f) const pure virtual
Sets the effect range for the model.
auto funcBCh() -> int pure virtual
auto funcC0h() -> int pure virtual
void SetEffectEnable(Model* pModel, bool enable, uint32_t instanceID = 0) const pure virtual
Enables or disables the effects in the model.
auto SetEffectFloatParams(Model* pModel, Swarm::IEffect::FloatParams param, const float* data, int count, uint32_t instanceID = 0) const -> bool pure virtual
auto SetEffectIntParams(Model* pModel, Swarm::IEffect::IntParams param, const int* data, int count, uint32_t instanceID = 0) const -> bool pure virtual
auto SetEffectObjectParam(Model* pModel, Swarm::IEffect::IntParams param, Object* data, uint32_t instanceID = 0) const -> bool pure virtual
auto funcD4h(Model* pModel, const Transform* pTransform = nullptr, uint32_t instanceID = 0) -> int pure virtual
auto funcD8h() -> int pure virtual
auto funcDCh() -> int pure virtual
auto funcE0h() -> int pure virtual
void GetHullBoundingBox(const Model* pModel, BoundingBox& dst) const pure virtual
auto GetMorphHandles(const Model* pModel, MorphHandleInfo* dst, int count) -> int pure virtual
auto funcECh() -> int pure virtual
auto funcF0h() -> int pure virtual
auto funcF4h() -> int pure virtual
auto funcF8h() -> int pure virtual
auto funcFCh() -> int pure virtual
auto func100h() -> int pure virtual
auto func104h() -> int pure virtual
auto func108h() -> int pure virtual
auto func10Ch() -> int pure virtual
auto func110h() -> int pure virtual
auto func114h() -> int pure virtual
auto func118h() -> int pure virtual
auto func11Ch() -> int pure virtual
auto func120h() -> int pure virtual
auto func124h() -> int pure virtual
auto func128h() -> int pure virtual
auto func12Ch() -> int pure virtual
auto func130h() -> int pure virtual
void SetVisible(bool visible) pure virtual
Toggles the visibility of all the world, including the lighting and all the models contained.
auto func138h() -> int pure virtual
auto ToRenderable() -> IRenderable* pure virtual
Returns the IRenderable object that can be used to render this model world.
auto AddLightingWorld(ILightingWorld* pWorld, int slotIndex, bool) -> int pure virtual
auto GetLightingWorld(int slotIndex) -> ILightingWorld* pure virtual
auto func148h(Swarm::IEffectWorld*) -> int pure virtual
auto func14Ch() -> Swarm::IEffectWorld* pure virtual
auto func150h() -> int pure virtual
auto func154h() -> int pure virtual
auto func158h() -> int pure virtual
auto func15Ch() -> int pure virtual
auto func160h() -> int pure virtual
auto func164h() -> int pure virtual
auto func168h() -> int pure virtual
auto SetModelVisible(Model* pModel, bool visible) -> bool pure virtual
Changes the visibility of a given model inside this world.
void DestroyModel(Model* pModel, bool) pure virtual
auto Initialize() -> bool pure virtual
auto Dispose() -> bool pure virtual
void func17Ch() pure virtual

Protected functions

void LoadModelProperties(const App::PropertyList* pPropList, ModelAsset* pAsset, int nFlags, int arg_C)

Function documentation

Model* Graphics::IModelWorld::LoadModel(uint32_t instanceID, uint32_t groupID, int arg_8 = 0) pure virtual

Loads a model from the resources system with the given instance and group ID.

Parameters
instanceID
groupID
arg_8

Keep in mind that a model refers to the configuration file (i.e. the .prop file) which includes the model files for each level of detail, the effects that must be used, etc. If the model configuration does not exist, a builtin model might be used.

Model* Graphics::IModelWorld::Raycast(const Vector3& point1, const Vector3& point2, float* factorDst = nullptr, Vector3* dstIntersectionPoint = nullptr, Vector3* = nullptr, FilterSettings& settings = FilterSettings(), int* = nullptr, int* = nullptr) pure virtual

Gets the first model that is intersected with the segment between point1 and point2.

Returns The closest model that intersected, or nullptr if no model intersected the ray.

bool Graphics::IModelWorld::GetModels(vector<Model*>& dst, FilterSettings& settings = FilterSettings()) pure virtual

Gets all the models that fit the filter.

Parameters
dst
settings Settings that decide which models are valid.
Returns True if any model intersected, false otherwise.

By default, the filter accepts all models.

bool Graphics::IModelWorld::RaycastAllOrdered(const Vector3& point1, const Vector3& point2, vector<pair<Model*, float>>& result, FilterSettings& settings = FilterSettings(), float = 0.0) pure virtual

Gets all the models that intersect with a segment.

Parameters
point1 The start of the ray.
point2 The end of the ray.
result The vector where the { model, factor } pairs will be added.
settings Settings that decide which models are valid.
Returns True if any model intersected, false otherwise.

It adds them in the vector ordered by distance to point1; the vector will contains pairs of model and a float, the proportion between the two points where it intersected.

bool Graphics::IModelWorld::RaycastAll(const Vector3& point1, const Vector3& point2, vector<Model*>& result, FilterSettings& settings = FilterSettings(), float = 0.0) pure virtual

Gets all the models that intersect with a segment.

Parameters
point1 The start of the ray.
point2 The end of the ray.
result The vector where the models will be added.
settings Settings that decide which models are valid.
Returns True if any model intersected, false otherwise.

bool Graphics::IModelWorld::IntersectSphere(const Vector3& center, float radius, vector<Model*> result, FilterSettings& settings = FilterSettings()) pure virtual

Finds all the models that intersect with the sphere with center and radius.

Parameters
center The center point of the sphere.
radius The radius of the sphere.
result The vector where the models will be added.
settings Settings that decide which models are valid and which collision mode is used.
Returns True if any model intersected, false otherwise.

bool Graphics::IModelWorld::IntersectBBox(const BoundingBox& bbox, vector<Model*>& result, FilterSettings& settings = FilterSettings()) pure virtual

Finds all the models that intersect with the given bounding box.

Parameters
bbox The bounding box to check.
result The vector where the models will be added.
settings Settings that decide which models are valid and which collision mode is used.
Returns True if any model intersected, false otherwise.

bool Graphics::IModelWorld::ModelIntersectSphere(const Vector3& center, float radius, const Model* model, FilterSettings& settings = FilterSettings()) pure virtual

Returns true if the sphere with center and radius intersects with the model.

Parameters
center The center point of the sphere.
radius The radius of the sphere.
model The model to intersect with.
settings Settings that decide which models are valid and which collision mode is used.
Returns True if the model intersects with the bbox, false otherwise.

bool Graphics::IModelWorld::ModelIntersectBBox(const BoundingBox& bbox, const Model* model, FilterSettings& settings = FilterSettings()) pure virtual

Returns true if the given bounding box intersects with the model.

Parameters
bbox The bounding box to check.
model The model to intersect with.
settings Settings that decide which models are valid and which collision mode is used.
Returns True if the model intersects with the bbox, false otherwise.

void Graphics::IModelWorld::GetResourceID(const Model* pModel, uint32_t* pDstInstanceID, uint32_t* pDstGroupID) pure virtual

Used to get the instance and group ID of the given model.

Parameters
pModel The model.
pDstInstanceID [Optional] Reference to the destination variable for the instance ID.
pDstGroupID [Optional] Reference to the destination variable for the group ID.

void Graphics::IModelWorld::UpdateModel(const Model* pModel) pure virtual

Ensures the given model is loaded and all its parameters are updated.

Parameters
pModel

float Graphics::IModelWorld::GetBoundingRadius(const Model* pModel) pure virtual

Returns the model bounding radius, calling UpdateModel() if the model does not have the 'overrideBoundingRadius' property.

Parameters
pModel
Returns The bounding radius.

const BoundingBox& Graphics::IModelWorld::GetBoundingBox(const Model* pModel) pure virtual

Returns the model bounding box, calling UpdateModel() if the model does not have the 'overrideBoundingBox' property.

Parameters
pModel
Returns The bounding box.

int Graphics::IModelWorld::GetAnimCount(const Model* pModel, int skeletonSinkIndex = 0) const pure virtual

Returns the amount of animations contained in the model.

Parameters
pModel
skeletonSinkIndex

int Graphics::IModelWorld::GetAnimIDs(const Model* pModel, uint32_t* dst, int skeletonSinkIndex = 0) const pure virtual

Used to get the IDs of the animations contained in the model.

Parameters
pModel
dst out
skeletonSinkIndex

dst must be an array of the size returned by GetAnimCount()

void Graphics::IModelWorld::SetAnimTime(Model* pModel, uint32_t animID, float time, int = 0) pure virtual

Changes the current time of an animation in the model.

Parameters
pModel
animID
time

The time must be in the range returned by GetAnimRange()

bool Graphics::IModelWorld::GetAnimRange(const Model* pModel, uint32_t animID, float& dstStart, float& dstEnd, int = 0) const pure virtual

Used to get the start and end time of an animation in the model, in seconds.

Parameters
pModel
animID
dstStart out
dstEnd out

The length of the animation can be calculated with dstEnd - dstStart.

int Graphics::IModelWorld::GetLodMeshCount(const Model* pModel) const pure virtual

Returns how many mesh versions this model has, which depend on the level of detail (LOD).

Parameters
pModel

void Graphics::IModelWorld::SetFixedLod(Model* pModel, int lod) const pure virtual

Forces the model to use a certain lod level, or restores it to the default (which is changing lod level depending on distance).

Parameters
pModel The model to change.
lod The level of detail t use, between 0 and 3. If -1 is used, the lod will be decided by distance.

void Graphics::IModelWorld::SetEffectRange(Model* pModel, double effectRange = -1.0f) const pure virtual

Sets the effect range for the model.

If the value is negative, effect range will be ignored, so effects in this model will be displayed at any distance. Otherwise, the value is ignored, and the effect range is loaded from the model .prop file.

void Graphics::IModelWorld::SetEffectEnable(Model* pModel, bool enable, uint32_t instanceID = 0) const pure virtual

Enables or disables the effects in the model.

Parameters
pModel
enable If true, effects will be enabled
instanceID [Optional] If not 0, only effects with this ID will be changed.

An instance ID can be specified; in that case, only effects with that ID will be affected.

void Graphics::IModelWorld::SetVisible(bool visible) pure virtual

Toggles the visibility of all the world, including the lighting and all the models contained.

Parameters
visible Whether the world must be visible or not.

bool Graphics::IModelWorld::SetModelVisible(Model* pModel, bool visible) pure virtual

Changes the visibility of a given model inside this world.

Parameters
pModel The model to set visible/invisible, which must be included inside this world.
visible Whether the model must be visible or not.