예제 #1
0
        public Ship(Model model, Model model2, Vector3 pos)
        {
            this.model = model;
            this.model2 = model2;

            foreach (var mesh in model.Meshes)
            {
                foreach (BasicEffect effect in mesh.Effects)
                {
                    Sun.Apply(effect);
                }
            }

            foreach (var mesh in model2.Meshes)
            {
                foreach (BasicEffect effect in mesh.Effects)
                {
                    Sun.Apply(effect);
                }
            }

            //model.Meshes

            float w = 1.4f, l = 1.5f;
            verlets = new Verlet[]
            {
                new Verlet( new Vector3( l, -w, 0 ) + pos ),
                new Verlet( new Vector3( l, w, 0 ) + pos ),
                new Verlet( new Vector3( -l, w, 0 ) + pos ),
                new Verlet( new Vector3( -l, -w, 0 ) + pos ),
                new Verlet( new Vector3( 0, 0, 1f ) + pos ),
                new Verlet( new Vector3( 0, -2/2, -0.5f ) + pos )
            };
            GenerateFullyConnectedBody();
        }
예제 #2
0
 public static void ApplyLengthConstraint(ref Verlet v1, ref Verlet v2, float length)
 {
     Vector3 dPos = v2.Pos - v1.Pos;
     float dLength = dPos.Length();
     Vector3 correction = (dLength - length) / dLength * 0.5f * dPos;
     v1.Pos += correction;
     v2.Pos -= correction;
 }