コード例 #1
0
        private void PrepareAnimation()
        {
            floorPoint   = new Point3D(0, ((TSkeleton[])SKLRecording[0])[0].Position[15].Y, 0);
            myBallModels = new BallModel[1];
            for (int a = 0; a < myBallModels.Length; a++)
            {
                if (a == 0)
                {
                    myBallModels[a] = new BallModel(_models, Colors.Red, Colors.Green);
                }
                else
                {
                    myBallModels[a] = new BallModel(_models, Colors.Orange, Colors.BlueViolet);
                }
            }

            _models.ForEach(x => mainViewport.Children.Add(x));


            ImageBrush colors_brush = new ImageBrush();

            colors_brush.ImageSource =
                new BitmapImage(new Uri("Wall3.png", UriKind.Relative));

            //colors_brush.TileMode = TileMode.Tile;
            //colors_brush.Stretch = Stretch.None;
            DiffuseMaterial colors_material =
                new DiffuseMaterial(colors_brush);

            double eps        = 0.1;
            double roomHeight = 4;
            double roomWidth  = 10;

            //front
            mainViewport.Children.Add(GraphicPrimitiveGenerator.GetTexturedCube(colors_material, new Point3D(floorPoint.X, floorPoint.Y + (roomHeight / 2.0) - eps, floorPoint.Z + (roomWidth / 2.0)), new Size3D(roomWidth, roomHeight, 0.01)));
            //right
            mainViewport.Children.Add(GraphicPrimitiveGenerator.GetTexturedCube(colors_material, new Point3D(floorPoint.X - (roomWidth / 2.0), floorPoint.Y + (roomHeight / 2.0) - eps, floorPoint.Z), new Size3D(0.01, roomHeight, roomWidth)));
            //left
            mainViewport.Children.Add(GraphicPrimitiveGenerator.GetTexturedCube(colors_material, new Point3D(floorPoint.X + (roomWidth / 2.0), floorPoint.Y + (roomHeight / 2.0) - eps, floorPoint.Z), new Size3D(0.01, roomHeight, roomWidth)));
            //rear
            mainViewport.Children.Add(GraphicPrimitiveGenerator.GetTexturedCube(colors_material, new Point3D(floorPoint.X, floorPoint.Y + (roomHeight / 2.0) - eps, floorPoint.Z - (roomWidth / 2.0)), new Size3D(roomWidth, roomHeight, 0.01)));

            colors_brush             = new ImageBrush();
            colors_brush.ImageSource =
                new BitmapImage(new Uri("Floor.png", UriKind.Relative));
            //new BitmapImage(new Uri("Floor3.png", UriKind.Relative));
            colors_material =
                new DiffuseMaterial(colors_brush);

            //ceiling
            ceiling = GraphicPrimitiveGenerator.GetTexturedCube(colors_material, new Point3D(floorPoint.X, floorPoint.Y + roomHeight - eps, floorPoint.Z), new Size3D(roomWidth, 0.01, roomWidth));
            mainViewport.Children.Add(ceiling);
            //floor
            mainViewport.Children.Add(GraphicPrimitiveGenerator.GetTexturedCube(colors_material, new Point3D(floorPoint.X, floorPoint.Y, floorPoint.Z), new Size3D(roomWidth, 0.01, roomWidth)));
            mainViewport.ClipToBounds     = false;
            mainViewport.IsHitTestVisible = false;
        }
コード例 #2
0
ファイル: BallModel.cs プロジェクト: hendra24/Tugas-Akhir
 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);
                     }
                 }
             }
         }
     }
 }