This project is read-only.

Moving Model along with marker

Nov 27, 2011 at 12:32 AM
Edited Nov 27, 2011 at 12:33 AM


   I am new to Goblin XNA. Can some body help me on the following.

I have a sphere model and ground marker. The sphere model should appear just on top of the the Ground Marker and when the marker is moved 

the sphere should move along on the screen. Currently what happens is the sphere appear on different location.


Following is my code.


GeometryNode sphereNode = new GeometryNode("Sphere");           

sphereNode.Model = new Sphere(3, 20, 20);           

sphereNode.AddToPhysicsEngine = true;
Material sphereMaterial = new Material();           

sphereMaterial.Diffuse = new Vector4(0, 0.5f, 0, 1);           

sphereMaterial.Specular = Color.White.ToVector4();           

sphereMaterial.SpecularPower = 10;
sphereNode.Material = sphereMaterial;
_monsterTransformNode6 = new TransformNode           


Translation = new Vector3(0,0,0)           






Nov 27, 2011 at 1:09 AM
Edited Nov 27, 2011 at 1:09 AM

you can update the positioning of the sphere by using the marker worldtransformation matrix in the Draw() method

try this


if (marker.MarkerFound)
                Vector3 fixObject = new Vector3(0,0,0);
                Matrix mat = Matrix.CreateTranslation(fixObject) *

                // Modify the transformation in the physics engine
                ((NewtonPhysics)scene.PhysicsEngine).SetTransform(groundNode.Physics, mat);


put this code before base.Draw

hope this helps

Nov 27, 2011 at 3:16 AM


       Thanks for your support. I could see it moving but I am still not ableto achieve what I am intended to do.
I want the sphere to appear just on top of the marker and move along with the markerwhen I physically move the marker. Now the sphere appears some where else on the screen. When I move the marker, the sphere moves but not on the same pace. At some point the marker starts overtaking the sphere on the screen.


Nov 27, 2011 at 6:38 AM

Can some one help on this please?

Nov 27, 2011 at 7:10 AM

Assuming your marker node is already added to the scene's root node, if you do not intend to perform physics simulation, you should NOT set AddToPhysicsEngine to true. It should appear on top of the marker as it is. Also, you probably want to shift the sphere 3 up toward Z direction so that it will appear exactly on top of the marker.