irrlicht - SetAbsolutePosition
BlitzMax Forums/BlitzMax Programming/irrlicht - SetAbsolutePosition
| ||
Hi, I have an animated mesh which I want to control. I have global positions the joints should go to but unfortunately SetPosition() always calulates from the parent's node. I found http://irrlicht.sourceforge.net/forum/viewtopic.php?t=42342 but it doesn't work for me. I don't know why. The code does not work. What I'm looking for is a method 'setAbsolutePosition' which would return the original in 'c.setAbsolutePosition(c.getAbsolutePosition())' Thought this would be easy... |
| ||
It appears to be correct, in theory; You are getting the child's world transformation, transforming it by the parent's inverse world transformation which should give the child's transformation relative to the parent. The only thing I can think of is that 'matr = w2n.Mult(matr)' operation. Are you sure it's not 'matr = matr.Mult(w2n)' ? EDIT: I don't understand that 'w2n:Matrix4 = New Matrix4.Create()'. If you're calling 'Create()', it should return an instance already - you wouldn't have to use New as well. Generally inside the Create() function of a Type the programmer uses New to create a new instance and returns it so you don't have to use New yourself. EDIT2: After hunting for the source, yeah, you should not use New. Just call Create: Function Create:Matrix4(eConstructor:Int=EM4CONST_IDENTITY) Return createFromHandle(IrrCore_Matrix4_new(eConstructor),True) EndFunction Function createFromHandle:Matrix4(pMat:Int,bMustDel:Int=True) If Not pMat Then Return Null Local oRetVal:Matrix4=New Matrix4 '<--- It already creates a New one for you. oRetVal.attach(pMat,bMustDel) Return oRetVal EndFunction |
| ||
Unless Create() is a Method which returns Self. I usually construct my Type hierarchies in this way, so you can have a constructor with parameters - unlike New which takes none. |