/// <summary>
 /// Initializes a new instance of the GhostObject class.
 /// DEfault Object in 0,0,0 identity rotation and 1,1,1 scale
 /// </summary>
 /// <param name="bb">The bb.</param>
 public PhysxGhostObject(BoundingBox? bb = null)         
 {
     this.pos = Vector3.Zero;
     this.ori = Matrix.Identity;
     this.scale = Vector3.One;
     this.bb = bb;
 }
Example #2
0
        public bool Convert(string s, out object value)
        {
            BoundingBox v = new BoundingBox();
            value = v;
            object corner;
            string[] splits = s.Split(VALUE_DELIMITERS, StringSplitOptions.RemoveEmptyEntries);
            if(splits.Length < 2) return false;
            int vi = 0;
            foreach(var sv in splits) {
                if(vi == 2) break;
                if(string.IsNullOrWhiteSpace(sv))
                    continue;
                if(vec3Conv.Convert(sv, out corner)) {
                    switch(vi) {
                        case 0: v.Min = (Vector3)corner; break;
                        case 1: v.Max = (Vector3)corner; break;
                    }
                    vi++;
                }
            }
            if(vi < 2) return false;

            value = v;
            return true;
        }
Example #3
0
        public void DrawBoundingBox(BoundingBox box)
        {
            IGraphicsDeviceService graphicsService =
                    (IGraphicsDeviceService)base.Game.Services.GetService(
                                                    typeof(IGraphicsDeviceService));

            GraphicsDevice device = graphicsService.GraphicsDevice;

            vertices[0].Position = new Vector3(box.Min.X, box.Min.Y, box.Min.Z);
            vertices[1].Position = new Vector3(box.Max.X, box.Min.Y, box.Min.Z);
            vertices[2].Position = new Vector3(box.Max.X, box.Min.Y, box.Max.Z);
            vertices[3].Position = new Vector3(box.Min.X, box.Min.Y, box.Max.Z);

            vertices[4].Position = new Vector3(box.Min.X, box.Max.Y, box.Min.Z);
            vertices[5].Position = new Vector3(box.Max.X, box.Max.Y, box.Min.Z);
            vertices[6].Position = new Vector3(box.Max.X, box.Max.Y, box.Max.Z);
            vertices[7].Position = new Vector3(box.Min.X, box.Max.Y, box.Max.Z);

            Predraw(0);
            device.DrawUserIndexedPrimitives<VertexPositionColor>(
                PrimitiveType.LineList, vertices,
                0,
                8,
                indices,
                0,
                12);
            Postdraw();
        }
Example #4
0
        public RedHead(Game game, Vector3 pos, Level l)
            : base(game, pos, l)
        {
            //Parameters for this specific enemy
            life = 5;
            textures = new Texture2D[life];
            Damage = 5;
            this.level = l;
            this.position = pos;
            RotationSpeed = 0.1f;
            ForwardSpeed = 6f;
            boxMin = new Vector3(-0.235f, 0, -0.235f);
            boxMax = new Vector3(0.235f, 0.8f, 0.235f);
            boundingBox = new BoundingBox(position + boxMin, position + boxMax);
            //Different textures for each life count
            textures[4] = ContentPreImporter.GetTexture("RedHead");
            textures[3] = ContentPreImporter.GetTexture("RedHead4");
            textures[2] = ContentPreImporter.GetTexture("RedHead3");
            textures[1] = ContentPreImporter.GetTexture("RedHead2");
            textures[0] = ContentPreImporter.GetTexture("RedHead1");
            hurtSound = ContentPreImporter.GetSound("enemyHurt");

            billboard = new Billboard(game, textures[life - 1], Vector2.One / 2);
            billboard.Move(position + new Vector3(0, 0.25f, 0));
            billboard.ForceUpdate();
            target = pos;
            //Set new values for the fog if required
            billboard.OverrideFog(GlobalSettings.FogEnabled, GlobalSettings.FogColor, GlobalSettings.FogStart, GlobalSettings.FogEnd * 2.1f);
        }
        /// <summary>
        /// Model 全体を包む BoundingBox を取得します。
        /// </summary>
        /// <param name="model">Model。</param>
        /// <param name="result">Model 全体を包む BoundingBox。</param>
        public static void GetBoundingBox(this Model model, out BoundingBox result)
        {
            var boneTransforms = new Matrix[model.Bones.Count];
            model.CopyAbsoluteBoneTransformsTo(boneTransforms);

            var points = new List<Vector3>();
            foreach (var mesh in model.Meshes)
            {
                foreach (var part in mesh.MeshParts)
                {
                    var vertexBuffer = part.VertexBuffer;
                    var data = new float[vertexBuffer.VertexCount * vertexBuffer.VertexDeclaration.VertexStride / sizeof(float)];
                    vertexBuffer.GetData<float>(data);
                    var boneTransform = boneTransforms[mesh.ParentBone.Index];
                    var increment = vertexBuffer.VertexDeclaration.VertexStride / sizeof(float);
                    for (int i = 0; i < data.Length; i += increment)
                    {
                        Vector3 point;
                        point.X = data[i];
                        point.Y = data[i + 1];
                        point.Z = data[i + 2];

                        point = Vector3.Transform(point, boneTransform);

                        points.Add(point);
                    }
                }
            }
            result = BoundingBox.CreateFromPoints(points);
        }
Example #6
0
        public ContainmentType Contains(ref BoundingBox boundingBox)
        {
            ContainmentType result;
            _boundingSphere.Contains(ref boundingBox, out result);

            return result;
        }
Example #7
0
        public QuadNode(NodeType nodeType, int nodeSize, int nodeDepth, QuadNode parent, QuadTree parentTree, int positionIndex)
        {
            NodeType = nodeType;
            _nodeSize = nodeSize;
            _nodeDepth = nodeDepth;
            _positionIndex = positionIndex;

            _parent = parent;
            _parentTree = parentTree;

            //Add the 9 vertices
            AddVertices();

            Bounds = new BoundingBox(_parentTree.Vertices[VertexTopLeft.Index].Position,
                        _parentTree.Vertices[VertexBottomRight.Index].Position);

            if (nodeSize >= 4)
                AddChildren();

            //Make call to UpdateNeighbors from the parent node.
            //This will update all neighbors recursively for the
            //children as well.  This ensures all nodes are created
            //prior to updating neighbors.
            if (_nodeDepth == 1)
            {
                AddNeighbors();

                VertexTopLeft.Activated = true;
                VertexTopRight.Activated = true;
                VertexCenter.Activated = true;
                VertexBottomLeft.Activated = true;
                VertexBottomRight.Activated = true;

            }
        }
        /// <summary>
        /// Constructs the arena. Also constructs several platforms and physics elements
        /// which need to get added to the EntityManager and PhysicsSimulator.
        /// </summary>
        /// <param name="entityManager"></param>
        /// <param name="physicsSimulator"></param>
        public SplitBaseArena(EntityManager entityManager, PhysicsSimulator physicsSimulator)
        {
            // Create the platforms.
            float focus = 15.0f;
            Platform leftGround = new Platform(new Vector3(-focus, 0, 0), 22.0f, 2.0f, 5.0f);
            Platform rightGround = new Platform(new Vector3(focus, 0, 0), 22.0f, 2.0f, 5.0f);

            Platforms.Add(leftGround);
            entityManager.AddEntity(leftGround);
            physicsSimulator.AddPhysicsEntity(leftGround.GetBox());

            Platforms.Add(rightGround);
            entityManager.AddEntity(rightGround);
            physicsSimulator.AddPhysicsEntity(rightGround.GetBox());

            // Create the Spawn Positions
            spawnPositions = new List<Vector3>();
            spawnPositions.Add(new Vector3(-15, 10, 0));
            spawnPositions.Add(new Vector3(-5, 15, 0));
            spawnPositions.Add(new Vector3(5, 15, 0));
            spawnPositions.Add(new Vector3(15, 10, 0));

            // Create the Bounding box.
            boundingBox = new BoundingBox(new Vector3(-70, -20, -20), new Vector3(70, 60, 20));
        }
Example #9
0
        public static void DrawBoundingBox(BoundingBox bBox, GraphicsDevice device, BasicEffect basicEffect, Matrix worldMatrix, Matrix viewMatrix, Matrix projectionMatrix)
        {
            Vector3 v1 = bBox.Min;
            Vector3 v2 = bBox.Max;

            VertexPositionColor[] cubeLineVertices = new VertexPositionColor[8];
            cubeLineVertices[0] = new VertexPositionColor(v1, Color.White);
            cubeLineVertices[1] = new VertexPositionColor(new Vector3(v2.X, v1.Y, v1.Z), Color.Red);
            cubeLineVertices[2] = new VertexPositionColor(new Vector3(v2.X, v1.Y, v2.Z), Color.Green);
            cubeLineVertices[3] = new VertexPositionColor(new Vector3(v1.X, v1.Y, v2.Z), Color.Blue);

            cubeLineVertices[4] = new VertexPositionColor(new Vector3(v1.X, v2.Y, v1.Z), Color.White);
            cubeLineVertices[5] = new VertexPositionColor(new Vector3(v2.X, v2.Y, v1.Z), Color.Red);
            cubeLineVertices[6] = new VertexPositionColor(v2, Color.Green);
            cubeLineVertices[7] = new VertexPositionColor(new Vector3(v1.X, v2.Y, v2.Z), Color.Blue);

            short[] cubeLineIndices = { 0, 1, 1, 2, 2, 3, 3, 0, 4, 5, 5, 6, 6, 7, 7, 4, 0, 4, 1, 5, 2, 6, 3, 7 };

            basicEffect.World = worldMatrix;
            basicEffect.View = viewMatrix;
            basicEffect.Projection = projectionMatrix;
            basicEffect.VertexColorEnabled = true;

            device.RasterizerState = _solidRasterizer;
            foreach (EffectPass pass in basicEffect.CurrentTechnique.Passes)
            {
                pass.Apply();
                device.DrawUserIndexedPrimitives<VertexPositionColor>(PrimitiveType.LineList, cubeLineVertices, 0, 8, cubeLineIndices, 0, 12);
            }
        }
Example #10
0
 public BoundingBox Collision()
 {
     Vector3 Middle= new Vector3(Position.X+100,Position.Y+100,Position.Z-75);
     Vector3 abc = new Vector3(80);
     BoundingBox bb= new BoundingBox(Middle - new Vector3(40), Middle + new Vector3(40));
     return bb;
 }
Example #11
0
 private BSP(Node root, BoundingBox? bounds, object[] description, bool createDescription = true)
 {
     _root = root;
     Bounds = bounds;
     _description = description;
     _createDescription = createDescription;
 }
        public static BoundingBox Transform(BoundingBox bounds, Matrix matrix)
        {
            BoundingBox t;

            t.Min = matrix.Translation;
            t.Max = matrix.Translation;

            t.Min.X += (matrix.M11 < 0) ? bounds.Max.X * matrix.M11 : bounds.Min.X * matrix.M11;
            t.Min.X += (matrix.M21 < 0) ? bounds.Max.Y * matrix.M21 : bounds.Min.Y * matrix.M21;
            t.Min.X += (matrix.M31 < 0) ? bounds.Max.Z * matrix.M31 : bounds.Min.Z * matrix.M31;
            t.Max.X += (matrix.M11 > 0) ? bounds.Max.X * matrix.M11 : bounds.Min.X * matrix.M11;
            t.Max.X += (matrix.M21 > 0) ? bounds.Max.Y * matrix.M21 : bounds.Min.Y * matrix.M21;
            t.Max.X += (matrix.M31 > 0) ? bounds.Max.Z * matrix.M31 : bounds.Min.Z * matrix.M31;

            t.Min.Y += (matrix.M12 < 0) ? bounds.Max.X * matrix.M12 : bounds.Min.X * matrix.M12;
            t.Min.Y += (matrix.M22 < 0) ? bounds.Max.Y * matrix.M22 : bounds.Min.Y * matrix.M22;
            t.Min.Y += (matrix.M32 < 0) ? bounds.Max.Z * matrix.M32 : bounds.Min.Z * matrix.M32;
            t.Max.Y += (matrix.M12 > 0) ? bounds.Max.X * matrix.M12 : bounds.Min.X * matrix.M12;
            t.Max.Y += (matrix.M22 > 0) ? bounds.Max.Y * matrix.M22 : bounds.Min.Y * matrix.M22;
            t.Max.Y += (matrix.M32 > 0) ? bounds.Max.Z * matrix.M32 : bounds.Min.Z * matrix.M32;

            t.Min.Z += (matrix.M13 < 0) ? bounds.Max.X * matrix.M13 : bounds.Min.X * matrix.M13;
            t.Min.Z += (matrix.M23 < 0) ? bounds.Max.Y * matrix.M23 : bounds.Min.Y * matrix.M23;
            t.Min.Z += (matrix.M33 < 0) ? bounds.Max.Z * matrix.M33 : bounds.Min.Z * matrix.M33;
            t.Max.Z += (matrix.M13 > 0) ? bounds.Max.X * matrix.M13 : bounds.Min.X * matrix.M13;
            t.Max.Z += (matrix.M23 > 0) ? bounds.Max.Y * matrix.M23 : bounds.Min.Y * matrix.M23;
            t.Max.Z += (matrix.M33 > 0) ? bounds.Max.Z * matrix.M33 : bounds.Min.Z * matrix.M33;

            return t;
        }
Example #13
0
 public override void Update(GameTime gametime)
 {
     min = MIN + currentPosition;
     max = MAX + currentPosition;
     tankBox = new BoundingBox(min, max);
     turretRorationValue = (float)Math.Sin(gametime.TotalGameTime.TotalSeconds);
 }
 /// <summary>
 /// konstruktor
 /// </summary>
 /// <param name="game">instance hry</param>
 /// <param name="x">poloha v hernim poli na ose x</param>
 /// <param name="y">poloha v hernim poli na ose y</param>
 public AbstractBonus(Game game, AbstractWall wall)
     : base(game)
 {
     base.modelPosition = new Vector3(wall.ModelPosition.X, 0, wall.ModelPosition.Z);
     boundingBox = new BoundingBox(new Vector3(modelPosition.X - 10, modelPosition.Y, modelPosition.Z - 10),
         new Vector3(modelPosition.X + 10, modelPosition.Y + 20, modelPosition.Z + 10));
 }
    /// <summary>
    /// Initializes a new instance of the <see cref="GhostObject"/> class.
    /// </summary>
    /// <param name="position">The position.</param>
    /// <param name="orientation">The orientation.</param>
    /// <param name="scale">The scale.</param>
 public GhostObject(Vector3 position, Matrix orientation, Vector3 scale, BoundingBox? bb = null) : base(MaterialDescription.DefaultBepuMaterial(), 0)
 {
     this.pos = position;
     this.ori = orientation;
     this.scale = scale;
     this.bb = bb;
 }
        public static void Render(BoundingBox box,
                                  GraphicsDevice graphicsDevice,
                                  Matrix view,
                                  Matrix projection,
                                  Color color)
        {
            if (_effect.IsNull())
                _effect = new BasicEffect(graphicsDevice) { VertexColorEnabled = true, LightingEnabled = false };

            var corners = box.GetCorners();

            for (var i = 0; i < 8; i++)
            {
                Vertices[i].Position = corners[i];
                Vertices[i].Color = color;
            }

            _effect.View = view;
            _effect.Projection = projection;

            foreach (var pass in _effect.CurrentTechnique.Passes)
            {
                pass.Apply();
                graphicsDevice.DrawUserIndexedPrimitives(PrimitiveType.LineList,
                                                         Vertices,
                                                         0,
                                                         8,
                                                         Indices,
                                                         0,
                                                         Indices.Length / 2);
            }
        }
Example #17
0
 public GameObject()
 {
     Model = null;
     Position = Vector3.Zero;
     BoundingSphere = new BoundingSphere();
     boundingBox = new BoundingBox();
 }
        public void colisao()
        {
            Vector3 A = new Vector3(screen.player.positionPlayer.X+5, screen.player.positionPlayer.Y+10, 0);
            Vector3 B = new Vector3(screen.player.positionPlayer.X + 44, screen.player.positionPlayer.Y + screen.player.imgPlayer.Height - 13, 0);

            Vector3 C = new Vector3(posicao.X, posicao.Y, 0);
            Vector3 D = new Vector3(posicao.X + largura, posicao.Y + image.Height, 0);

            BoundingBox boxPlayer = new BoundingBox(A, B);
            BoundingBox boxEnemy = new BoundingBox(C, D);

            if (boxEnemy.Intersects(boxPlayer))
            {
                screen.removeComponent(this);
                screen.addComponent(new Explosao(mygame, C + new Vector3(0, 10, 0), 1, screen));
                screen.player.hp--;
                if (screen.player.hp < 0) {
                    screen.addComponent(new Explosao(mygame, new Vector3(screen.player.positionPlayer.X, screen.player.positionPlayer.Y, 0), 2, screen));
                    screen.player.vida--;
                    screen.player.hp = 5;
                }
                if(screen.player.vida < 0){
                    screen.removeComponent(screen.player);
                    mygame.setScreen(new ScreenSplash(mygame));
                }

            }
        }
Example #19
0
        /// <summary>
        /// Creates a new chunk.
        /// </summary>
        /// <param name="world">The world this chunk belongs to.</param>
        /// <param name="index">The index of the chunk.</param>
        /// <param name="generateTerrain">True to generate some initial terrain, false to leave each block empty.</param>
        private Chunk( World world, Vector3 index, bool generateTerrain )
        {
            _world = world;
            _data = new ChunkData( index );
            _terrain = new VoxelBuffer();

            // create bounds
            var sizeOffs = ChunkData.SizeXZ * 0.5f - 0.5f;
            Vector3 boundsMin = new Vector3(
                index.X - sizeOffs,
                -0.5f,
                index.Z - sizeOffs
            );
            Vector3 boundsMax = new Vector3(
                index.X + sizeOffs,
                0.5f + ChunkData.SizeY,
                index.Z + sizeOffs
            );
            _bounds = new BoundingBox( boundsMin, boundsMax );
            _octree = new ChunkOctree( _bounds );

            // check if we need to populate
            if ( generateTerrain )
            {
                PopulateTerrain();
            }
        }
Example #20
0
        public static void DrawBBox(BoundingBox box, Matrix Projection, Matrix View, Matrix localWorld,Color color)
        {
            // Use inside a drawing loop

                Vector3[] corners = box.GetCorners();
                VertexPositionColor[] primitiveList = new VertexPositionColor[corners.Length];

                // Assign the 8 box vertices
                for (int i = 0; i < corners.Length; i++)
                {
                    primitiveList[i] = new VertexPositionColor(corners[i], color);
                }

                /* Set your own effect parameters here */

                boxEffect.World = localWorld;
                boxEffect.View = View;
                boxEffect.Projection = Projection;
                boxEffect.TextureEnabled = false;

                // Draw the box with a LineList
                foreach (EffectPass pass in boxEffect.CurrentTechnique.Passes)
                {
                    pass.Apply();
                    device.DrawUserIndexedPrimitives(
                        PrimitiveType.LineList, primitiveList, 0, 8,
                        bBoxIndices, 0, 12);
                }
        }
Example #21
0
        public void Constructor()
        {
            // Overloaded constructor, normal use
            b = new BoundingBox(new Vector3(-5, 3, 1),new Vector3(8, -10, 0));
            Assert.AreEqual(new Vector3(-5, 3, 1), b.Min, "Constructor#1.Min");
            Assert.AreEqual(new Vector3(8, -10, 0), b.Max, "Constructor#1.Max");

            // Overloaded constructor, when Min = Max
            b = new BoundingBox(new Vector3(0, 0, 1), new Vector3(0, 0, 1));
            Assert.AreEqual(new Vector3(0, 0, 1), b.Min, "Constructor#2.Min");
            Assert.AreEqual(new Vector3(0, 0, 1), b.Max, "Constructor#2.Max");

            // Overloaded constructor, when Min is the minimum value and Max the maximum
            b = new BoundingBox(new Vector3(float.MinValue), new Vector3(float.MaxValue));
            Assert.AreEqual(new Vector3(float.MinValue), b.Min, "Constructor#3.Min");
            Assert.AreEqual(new Vector3(float.MaxValue), b.Max, "Constructor#3.Max");

            // Overloaded constructor, changing passing Max first and Min afterwards
            // As stupid as it seems, MS's XNA doesn't check, just assumes first is Min
            // and second is Max
            b = new BoundingBox(new Vector3(10, 10, 10), new Vector3(0, 0, 0));
            Assert.AreEqual(new Vector3(10, 10, 10), b.Min, "Constructor#4.Min");
            Assert.AreEqual(new Vector3(0, 0, 0), b.Max, "Constructor#4.Max");

            // Overloaded constructor, using other Vector3
            // As before, MS's XNA does not check what's the minimum and maximum
            b = new BoundingBox(new Vector3(0, 5, 10), new Vector3(10, 5, 0));
            Assert.AreEqual(new Vector3(0, 5, 10), b.Min, "Constructor#5.Min");
            Assert.AreEqual(new Vector3(10, 5, 0), b.Max, "Constructor#5.Max");

            // Default constructor
            b = new BoundingBox();
            Assert.AreEqual(new Vector3(0, 0, 0), b.Min, "Constructor#6.Min");
            Assert.AreEqual(new Vector3(0, 0, 0), b.Max, "Constructor#6.Max");
        }
Example #22
0
        public override void Initialize(Texture2D TextureForParticle, int ParticleCount, int MaxLife, Direction Direction, BoundingBox EnviromentBounds, Color Color)
        {
            base._t2dMainTexture = TextureForParticle;
            base._pContainer = new Particle[ParticleCount];
            base.EnviromentBounds = EnviromentBounds;
            base._Points = new VertexPositionColor[ParticleCount];
            for (int i = 0; i < ParticleCount; i++)
            {
                _pContainer[i] = new Particle();
                _pContainer[i].Life = Engine.Randomize(MaxLife / 4, MaxLife);
                _Points[i].Color = Color;
                _Points[i].Position = Engine.TempVector3(Engine.Randomize((int)EnviromentBounds.Min.X, (int)EnviromentBounds.Max.X),
                    Engine.Randomize((int)EnviromentBounds.Min.Y, (int)EnviromentBounds.Max.Y + 100),
                    Engine.Randomize((int)EnviromentBounds.Min.Z, (int)EnviromentBounds.Max.Z));
                float a = Engine.Randomize(2, 6);
                _pContainer[i].Velocity.Y = (a / DIVISIONAL_COEFFICENT);
                if(Engine.Randomize(1, 3) == 1)
                _pContainer[i].Velocity.X = (a / DIVISIONAL_COEFFICENT);
                else _pContainer[i].Velocity.X = -(a / DIVISIONAL_COEFFICENT);

                if(Engine.Randomize(1, 3) == 2)
                    _pContainer[i].Velocity.Z = (a / DIVISIONAL_COEFFICENT);
                else _pContainer[i].Velocity.Z = -(a / DIVISIONAL_COEFFICENT);
            }
        }
Example #23
0
        public static void AddBoundingBox(BoundingBox box, Color color, float life)
        {
            DebugShape shape = GetShapeForLines(12, life);

            box.GetCorners(Corners);

            shape.Vertices[0] = new VertexPositionColor(Corners[0], color);
            shape.Vertices[1] = new VertexPositionColor(Corners[1], color);
            shape.Vertices[2] = new VertexPositionColor(Corners[1], color);
            shape.Vertices[3] = new VertexPositionColor(Corners[2], color);
            shape.Vertices[4] = new VertexPositionColor(Corners[2], color);
            shape.Vertices[5] = new VertexPositionColor(Corners[3], color);
            shape.Vertices[6] = new VertexPositionColor(Corners[3], color);
            shape.Vertices[7] = new VertexPositionColor(Corners[0], color);

            shape.Vertices[8] = new VertexPositionColor(Corners[4], color);
            shape.Vertices[9] = new VertexPositionColor(Corners[5], color);
            shape.Vertices[10] = new VertexPositionColor(Corners[5], color);
            shape.Vertices[11] = new VertexPositionColor(Corners[6], color);
            shape.Vertices[12] = new VertexPositionColor(Corners[6], color);
            shape.Vertices[13] = new VertexPositionColor(Corners[7], color);
            shape.Vertices[14] = new VertexPositionColor(Corners[7], color);
            shape.Vertices[15] = new VertexPositionColor(Corners[4], color);

            shape.Vertices[16] = new VertexPositionColor(Corners[0], color);
            shape.Vertices[17] = new VertexPositionColor(Corners[4], color);
            shape.Vertices[18] = new VertexPositionColor(Corners[1], color);
            shape.Vertices[19] = new VertexPositionColor(Corners[5], color);
            shape.Vertices[20] = new VertexPositionColor(Corners[2], color);
            shape.Vertices[21] = new VertexPositionColor(Corners[6], color);
            shape.Vertices[22] = new VertexPositionColor(Corners[3], color);
            shape.Vertices[23] = new VertexPositionColor(Corners[7], color);
        }
Example #24
0
        public static VertexPositionColor[] GetVerticesFromBounds(BoundingBox bounds, Color hitboxColor)
        {
            Vector3[] corners = bounds.GetCorners();
            VertexPositionColor[] debugVerts = new VertexPositionColor[24];
            debugVerts[0] = new VertexPositionColor(corners[0], hitboxColor);
            debugVerts[1] = new VertexPositionColor(corners[1], hitboxColor);
            debugVerts[2] = new VertexPositionColor(corners[1], hitboxColor);
            debugVerts[3] = new VertexPositionColor(corners[5], hitboxColor);
            debugVerts[4] = new VertexPositionColor(corners[5], hitboxColor);
            debugVerts[5] = new VertexPositionColor(corners[4], hitboxColor);
            debugVerts[6] = new VertexPositionColor(corners[4], hitboxColor);
            debugVerts[7] = new VertexPositionColor(corners[0], hitboxColor);

            debugVerts[8] = new VertexPositionColor(corners[3], hitboxColor);
            debugVerts[9] = new VertexPositionColor(corners[2], hitboxColor);
            debugVerts[10] = new VertexPositionColor(corners[2], hitboxColor);
            debugVerts[11] = new VertexPositionColor(corners[6], hitboxColor);
            debugVerts[12] = new VertexPositionColor(corners[6], hitboxColor);
            debugVerts[13] = new VertexPositionColor(corners[7], hitboxColor);
            debugVerts[14] = new VertexPositionColor(corners[7], hitboxColor);
            debugVerts[15] = new VertexPositionColor(corners[3], hitboxColor);

            debugVerts[16] = new VertexPositionColor(corners[3], hitboxColor);
            debugVerts[17] = new VertexPositionColor(corners[0], hitboxColor);
            debugVerts[18] = new VertexPositionColor(corners[2], hitboxColor);
            debugVerts[19] = new VertexPositionColor(corners[1], hitboxColor);
            debugVerts[20] = new VertexPositionColor(corners[6], hitboxColor);
            debugVerts[21] = new VertexPositionColor(corners[5], hitboxColor);
            debugVerts[22] = new VertexPositionColor(corners[7], hitboxColor);
            debugVerts[23] = new VertexPositionColor(corners[4], hitboxColor);

            return debugVerts;
        }
Example #25
0
 public override BoundingBox[] GetCollisionBoxes()
 {
     BoundingBox[] result = new BoundingBox[2];
     result[0] = new BoundingBox(new Vector3(0, 0, 0), new Vector3(0.5f, 1, 1));
     result[1] = new BoundingBox(new Vector3(0.5f, 0, 0), new Vector3(1, 1, 1));
     return result;
 }
 /// <summary>
 /// konstruktor
 /// </summary>
 /// <param name="game">instance hry</param>
 /// <param name="x">poloha v hernim poli na ose x</param>
 /// <param name="y">poloha v hernim poli na ose y</param>
 public AbstractWall(Game game, int x, int y)
     : base(game)
 {
     base.modelPosition = new Vector3(x * 20, 0, y * 20);
     boundingBox = new BoundingBox(new Vector3(modelPosition.X - 10, modelPosition.Y, modelPosition.Z - 10),
         new Vector3(modelPosition.X + 10, modelPosition.Y + 20, modelPosition.Z + 10));
 }
Example #27
0
        public Player(Vector3 position,
            Vector3 velocity)
        {
            mPosition = position;
            mVelocity = velocity;

            mBound = new BoundingBox(mPosition + new Vector3(-5.0f, -100.0f, -5.0f), mPosition + new Vector3(5.0f, 35.0f, 5.0f));

            mYaw   = 0.0f;
            mPitch = 0.0f;

            mPlayerCamera = new Camera(mPosition, Quaternion.CreateFromAxisAngle(Vector3.Up, mYaw));

            // Start Player with 3 Stones.
            mBackpack.Clear();
            Player.AddItem("Stone");
            Player.AdjustQuantity("Stone", 2);

            m_rumble_start  = 150.0f;
            m_rumble_finish = 150.0f;
            m_prev_time     = 0.0f;
            m_time          = 0.0f;

            mFinishJump = SoundMaster.GetSound("jump_thud");
            mThrowStone = SoundMaster.GetSound("throw_sound");
        }
 /// <summary>
 /// konstruktor
 /// </summary>
 /// <param name="game">instance tridy</param>
 /// <param name="position">pozice bloku</param>
 public LabyrinthBlock(Game game, Vector3 position)
     : base(game)
 {
     base.modelPosition = position;
     boundingBox = new BoundingBox(new Vector3(position.X - 10, position.Y, position.Z - 10),
         new Vector3(position.X + 10, position.Y + 20, position.Z + 10));
 }
        /// <summary>
        /// Renders the bounding box for debugging purposes.
        /// </summary>
        /// <param name="box">The box to render.</param>
        /// <param name="graphicsDevice">The graphics device to use when rendering.</param>
        /// <param name="view">The current view matrix.</param>
        /// <param name="projection">The current projection matrix.</param>
        /// <param name="color">The color to use drawing the lines of the box.</param>
        public static void Render(
            BoundingBox box,
            GraphicsDevice graphicsDevice,
            Matrix view,
            Matrix projection,
            Color color)
        {
            if (box.Min == box.Max)
            {
                return;
            }

            if (effect == null)
            {
                effect = new BasicEffect(graphicsDevice)
                             {TextureEnabled = false, VertexColorEnabled = true, LightingEnabled = false};
            }

            Vector3[] corners = box.GetCorners();
            for (int i = 0; i < 8; i++)
            {
                verts[i].Position = corners[i];
                verts[i].Color = color;
            }

            effect.View = view;
            effect.Projection = projection;

            foreach (EffectPass pass in effect.CurrentTechnique.Passes)
            {
                pass.Apply();
                graphicsDevice.DrawUserIndexedPrimitives(PrimitiveType.LineList, verts, 0, 8, indices, 0,
                                                         indices.Length/2);
            }
        }
    /// <summary>
    /// Initializes a new instance of the <see cref="PhysxGhostObject"/> class.
    /// </summary>
    /// <param name="position">The position.</param>
    /// <param name="orientation">The orientation.</param>
    /// <param name="scale">The scale.</param>
    /// <param name="bb">The bb.</param>
 public PhysxGhostObject(Vector3 position, Matrix orientation, Vector3 scale, BoundingBox? bb = null) 
 {
     this.pos = position;
     this.ori = orientation;
     this.scale = scale;
     this.bb = bb;
 }