Hey everyone, i'm doing my best to program my first RTS-Game with the Irrlicht engine.
Here is my problem:
I got a class "Vehicle" and every Vehicle gets a pointer on a scene node, which is e.g. a Tank or a Rover...
now i want to select one Node with my cursor ( by using a ray and the getSceneNodeAndCollisionPointFromRay-method). that works fine! but i now i want to get the Object of type "Vehicle", which belongs to the selected scene-node.
example:
I got a Vehicle "Super-Tank" and it has a pointer on a sceneNode called "tankNode". now i select the tanknode with my mouse cursor, and i want the program to give me the belonging Object, the "Super-Tank".
any Ideas how i could do that?
thank you so much and forgive my bad english
Question about sceneNodes
Re: Question about sceneNodes
There would be quite a few ways to do this.
1)Iterate over all objects and compare nodes.
2)modify irrlicht's scene node's source to accept your object's pointer to be stored.
3)use external collision library to get your collisions, usually those libraries let you in some way store your objects with collision objects.
4)???
1)Iterate over all objects and compare nodes.
2)modify irrlicht's scene node's source to accept your object's pointer to be stored.
3)use external collision library to get your collisions, usually those libraries let you in some way store your objects with collision objects.
4)???
Working on game: Marrbles (Currently stopped).
Re: Question about sceneNodes
I did number 2, it was just a few lines of code to add a user pointer in to the scene node class. Now when i select a node, i can access that node properties, like hp or whatever.
-
- Posts: 1186
- Joined: Fri Dec 29, 2006 12:04 am
Re: Question about sceneNodes
You don't need to hack the engine, you could use a map (irr::core::map or std::map) with the node as the key.
"Whoops..."
Re: Question about sceneNodes
True, but always good to learn how to get, hack and compile the source if you are serious on using irrlicht for some time ; )
Re: Question about sceneNodes
I'm always glad when people can hack the engine, but still be careful and avoid it unless you have to. I started out that way - hacking everything that I felt was missing directly into the engine - and later learned how much harder it makes updating your engine to a new version. I still hack from time to time in my engine versions, but learned to do at least one thing - create a patch-file for every single change I make.Virror wrote:True, but always good to learn how to get, hack and compile the source if you are serious on using irrlicht for some time ; )
IRC: #irrlicht on irc.libera.chat
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
Re: Question about sceneNodes
True, patch file is the best option ofcourse, but i count that as a hack as well because its still a "change" to the engine : )
Re: Question about sceneNodes
The patch is for you own documentation. Just so when you start changing the engine you will still know afterward which changes belong together. I didn't do that the first time I modified a local engine and then spend over a week just figuring out my own changes once I updated to a newer Irrlicht. The easiest way to do that is if you put your local Irrlicht into a version control program like mercurial and just check-in after each change. Then you can do diffs between those versions.
Well... doesn't matter for a single change - but if you start having more than that it pretty soon starts saving a lot of time.
But the best way is trying to avoid engine changes, so as long as you can do the same in your application in some way (for example using a map in this case) it's always the better solution.
Well... doesn't matter for a single change - but if you start having more than that it pretty soon starts saving a lot of time.
But the best way is trying to avoid engine changes, so as long as you can do the same in your application in some way (for example using a map in this case) it's always the better solution.
IRC: #irrlicht on irc.libera.chat
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
Re: Question about sceneNodes
I prefer to not change the engine, but create plugins for it. Works great e.g. in my ODE integration (aka "IrrODE"), but I have also written a whole bunch of plugins for IrrEdit so that I don't have to hard code a lot of things (e.g. the checkpoints in the "Stunt Marble Racers" game). I guess for user data I would also write a scenenode that doesn't render anything but holds the information needed and make it a child of the node it belongs to. OK, the IrrOde wrapper does include a user data pointer I have used in the IrrOdeCar demo just to count hits when an airplane shoots at another one
Dustbin::Games on the web: https://www.dustbin-online.de/
Dustbin::Games on facebook: https://www.facebook.com/dustbingames/
Dustbin::Games on twitter: https://twitter.com/dustbingames
Dustbin::Games on facebook: https://www.facebook.com/dustbingames/
Dustbin::Games on twitter: https://twitter.com/dustbingames