This project is read-only.

Marker position

Jan 10, 2013 at 8:22 PM

Hy.I want to display 2 images over 2 different markers and draw a line between them. how can i get the x and y possition of the marker.thanks!

Feb 4, 2013 at 3:58 PM
Hi ionutzzzusv!

I got the same question. Did you solve that?
Feb 6, 2013 at 6:44 AM
Feb 7, 2013 at 9:23 AM
Thanks your reply Edd1138!

Theese are already been tried, but when I decompose the toolbar's worldtransformation, there is some problem with the components (X, Y, Z). I draw a circle to the X and Y position of the marker and the position of the circle and the marker position not the same... how did you solved this?
Feb 7, 2013 at 10:41 AM
Edited Feb 7, 2013 at 10:42 AM
try this
 var coor2d = State.Device.Viewport.Project(
                     vect, // The 3D coordinates (Vector3) you want to project to screen space
                     State.ProjectionMatrix,          // Projection matrix of your camera
                     Matrix.Identity,                 // View matrix of your camera (since ALVAR camera is located at 0,0,0 we can just pass Identity)
            if (groundMarkerNode.MarkerFound)
                DrawText("merge", Convert.ToInt32(coor2d.X), Convert.ToInt32(coor2d.Y));

 private void DrawText(string nume_text, int x, int y)

            spriteBatch.DrawString(font, nume_text, new Vector2(x, y), Color.Black);
Feb 13, 2013 at 9:29 AM
Edited Feb 13, 2013 at 9:46 AM
Hi ionutzzzusv and bedarob!

ionutzzzusv, thank you, by the code!!

This code made the word "Follow" move in 2D screen space with the toolbarMarkerNode.

In Tutorial8 , after the "scene.Draw..............." in Draw method:
            string  word = "Follow";

            Matrix view2 = groundMarkerNode.WorldTransformation * State.ViewMatrix;

            Vector3 anyname = new Vector3(0, 0, 10);

           //to solve the "wrong location" problem, just apply the same principle of the red Cube explained in the same tutorial.
            Matrix yourmatrix = Matrix.CreateTranslation(anyname) *
                       toolbarMarkerNode.WorldTransformation *

            Vector3 coord2d = graphics.GraphicsDevice.Viewport.Project(yourmatrix.Translation,
            State.ProjectionMatrix, view2, Matrix.Identity);

            if (toolbarMarkerNode.MarkerFound)
            spriteBatch.DrawString(yourfont, word, new Vector2(coord2d.X, coord2d.Y), Color.YellowGreen);
Hope you can find the solution here.

Feb 13, 2013 at 9:46 AM
Hi Guys!

This was the best solution for me:
Vector3 toolbarCoordinates = graphics.GraphicsDevice.Viewport.Project(
The toolbarCoordinates' X and Y property gets the marker's X and Y coordinate in the screen. I draw a red circle in the middle of the toolbarMarker with it. Thanks your help! ;)
Feb 13, 2013 at 9:53 AM

Much more simple, thank you!