Пример #1
0
        private void CreateObjects()
        {
            float size = 4.0f;

            // Create a marker node to track a feature-based image.
            // NOTE: If you get an exception here, that means you haven't generated the .dat file yet
            // Please see this
            MarkerNode groundMarkerNode = new MarkerNode(scene.MarkerTracker, "markerless.png.dat");

            // Now add the above nodes to the scene graph in the appropriate order.
            // Note that only the nodes added below the marker node are affected by
            // the marker transformation.
            scene.RootNode.AddChild(groundMarkerNode);

            // Create a geometry node with a model of a box that will be overlaid on top of the image
            GeometryNode boxNode = new GeometryNode("Box")
            {
                Model    = new Box(size),
                Material = new Material()
                {
                    Diffuse       = Color.Red.ToVector4(),
                    Specular      = Color.White.ToVector4(),
                    SpecularPower = 10
                }
            };

            TransformNode boxTrans = new TransformNode()
            {
                Translation = new Vector3(0, 0, -size / 2)
            };

            groundMarkerNode.AddChild(boxTrans);
            boxTrans.AddChild(boxNode);
        }
Пример #2
0
        public Block(MarkerNode markerNode, string[] names, float scale, ref GlobalVariables g)
        {
            global = g;

            buildingsInBlocks = new List <Building>();

            blockNode = markerNode;

            blockTransNode       = new TransformNode();
            blockTransNode.Scale = Vector3.One * scale;
            //////////////////////////////////////////////////////////////////////blockTransNode.Translation = new Vector3(0.0f, -64.25f, 0.0f);
            //blockTransNode.Translation = new Vector3(0.0f, -64.25f, 0.0f);  //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
            //blockTransNode.Translation = new Vector3(-33.5f, -54.25f, 0);
            blockTransNode.Rotation = Quaternion.CreateFromAxisAngle(Vector3.UnitZ, MathHelper.PiOver2);
            blockNode.AddChild(blockTransNode);

            foreach (string s in names)
            {
                //Note, this needs to be changed so we are able to add different buildings to a marker

                Building tempBuilding = new Building(s, ref global);
                tempBuilding.loadBuildingModel(true, 1.0f); //change scale factor if necessary
                buildingsInBlocks.Add(tempBuilding);
                //blockTransNode.AddChild(tempBuilding.getBuildingNode()); /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
                //  blockTransNode.Scale = new Vector3(blockTransNode.Scale.X * 1.0f, blockTransNode.Scale.Y * 1.0f, blockTransNode.Scale.Z * 1.0f);
                //    blockNode.AddChild(blockTransNode);
            }
        }
Пример #3
0
        private GeometryNode ObstModel;                 //Geometry Node und Model

        #endregion

        #region Constructor

        public Game_Weapon(PrimitiveModel BulletModel, Material BulletMaterial, MarkerNode GrdMarkerNode)
        {
            FOV         = NORMAL_FOV;
            DeltaGiro   = DELTA_THETA;
            Active      = true;
            ActAngle    = 0;
            InitAngle   = 0;
            MaxAng      = 360;
            RadActAngle = 0;
            GirDir      = RotDirection.RECHS;
            RotaMode    = RotMode.CONTINUE;

            this.BulletModel = BulletModel;
            BulletMat        = BulletMaterial;
            GMarkerNode      = GrdMarkerNode;

            WBullets = new List <Bullet>();

            //Config type of Shoot
            WaitBullet     = WAIT_SHOOT;
            CountToShoot   = WaitBullet;
            ReloadTime     = WAIT_RELOAD;
            CountToReload  = 0;
            CountOfBullets = 0;
            NumBullets     = Game_Logic.MAX_BULLET;

            RadOffset    = Math.PI * (95) / 180.0;
            BulletOffset = new Vector3(0, 10, 30);
        }
Пример #4
0
        /********************* Basic Elements ****************/

        public GeometryNode CreateCube(MarkerNode Marker, Vector4 CubeColor)
        {
            GeometryNode boxNode;

            // Create a geometry node with a model of a box
            boxNode       = new GeometryNode("Box");
            boxNode.Model = new TexturedBox(32.4f);

            // Add this box model to the physics engine for collision detection
            boxNode.AddToPhysicsEngine = true;
            boxNode.Physics.Shape      = ShapeType.Box;
            // Make this box model cast and receive shadows
            boxNode.Model.ShadowAttribute = ShadowAttribute.ReceiveCast;
            // Assign a shadow shader for this model that uses the IShadowMap we assigned to the scene
            boxNode.Model.Shader = new SimpleShadowShader(GShadowMap);

            // Create a material to apply to the box model
            Material boxMaterial = new Material();

            boxMaterial.Diffuse       = CubeColor;
            boxMaterial.Specular      = Color.White.ToVector4();
            boxMaterial.SpecularPower = 10;

            boxNode.Material = boxMaterial;

            // Add this box model node to the ground marker node
            Marker.AddChild(boxNode);

            return(boxNode);

            // Create a collision pair and add a collision callback function that will be
            // called when the pair collides
            //NewtonPhysics.CollisionPair pair = new NewtonPhysics.CollisionPair(boxNode.Physics, sphereNode.Physics);
            //((NewtonPhysics)scene.PhysicsEngine).AddCollisionCallback(pair, BoxSphereCollision);
        }
Пример #5
0
        private void SetupMarkerTracking()
        {
            DirectShowCapture captureDevice = new DirectShowCapture();

            captureDevice.InitVideoCapture(0, FrameRate._60Hz, Resolution._640x480,
                                           ImageFormat.R8G8B8_24, false);

            scene.AddVideoCaptureDevice(captureDevice);

            // Use ALVAR marker tracker
            ALVARMarkerTracker tracker = new ALVARMarkerTracker();

            tracker.MaxMarkerError = 0.02f;
            tracker.ZNearPlane     = arCameraNode.Camera.ZNearPlane;
            tracker.ZFarPlane      = arCameraNode.Camera.ZFarPlane;

            tracker.InitTracker(captureDevice.Width, captureDevice.Height, "default_calib.xml", 32.4f);

            // Set the marker tracker to use for our scene
            scene.MarkerTracker = tracker;

            // Display the camera image in the background. Note that this parameter should
            // be set after adding at least one video capture device to the Scene class.
            scene.ShowCameraImage = true;

            // Create a marker node to track a ground marker array.
            groundMarkerNode = new MarkerNode(scene.MarkerTracker, "ALVARGroundArray.xml");
            scene.RootNode.AddChild(groundMarkerNode);
        }
Пример #6
0
        void addClick(object sender, EventArgs e)
        {
            using (InputBox box = new InputBox()) {
                box.Label.Text = ResourceService.GetString("Dialog.HighlightingEditor.Markers.EnterName");
                if (box.ShowDialog() == DialogResult.Cancel)
                {
                    return;
                }

                if (box.TextBox.Text == "")
                {
                    return;
                }
                foreach (ListViewItem item in listView.Items)
                {
                    if (item.Text == box.TextBox.Text)
                    {
                        return;
                    }
                }

                MarkerNode   rsn = new MarkerNode(box.TextBox.Text, previous);
                ListViewItem lv  = new ListViewItem(box.TextBox.Text);
                lv.Tag = rsn;
                parentNode.Nodes.Add(rsn);
                listView.Items.Add(lv);
            }
        }
Пример #7
0
            internal static Node ParseNode(EndianReader reader)
            {
                float time     = reader.ReadFloat32();
                int   type     = reader.ReadInt32();
                float duration = reader.ReadFloat32();
                int   data     = reader.ReadInt32();

                Node node = null;

                switch (type)
                {
                case 0x09FFFFFF:                         // marker_t
                    node = new MarkerNode();
                    break;

                case 0x0AFFFFFF:                         // Some sort of XML metadata
                    node = new MarkerNode();
                    break;

                default:
                    node = new Node();
                    break;
                }

                node.Time     = time;
                node.Type     = type;
                node.Duration = duration;
                node.Data     = data;

                return(node);
            }
Пример #8
0
        public static GeometryNode AddModel(MarkerNode Marker, String Folder, String Model, bool IntMaterial, float Scala)
        {
            GeometryNode ObstNode;

            if (Model == "null")
            {
                return(ObstNode = new GeometryNode());
            }

            ObstNode = Graphics3D.LoadModel("Models/" + Folder, Model, IntMaterial);

            //define the Physic Material name
            ObstNode.Physics.MaterialName = "Obstacle";

            TransformNode parentTransNode = new TransformNode();

            parentTransNode.Name     = Model;
            parentTransNode.Scale    = new Vector3(Scala, Scala + 2, Scala);
            parentTransNode.Rotation = Quaternion.CreateFromAxisAngle(new Vector3(1, 0, 0), MathHelper.ToRadians(90));
            //Add Rotation because Blender Axis
            parentTransNode.AddChild(ObstNode);

            // Add this box model node to the ground marker node
            if (Marker != null)
            {
                Marker.AddChild(parentTransNode);
            }

            return(ObstNode);
        }
        MarkerEmitterNode CreateMarkerEmitterNode(Vector2 mouseScreenPos, string markerName)
        {
            // find the marker node with this name
            MarkerNode markerNode = null;

            foreach (var node in graph.Nodes)
            {
                if (node is MarkerNode)
                {
                    var marker = node as MarkerNode;
                    if (marker.Caption == markerName)
                    {
                        markerNode = marker;
                        break;
                    }
                }
            }

            if (markerNode == null)
            {
                // No marker node found with this ids
                return(null);
            }
            var emitterNode = CreateNode <MarkerEmitterNode>(mouseScreenPos);

            emitterNode.Marker = markerNode;
            return(emitterNode);
        }
Пример #10
0
        public override void StoreSettings()
        {
            MarkerNode node = (MarkerNode)parentNode;

            node.What           = nameBox.Text;
            node.HighlightColor = color;
            node.MarkMarker     = checkBox.Checked;
        }
Пример #11
0
        public Catalog(Scene s)
        {
            this.my_scene = s;

            this.marker       = new MarkerNode(my_scene.MarkerTracker, "palette_marker.xml");
            this.changeMarker = new MarkerNode(my_scene.MarkerTracker, "palette_turn_marker.xml");
            my_scene.RootNode.AddChild(marker);
            my_scene.RootNode.AddChild(changeMarker);
            library = new ItemLibrary("models.txt");
            names2itemsInCatalog = new Dictionary <string, Item>();
            names2itemsInRoom    = new Dictionary <string, Item>();
            item_list            = library.getAllItems();
            //  this.objects = l;
            int grid_x = 0;
            int grid_y = 0;

            foreach (Item i in item_list)
            {
                names2itemsInCatalog.Add(i.Label, i);
                i.setGroupID(catalogGroupID);
                i.Scale = new Vector3(9.0f, 9.0f, 9.0f) / i.Radius;
            }
            for (int i = cur_start; i < cur_end && i < item_list.Count; i++)
            {
                if (grid_x > 15)
                {
                    grid_x  = 0;
                    grid_y -= 15;
                }
                item_list[i].BindTo(marker);
                item_list[i].MoveTo(new Vector3(grid_x, grid_y, 0));
                grid_x += 15;
            }

            // Create a geometry node with a model of box
            GeometryNode boxNode = new GeometryNode("Box");

            boxNode.Model = new Box(30, 30, 0.1f);

            TransformNode boxTransNode = new TransformNode();

            boxTransNode.AddChild(boxNode);
            boxTransNode.Translation += new Vector3(6, -6, -0.5f);

            Material boxMat = new Material();

            boxMat.Diffuse = Color.DimGray.ToVector4();

            boxNode.Material = boxMat;

            marker.AddChild(boxTransNode);
        }
Пример #12
0
        public void MarkStart(int index)
        {
            MarkerNode added = new MarkerNode {
                Depth = nodes.Count
            };

            if (nodes.Count > 0)
            {
                nodes.Peek().AddChildOrSibling(added);
            }

            starts.Push(index);
            nodes.Push(added);
        }
Пример #13
0
        public override void LoadSettings()
        {
            MarkerNode node = (MarkerNode)parentNode;

            PropertyService propertyService = (PropertyService)ServiceManager.Services.GetService(typeof(PropertyService));
            IProperties     properties      = ((IProperties)propertyService.GetProperty("NetFocus.DataStructure.TextEditor.Document.DefaultDocumentProperties", new DefaultProperties()));

            sampleLabel.Font = ParseFont(properties.GetProperty("DefaultFont", new Font("Courier New", 10).ToString()));

            color            = node.HighlightColor;
            nameBox.Text     = node.What;
            checkBox.Checked = node.MarkMarker;
            PreviewUpdate(sampleLabel, color);
        }
Пример #14
0
        public void resetBall(MarkerNode groundReference)
        {
            animationStartedApplyGravity = false;
            _position.X = 100;
            _position.Y = 0;
            _position.Z = 100;
            _momentum.X = 0;
            _momentum.Y = 0;
            _momentum.Z = 0;
            bounceCount = 0;

            Matrix mat = Matrix.CreateTranslation(_position);

            ((NewtonPhysics)sc.PhysicsEngine).SetTransform(obj.Physics, mat);
        }
Пример #15
0
        public MarkerOptionPanel(MarkerNode parent, bool prev) : base(parent)
        {
            SetupFromXmlFile(System.IO.Path.Combine(PropertyService.DataDirectory,
                                                    @"resources\panels\HighlightingEditor\Marker.xfrm"));

            chgBtn        = (Button)ControlDictionary["chgBtn"];
            chgBtn.Click += new EventHandler(chgBtnClick);

            checkBox    = (CheckBox)ControlDictionary["checkBox"];
            nameBox     = (TextBox)ControlDictionary["nameBox"];
            sampleLabel = (Label)ControlDictionary["sampleLabel"];

            previous = prev;
            ControlDictionary["explLabel"].Text = ResourceService.GetString(previous ? "Dialog.HighlightingEditor.Marker.ExplanationPrev" : "Dialog.HighlightingEditor.Marker.ExplanationNext");
        }
Пример #16
0
        public static void CreateBall(MarkerNode Marker)
        {
            // Create a geometry node for Sphere
            PrimitiveModel PsphereModel = new Sphere(15f, 20, 20);

            // Create a material to apply to the sphere model
            Material sphereMaterial = new Material();

            sphereMaterial.Diffuse       = new Vector4(0, 0.5f, 0, 1);
            sphereMaterial.Specular      = Color.White.ToVector4();
            sphereMaterial.SpecularPower = 10;

            GeometryNode sphereNode = new GeometryNode("Sphere");

            //sphereNode.Model = new TexturedSphere(16, 20, 20);
            sphereNode.Model    = PsphereModel;
            sphereNode.Material = sphereMaterial;

            // Add this sphere model to the physics engine for collision detection
            sphereNode.Physics.Interactable = true;
            sphereNode.Physics.Collidable   = true;
            sphereNode.Physics.Shape        = ShapeType.Sphere;
            sphereNode.Physics.Mass         = 30;

            //sphereNode.Physics.ApplyGravity = false;
            sphereNode.Physics.InitialLinearVelocity = new Vector3(30, 0, 0);
            //sphereNode.Physics.MaterialName = "Sphere";
            //sphereNode.Physics.ApplyGravity = true;
            sphereNode.AddToPhysicsEngine = true;

            // Make this sphere model cast and receive shadows
            //sphereNode.Model.ShadowAttribute = ShadowAttribute.ReceiveCast;
            // Assign a shadow shader for this model that uses the IShadowMap we assigned to the scene
            //sphereNode.Model.Shader = new SimpleShadowShader(scene.ShadowMap);

            TransformNode sphereTransNode = new TransformNode();

            sphereTransNode.Translation = new Vector3(50, 0, 50);

            // Now add the above nodes to the scene graph in the appropriate order.
            // Note that only the nodes added below the marker node are affected by
            // the marker transformation.
            Marker.AddChild(sphereTransNode);
            sphereTransNode.AddChild(sphereNode);
        }
Пример #17
0
        public override void updatePosition(MarkerNode groundReference)
        {
            int deltaT = (DateTime.Now - lastTimePositionWasUpdated).Milliseconds;

            _position += _momentum * deltaT;

            Matrix mat = Matrix.CreateTranslation(_position);

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

            lastTimePositionWasUpdated = DateTime.Now;

            if (bounceCount > MAXRBOUNCEBEFORERESET)
            {
                resetBall(groundReference);
            }
            //if (_position.LengthSquared() > 1000000)
            //{
            //    resetBall(groundReference);
            //}
            Vector3    groundScale;
            Quaternion groundQuaternion;
            Vector3    groundTranslation;

            groundReference.WorldTransformation.Decompose(out groundScale, out groundQuaternion, out groundTranslation);
            Vector3    ballScale;
            Quaternion ballQuaternion;
            Vector3    ballTranslation;

            obj.Physics.PhysicsWorldTransform.Decompose(out ballScale, out ballQuaternion, out ballTranslation);

            float ball_ground_distance_squared = (groundTranslation - ballTranslation).LengthSquared();

            if ((ballTranslation).LengthSquared() > 400000)
            {
                resetBall(groundReference);
            }
        }
Пример #18
0
        private static void DestroyEmitterNodes(Graph graph, MarkerNode markerNode)
        {
            var emitterNodes = new List <GraphNode>();

            foreach (var node in graph.Nodes)
            {
                if (node is MarkerEmitterNode)
                {
                    var emitterNode = node as MarkerEmitterNode;
                    if (emitterNode.Marker == markerNode)
                    {
                        emitterNodes.Add(emitterNode);
                    }
                }
            }

            // delete the emitter nodes
            foreach (var emitterNode in emitterNodes)
            {
                DestroyNode(emitterNode);
            }
        }
Пример #19
0
        public void Save(EndianReader writer)
        {
            Nodes.Sort(new NodeComparer());
            int stringoffset = Nodes.Count * 0x10;

            // First build the stringtable
            MemoryStream stringtable = new MemoryStream();
            EndianReader swriter     = new EndianReader(stringtable, writer.Endian);

            foreach (Node node in Nodes)
            {
                MarkerNode marker = node as MarkerNode;
                if (marker != null)
                {
                    marker.Data = stringoffset;
                    swriter.Write(Util.Encoding.GetBytes(marker.Text));
                    swriter.Write((byte)0);
                    stringoffset += marker.Text.Length + 1;
                }
            }

            writer.Write(Version);
            writer.Write(Checksum);
            writer.Write(Nodes.Count);
            writer.Write((int)stringtable.Length);

            foreach (Node node in Nodes)
            {
                node.Save(writer);
            }

            stringtable.Position = 0;
            Util.StreamCopy(writer.Base, stringtable);

            writer.PadToMultiple(0x20);
        }
Пример #20
0
        public static Mub Create(EndianReader reader)
        {
            Mub mub = new Mub();

            mub.Version = reader.ReadInt32();

            if (mub.Version != 1 && mub.Version != 2)
            {
                throw new FormatException();                 // Unknown version number
            }
            mub.Checksum = reader.ReadInt32();

            int nodes    = reader.ReadInt32();
            int datasize = reader.ReadInt32();

            long begin = reader.Position;

            for (int i = 0; i < nodes; i++)
            {
                Node node = Node.ParseNode(reader);

                mub.Nodes.Add(node);
            }

            foreach (Node node in mub.Nodes)
            {
                MarkerNode mark = node as MarkerNode;
                if (mark != null)
                {
                    reader.Position = begin + mark.Data;
                    mark.Text       = Util.ReadCString(reader.Base);
                }
            }

            return(mub);
        }
Пример #21
0
        public Graphics3D(MarkerNode MarkerNode, IShadowMap ShadowMap)
        {
            //Asignation Ground Node
            this.groundMarkerNode = MarkerNode;
            //Asignation Shadow Map
            this.GShadowMap = ShadowMap;

            //Add Big Parent for All Scenary Elements
            parentTNodeGrd      = new TransformNode();
            parentTNodeGrd.Name = "Level";
            groundMarkerNode.AddChild(parentTNodeGrd);

            // Create a material for the model
            BulletrMat               = new Material();
            BulletrMat.Diffuse       = Color.Blue.ToVector4();
            BulletrMat.Specular      = Color.White.ToVector4();
            BulletrMat.SpecularPower = 10;

            //create Bullet Model
            BulletModel = new TexturedBox(2.0f);

            LoadLevel = false;
            LoadCars  = false;
        }
Пример #22
0
        private void createObjects()
        {
            // Create a marker node to track the ground array
            ground_marker_node = new MarkerNode(scene.MarkerTracker, "SlimeGroundArray.xml", NyARToolkitTracker.ComputationMethod.Average);
            scene.RootNode.AddChild(ground_marker_node);

            InvisibleWall invisWallOne   = new InvisibleWall(float.MaxValue, new Vector3(COURT_WIDTH, PLANAR_THICKNESS, COURT_LENGTH));
            InvisibleWall invisWallTwo   = new InvisibleWall(float.MaxValue, new Vector3(PLANAR_THICKNESS, COURT_LENGTH, COURT_LENGTH));
            InvisibleWall invisWallThree = new InvisibleWall(float.MaxValue, new Vector3(COURT_WIDTH, PLANAR_THICKNESS, COURT_LENGTH));
            InvisibleWall invisWallFour  = new InvisibleWall(float.MaxValue, new Vector3(PLANAR_THICKNESS, COURT_LENGTH, COURT_LENGTH));

            invisWallOne.translate(new Vector3(0, COURT_LENGTH / 2, COURT_LENGTH / 2));
            invisWallTwo.translate(new Vector3(-(COURT_WIDTH / 2), 0, COURT_LENGTH / 2));
            invisWallThree.translate(new Vector3(0, -(COURT_LENGTH / 2), COURT_LENGTH / 2));
            invisWallFour.translate(new Vector3(COURT_WIDTH / 2, 0, COURT_LENGTH / 2));

            // Add the walls onto the ground marker
            ground_marker_node.AddChild(invisWallOne.getTransformNode());
            ground_marker_node.AddChild(invisWallTwo.getTransformNode());
            ground_marker_node.AddChild(invisWallThree.getTransformNode());
            ground_marker_node.AddChild(invisWallFour.getTransformNode());

            // Create the court
            court = new Court(float.MaxValue, new Vector3(COURT_WIDTH, COURT_LENGTH, PLANAR_THICKNESS * 4));
            // Initial translation
            court.translate(new Vector3(0, 0, -14f));
            // Add it to the scene
            ground_marker_node.AddChild(court.getTransformNode());

            // Time to create the net
            Net net = new Net(float.MaxValue, new Vector3(COURT_WIDTH, PLANAR_THICKNESS, GROUND_MARKER_SIZE));

            // Initial translation
            net.translate(new Vector3(0, 0, 1f + (GROUND_MARKER_SIZE / 2)));
            // Add it to the scene
            ground_marker_node.AddChild(net.getTransformNode());

            // Lets create the all important volleyball
            if (selected_game_type == (int)game_types.opponent)
            {
                vball = new VolleyBall(1f, GROUND_MARKER_SIZE / 2f, bounceSound, true);
            }
            else
            {
                vball = new VolleyBall(1f, GROUND_MARKER_SIZE / 2f, bounceSound, false);
            }
            // Perform initial manipulations
            vball.translate(PLAYER_BALL_START);
            // Add it to the scene
            ground_marker_node.AddChild(vball.getTransformNode());

            // Create a marker node to track the paddle
            player_marker_node = new MarkerNode(scene.MarkerTracker, "id511.xml", NyARToolkitTracker.ComputationMethod.Average);
            scene.RootNode.AddChild(player_marker_node);

            // Create the slime for the player
            //player_slime = new Paddle(float.MaxValue, new Vector3(WAND_MARKER_SIZE * 1.5f, WAND_MARKER_SIZE * 1.5f, 3f), Color.Red.ToVector4());
            player_slime = new Slime(float.MaxValue, GROUND_MARKER_SIZE, new Vector4(0.160784f, 0.501961f, 0.72549f, 1f), COURT_WIDTH / 2, -1 * COURT_WIDTH / 2, 0f, -1 * COURT_LENGTH / 2);
            // Initial translation
            player_slime.translate(PLAYER_SLIME_START);
            //player_slime.setRotation(Quaternion.CreateFromAxisAngle(Vector3.UnitX, MathHelper.ToRadians(-PADDLE_ANGLE)));
            //player_slime.setRotation(Quaternion.CreateFromAxisAngle(Vector3.UnitX, MathHelper.ToRadians(90)));
            // Add it to the scene
            ground_marker_node.AddChild(player_slime.getTransformNode());

            // Create the slime for the opponent
            //opponent_slime = new Paddle(float.MaxValue, new Vector3(WAND_MARKER_SIZE  * 1.5f, WAND_MARKER_SIZE * 1.5f, 3f), Color.Purple.ToVector4());
            opponent_slime = new Slime(float.MaxValue, GROUND_MARKER_SIZE, new Vector4(0.556863f, 0.266667f, 0.678431f, 1f), COURT_WIDTH / 2, -1 * COURT_WIDTH / 2, COURT_LENGTH / 2, 0f);
            // Initial translation
            opponent_slime.translate(OPPONENT_SLIME_START);
            //opponent_slime.setRotation(Quaternion.CreateFromAxisAngle(Vector3.UnitX, MathHelper.ToRadians(PADDLE_ANGLE)));
            //opponent_slime.setRotation(Quaternion.CreateFromAxisAngle(Vector3.UnitX, MathHelper.ToRadians(90)));
            // Add it to the scene
            ground_marker_node.AddChild(opponent_slime.getTransformNode());

            // Create the laser sight target
            target = new Target(TARGET_SIZE, Color.Red.ToVector4());
            // perform initial translations
            target.setTranslation(new Vector3(PLAYER_BALL_START.X, PLAYER_BALL_START.Y, (TARGET_SIZE / 2) + PLANAR_THICKNESS));
            // Add it to the scene
            ground_marker_node.AddChild(target.getTransformNode());
        }
Пример #23
0
        private void SetupMarkerTracking()
        {
            DirectShowCapture captureDevice = new DirectShowCapture();

            captureDevice.InitVideoCapture(0, FrameRate._30Hz, Resolution._640x480,
                                           ImageFormat.R8G8B8_24, false);

            // Add this video capture device to the scene so that it can be used for
            // the marker tracker
            scene.AddVideoCaptureDevice(captureDevice);

            // if we're using Wrap920AR, then we need to add another capture device for
            // processing stereo camera
            DirectShowCapture captureDevice2 = null;

            if (iTracker.ProductID == iWearDllBridge.IWRProductID.IWR_PROD_WRAP920)
            {
                captureDevice2 = new DirectShowCapture();
                captureDevice2.InitVideoCapture(1, FrameRate._30Hz, Resolution._640x480,
                                                ImageFormat.R8G8B8_24, false);

                scene.AddVideoCaptureDevice(captureDevice2);

                // Calculate the right projection matrix using the camera intrinsic parameters for the
                // right camera
                ((StereoCamera)scene.CameraNode.Camera).RightProjection =
                    ALVARDllBridge.GetCameraProjection("Wrap920_Right.xml", captureDevice2.Width,
                                                       captureDevice2.Height, 0.1f, 1000);
            }

            // Create an optical marker tracker that uses ALVAR library
            ALVARMarkerTracker tracker = new ALVARMarkerTracker();

            tracker.MaxMarkerError = 0.02f;
            tracker.ZNearPlane     = 0.1f;
            tracker.ZFarPlane      = 1000;
            tracker.InitTracker(captureDevice.Width, captureDevice.Height, "Wrap920_Left.xml", markerSize);

            ((StereoCamera)scene.CameraNode.Camera).LeftProjection = tracker.CameraProjection;

            scene.MarkerTracker = tracker;

            if (iTracker.ProductID == iWearDllBridge.IWRProductID.IWR_PROD_WRAP920)
            {
                scene.LeftEyeVideoID  = 0;
                scene.RightEyeVideoID = 1;
                scene.TrackerVideoID  = 0;
            }
            else
            {
                scene.LeftEyeVideoID  = 0;
                scene.RightEyeVideoID = 0;
                scene.TrackerVideoID  = 0;
            }

            // Create a marker node to track a ground marker array.
            groundMarkerNode = new MarkerNode(scene.MarkerTracker, "ALVARGroundArray.xml");

            // Add a transform node to tranlate the objects to be centered around the
            // marker board.
            TransformNode transNode = new TransformNode();

            scene.RootNode.AddChild(groundMarkerNode);

            scene.ShowCameraImage = true;
        }
Пример #24
0
        private void CreateObjects()
        {
            // Create a geometry node with a model of a sphere that will be overlaid on
            // top of the ground marker array
            GeometryNode sphereNode = new GeometryNode("Sphere");

            // We will use TexturedSphere instead of regular Box class since we will need the
            // texture coordinates elements for passing the vertices to the SimpleShadowShader
            // we will be using
            sphereNode.Model = new TexturedSphere(16, 20, 20);

            // Add this sphere model to the physics engine for collision detection
            sphereNode.AddToPhysicsEngine = true;
            sphereNode.Physics.Shape      = ShapeType.Sphere;
            // Make this sphere model cast and receive shadows
            sphereNode.Model.ShadowAttribute = ShadowAttribute.ReceiveCast;
            // Assign a shadow shader for this model that uses the IShadowMap we assigned to the scene
            sphereNode.Model.Shader = new SimpleShadowShader(scene.ShadowMap);

            // Create a marker node to track a ground marker array.
            groundMarkerNode = new MarkerNode(scene.MarkerTracker, "ALVARGroundArray.xml");

            TransformNode sphereTransNode = new TransformNode();

            sphereTransNode.Translation = new Vector3(0, 0, 50);

            // Create a material to apply to the sphere model
            Material sphereMaterial = new Material();

            sphereMaterial.Diffuse       = new Vector4(0, 0.5f, 0, 1);
            sphereMaterial.Specular      = Color.White.ToVector4();
            sphereMaterial.SpecularPower = 10;

            sphereNode.Material = sphereMaterial;

            // Now add the above nodes to the scene graph in the appropriate order.
            // Note that only the nodes added below the marker node are affected by
            // the marker transformation.
            scene.RootNode.AddChild(groundMarkerNode);
            groundMarkerNode.AddChild(sphereTransNode);
            sphereTransNode.AddChild(sphereNode);

            // Create a geometry node with a model of a box that will be overlaid on
            // top of the ground marker array initially. (When the toolbar marker array is
            // detected, it will be overlaid on top of the toolbar marker array.)
            boxNode = new GeometryNode("Box");
            // We will use TexturedBox instead of regular Box class since we will need the
            // texture coordinates elements for passing the vertices to the SimpleShadowShader
            // we will be using
            boxNode.Model = new TexturedBox(32.4f);

            // Add this box model to the physics engine for collision detection
            boxNode.AddToPhysicsEngine = true;
            boxNode.Physics.Shape      = ShapeType.Box;
            // Make this box model cast and receive shadows
            boxNode.Model.ShadowAttribute = ShadowAttribute.ReceiveCast;
            // Assign a shadow shader for this model that uses the IShadowMap we assigned to the scene
            boxNode.Model.Shader = new SimpleShadowShader(scene.ShadowMap);

            // Create a marker node to track a toolbar marker array.
            toolbarMarkerNode = new MarkerNode(scene.MarkerTracker, "ALVARToolbar.xml");

            scene.RootNode.AddChild(toolbarMarkerNode);

            // Create a material to apply to the box model
            Material boxMaterial = new Material();

            boxMaterial.Diffuse       = new Vector4(0.5f, 0, 0, 1);
            boxMaterial.Specular      = Color.White.ToVector4();
            boxMaterial.SpecularPower = 10;

            boxNode.Material = boxMaterial;

            // Add this box model node to the ground marker node
            groundMarkerNode.AddChild(boxNode);

            // Create a collision pair and add a collision callback function that will be
            // called when the pair collides
            NewtonPhysics.CollisionPair pair = new NewtonPhysics.CollisionPair(boxNode.Physics, sphereNode.Physics);
            ((NewtonPhysics)scene.PhysicsEngine).AddCollisionCallback(pair, BoxSphereCollision);
        }
Пример #25
0
 public virtual void updatePosition(MarkerNode groundReference)
 {
 }
Пример #26
0
        private void CreateObjects()
        {
            // Create a marker node to track a ground marker array.
            groundMarkerNode = new MarkerNode(scene.MarkerTracker, "ALVARGroundArray.xml");


            // Now add the above nodes to the scene graph in the appropriate order.
            // Note that only the nodes added below the marker node are affected by
            // the marker transformation.
            scene.RootNode.AddChild(groundMarkerNode);

            // Create a geometry node with a model of a box that will be overlaid on
            // top of the ground marker array initially. (When the toolbar marker array is
            // detected, it will be overlaid on top of the toolbar marker array.)
            boxNode = new GeometryNode("Box");
            // We will use TexturedBox instead of regular Box class since we will need the
            // texture coordinates elements for passing the vertices to the SimpleShadowShader
            // we will be using
            boxNode.Model = new TexturedBox(100f, 100f, 5);

            // Add this box model to the physics engine for collision detection
            boxNode.AddToPhysicsEngine = true;
            boxNode.Physics.Shape      = ShapeType.Box;
            // Make this box model cast and receive shadows
            boxNode.Model.ShadowAttribute = ShadowAttribute.ReceiveCast;
            // Assign a shadow shader for this model that uses the IShadowMap we assigned to the scene
            boxNode.Model.Shader = new SimpleShadowShader(scene.ShadowMap);

            // Create a marker node to track a toolbar marker array.
            toolbarMarkerNode = new MarkerNode(scene.MarkerTracker, "ALVARToolbar.xml");

            scene.RootNode.AddChild(toolbarMarkerNode);

            // Create a material to apply to the box model
            Material boxMaterial = new Material();

            boxMaterial.Diffuse       = new Vector4(0.5f, 0, 0, 1);
            boxMaterial.Specular      = Color.White.ToVector4();
            boxMaterial.SpecularPower = 10;

            boxNode.Material = boxMaterial;

            // Add this box model node to the ground marker node
            groundMarkerNode.AddChild(boxNode);

            p1Tiro = new Tiro("p1Tiro", new Vector3(150, 0, 300), 1, 20, scene, groundMarkerNode);
            groundMarkerNode.AddChild(p1Tiro.objTransfNode);
            updatables.Add(p1Tiro);

            NewtonPhysics.CollisionPair CannonPlayerColisionPair = new NewtonPhysics.CollisionPair(p1Tiro.obj.Physics, boxNode.Physics);

            ((NewtonPhysics)scene.PhysicsEngine).AddCollisionCallback(CannonPlayerColisionPair, playerShot);

            targetNode = new GeometryNode("Box");
            // We will use TexturedBox instead of regular Box class since we will need the
            // texture coordinates elements for passing the vertices to the SimpleShadowShader
            // we will be using
            targetNode.Model = new TexturedBox(20f, 20f, 5);

            // Add this box model to the physics engine for collision detection
            targetNode.AddToPhysicsEngine = true;
            targetNode.Physics.Shape      = ShapeType.Box;
            // Make this box model cast and receive shadows
            targetNode.Model.ShadowAttribute = ShadowAttribute.ReceiveCast;
            // Assign a shadow shader for this model that uses the IShadowMap we assigned to the scene
            targetNode.Model.Shader = new SimpleShadowShader(scene.ShadowMap);

            Material targetMaterial = new Material();

            targetMaterial.Diffuse       = Color.Indigo.ToVector4();
            targetMaterial.Specular      = Color.DarkGoldenrod.ToVector4();
            targetMaterial.SpecularPower = 10;

            targetNode.Material = targetMaterial;

            groundMarkerNode.AddChild(targetNode);

            NewtonPhysics.CollisionPair PlayerScoreColisionPair = new NewtonPhysics.CollisionPair(p1Tiro.obj.Physics, targetNode.Physics);

            ((NewtonPhysics)scene.PhysicsEngine).AddCollisionCallback(PlayerScoreColisionPair, playerScore);
        }
Пример #27
0
        private TransformNode BulletTrans;          //Transfor Node for Bullet

        #endregion

        #region Constructors

        public Bullet(Vector3 InitPos, PrimitiveModel BulletModel, Material Material, Vector3 DirBullet, MarkerNode grdMarkerNode)
        {
            //Create Bullet
            ShootBullet       = new GeometryNode();
            ShootBullet.Name  = "ShootBullet" + ShootBullet.ID;
            ShootBullet.Model = BulletModel;

            ShootBullet.Material             = Material;
            ShootBullet.Physics.Interactable = true;
            ShootBullet.Physics.Collidable   = true;
            ShootBullet.Physics.Shape        = GoblinXNA.Physics.ShapeType.Box;
            ShootBullet.Physics.Mass         = 60f;
            ShootBullet.Physics.MaterialName = "Bullet";
            ShootBullet.AddToPhysicsEngine   = true;

            // Assign the initial velocity to this shooting box
            ShootBullet.Physics.InitialLinearVelocity = new Vector3(DirBullet.X * 80, DirBullet.Y * 80, DirBullet.Z * 50);

            BulletTrans             = new TransformNode();
            BulletTrans.Translation = InitPos;

            grdMarkerNode.AddChild(BulletTrans);
            BulletTrans.AddChild(ShootBullet);

            //Normal asignament
            isvisible = true;

            //Agrego Segundo desde que se creo
            livetime = Convert.ToInt32(DateTime.Now.TimeOfDay.TotalSeconds) + BULLET_TIMELIVE;
        }
Пример #28
0
 //Associate building marker with an ARTag
 public void setMarkerNode(MarkerNode markerName)
 {
     blockNode = markerName;
 }
Пример #29
0
        public void CreateObjects()
        {
            floor       = new GeometryNode("Floor");//floor
            floor.Model = new Box(floorBreadth, floorLength, 0.0001f);
            floor.Model.ReceiveShadows = true;
            floorTransNode             = new TransformNode();
            floorTransNode.Translation = new Vector3(floorBreadth / 3, -floorLength / 2, 0);      // 0 0
            floor.Physics.Collidable   = true;
            floor.Physics.Pickable     = true;
            floor.GroupID            = roomGroupID;
            floor.Physics.Shape      = GoblinXNA.Physics.ShapeType.Box;
            floor.AddToPhysicsEngine = true;
            //grid1.IsOccluder = true;


            //Material for the room floor
            floorMaterial = new Material();
            Vector4 alpha     = Color.Gray.ToVector4();
            Vector3 tempAlpha = new Vector3(alpha.X, alpha.Y, alpha.Z);

            floorMaterial.Diffuse       = new Vector4(tempAlpha, 0.2f);
            floorMaterial.Specular      = Color.White.ToVector4();
            floorMaterial.SpecularPower = 20;

            floor.Material = floorMaterial;

            //Material for the walls
            wallsMaterial               = new Material();
            wallsMaterial.Diffuse       = Color.Gray.ToVector4();
            wallsMaterial.Specular      = Color.White.ToVector4();
            wallsMaterial.SpecularPower = 20;

            frontWall                      = new GeometryNode("Front wall");//front wall
            frontWall.Model                = new Box(floorBreadth, floorLength, 1);
            frontWallTransNode             = new TransformNode();
            frontWallTransNode.Translation = new Vector3(floorBreadth / 3, 0, floorLength / 2);  // 1 0
            frontWallTransNode.Rotation    = Quaternion.CreateFromAxisAngle(Vector3.UnitX, MathHelper.ToRadians(90));
            frontWall.Material             = wallsMaterial;
            frontWall.GroupID              = roomGroupID;
            frontWall.AddToPhysicsEngine   = true;
            frontWall.Physics.Collidable   = true;
            frontWall.Physics.Pickable     = true;
            frontWall.Physics.Shape        = GoblinXNA.Physics.ShapeType.Box;



            rightWall                      = new GeometryNode("Right wall");//right side wall
            rightWall.Model                = new Box(floorBreadth, floorLength, 1);
            rightWallTransNode             = new TransformNode();
            rightWallTransNode.Translation = new Vector3(floorBreadth * 4.2f / 5, -floorLength / 2, floorLength / 2); // -1 0
            rightWallTransNode.Rotation    = Quaternion.CreateFromAxisAngle(Vector3.UnitY, MathHelper.ToRadians(90));
            rightWall.Material             = wallsMaterial;
            rightWall.AddToPhysicsEngine   = true;
            rightWall.GroupID              = roomGroupID;
            rightWall.Physics.Pickable     = true;
            rightWall.Physics.Collidable   = true;
            rightWall.Physics.Shape        = GoblinXNA.Physics.ShapeType.Box;



            // Create a marker node to track a ground marker array.
#if USE_ARTAG
            groundMarkerNode = new MarkerNode(scene.MarkerTracker, "ground");

            // Since we expect that the ground marker array won't move very much, we use a
            // small smoothing alpha.
            //groundMarkerNode.Smoother = new DESSmoother(0.2f, 0.1f, 1, 1);
#else
            //   groundMarkerNode = new MarkerNode(scene.MarkerTracker, "ALVARGroundArray.xml");
            groundMarkerNode = new MarkerNode(this.scene.MarkerTracker, "ALVARConfig.txt");
#endif



            // Now add the above nodes to the scene graph in the appropriate order.
            // Note that only the nodes added below the marker node are affected by
            // the marker transformation.
            scene.RootNode.AddChild(groundMarkerNode);



            //Change the toolbar.txt config file. As of now, toolbar has markers included in the long stretch-alvarConfig.txt
            worldInMiniatureMarkerNode = new MarkerNode(scene.MarkerTracker, "ALVARConfig32_33.txt");


            scene.RootNode.AddChild(worldInMiniatureMarkerNode);



            groundMarkerNode.AddChild(floorTransNode);
            floorTransNode.AddChild(floor);


            groundMarkerNode.AddChild(frontWallTransNode);
            frontWallTransNode.AddChild(frontWall);

            groundMarkerNode.AddChild(rightWallTransNode);
            rightWallTransNode.AddChild(rightWall);
        }
Пример #30
0
        public Tiro(String name, Vector3 inicialPosition, int _mass, int size, Scene scene, MarkerNode groundReference)
        {
            bounceCount = 0;

            animationStartedApplyGravity = false;

            sc = scene;

            obj       = new GeometryNode(name);
            _momentum = new Vector3(0, 0, 0);
            _position = inicialPosition;
            obj.Model = new TexturedSphere(size, 20, 20);
            obj.AddToPhysicsEngine    = true;
            obj.Physics.Shape         = ShapeType.Sphere;
            obj.Model.ShadowAttribute = ShadowAttribute.ReceiveCast;
            obj.Model.Shader          = new SimpleShadowShader(scene.ShadowMap);

            obj.Physics.Interactable = true;
            obj.Physics.Collidable   = true;
            obj.Physics.Shape        = GoblinXNA.Physics.ShapeType.Sphere;
            obj.Physics.Mass         = 30f;
            obj.Physics.MaterialName = "CannonBall";
            obj.Physics.ApplyGravity = false;

            objTransfNode = new TransformNode(_position);
            objTransfNode.AddChild(obj);

            Material objMaterial = new Material();

            objMaterial.Diffuse       = new Vector4(0, 0.5f, 0, 1);
            objMaterial.Specular      = Color.White.ToVector4();
            objMaterial.SpecularPower = 10;

            obj.Material = objMaterial;

            mass = _mass;

            lastTimePositionWasUpdated = DateTime.Now;

            resetBall(groundReference);
        }