예제 #1
0
        //Transform3D[] t3DModels = null;

        private void MoveBalls(TSkeleton skeleton)
        {
            for (int a = 0; a < 21; a++)
            {
                BallBoundingBox bbb = (BallBoundingBox)balls[a];
                bbb.X = skeleton.Position[a].X;
                bbb.Y = skeleton.Position[a].Y;
                bbb.Z = skeleton.Position[a].Z;
            }
            for (int a = 0; a < jointIndexAray.Count; a++)
            {
                BallBoundingBox bbb       = (BallBoundingBox)balls[a + 21];
                JointIndex      ji        = (JointIndex)jointIndexAray[a];
                int             divHelper = ji.visuals.Count + 1;
                for (int b = 0; b < ji.visuals.Count; b++)
                {
                    ModelVisual3D mv3d = (ModelVisual3D)ji.visuals[b];
                    float         f16X = skeleton.Position[ji.joint1].X;
                    float         f16Y = skeleton.Position[ji.joint1].Y;
                    float         f16Z = skeleton.Position[ji.joint1].Z;

                    float f17X = skeleton.Position[ji.joint2].X;
                    float f17Y = skeleton.Position[ji.joint2].Y;
                    float f17Z = skeleton.Position[ji.joint2].Z;

                    float aa = (float)(b + 1) / divHelper;
                    //float aa = (float)b / ji.visuals.Count;
                    bbb.X = (aa * f16X) + ((1 - aa) * f17X);
                    bbb.Y = (aa * f16Y) + ((1 - aa) * f17Y);
                    bbb.Z = (aa * f16Z) + ((1 - aa) * f17Z);
                }
            }
        }
예제 #2
0
        public bool Collide(BallBoundingBox ballBoundingBox)
        {
            double distance = ((X - ballBoundingBox.X) * (X - ballBoundingBox.X)) + ((Y - ballBoundingBox.Y) * (Y - ballBoundingBox.Y)) + ((Z - ballBoundingBox.Z) * (Z - ballBoundingBox.Z));

            if (distance < ((ballBoundingBox.Radius + Radius) * (ballBoundingBox.Radius + Radius)))
            {
                return(true);
            }
            return(false);
        }
예제 #3
0
 public void DetectCollision(BallModel ballModel, ArrayList collisions)
 {
     for (int a = 0; a < balls.Count; a++)
     {
         for (int b = a; b < ballModel.balls.Count; b++)
         {
             BallBoundingBox bbb  = (BallBoundingBox)balls[a];
             BallBoundingBox bbb2 = (BallBoundingBox)ballModel.balls[b];
             if (bbb.Collide(bbb2))
             {
                 if (collisions != null)
                 {
                     CollisionExemplar ce = new CollisionExemplar(bbb.JointType1, bbb.JointType2, bbb2.JointType1, bbb2.JointType2);
                     if (!collisions.Contains(ce))
                     {
                         collisions.Add(ce);
                     }
                 }
             }
         }
     }
 }