/* * Sky * http://vterrain.org/Atmosphere/index.html * * https://gamedev.ru/code/forum/?id=19689 * http://www.philohome.com/skycollec/skycollec.htm * http://steps3d.narod.ru/tutorials/sky-tutorial.html */ public static SkyGameObject Create(IEntityManager manager) { var resources = Path.Combine(@"Resources\sky\"); //../../../../D3DLab.Wpf.Engine.App/Resources/sky/ var tag = new ElementTag("SkyDome"); var plane = new ElementTag("SkyPlane"); //var geo = GenerateSphere(2, Vector3.Zero, 15f.ToRad()); var file = new FileInfo(Path.Combine(resources, "sky.obj")); var points = new List <Vector3>(); var indx = new List <int>(); var index = 0; foreach (var line in File.ReadAllLines(file.FullName)) { var parts = line.Split(' '); points.Add(new Vector3(float.Parse(parts[1]), float.Parse(parts[2]), float.Parse(parts[3]))); indx.Add(index); index++; } var geo = new HittableGeometryComponent(); geo.Positions = points.ToImmutableArray(); geo.Indices = indx.ToImmutableArray(); geo.Color = V4Colors.White; //geo.TextureCoordinates = geo.Positions.Select(x => new Vector2()).ToImmutableArray(); manager.CreateEntity(tag) .AddComponents(new IGraphicComponent[] { new D3DSkyRenderComponent() { }, geo, TransformComponent.Identity(), new GradientMaterialComponent(), new FollowUpCameraPositionComponent() }); var planemesh = GeometryBuilder.BuildSkyPlane(SkyPlaneData.Default); manager.CreateEntity(plane) .AddComponents(new IGraphicComponent[] { new D3DSkyPlaneRenderComponent(), new D3DTexturedMaterialSamplerComponent( new System.IO.FileInfo(Path.Combine(resources, "cloud001.bmp")), new System.IO.FileInfo(Path.Combine(resources, "cloud002.bmp")) ), new SimpleGeometryComponent { Positions = planemesh.Positions.ToImmutableArray(), Indices = planemesh.Indices.ToImmutableArray(), TextureCoordinates = planemesh.TextureCoordinates.ToImmutableArray(), }, TransformComponent.Identity(), new FollowUpCameraPositionComponent(), new SkyPlaneParallaxAnimationComponent() }); return(new SkyGameObject(tag)); }