internal override void LoadCullingInformation(MeshCulling culling)
 {
     ReferencedStuds.Clear();
     ReferencedStuds.AddRange(ConvertFromRefs(culling.Studs));
     //var connectorRef = culling.Studs.FirstOrDefault() ?? culling.AdjacentStuds.FirstOrDefault();
     //ConnectionIndex = connectorRef != null ? connectorRef.ConnectorIndex : -1;
 }
Exemple #2
0
        public static SurfaceComponent CreateFromLDD(MeshCulling culling, ModelMesh mainModel)
        {
            SurfaceComponent modelComponent = null;

            switch (culling.Type)
            {
            case MeshCullingType.MainModel:
                modelComponent = new PartModel();
                break;

            case MeshCullingType.MaleStud:
                modelComponent = new MaleStudModel();
                break;

            case MeshCullingType.FemaleStud:
                modelComponent = new FemaleStudModel();
                break;

            case MeshCullingType.BrickTube:
                modelComponent = new BrickTubeModel();
                break;
            }

            if (modelComponent != null)
            {
                modelComponent.LoadCullingInformation(culling);
                modelComponent.Meshes.Add(new ModelMeshReference(mainModel, culling));
            }

            return(modelComponent);
        }
Exemple #3
0
        internal override void FillCullingInformation(MeshCulling culling)
        {
            base.FillCullingInformation(culling);

            if (ReplacementMeshes.Any())
            {
                var builder = new GeometryBuilder();
                foreach (var meshRef in ReplacementMeshes)
                {
                    builder.CombineGeometry(meshRef.GetGeometry(true));
                }

                if (Surface.SurfaceID == 0)
                {
                    builder.RemoveTextureCoords();
                }

                culling.ReplacementMesh = builder.GetGeometry();
            }
        }
Exemple #4
0
        public static MeshFile ReadMesh(Stream stream)
        {
            try
            {
                var  meshFile   = ReadMeshFile(stream);
                var  meshType   = (MeshType)meshFile.Header.MeshType;
                bool isTextured = meshType == MeshType.StandardTextured || meshType == MeshType.FlexibleTextured;
                bool isFlexible = meshType == MeshType.Flexible || meshType == MeshType.FlexibleTextured;

                var mainMesh = MeshGeometry.Create(meshFile.Geometry);

                SetShaderData(meshFile, meshFile.Geometry, mainMesh);

                var mesh = new MeshFile(mainMesh);
                if (stream is FileStream fs)
                {
                    mesh.Filename = fs.Name;
                }

                mesh.SetGeometry(mainMesh);

                for (int i = 0; i < meshFile.Cullings.Length; i++)
                {
                    var data    = meshFile.Cullings[i];
                    var culling = new MeshCulling((MeshCullingType)data.Type)
                    {
                        FromIndex   = data.FromIndex,
                        IndexCount  = data.IndexCount,
                        FromVertex  = data.FromVertex,
                        VertexCount = data.VertexCount,
                    };

                    if (data.Studs != null && data.Studs.Length > 0)
                    {
                        for (int j = 0; j < data.Studs.Length; j++)
                        {
                            culling.Studs.Add(new Custom2DFieldReference(data.Studs[j]));
                        }
                    }

                    if (data.AdjacentStuds != null && data.AdjacentStuds.Length > 0)
                    {
                        for (int j = 0; j < data.AdjacentStuds.Length; j++)
                        {
                            culling.AdjacentStuds.Add(new Custom2DFieldReference(data.AdjacentStuds[j]));
                        }
                    }

                    if (data.AlternateMesh.HasValue)
                    {
                        var geom = MeshGeometry.Create(data.AlternateMesh.Value);
                        SetShaderData(meshFile, data.AlternateMesh.Value, geom);
                        culling.ReplacementMesh = geom;
                    }

                    mesh.Cullings.Add(culling);
                }
                return(mesh);
            }
            catch
            {
                throw;
            }
        }
Exemple #5
0
 internal virtual void FillCullingInformation(MeshCulling culling)
 {
 }
Exemple #6
0
 internal virtual void LoadCullingInformation(MeshCulling culling)
 {
 }
Exemple #7
0
        internal override void LoadCullingInformation(MeshCulling culling)
        {
            base.LoadCullingInformation(culling);

            //Studs.AddRange(ConvertFromRefs(culling.Studs));
        }
Exemple #8
0
 public MeshGeometry GetCullingGeometry(MeshCulling culling)
 {
     return(Geometry.GetPartialGeometry(culling.FromIndex, culling.IndexCount, culling.FromVertex, culling.VertexCount));
 }
 internal override void FillCullingInformation(MeshCulling culling)
 {
     base.FillCullingInformation(culling);
     culling.Studs.AddRange(ReferencedStuds.Select(x => ConvertToRef(x)));
 }
Exemple #10
0
        private static MESH_CULLING SerializeMeshCulling(MESH_FILE file, ShaderDataHelper shaderData, MeshCulling meshCulling)
        {
            var culling = new MESH_CULLING
            {
                Type        = (int)meshCulling.Type,
                FromVertex  = meshCulling.FromVertex,
                VertexCount = meshCulling.VertexCount,
                FromIndex   = meshCulling.FromIndex,
                IndexCount  = meshCulling.IndexCount
            };

            if (meshCulling.ReplacementMesh != null)
            {
                culling.AlternateMesh = SerializeMeshGeometry(file, shaderData, meshCulling.ReplacementMesh);
            }

            if (meshCulling.Studs != null && meshCulling.Studs.Any())
            {
                culling.Studs = meshCulling.Studs.Select(x => x.Serialize()).ToArray();
            }

            if (meshCulling.AdjacentStuds != null && meshCulling.AdjacentStuds.Any())
            {
                culling.AdjacentStuds = meshCulling.AdjacentStuds.Select(x => x.Serialize()).ToArray();
            }

            return(culling);
        }