コード例 #1
0
ファイル: Gaming.cs プロジェクト: pavluntiy/superProject
        private void calculateCollisions(ref WorldTriangle[] triangles, ref Ball ball, ref Vector3 force, ref Vector3 impuls)
        {
            Dictionary<Vector3, int> usedNormals = new Dictionary<Vector3, int>();
            HashSet<Vector3> forces = new HashSet<Vector3>();
            Vector3 remainingForce = Vector3.Zero;
            Vector3  impulsResult = new Vector3(0, 0, 0), forceResult = new Vector3(0, 0, 0), remainingImpuls = impuls;
            foreach(var triangle in triangles){
                Vector3[] ct = new Vector3[]{triangle.A, triangle.B, triangle.C};
                Vector3 normal = triangle.normal;
                bool onEdge;

                if (Intersects(ref ball.boundingSphere, ref ct, out onEdge))
                {
                    if (normal == Vector3.Zero)
                    {
                        continue;
                    }
                    if (triangle.material == Material.Wood)
                    {
                        interactWithWood(ref force, ref impuls, ref forceResult, ref impulsResult, ref remainingForce, ref remainingImpuls, ref usedNormals, ref onEdge, ref normal);
                    }
                    if (triangle.material == Material.Metal)
                    {
                        interactWithMetal(ref force, ref impuls, ref forceResult, ref impulsResult, ref remainingForce, ref remainingImpuls, ref usedNormals, ref onEdge, ref normal);
                    }

                    if (triangle.material == Material.Lava)
                    {
                        interactWithLava(ref force, ref impuls, ref forceResult, ref impulsResult, ref remainingForce, ref remainingImpuls, ref usedNormals, ref onEdge, ref normal);
                    }
                    if (triangle.material == Material.Slime)
                    {
                        interactWithSlime(ref force, ref impuls, ref forceResult, ref impulsResult, ref remainingForce, ref remainingImpuls, ref usedNormals, ref onEdge, ref normal);
                    }

                    if (triangle.material == Material.Marble ||
                        triangle.material == Material.Plastic ||
                        triangle.material == Material.Stone)
                    {
                        interactWithTransformer(triangle.material, ref force, ref impuls, ref forceResult, ref impulsResult, ref remainingForce, ref remainingImpuls, ref usedNormals, ref onEdge, ref normal);
                    }
                }

            }

            impuls = impulsResult + remainingImpuls;
            force += forceResult;
        }
コード例 #2
0
ファイル: Gaming.cs プロジェクト: pavluntiy/superProject
        protected override void LoadContent()
        {
            effect = new BasicEffect(device);
               textures = new Dictionary<Material,Texture2D>();
            textures[Material.Wood] = parentGame.Content.Load<Texture2D>("wood");
            textures[Material.Metal] = parentGame.Content.Load<Texture2D>("metal");
            textures[Material.Slime] = parentGame.Content.Load<Texture2D>("slime");
            textures[Material.Lava] = parentGame.Content.Load<Texture2D>("lava");

            skyBoxEffect = parentGame.Content.Load<Effect>("skyBoxEffect");
            ball = new Ball(loadModel("ball"), this);
            textures[Material.Marble] = ball.textures[Ball.Material.Marble] = parentGame.Content.Load<Texture2D>("marble");
            textures[Material.Plastic] = ball.textures[Ball.Material.Plastic] = parentGame.Content.Load<Texture2D>("plastic");
            textures[Material.Stone] = ball.textures[Ball.Material.Stone] = parentGame.Content.Load<Texture2D>("stone");

            bonusTextures = new Dictionary<Bonus.BonusType, Texture2D>();
            bonusTextures[Bonus.BonusType.Live] = parentGame.Content.Load<Texture2D>("live_texture");
            bonusTextures[Bonus.BonusType.Score] = parentGame.Content.Load<Texture2D>("score_texture");
            bonusTextures[Bonus.BonusType.Save] = parentGame.Content.Load<Texture2D>("save_texture");
            bonusTextures[Bonus.BonusType.End] = parentGame.Content.Load<Texture2D>("end_texture");
            bonusTextures[Bonus.BonusType.Key] = parentGame.Content.Load<Texture2D>("key_texture");

            font = parentGame.Content.Load<SpriteFont>("myFont");
            skyBoxTexture = parentGame.Content.Load<TextureCube>(this.name + " " + "sky");

            skyBoxModel = loadModel("SkySphereModel");

            setBonuses();
            SetUpCamera();
            SetModel();
            SetUpVertices();
            DrawStaticWorld();
        }