I'm currently using Irrlicht to do a small game, and I'm using the collision manager to detect the clicked object in the interface. But the collision manager only returns an ISceneNode, and I want to get my own class.
I used Ogre in another project, and it was possible to set and get user data by using the method "setUserObject" on the class "MovableObject" returned by the ray casting.
Irrlicht's collision manager returns an ISceneNode, but there is no way to store a pointer there (and I think that having to create a map between the id of the scene node and my class is not really a good solution).
Maybe I missed something, if so please head me int the good direction.
Actually I patched ISceneNode.h with the following patch and it's working very well :
Code: Select all
--- irrlicht-1.3/include/ISceneNode.h 2007-03-10 10:32:08.000000000 +0100
+++ irrlicht-1.3-mod/include/ISceneNode.h 2007-05-02 14:18:43.000000000 +0200
@@ -40,7 +40,8 @@ namespace scene
: RelativeTranslation(position), RelativeRotation(rotation), RelativeScale(scale),
Parent(parent), ID(id), SceneManager(mgr), TriangleSelector(0),
AutomaticCullingState(EAC_BOX), IsVisible(true),
- DebugDataVisible(EDS_OFF), IsDebugObject(false)
+ DebugDataVisible(EDS_OFF), IsDebugObject(false),
+ UserData(NULL)
{
if (Parent)
Parent->addChild(this);
@@ -604,6 +605,16 @@ namespace scene
updateAbsolutePosition();
}
+ inline virtual void setUserData(void *data)
+ {
+ UserData = data;
+ }
+
+ inline virtual void *getUserData()
+ {
+ return UserData;
+ }
+
protected:
//! name of the scene node.
@@ -650,6 +661,9 @@ namespace scene
//! is debug object?
bool IsDebugObject;
+
+ //! User data
+ void *UserData;
};
} // end namespace scene
