computing 3d location relative to ship location--solved

If you are a new Irrlicht Engine user, and have a newbie-question, this is the forum for you. You may also post general programming questions here.
Post Reply
reifsnyderb
Posts: 45
Joined: Wed Oct 29, 2008 6:03 pm

computing 3d location relative to ship location--solved

Post by reifsnyderb »

Hello,

I am working on a game, of sorts, and need to have working guns mounted to my ship. For example, the gun needs to be slightly below and to the left or right of the location of the ship. (i.e. mounted on a wing) While I have the rotation figured out, what I really need to do is to calculate the position of the gun so that the blast, from the gun, appears to the player to be coming from the correct location. For example, if the left gun is fired, the blast should be coming from the left wing location and not the center of the ship. I think the solution is to use the matrix math to calculate the offset location from the ship position and use this as the starting point of the blast. However, I am not sure how to do this. Could somebody please point me in the right direction?

Thanks,

Brian
Last edited by reifsnyderb on Thu Oct 18, 2012 1:23 pm, edited 1 time in total.
Mel
Competition winner
Posts: 2293
Joined: Wed May 07, 2008 11:40 am
Location: Granada, Spain

Re: computing 3d location relative to ship location

Post by Mel »

No, it is, luckyly, simpler than that. You may attach a node to another node by setting it as its child. So, you may attach the gun to your ship, and moving the ship, the gun will move (and rotate) along. Now, when you move and rotate your gun, it will become relative to the parent's transformation. And when you need the absolute position of the gun, you may call "getAbsolutePosition()" after calling "updateAbsolutePosition()"

Check the ISceneNode documentation to have a more complete overview of how the hierarchies work.
"There is nothing truly useless, it always serves as a bad example". Arthur A. Schmitt
reifsnyderb
Posts: 45
Joined: Wed Oct 29, 2008 6:03 pm

Re: computing 3d location relative to ship location

Post by reifsnyderb »

Thanks! That is the answer I am looking for. :D

Regards,

Brian


[quote="Mel"]No, it is, luckyly, simpler than that. You may attach a node to another node by setting it as its child. So, you may attach the gun to your ship, and moving the ship, the gun will move (and rotate) along. Now, when you move and rotate your gun, it will become relative to the parent's transformation. And when you need the absolute position of the gun, you may call "getAbsolutePosition()" after calling "updateAbsolutePosition()"

Check the ISceneNode documentation to have a more complete overview of how the hierarchies work.[/quote]
reifsnyderb
Posts: 45
Joined: Wed Oct 29, 2008 6:03 pm

Re: computing 3d location relative to ship location

Post by reifsnyderb »

Got it working! Thanks again. :D

Brian
Mel
Competition winner
Posts: 2293
Joined: Wed May 07, 2008 11:40 am
Location: Granada, Spain

Re: computing 3d location relative to ship location

Post by Mel »

You may put a "solved" on the title of your thread ;)
"There is nothing truly useless, it always serves as a bad example". Arthur A. Schmitt
reifsnyderb
Posts: 45
Joined: Wed Oct 29, 2008 6:03 pm

Re: computing 3d location relative to ship location

Post by reifsnyderb »

Done. :wink:

[quote="Mel"]You may put a "solved" on the title of your thread ;)[/quote]
Post Reply