This project is read-only.

Position of Point relative to a node

Jan 5, 2011 at 2:05 PM

Hey guys,

i'm using Newton to do mouse picking like in the example, but i want to have the coordinates of the clicked point relative to a node. I cant make it work.

The testNode is attached to the groundNode and should show where the Ray Collision happens. If the testNode is attached to the scene root node it's no problem, but i dont get it to work if its attached to the groundNode.

        List<PickedObject> pickedObjects = ((NewtonPhysics)parent.gameScene.PhysicsEngine).PickRayCast(nearPoint, farPoint);

        if (pickedObjects.Count > 0)

            // That is the clicked point relative to the Camera Node
            Vector3 worldPoint = nearPoint + normRay * pickedObjects[0].IntersectParam;

           // Relative Point
           Vector3 relPoint = worldPoint - groundNode.Translation;
           testNode.Translation = relPoint;
We need the relative coordinates later for heightmap calculation. Thx for your help.

Jan 9, 2011 at 2:11 AM

hmm,, so you need the real position of your objects right?

if you want to do that you must calculate all elements of matrix transformation for all node above your testNode ( not only translation but you must consider every transformation include scale and rotation)

here's my code to calculate real position of a object, and the parameter of the function is your testNodeTranslation point

groundNodeTransformation is your Transformation of your gound node and markerNodeTransformation is Matrix Tranformation of your marker node

public static Vector3 ConvertToRealPosition(Vector3 pos)

            Matrix trans = groundNodeTransformation * markerNodeTransformation;
            return Vector3.Transform(pos, trans);


Jan 9, 2011 at 11:09 PM

I needed it right the other way (I had the world coordinates), you brought me on the right path, thanks.

I did just the same thing but with an inverted matrix.