public StageBuilder(Model3DGroup Container, CollisionResponser Responser, Setup Settings)
            {
                this.Terrain3D   = new MeshGeometry3D();
                this.MeshBuilder = new BasicBuilder(Container, Responser, Settings);
                this.Responser   = Responser;
                this.Container   = Container;
                this.Settings    = Settings;

                var GeometryModel = new GeometryModel3D();

                GeometryModel.Geometry = Terrain3D;
                GeometryModel.Material = new DiffuseMaterial(LoadTexture());
                //GeometryModel.BackMaterial = new DiffuseMaterial(Brushes.Black);

                lastTP           = new TerrainPoint();
                lastTP.point3d.X = 0;
                lastTP.point3d.Y = -1;
                lastTP.point3d.Z = 0;

                BoundBox = new Rect3D(0, 0, 0, 0, 0, 0);

                TerrainPoints = new List <TerrainPoint>(100);
                TerrainPoints.Add(lastTP);
                RandomTerrainPoints(100);

                //Container.Children.Add(GeometryModel);
            }
 public void RandomTerrainPoints(int count)
 {
     for (int i = 0; i < count; i++)
     {
         TerrainPoint np = RandomTerrainPoint(i > 10);
         lastTP = np;
         TerrainPoints.Add(np);
     }
 }
            public TerrainPoint RandomTerrainPoint(bool IsRandom = true)
            {
                TerrainPoint tmp = new TerrainPoint();

                tmp.angle          = Math.Min(Math.PI * 2, Math.Max(lastTP.angle + (IsRandom ? (Settings.Random(curve_param) - curve_param / 2) : 0), -Math.PI));
                tmp.vertical_angle = Math.Min(max_vertical_param, Math.Max(lastTP.vertical_angle + (IsRandom ? ((Settings.Random() - 0.5) * max_vertical_param / 3) : 0), -max_vertical_param));

                tmp.point3d.Z = lastTP.point3d.Z + r * Math.Sin(tmp.angle);
                tmp.point3d.X = lastTP.point3d.X + r * Math.Cos(tmp.angle);
                tmp.point3d.Y = lastTP.point3d.Y + r / 4 * Math.Sin(tmp.vertical_angle);

                return(tmp);
            }
            /**
             * Calculates left and right side of the road
             */
            protected RoadArc CalculateHelperPoints(TerrainPoint calculating_point)
            {
                double  distance = 5;
                RoadArc tmp_arc  = new RoadArc();

                double add_x = Math.Cos(calculating_point.angle + Math.PI / 2) * distance;
                double add_z = Math.Sin(calculating_point.angle + Math.PI / 2) * distance;

                tmp_arc.left_x = calculating_point.point3d.X - add_x;
                tmp_arc.left_z = calculating_point.point3d.Z - add_z;

                tmp_arc.right_x = calculating_point.point3d.X + add_x;
                tmp_arc.right_z = calculating_point.point3d.Z + add_z;

                tmp_arc.left_x2 = calculating_point.point3d.X - add_x * 8;
                tmp_arc.left_z2 = calculating_point.point3d.Z - add_z;

                tmp_arc.right_x2 = calculating_point.point3d.X + add_x * 14;
                tmp_arc.right_z2 = calculating_point.point3d.Z + add_z;

                return(tmp_arc);
            }
 public void addRoad(TerrainPoint from, TerrainPoint to)
 {
 }