I can't see model on the marker

Nov 13, 2010 at 9:37 AM

Hi, My code was functioned in goblin v3.3, but now I use v3.5. Here is code or here is project http://obohatenarealit.svn.sourceforge.net/viewvc/obohatenarealit/. On marker I can't see model or cube for example.
This is code from goblin, something is change.

DominoGame.cs

        protected override void Initialize()
        {
            // Initialize the GoblinXNA framework
            State.InitGoblin(graphics, Content, "");

            Sound.Initialize("ARDomino");

            // Initialize the scene graph
            scene = new Scene(this);

            scene.PhysicsEngine = new NewtonPhysics();
            // Make the physics simulation space larger to 500x500 centered at the origin
            ((NewtonPhysics)scene.PhysicsEngine).WorldSize = new BoundingBox(Vector3.One * -250,
                Vector3.One * 250);

            // Use ALVAR tracking libraryF
            markerLibrary = MarkerLibrary.ALVAR;

            SetupMarkerTracking();

            // Set up the lights used in the scene
            CreateLights();

            CreateGround();

            DManager = new DominoManager(dominos, markerNode, Content, graphics.GraphicsDevice);
            DManager.LoadDominos();
            List<DominoBoxFull> bigBoxes = DManager.getBigBoxes();
            SManager = new SoundManager(bigBoxes);
            DRecorder = new DominoRecorder();

            uiManager.Initialize(scene, GameModeSwitched, Content);

            // Show Frames-Per-Second on the screen for debugging
            State.ShowFPS = true;

            MouseInput.Instance.MousePressEvent += new HandleMousePress(MousePressHandler);
            MouseInput.Instance.MouseDragEvent += new HandleMouseDrag(MouseDragHandler);
            MouseInput.Instance.MouseReleaseEvent += new HandleMouseRelease(MouseReleaseHandler);
            MouseInput.Instance.MouseMoveEvent += new HandleMouseMove(MouseMoveHandler);

            KeyboardInput.Instance.KeyPressEvent += new HandleKeyPress(KeyPressHandler);
            KeyboardInput.Instance.KeyReleaseEvent += new HandleKeyRelease(KeyReleaseHandler);

#if DEBUG
            GoblinXNA.State.ShowNotifications = true;

#endif
            base.Initialize();
        }


        private void SetupMarkerTracking()
        {
            DirectShowCapture captureDevice = new DirectShowCapture();
            captureDevice.InitVideoCapture(0, FrameRate._30Hz, Resolution._320x240, ImageFormat.R8G8B8_24, false);
            //captureDevice.InitVideoCapture(0, FrameRate._30Hz, Resolution._640x480, ImageFormat.R8G8B8_24, false);

            scene.AddVideoCaptureDevice(captureDevice);

            IMarkerTracker tracker = null;
            if (markerLibrary == MarkerLibrary.ARTag)
            {
                tracker = new ARTagTracker();
                tracker.InitTracker(638.052f, 633.673f, captureDevice.Width, captureDevice.Height,
                    false, "ARDominoARTag.cf");
            }
            else
            {
                tracker = new ALVARMarkerTracker();
                ((ALVARMarkerTracker)tracker).MaxMarkerError = 0.02f;
                tracker.InitTracker(100, 200, "configs/calib.xml", 9.0);

            }

            scene.MarkerTracker = tracker;

            scene.ShowCameraImage = true;

            scene.PhysicsEngine.GravityDirection = -Vector3.UnitZ;

            // Create a marker node to track the ground plane
            if (markerLibrary == MarkerLibrary.ARTag)
            {
                markerNode = new MarkerNode(scene.MarkerTracker, "ground");
            }
            else
            {
                int[] ids = new int[54];
                for (int i = 0; i < ids.Length; i++)
                    ids[i] = i;
                markerNode = new MarkerNode(scene.MarkerTracker, "markerDefinitions/ARDominoALVAR.txt", ids);
                //int[] ids2 = new int[1];
                //ids2[0] = 100;
                //markerNode = new MarkerNode(scene.MarkerTracker, "ALVARConfigFromXML.txt", ids2);
            }

            scene.RootNode.AddChild(markerNode);
        }

        public static GeometryNode getGround(int id)
        {
            GeometryNode groundNode = new GeometryNode("Ground_" + id.ToString());
            groundNode.Model = new Box(126, 86, 0.2f);
           
            groundNode.Physics.Collidable = true;
            groundNode.Physics.Shape = ShapeType.Box;
            groundNode.Physics.MaterialName = "Ground";
            groundNode.Physics.Pickable = true;
            groundNode.AddToPhysicsEngine = true;
            groundNode.IsOccluder = true;

            groundNode.Model.ReceiveShadows = true;

            Material groundMaterial = new Material();
            groundMaterial.Diffuse = Color.White.ToVector4();
            groundMaterial.Specular = Color.White.ToVector4();
            groundMaterial.SpecularPower = 20;

            groundNode.Material = groundMaterial;
            return groundNode;
        }
    
    private void CreateGround()
        {
            markerNode.AddChild(getGround(-1));
        }


Here curMarkerNode contains for example marker_100.txt and markerID is id of marker like 100.png, these informations are reload from xml, where are definitions
for models, texture, idmarker ...
DominoManager.cs
            for (int i = 0; i < NodeList.Count; i++)
            {
                node = NodeList[i];
                //create new tool which is made from 81 boxes
                DominoBoxFull Box;
                int[] ids = new int[1];
                ids[0] = Convert.ToInt32(node.SelectSingleNode("markerID").InnerText);
                string markerConfPath = "markerDefinitions/marker_" + ids[0].ToString() + ".txt";
                MarkerNode curMarkerNode = new MarkerNode(DominoGame.scene.MarkerTracker, markerConfPath, ids);
                //  string soundFile = node.SelectSingleNode("sound").InnerText;
                //markerNode.AddChild(curMarkerNode);
                DominoGame.scene.RootNode.AddChild(curMarkerNode);
               
                Box = new DominoModel(dominos, curMarkerNode, i, Content, graphics);
                bigBoxes.Add(Box);
            }

This class is called from DominoManager.cs
DominoModel.cs
               ModelLoader loader = new ModelLoader();
            Model shipModel = (Model)loader.Load("", model);
            dominoModel = shipModel;
            dominoModel.CastShadows = true;
            dominoModel.ReceiveShadows = true;
            GeometryNode dominoNode = new GeometryNode(name);
            dominoNode.Model = dominoModel;
            dominoNode.Physics.Mass = 20;
            dominoNode.Physics.Shape = ShapeType.Box;
            dominoNode.Physics.MaterialName = "Domino";
            dominoNode.Physics.Pickable = true;
            dominoNode.AddToPhysicsEngine = true;
            Material dominoMaterial = new Material();
            dominoMaterial.Diffuse = new Color(red, green, blue).ToVector4();
            colorTexture = new Color(red, green, blue);
            dominoMaterial.Specular = new Color(red, green, blue, alpha).ToVector4();
            dominoMaterial.SpecularPower = 10;
            dominoNode.UserData = properties;
            dominoMaterial.Texture = Content.Load<Texture2D>(texture);
            dominoNode.Material = dominoMaterial;
            TransformNode dominoTransNode = new TransformNode();
            markerNode.AddChild(dominoTransNode);
            dominoTransNode.AddChild(dominoNode);
            dominos.Add(dominoNode);

Why I can't see model on marker, can you someone advice me pls,
Thank you
Monika

Nov 17, 2010 at 11:57 AM
Edited Nov 17, 2010 at 6:00 PM

I used marker for version 3.3, so I realized that for version 3.5 I have to use other markers, because for example MarkerData_150 doesn't function.

Coordinator
Nov 17, 2010 at 8:18 PM

Really? If you're using ALVAR for 3.3, then it should work for 3.5 unless there are some changes in ALVAR package for their latest version.

By the way, I do not have time to look into large set of codes.

Ohan

Nov 18, 2010 at 4:43 PM

I have yet tried once, and I noticed that I had set different path in version 3.3 than version 3.5 so markers are OK, sorry for post, My mistake.

Monika