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
computing 3d location relative to ship location--solved
-
reifsnyderb
- Posts: 45
- Joined: Wed Oct 29, 2008 6:03 pm
computing 3d location relative to ship location--solved
Last edited by reifsnyderb on Thu Oct 18, 2012 1:23 pm, edited 1 time in total.
Re: computing 3d location relative to ship location
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.
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
Thanks! That is the answer I am looking for.
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]
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
Got it working! Thanks again.
Brian
Brian
Re: computing 3d location relative to ship location
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
Done.
[quote="Mel"]You may put a "solved" on the title of your thread
[/quote]
[quote="Mel"]You may put a "solved" on the title of your thread