Exemple #1
0
        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));
        }