コード例 #1
0
ファイル: Asteroid.cs プロジェクト: Pustinek-G/Personal
        public static void Init()
        {
            model = new ObjMesh("Resources\\Models\\Planets\\Rock1.obj");
            tex = Game.LoadTexture("Resources\\Textures\\Rock-Texture-Surface.jpg");

            asteriods = new List<Asteroid>();
            //asteriods.Add(new Asteroid(new Vector3(0, 0, -100), new Vector3(0, 0, 30f), 3f));
            //asteriods.Add(new Asteroid(new Vector3(0, 0, 100), new Vector3(0, 0, -30f), 1f));

            for (int i = 0; i < 200; i++)
            {
                Vector3 pos = new Vector3(AppSettings.random.Next(100, 500), AppSettings.random.Next(100, 500), AppSettings.random.Next(100, 500));
                Vector3 n = -Vector3.UnitX;
                n.Normalize();
                Asteroid a = new Asteroid(pos, n*10, AppSettings.random.Next(1, 5));
                asteriods.Add(a);

            }

            for (int i = 0; i < 200; i++)
            {
                Vector3 pos = new Vector3(0-AppSettings.random.Next(100, 500), AppSettings.random.Next(100, 500), AppSettings.random.Next(100, 500));
                Vector3 n = Vector3.UnitX;
                n.Normalize();
                Asteroid a = new Asteroid(pos, n * 10, AppSettings.random.Next(1, 5));
                asteriods.Add(a);

            }
        }
コード例 #2
0
ファイル: Asteroid.cs プロジェクト: Pustinek-G/Personal
        public void Crash(Asteroid o)
        {
            float mass1 = this.mass;
            float mass2 = o.mass;
            Vector3 n = (this.bb.center+this.position) - (o.bb.center+o.position);
            n.NormalizeFast();

            float a1 = Vector3.Dot(this.movement, n);
            float a2 = Vector3.Dot(o.movement, n);

            float iz = (2f * (a1 - a2)) / (mass1 + mass2);

            this.movement -= iz * mass2 * n;
            o.movement += iz * mass1 * n;
        }