Ignoring the rotation values of the parent node(s)?
Ignoring the rotation values of the parent node(s)?
Hi all,
My problem:
I have a child node attached to at least one parent node in my scene hierarchy, but I need the child node to use a different rotation that is independent of the rotation values of the parent(s).
I still need it to be an attached child node because of the need to follow any position movements and visibility of the parent node.
An example would be trying to have eyeball object "look at" a point in space, while the "body" and "head" (in which the eyeball is attached to in the hierarchy) are translating and rotating.
Any help would be great. I'm sure this has been solved many times. I search the forums before asking this but no luck.
My problem:
I have a child node attached to at least one parent node in my scene hierarchy, but I need the child node to use a different rotation that is independent of the rotation values of the parent(s).
I still need it to be an attached child node because of the need to follow any position movements and visibility of the parent node.
An example would be trying to have eyeball object "look at" a point in space, while the "body" and "head" (in which the eyeball is attached to in the hierarchy) are translating and rotating.
Any help would be great. I'm sure this has been solved many times. I search the forums before asking this but no luck.
My game: Star Sonata
Star Sonata is a massively multiplayer space game.
Star Sonata is a massively multiplayer space game.
Alternatively you could just not parent the eyeballs to the head but just set their position properly each frame.
Though of course you SHOULD take the parents rotation because what if the head tips backwards or forwards for example? Then the rotation of the head will change which will change the required rotation and positioning for the eyes. Basically i guess you should just get the absolute rotation of the eyes and calculate their rotation, to look at a certain point, based on that, each frame.
Though of course you SHOULD take the parents rotation because what if the head tips backwards or forwards for example? Then the rotation of the head will change which will change the required rotation and positioning for the eyes. Basically i guess you should just get the absolute rotation of the eyes and calculate their rotation, to look at a certain point, based on that, each frame.
-
rogerborg
- Admin
- Posts: 3590
- Joined: Mon Oct 09, 2006 9:36 am
- Location: Scotland - gonnae no slag aff mah Engleesh
- Contact:
And the easiest way to do that would be to use... a custom scene node.JP wrote:Alternatively you could just not parent the eyeballs to the head but just set their position properly each frame.
I'm still burned out from my burst of maths yesterday, but I'll try and have a think about a custom node to do this, where "this" is defined as:
Rotate to look at a specific point, clamping the allowed rotation to some delta from the parent node's rotation.
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
Sorry I'm back. I've been reading up on building my own custom scene nodes to make sure my child node's rotation is replaced by an absolute custom node rotation of my choosing that's independent of the parent's rotation.
It appears that I need to override a virtual function in ISceneNode and get the value of AbsoluteTransformation and modify it to it ignore all the rotation values. But which function do I change this value in? Or am I completely off here?
It appears that I need to override a virtual function in ISceneNode and get the value of AbsoluteTransformation and modify it to it ignore all the rotation values. But which function do I change this value in? Or am I completely off here?
My game: Star Sonata
Star Sonata is a massively multiplayer space game.
Star Sonata is a massively multiplayer space game.
Yep I will. I think might have it figured out. But I'm still writing it.dlangdev wrote:can you post the code when you're done with the mod. i'd like to have a copy of it.
thanks much.
My game: Star Sonata
Star Sonata is a massively multiplayer space game.
Star Sonata is a massively multiplayer space game.
Ok what if I just want to override one function in the class heirarchy of CAnimatedMeshSceneNode or even CMeshSceneNode.
I understand the IMeshSceneNode abstract philosophy but I just want to modify one virtual member function via an inherited class called e.g. class myCAnimatedMeshSceneNode.
I don't understand how do this without cutting and pasting a ton of code from CAnimatedMeshSceneNode to meet the needs of the abstract interfeace of IAnimatedMeshSceneNode.
I understand the IMeshSceneNode abstract philosophy but I just want to modify one virtual member function via an inherited class called e.g. class myCAnimatedMeshSceneNode.
I don't understand how do this without cutting and pasting a ton of code from CAnimatedMeshSceneNode to meet the needs of the abstract interfeace of IAnimatedMeshSceneNode.
My game: Star Sonata
Star Sonata is a massively multiplayer space game.
Star Sonata is a massively multiplayer space game.
-
rogerborg
- Admin
- Posts: 3590
- Joined: Mon Oct 09, 2006 9:36 am
- Location: Scotland - gonnae no slag aff mah Engleesh
- Contact:
Suck it up, soldier. Copying CAnimatedMeshSceneNode, renaming it, and doing a find and replace on CAnimatedMeshSceneNode inside it would take, what, 2 minutes?
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
Ya, I feel ya.rogerborg wrote:Suck it up, soldier. Copying CAnimatedMeshSceneNode, renaming it, and doing a find and replace on CAnimatedMeshSceneNode inside it would take, what, 2 minutes?
<mini rant>
Maybe I'm mistaken but I'm a little bit surprised that the Irrlicht design actually forces a very bad and dangerous coding practice. What if one requires a dozen custom anim node classes? This is code bloat and cache unfriendly.
And what if there is a bug fix or change in the original Irrlicht anim node. The change potentially would have to be propagated to all the custom versions of the copied code.
I don't see why they actively discourage me from inheriting from CAnimatedMeshSceneNode given these drawbacks given these problems?
</rant>
Yes, I know it's free. And I'm very grateful for any work done by open source developers but I'm confused.
My game: Star Sonata
Star Sonata is a massively multiplayer space game.
Star Sonata is a massively multiplayer space game.
Oh! I think that might work. Thanks.hybrid wrote:Can't you just put up a custom scene node which ignores the rotation and parent it to the animated scene node?
My game: Star Sonata
Star Sonata is a massively multiplayer space game.
Star Sonata is a massively multiplayer space game.
Yep that did the trick. Thanks. You helped me think of a new way to attacking my problem. Much appreciated.Castaa wrote:Oh! I think that might work. Thanks.hybrid wrote:Can't you just put up a custom scene node which ignores the rotation and parent it to the animated scene node?
My game: Star Sonata
Star Sonata is a massively multiplayer space game.
Star Sonata is a massively multiplayer space game.
dlangdev wrote:can you post the code when you're done with the mod. i'd like to have a copy of it.
thanks much.
Code: Select all
// this class is a special node that blocks the parent rotation from being used to calculate the child's rotation //
class CTargetRingAdjustmentNode : public irr::scene::ISceneNode
{
core::aabbox3d<f32> m_Box;
public:
CTargetRingAdjustmentNode(irr::scene::ISceneNode* parent, irr::scene::ISceneManager* mgr)
: scene::ISceneNode(parent, mgr)
{
#ifdef _DEBUG
setDebugName("CTargetRingAdjustmentNode");
#endif
}
virtual void updateAbsolutePosition()
{
if( Parent )
{
core::matrix4 mat = Parent->getAbsoluteTransformation();
mat.setRotationDegrees(irr::core::vector3df(0,0,0));
AbsoluteTransformation = mat * getRelativeTransformation();
}
else
{
AbsoluteTransformation = getRelativeTransformation();
}
}
virtual void OnRegisterSceneNode()
{
if (IsVisible)
{
SceneManager->registerNodeForRendering(this);
}
ISceneNode::OnRegisterSceneNode();
}
virtual void render()
{
// this node only effects rotations of it's children and doesn't render anything //
}
virtual const core::aabbox3d<f32>& getBoundingBox() const
{
return m_Box;
}
};My game: Star Sonata
Star Sonata is a massively multiplayer space game.
Star Sonata is a massively multiplayer space game.

