Exemple #1
0
        public static TerrainGameObject Create(IEntityManager manager)
        {
            var tag = new ElementTag("Terrain");

            var resources = Path.Combine(@"Resources\terrain\");
            //"../../../../D3DLab.Wpf.Engine.App/Resources/terrain/"
            var grass    = Path.Combine(resources, "1.jpg");
            var slope    = Path.Combine(resources, "slope.bmp");
            var rock     = Path.Combine(resources, "rock-lambertian.jpg");
            var seafloor = Path.Combine(resources, "seafloor.bmp");
            var sand     = Path.Combine(resources, "sand-lambertian.png");
            var shore    = Path.Combine(resources, "shore.jpg");
            var dirt     = Path.Combine(resources, "dirt.bmp");
            var snow     = Path.Combine(resources, "snow01n.bmp");


            var heigtmap = Path.Combine(resources, "test.bmp");

            manager.CreateEntity(tag)
            .AddComponents(new IGraphicComponent[] {
                new D3DTerrainRenderComponent()
                {
                    CanRender = false
                },
                new Systems.TerrainConfigurationComponent {
                    Width  = 256,
                    Height = 256,
                },
                new D3DTexturedMaterialSamplerComponent(
                    new System.IO.FileInfo(seafloor),
                    new System.IO.FileInfo(shore),
                    new System.IO.FileInfo(sand),
                    new System.IO.FileInfo(grass),
                    new System.IO.FileInfo(dirt),
                    new System.IO.FileInfo(rock),
                    new System.IO.FileInfo(slope),

                    new System.IO.FileInfo(Path.Combine(resources, "rock01n.bmp")),
                    new System.IO.FileInfo(snow),
                    new System.IO.FileInfo(Path.Combine(resources, "distance01n.bmp"))
                    ),
                TransformComponent.Identity(),
                PhysicalComponentFactory.CreateStaticMesh()
            });

            return(new TerrainGameObject(tag));
        }
Exemple #2
0
        public static SingleGameObject CreateStatic(IEntityManager manager, BoundingBox box)
        {
            var tag = new ElementTag("Physics Static " + Guid.NewGuid());

            var geobox = GeometryBuilder.BuildGeoBox(box);

            manager.CreateEntity(tag)
            .AddComponents(new IGraphicComponent[] {
                new SimpleGeometryComponent {
                    Positions = geobox.Positions.ToImmutableArray(),
                    Indices   = geobox.Indices.ToImmutableArray(),
                    Normals   = geobox.Positions.CalculateNormals(geobox.Indices).ToImmutableArray(),
                    Color     = new Vector4(1, 0, 0, 1)
                },
                new D3DTriangleColoredVertexRenderComponent(),
                TransformComponent.Identity(),
                //PhysicalComponentFactory.CreateStaticAABB(),
                PhysicalComponentFactory.CreateStaticMesh(),
            });

            return(new PhysicsObjectTest(tag));
        }