Exemple #1
0
        public void CreateGround(bool Occluder)
        {
            GeometryNode groundNode = new GeometryNode("Ground");

            //Cordenates X, y, Z
            groundNode.Model = new TexturedBox(324, 180, 0.1f);

            // Set this model Occluded ist or not
            groundNode.IsOccluder = Occluder;

            //Setup Physics Aspecte
            groundNode.Physics.Collidable   = true;
            groundNode.Physics.Shape        = GoblinXNA.Physics.ShapeType.Box;
            groundNode.Physics.MaterialName = "Ground";
            groundNode.AddToPhysicsEngine   = true;

            // Make the ground model to receive shadow casted by other objects
            groundNode.Model.ShadowAttribute = ShadowAttribute.ReceiveOnly;
            // Assign a shadow shader
            groundNode.Model.Shader = new SimpleShadowShader(GShadowMap);

            //Material
            Material groundMaterial = new Material();

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

            //Assig Material
            groundNode.Material = groundMaterial;

            //Add Model in the Scene
            parentTNodeGrd.AddChild(groundNode);
        }
Exemple #2
0
        private void Initialize()
        {
            // Initialize physics.
            InitializePhysics();

            // Add lights.
            AddLights();

            // Add ball.
            AddBall();

            // Add tunnel.
            AddTunnel();

            // Add players.

            // Team 1.
            _transTeam1Node = new TransformNode();
            _levelRootNode.AddChild(_transTeam1Node);
            _transTeam1Node.Translation = new Vector3(0.0f, -Tunnel.Length / 2.0f, 0.0f);
            AddPlayers(_info.Team1PlayerTypes, _team1, Role.Team1, Team1NamePrefix);

            // Team 2.
            _transTeam2Node = new TransformNode();
            _levelRootNode.AddChild(_transTeam2Node);
            _transTeam2Node.Translation = new Vector3(0.0f, Tunnel.Length / 2.0f, 0.0f);
            AddPlayers(_info.Team2PlayerTypes, _team2, Role.Team2, Team2NamePrefix);
        }
Exemple #3
0
        public void createPointer()
        {
            global.toolbar1Node       = new GeometryNode("Toolbar1");
            global.toolbar1Node.Model = new Box(18, 28, 0.1f); //I think toolbar itself is 20x8
            // Set this toolbar model to act as an occluder so that it appears transparent
            global.toolbar1Node.IsOccluder = true;
            // Make the toolbar model to receive shadow casted by other objects with
            // CastShadows set to true
            global.toolbar1Node.Model.ReceiveShadows = true;
            Material toolbar1Material = new Material();

            toolbar1Material.Diffuse                     = Color.Gray.ToVector4();
            toolbar1Material.Specular                    = Color.White.ToVector4();
            toolbar1Material.SpecularPower               = 20;
            global.toolbar1Node.Material                 = toolbar1Material;
            global.toolBar1OccluderTransNode             = new TransformNode();
            global.toolBar1OccluderTransNode.Translation = new Vector3(3, 10, 0);
            global.toolbar1MarkerNode.AddChild(global.toolBar1OccluderTransNode);
            global.toolBar1OccluderTransNode.AddChild(global.toolbar1Node);

            //Now we create the 3D arrow pointer on top of toolbar 1
            TransformNode pointerTipTransNode = new TransformNode();
            float         pointerConeHeight   = 3.0f;
            Matrix        pointerTipRotation  = (Matrix.CreateRotationX((float)Math.PI));

            pointerTipTransNode.Rotation    = Quaternion.CreateFromRotationMatrix(pointerTipRotation);
            pointerTipTransNode.Translation = new Vector3(4.0f, -3.0f, 1.3f);
            global.pointerTip               = new GeometryNode("Pointer Tip");
            global.pointerTip.Model         = new Cylinder(1.8f, 0.05f, pointerConeHeight, 12);
            global.pointerMaterial          = new Material();
            global.pointerMaterial.Emissive = Color.Red.ToVector4();
            global.pointerTip.Material      = global.pointerMaterial;

            global.pointerSegment       = new GeometryNode("Pointer Segment");
            global.pointerSegment.Model = new Cylinder(1.0f, 1.0f, 2.4f * pointerConeHeight, 12);
            TransformNode pointerSegmentTransNode = new TransformNode();

            pointerSegmentTransNode.Translation = new Vector3(0.0f, -3.6f, 0.0f);
            global.pointerSegment.Material      = global.pointerMaterial;
            global.toolbar1MarkerNode.AddChild(pointerTipTransNode);
            pointerTipTransNode.AddChild(global.pointerTip);
            pointerSegmentTransNode.AddChild(global.pointerSegment);
            pointerTipTransNode.AddChild(pointerSegmentTransNode);

            // Create a marker node to track a toolbar marker array. Since we expect that the
            // toolbar marker array will move a lot, we use a large smoothing alpha.
            global.toolbar1MarkerNode          = new MarkerNode(global.scene.MarkerTracker, "toolbar1");
            global.toolbar1MarkerNode.Smoother = new DESSmoother(0.8f, 0.8f);
            global.scene.RootNode.AddChild(global.toolbar1MarkerNode);
        }
Exemple #4
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;
        }
Exemple #5
0
        public Block(MarkerNode markerNode, string[] names, ref GlobalVariables g)
        {
            global = g;

            buildingsInBlocks = new List <Building>();

            blockNode = markerNode;

            float scale = 0.0073f;

            blockTransNode       = new TransformNode();
            blockTransNode.Scale = Vector3.One * scale;
            //           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);
            }
        }
Exemple #6
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);
        }
Exemple #7
0
        /// <summary>
        /// Shoot a box from the clicked mouse location
        /// </summary>
        /// <param name="near"></param>
        /// <param name="far"></param>
        private void ShootBox(Vector3 near, Vector3 far)
        {
            GeometryNode shootBox = new GeometryNode("ShooterBox" + shooterID++);

            shootBox.Model                = boxModel;
            shootBox.Material             = shooterMat;
            shootBox.Physics.Interactable = true;
            shootBox.Physics.Collidable   = true;
            shootBox.Physics.Shape        = GoblinXNA.Physics.ShapeType.Box;
            shootBox.Physics.Mass         = 60f;
            shootBox.AddToPhysicsEngine   = true;

            // Calculate the direction to shoot the box based on the near and far point
            Vector3 linVel = far - near;

            linVel.Normalize();
            // Multiply the direction with the velocity of 20
            linVel *= 30f;

            // Assign the initial velocity to this shooting box
            shootBox.Physics.InitialLinearVelocity = linVel;

            TransformNode shooterTrans = new TransformNode();

            shooterTrans.Translation = near;

            scene.RootNode.AddChild(shooterTrans);
            shooterTrans.AddChild(shootBox);
        }
Exemple #8
0
        public void CreateGroundLevel(string Folder, String Model, Vector3 ObjPos, Vector3 Scala)
        {
            GeometryNode groundNode;

            groundNode = LoadModel("Models/" + Folder, Model, true);

            //Setup Physics Aspecte
            groundNode.Physics.Collidable = true;

            // Make the ground model to receive shadow casted by other objects
            //groundNode.Model.ShadowAttribute = ShadowAttribute.ReceiveOnly;
            // Assign a shadow shader
            //groundNode.Model.Shader = new SimpleShadowShader(scene.ShadowMap);

            TransformNode parentTransNode = new TransformNode("ground");

            parentTransNode.Scale    = Scala;
            parentTransNode.Rotation = Quaternion.CreateFromAxisAngle(new Vector3(1, 0, 0), MathHelper.ToRadians(90));
            //Add Rotation because Blender Axis
            parentTransNode.Translation = ObjPos;
            parentTransNode.AddChild(groundNode);

            //Add Model in the Scene
            parentTNodeGrd.AddChild(parentTransNode);
        }
Exemple #9
0
        public void CreateShootBullet(Vector3 InitPos, Vector3 DirBullet, Color BulletColor)
        {
            if (BulletID == 20)
            {
                return;
            }

            GeometryNode ShootBullet = new GeometryNode("ShootBullet" + BulletID++);

            ShootBullet.Model = BulletModel;

            BulletrMat.Diffuse = BulletColor.ToVector4();

            ShootBullet.Material             = BulletrMat;
            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);

            TransformNode BulletTrans = new TransformNode();

            BulletTrans.Translation = InitPos;

            groundMarkerNode.AddChild(BulletTrans);
            BulletTrans.AddChild(ShootBullet);
        }
Exemple #10
0
        private void createCorderBackground()
        {
            cornerPanelTransformNode = new TransformNode("Corner Panel Trans");
            scene.RootNode.AddChild(cornerPanelTransformNode);

            cornerPanelNode       = new GeometryNode("Corner Panel");
            cornerPanelNode.Model = new TexturedLayer(new Vector2(250, 250));//new Box(300, 250, 1);
            cornerPanelTransformNode.AddChild(cornerPanelNode);


            cornerPanelTransformNode.Translation = new Vector3(2.3f, -1.58f, -5);
            cornerPanelTransformNode.Rotation    = Quaternion.CreateFromAxisAngle(Vector3.UnitX, MathHelper.ToRadians(90));
            //cornerPanelTransformNode.Translation = new Vector3(0, .06f, -1);

            cornerPanelTransformNode.Scale = new Vector3(0.005f, 0.005f, 0.005f);

            Material pointerLabelMaterial = new Material();

            pointerLabelMaterial.Diffuse = Color.White.ToVector4();; // new Vector4(0, 0.5f, 0, 1);
            // pointerLabelMaterial.Specular = Color.White.ToVector4();
            // pointerLabelMaterial.SpecularPower = 50;
            pointerLabelMaterial.Texture = Content.Load <Texture2D>("hud/cornerPanel");

            cornerPanelNode.Material = pointerLabelMaterial;

            //cornerPanelTransformNode.SetAlpha(0.55f);
            Vector4 tempColor = cornerPanelNode.Material.Diffuse;
            Vector3 tempVec   = new Vector3(tempColor.X, tempColor.Y, tempColor.Z);

            cornerPanelNode.Material.Diffuse = new Vector4(tempVec, 0.7f);
        }
Exemple #11
0
        private void createObj(int type, Vector3 dim)
        {
            geomNode = new GeometryNode("powerup" + type);

            geomNode.Model = new Box(dim.X, dim.Y, dim.Z);

            // Create a material to apply to the wall
            Material powerMaterial = new Material();
            Vector4  color;

            if (powerUpType == type)
            {
                color = Color.Black.ToVector4();
            }
            else
            {
                color = Color.DarkRed.ToVector4();
            }

            powerMaterial.Diffuse       = color;
            powerMaterial.Specular      = color;
            powerMaterial.SpecularPower = 5;

            geomNode.Material = powerMaterial;

            transNode = new TransformNode();
            transNode.AddChild(geomNode);
        }
Exemple #12
0
        /// <summary>
        /// Shoot a box from the clicked mouse location
        /// </summary>
        /// <param name="near"></param>
        /// <param name="far"></param>
        private void ShootBox(Vector3 near, Vector3 far)
        {
            GeometryNode shootBox = new GeometryNode("ShooterBox" + shooterID++);

            shootBox.Model    = boxModel;
            shootBox.Material = shooterMat;
#if !WINDOWS
            shootBox.Physics = new MataliObject(shootBox);
            ((MataliObject)shootBox.Physics).CollisionStartCallback = BoxCollideWithGround;
#endif
            // Define the material name of this shooting box model
            shootBox.Physics.MaterialName = "ShootingBox";
            shootBox.Physics.Interactable = true;
            shootBox.Physics.Collidable   = true;
            shootBox.Physics.Shape        = GoblinXNA.Physics.ShapeType.Box;
            shootBox.Physics.Mass         = 60f;
            shootBox.AddToPhysicsEngine   = true;

            // Calculate the direction to shoot the box based on the near and far point
            Vector3 linVel = far - near;
            linVel.Normalize();
            // Multiply the direction with the velocity of 20
            linVel *= 20f;

            // Assign the initial velocity to this shooting box
            shootBox.Physics.InitialLinearVelocity = linVel;

            TransformNode shooterTrans = new TransformNode();
            shooterTrans.Translation = near;

            scene.RootNode.AddChild(shooterTrans);
            shooterTrans.AddChild(shootBox);
        }
Exemple #13
0
        private void CreateObject()
        {
            {
                // Create a sphere
                GeometryNode shape = new GeometryNode();
                shape.Model        = new Sphere(2, 30, 30);
                shape.Model.Shader = generalShader;

                // Create a material which we want to apply to a sphere model
                Material modelMaterial = new Material();
                modelMaterial.Diffuse       = new Vector4(1, 1, 1, 1);
                modelMaterial.Specular      = Color.White.ToVector4();
                modelMaterial.SpecularPower = 128f;
                //modelMaterial.Emissive = Color.Yellow.ToVector4();
                shape.Material = modelMaterial;

                sphereTrans             = new TransformNode();
                sphereTrans.Translation = new Vector3(0, 2, 0);
                sphereTrans.AddChild(shape);
                scene.RootNode.AddChild(sphereTrans);
            }

            {
                // Create a ground
                GeometryNode shape = new GeometryNode();
                shape.Model        = new Box(200, 0.01f, 200);
                shape.Model.Shader = generalShader;

                // Create a material which we want to apply to a ground model
                Material modelMaterial = new Material();
                modelMaterial.Diffuse       = new Vector4(1, 1, 1, 1);
                modelMaterial.SpecularPower = 64f;


                shape.Material = modelMaterial;

                TransformNode trans = new TransformNode();
                trans.Translation = new Vector3(0, 0, 0);
                trans.AddChild(shape);
                scene.RootNode.AddChild(trans);
            }

            {
                // Create a box
                GeometryNode shape = new GeometryNode();
                shape.Model        = new Box(2);
                shape.Model.Shader = generalShader;

                // Create a material which we want to apply to a box model
                Material modelMaterial = new Material();
                modelMaterial.Diffuse = new Vector4(1, 1, 1, 1);

                shape.Material = modelMaterial;

                floorTrans             = new TransformNode();
                floorTrans.Translation = new Vector3(10, 1, 0);
                floorTrans.AddChild(shape);
                scene.RootNode.AddChild(floorTrans);
            }
        }
Exemple #14
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);
        }
Exemple #15
0
        private void CreateObjects()
        {
            // Loads a textured model of a ship
            ModelLoader loader    = new ModelLoader();
            Model       shipModel = (Model)loader.Load("", "p1_wedge");

            // Create a geometry node of a loaded ship model
            GeometryNode shipNode = new GeometryNode("Ship");

            shipNode.Model = shipModel;
            // This ship model has material definitions in the model file, so instead
            // of creating a material node for this ship model, we simply use its internal materials
            ((Model)shipNode.Model).UseInternalMaterials = true;
            ((Model)shipNode.Model).ContainsTransparency = true;

            // Create a transform node to define the transformation for the ship
            TransformNode shipTransNode = new TransformNode();

            // shipTransNode.Translation = new Vector3(0, 5, -12);
            shipTransNode.Scale    = new Vector3(0.002f, 0.002f, 0.002f); // It's huge!
            shipTransNode.Rotation = Quaternion.CreateFromAxisAngle(new Vector3(0, 1, 0),
                                                                    MathHelper.ToRadians(-90));

            shipTransParentNode = new TransformNode();

            //Set our rotation animation to ease in initially
            animationRotation = new AnimationHelper(Easing.EaseIn);

            startPosition = new Vector3(-10, 0, -10);
            endPosition   = new Vector3(5, 2, -5);

            startRotationVector = new Vector3(0, 0, 0);
            endRotationVector   = new Vector3(MathHelper.ToRadians(0), MathHelper.ToRadians(180), MathHelper.ToRadians(180));

            //Set our translation animation to ease in initially
            animationTranslation = new AnimationHelper(Easing.EaseIn);

            //Define what kind of interpolation to use.
            animationTranslation.Animate(arrayOfTransitions[currentInterpolation], startPosition, endPosition, 2);
            // animationTranslation.SetLooping(true, 5); // Use if you want to loop through an animation.

            // Set an action to take place once the animation concludes.
            animationTranslation.SetEndAction(delegate()
            {
                animationRotation.Animate(arrayOfTransitions[currentInterpolation], startRotationVector, endRotationVector, 2.0);
            }); // Note: if you loop and set this animation, it'll occur after the end of the first loop, not after the end of all loops!

            textToPrint = "Linear interpolation";

            // Now add the above nodes to the scene graph in appropriate order
            scene.RootNode.AddChild(shipTransParentNode);
            shipTransParentNode.AddChild(shipTransNode);
            shipTransNode.AddChild(shipNode);
        }
Exemple #16
0
        /// <summary>
        /// Creates a rope-like object by connecting several ball and socket joints.
        /// </summary>
        /// <param name="scene"></param>
        /// <param name="parentTrans"></param>
        public static void AddRope(Scene scene, TransformNode parentTrans)
        {
            Vector3 size     = new Vector3(1.5f, 0.25f, 0.25f);
            Vector3 location = new Vector3(0, 9, 0);

            IPhysicsObject link0 = null;

            Color[] colors = { Color.Red,    Color.Orange, Color.Yellow, Color.Green, Color.Blue,
                               Color.Indigo, Color.Violet };

            PrimitiveModel capsule = new Capsule(size.Y, size.X, 12);

            for (int i = 0; i < 7; i++)
            {
                TransformNode pileTrans = new TransformNode();
                pileTrans.Translation = location;

                Material linkMat = new Material();
                linkMat.Diffuse       = colors[i].ToVector4();
                linkMat.Specular      = Color.White.ToVector4();
                linkMat.SpecularPower = 10;

                GeometryNode link1 = new GeometryNode("Link " + i);
                link1.Model = capsule;
                link1.Model.ShadowAttribute = ShadowAttribute.ReceiveCast;
                link1.Material = linkMat;

                link1.AddToPhysicsEngine     = true;
                link1.Physics.Interactable   = true;
                link1.Physics.Collidable     = true;
                link1.Physics.Shape          = ShapeType.Capsule;
                link1.Physics.Mass           = 2.0f;
                link1.Physics.LinearDamping  = 1f;
                link1.Physics.AngularDamping = new Vector3(1f, 1f, 1f);

                parentTrans.AddChild(pileTrans);
                pileTrans.AddChild(link1);

                Vector3 pivot = location + parentTrans.Translation;
                pivot.Y += (size.X - size.Y) * 0.5f;

                BallAndSocketJoint joint = new BallAndSocketJoint(pivot);
                joint.Pin           = -Vector3.UnitY;
                joint.MaxConeAngle  = 0.0f;
                joint.MaxTwistAngle = 10.0f * MathHelper.Pi / 180;

                ((NewtonPhysics)scene.PhysicsEngine).CreateJoint(link1.Physics, link0, joint);

                link0    = link1.Physics;
                location = new Vector3(location.X, location.Y
                                       - (size.X - size.Y), location.Z);
            }
        }
Exemple #17
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);
        }
Exemple #18
0
        private void AddBall()
        {
            // Add ball and set ball initial velocity.
            _ball = new Ball(this, BallName);

            _transBallNode = new TransformNode();

            // TODO Set the transformation of the ball.

            _transBallNode.AddChild(_ball.Node);
            _levelRootNode.AddChild(_transBallNode);

            // TODO Set physics for the ball here.
        }
Exemple #19
0
        private void CreateObjects()
        {
            // Create our ground plane
            GeometryNode groundNode = new GeometryNode("Ground");

            groundNode.Model = new Box(Vector3.One);
            // Make this ground plane collidable, so other collidable objects can collide
            // with this ground
            groundNode.Physics.Collidable = true;
            groundNode.Physics.Shape      = GoblinXNA.Physics.ShapeType.Box;
            groundNode.AddToPhysicsEngine = true;

            // Create a material for the ground
            Material groundMat = new Material();

            groundMat.Diffuse       = Color.LightGreen.ToVector4();
            groundMat.Specular      = Color.White.ToVector4();
            groundMat.SpecularPower = 20;

            groundNode.Material = groundMat;

            // Create a parent transformation for both the ground and the sphere models
            TransformNode parentTransNode = new TransformNode();

            parentTransNode.Translation = new Vector3(0, -10, -20);

            // Create a scale transformation for the ground to make it bigger
            TransformNode groundScaleNode = new TransformNode();

            groundScaleNode.Scale = new Vector3(100, 1, 100);

            // Add this ground model to the scene
            scene.RootNode.AddChild(parentTransNode);
            parentTransNode.AddChild(groundScaleNode);
            groundScaleNode.AddChild(groundNode);

            // Add a rope-like object using ball and socket joint
            JointCreator.AddRope(scene, parentTransNode);

            // Add a door-like object using hinge joint
            JointCreator.AddDoubleSwingDoors(scene, parentTransNode);

            JointCreator.AddRollingBeats(scene, parentTransNode);

            // Add a race car
            car = VehicleCreator.AddRaceCar(scene, parentTransNode);

            // Create a camera that chases the car
            CreateChasingCamera((GeometryNode)car.Container);
        }
Exemple #20
0
        private void AddTunnel()
        {
            // Add tunnel.
            _tunnel = new Tunnel(this, TunnelName);

            _transTunnelNode = new TransformNode();

            // TODO Set the transformation of the tunnel.

            _transTunnelNode.AddChild(_tunnel.Node);
            _levelRootNode.AddChild(_transTunnelNode);

            // TODO Set physics for the tunnel here.
        }
Exemple #21
0
        protected void createObj(Vector4 color)
        {
            geomNode       = new GeometryNode("slime");
            geomNode.Model = new Sphere(1, 20, 20);

            Material paddleMaterial = new Material();

            paddleMaterial.Diffuse       = color;
            paddleMaterial.Specular      = color;
            paddleMaterial.SpecularPower = .15f;

            geomNode.Material = paddleMaterial;

            transNode = new TransformNode();
            transNode.AddChild(geomNode);
        }
Exemple #22
0
        public void AddLapida(Vector3 PosCar, int LevelHeight, float Scala)
        {
            GeometryNode LapidaNode = LoadModel("Models", "lapida", true);

            LapidaNode.Physics.Collidable = true;

            TransformNode parentTransNode = new TransformNode("Lapida");

            parentTransNode.Scale       = new Vector3(Scala, Scala + 2, Scala);
            parentTransNode.Rotation    = Quaternion.CreateFromAxisAngle(new Vector3(1, 0, 0), MathHelper.ToRadians(90));
            parentTransNode.Translation = new Vector3(PosCar.X, PosCar.Y, LevelHeight + 10);
            //Add Rotation because Blender Axis
            parentTransNode.AddChild(LapidaNode);

            //Add Model in the Scene
            groundMarkerNode.AddChild(parentTransNode);
        }
Exemple #23
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);
        }
Exemple #24
0
        private void build(IModel model, string name)
        {
            this.name           = name;
            this.instanceNumber = instance;

            restrictedDimension = new Vector3(1, 1, 0);
            geo   = new GeometryNode(this.Label);
            trans = new TransformNode(this.Label + "_Trans");

            instance++;
            trans.AddChild(geo);

            geo.Model              = model;
            geo.Physics.Shape      = GoblinXNA.Physics.ShapeType.Box;
            geo.Physics.Pickable   = true;
            geo.AddToPhysicsEngine = true;
            trans.Rotation         = Quaternion.CreateFromYawPitchRoll((float)Math.PI / 2, 0, (float)Math.PI / 2);
        }
Exemple #25
0
        private void createObj(Vector3 dim)
        {
            geomNode = new GeometryNode("court");

            geomNode.Model = new Box(dim.X, dim.Y, dim.Z);

            // Create a material to apply to the court
            Material courtMaterial = new Material();

            courtMaterial.Diffuse       = Color.DarkGreen.ToVector4();
            courtMaterial.Specular      = Color.DarkGreen.ToVector4();
            courtMaterial.SpecularPower = 0.3f;

            geomNode.Material = courtMaterial;

            transNode = new TransformNode();
            transNode.AddChild(geomNode);
        }
Exemple #26
0
        private void createObj(Vector3 dim)
        {
            geomNode = new GeometryNode("net");

            geomNode.Model = new Box(dim.X, dim.Y, dim.Z);

            // Create a material to apply to the court
            Material netMaterial = new Material();

            netMaterial.Diffuse       = Color.Brown.ToVector4();
            netMaterial.Specular      = Color.White.ToVector4();
            netMaterial.SpecularPower = 5;

            geomNode.Material = netMaterial;

            transNode = new TransformNode();
            transNode.AddChild(geomNode);
        }
Exemple #27
0
        protected void createObj(Vector3 size, Vector4 selected_color)
        {
            geomNode = new GeometryNode("paddle");

            geomNode.Model = new Box(size.X, size.Y, size.Z);

            // Create a material to apply to the ball
            Material paddleMaterial = new Material();

            paddleMaterial.Diffuse       = selected_color;
            paddleMaterial.Specular      = selected_color;
            paddleMaterial.SpecularPower = .3f;

            geomNode.Material = paddleMaterial;

            transNode = new TransformNode();
            transNode.AddChild(geomNode);
        }
        private void createObj(Vector3 dim)
        {
            geomNode = new GeometryNode("wall");

            geomNode.Model = new Box(dim.X, dim.Y, dim.Z);

            // Create a material to apply to the wall
            Material wallMaterial = new Material();

            wallMaterial.Diffuse       = new Vector4(0, 0, 0, 0);
            wallMaterial.Specular      = new Vector4(0, 0, 0, 0);
            wallMaterial.SpecularPower = 5;

            geomNode.Material = wallMaterial;

            transNode = new TransformNode();
            transNode.AddChild(geomNode);
        }
Exemple #29
0
        private void createObj(Vector4 colr)
        {
            geomNode = new GeometryNode("target");

            geomNode.Model = new Sphere(1, 20, 20);

            // Create a material to apply to the target
            Material targetMaterial = new Material();

            targetMaterial.Diffuse       = colr;
            targetMaterial.Specular      = Color.White.ToVector4();
            targetMaterial.SpecularPower = 5;

            geomNode.Material = targetMaterial;

            transNode = new TransformNode();
            transNode.AddChild(geomNode);
        }
Exemple #30
0
        protected override void createObj()
        {
            geomNode = new GeometryNode("volleyball");

            geomNode.Model = new Sphere(1, 20, 20);

            // Create a material to apply to the ball
            Material ballMaterial = new Material();

            ballMaterial.Diffuse       = new Vector4(0.752941f, 0.223529f, 0.168627f, 1f);
            ballMaterial.Specular      = new Vector4(0.752941f, 0.223529f, 0.168627f, 1f);
            ballMaterial.SpecularPower = .3f;

            geomNode.Material = ballMaterial;

            transNode = new TransformNode();
            transNode.AddChild(geomNode);
        }