Wasabi
Public Member Functions | Friends | List of all members
WObjectManager Class Reference

#include <WObject.hpp>

Inheritance diagram for WObjectManager:
WManager< WObject >

Public Member Functions

 WObjectManager (class Wasabi *const app)
 
WError Load ()
 
WObjectCreateObject (uint32_t ID=0) const
 
WObjectCreateObject (class WEffect *fx, uint32_t bindingSet, uint32_t ID=0) const
 
WObjectPickObject (double x, double y, bool bAnyHit, uint32_t iObjStartID=0, uint32_t iObjEndID=0, WVector3 *pt=nullptr, WVector2 *uv=nullptr, uint32_t *faceIndex=nullptr) const
 
- Public Member Functions inherited from WManager< WObject >
 WManager (class Wasabi *const a)
 
bool RegisterChangeCallback (std::string name, std::function< void(WObject *, bool)> callback)
 
void RemoveChangeCallback (std::string name)
 
void AddEntity (WObject *entity)
 
bool RemoveEntity (WObject *entity)
 
void OnEntityNameChanged (WObject *entity, std::string oldName)
 
virtual void Init ()
 
WObjectGetEntity (uint32_t ID) const
 
WObjectGetEntity (std::string name) const
 
WObjectGetEntityByIndex (uint32_t index) const
 
uint32_t GetEntitiesCount (void) const
 

Friends

class WObject
 

Additional Inherited Members

- Public Attributes inherited from WManager< WObject >
class Wasabi *const m_app
 
- Protected Attributes inherited from WManager< WObject >
std::vector< WObject * > m_entities [W_HASHTABLESIZE]
 
std::unordered_map< std::string, WObject * > m_entitiesByName
 

Detailed Description

Manager class for WObject.

Member Function Documentation

◆ CreateObject() [1/2]

WObject* WObjectManager::CreateObject ( class WEffect fx,
uint32_t  bindingSet,
uint32_t  ID = 0 
) const

Allocates and initializes a new object.

Parameters
fxAn effect to use. If nullptr, a default effect will be assigned
bindingSetBinding set to use for the material of the given fx
IDId of the new object
Returns
New object

◆ CreateObject() [2/2]

WObject* WObjectManager::CreateObject ( uint32_t  ID = 0) const

Allocates and initializes a new object.

Parameters
IDId of the new object
Returns
New object

◆ Load()

WError WObjectManager::Load ( )

Loads the manager.

Returns
Error code, see WError.h

◆ PickObject()

WObject* WObjectManager::PickObject ( double  x,
double  y,
bool  bAnyHit,
uint32_t  iObjStartID = 0,
uint32_t  iObjEndID = 0,
WVector3 pt = nullptr,
WVector2 uv = nullptr,
uint32_t *  faceIndex = nullptr 
) const

Checks if an object is in the view in the default renderer's camera and and part of that object is at the given (x,y) coordinates on the screen. If multiple objects are under the (x,y) coordinate, the one with the closest hit will be returned.

Parameters
xScreen x coordinate to check for a hit
yScreen y coordinate to check for a hit
bAnyHitIf set to true, the first hit will be returned, otherwise the closest one will be returned
iObjStartIDIf both iObjStartID and iObjEndID are non-zero, then only objects whose ID is between iObjStartID and iObjEndID (inclusive) are considered for picking
iObjEndIDIf both iObjStartID and iObjEndID are non-zero, then only objects whose ID is between iObjStartID and iObjEndID (inclusive) are considered for picking
ptOptional pointer to a 3D vector which will be populated with the 3D coordinate at which the hit occurred, if a hit was found
uvOptional pointer to a 2D vector which will be populated with the UV coordinates returned by WGeometry::Intersect(), if a hit was found
faceIndexOptional pointer to an integer which will be populated with the index of the triangle into the buffer of the geometry of the object that was hit, if a hit was found
Returns
Object that was picked, nullptr if no Object was was picked

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