示例#1
0
        public void LoadGameObject(IFileGeometry3D geo, FileInfo texture, string fileName)
        {
            var em = context.GetEntityManager();

            var box    = AxisAlignedBox.CreateFrom(geo.Positions);
            var center = box.Center;

            var c = (System.Windows.Media.Color)System.Windows.Media.ColorConverter.ConvertFromString("#B3B598");

            GraphicEntity en;

            if (geo.TextureCoors.Any())
            {
                en = EntityBuilders.BuildTextured(context, geo.Positions, geo.Indices,
                                                  geo.TextureCoors.ToArray(), texture,
                                                  SharpDX.Direct3D11.CullMode.None);
            }
            else
            {
                en = EntityBuilders.BuildColored(context, geo.Positions, geo.Indices, geo.Normals,
                                                 ToVector4(c), SharpDX.Direct3D11.CullMode.Front);
                en.UpdateComponent(FlatShadingGeometryComponent.Create());
            }
            en.UpdateComponent(TransformComponent.Create(Matrix4x4.CreateTranslation(Vector3.Zero - center)));
            GameObjects.Add(new SingleVisualObject(en.Tag, fileName));

            //var boxlines = PolylineGameObject.Create(
            //    Context,
            //    new ElementTag("poly"),
            //    GeometryBuilder.BuildBox(
            //        new AxisAlignedBox(box.Minimum, box.Maximum)),
            //    V4Colors.Blue
            //    );

            //Context.GetEntityManager().GetEntity(boxlines.Tag)
            //    .UpdateComponent(TransformComponent.Create(Matrix4x4.CreateTranslation(Vector3.Zero - center)));

            //GameObjects.Add(boxlines);
        }
示例#2
0
 public static ImmutableGeometryData ToGeometryData(this IFileGeometry3D fgeo)  //
 {
     return(new ImmutableGeometryData(fgeo.Positions, fgeo.Normals, fgeo.Indices,
                                      fgeo.TextureCoors, fgeo.Colors.Select(x => x.ToVector4()).ToList()));
 }