public static SingleGameObject Create(IEntityManager manager, BoundingBox box, Vector4 color) { var tag = new ElementTag("Physics Object" + Guid.NewGuid()); //var box = new BoundingBox(new Vector3(-5,10,-5), new Vector3(5,20,5)); box = box.Transform(Matrix4x4.CreateTranslation(new Vector3(64, 100, 32) - box.GetCenter())); 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 = color }, new D3DTriangleColoredVertexRenderComponent(), TransformComponent.Create(Matrix4x4.Identity), PhysicalComponentFactory.CreateAABB(), // PhysicalComponentFactory.CreateMesh(), }); return(new PhysicsObjectTest(tag)); }
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)); }
public static SingleGameObject CreateStaticAABB(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(), }); return(new PhysicsObjectTest(tag)); }