Mesh parenting to camera
Mesh parenting to camera
How can I parent a mesh to the camera so it faces the same direction and same position?
It's for an FPS but instead of the gun it's just hands.
I'm using the FPS camera.
It's for an FPS but instead of the gun it's just hands.
I'm using the FPS camera.
-
- Admin
- Posts: 3590
- Joined: Mon Oct 09, 2006 9:36 am
- Location: Scotland - gonnae no slag aff mah Engleesh
- Contact:
The answer is in the question.
If you can't see the mesh, try offsetting it along the Z axis:
until it appears.
Code: Select all
handsNode->setParent(cameraNode);
Code: Select all
handsNode->setPosition(vector3df(0, 0, 20));
Please upload candidate patches to the tracker.
Need help now? IRC to #irrlicht on irc.freenode.net
How To Ask Questions The Smart Way
Need help now? IRC to #irrlicht on irc.freenode.net
How To Ask Questions The Smart Way
Because when you set a parent the offset from the parent is the position of the node, so if you have you hands at 0,0,0 then when you parent it to the camera the hands will be moved to the exact position of the camera, and hence probably not visible.
So do as rogerborg suggests and fiddle around with the offset, moving it along the z axis should make it visible at some point and then you can scale and reposition it on the x and y axes as well to get it looking nice.
So do as rogerborg suggests and fiddle around with the offset, moving it along the z axis should make it visible at some point and then you can scale and reposition it on the x and y axes as well to get it looking nice.
-
- Admin
- Posts: 3590
- Joined: Mon Oct 09, 2006 9:36 am
- Location: Scotland - gonnae no slag aff mah Engleesh
- Contact:
Then something screwy is going on. Do you fancy making your source and resources available?
Please upload candidate patches to the tracker.
Need help now? IRC to #irrlicht on irc.freenode.net
How To Ask Questions The Smart Way
Need help now? IRC to #irrlicht on irc.freenode.net
How To Ask Questions The Smart Way
-
- Admin
- Posts: 3590
- Joined: Mon Oct 09, 2006 9:36 am
- Location: Scotland - gonnae no slag aff mah Engleesh
- Contact:
Great! Could you tell us what was wrong; it might help us to improve the APIs or docs.
Please upload candidate patches to the tracker.
Need help now? IRC to #irrlicht on irc.freenode.net
How To Ask Questions The Smart Way
Need help now? IRC to #irrlicht on irc.freenode.net
How To Ask Questions The Smart Way
-
- Admin
- Posts: 3590
- Joined: Mon Oct 09, 2006 9:36 am
- Location: Scotland - gonnae no slag aff mah Engleesh
- Contact:
And I'm sure that's not the problem, and that a node attached to a FPS camera node will rotate with the camera node and retain the same apparent orientation.
One of us took the time to test that before posting: can you guess which is which?
One of us took the time to test that before posting: can you guess which is which?
Please upload candidate patches to the tracker.
Need help now? IRC to #irrlicht on irc.freenode.net
How To Ask Questions The Smart Way
Need help now? IRC to #irrlicht on irc.freenode.net
How To Ask Questions The Smart Way
-
- Admin
- Posts: 3590
- Joined: Mon Oct 09, 2006 9:36 am
- Location: Scotland - gonnae no slag aff mah Engleesh
- Contact:
Apology accepted.
Please upload candidate patches to the tracker.
Need help now? IRC to #irrlicht on irc.freenode.net
How To Ask Questions The Smart Way
Need help now? IRC to #irrlicht on irc.freenode.net
How To Ask Questions The Smart Way