当前位置: 首页>>代码示例>>C#>>正文


C# GeometryModel3D.Freeze方法代码示例

本文整理汇总了C#中System.Windows.Media.Media3D.GeometryModel3D.Freeze方法的典型用法代码示例。如果您正苦于以下问题:C# GeometryModel3D.Freeze方法的具体用法?C# GeometryModel3D.Freeze怎么用?C# GeometryModel3D.Freeze使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Windows.Media.Media3D.GeometryModel3D的用法示例。


在下文中一共展示了GeometryModel3D.Freeze方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: CreateEllipse3D

        private GeometryModel3D CreateEllipse3D(Brush modelColor, Point3D startPoint, double radius, double maxHigh, Point[] texturePoint)
        {
            try
            {
                Material material = new DiffuseMaterial(modelColor);

                GeometryModel3D triangleModel = new GeometryModel3D(
                    CylinderMech(32, 32, radius, startPoint, maxHigh,texturePoint), material);

                triangleModel.Freeze();
                return triangleModel;
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
开发者ID:kse-jp,项目名称:RM-3000,代码行数:17,代码来源:EllipseModel.cs

示例2: ToModel3D

        /// <summary>
        /// Builds the model.
        /// </summary>
        /// <returns>The model.</returns>
        public Model3DGroup ToModel3D()
        {
            Model3DGroup modelGroup = null;
            this.Dispatch(
                () =>
                {
                    modelGroup = new Model3DGroup();
                    int i = 0;
                    foreach (var mesh in this.Meshes)
                    {
                        var gm = new GeometryModel3D
                                     {
                                         Geometry = mesh.ToMesh(),
                                         Material = this.Materials[i],
                                         BackMaterial = this.Materials[i]
                                     };
                        if (this.Freeze)
                        {
                            gm.Freeze();
                        }

                        modelGroup.Children.Add(gm);
                        i++;
                    }

                    if (this.Freeze)
                    {
                        modelGroup.Freeze();
                    }
                });
            return modelGroup;
        }
开发者ID:ondrej11,项目名称:o106,代码行数:36,代码来源:StLReader.cs

示例3: CreateEllipse2D

        /// <summary>
        /// create 2D Ellipse
        /// </summary>
        /// <param name="modelColor">color</param>
        /// <param name="startPoint">start point</param>
        /// <param name="radius">radius</param>
        /// <param name="normal">normal vector</param>
        /// <returns></returns>
        private GeometryModel3D CreateEllipse2D(Brush modelColor, Point3D startPoint, double radius, Vector3D normal)
        {
            try
            {
                Material material = new DiffuseMaterial(modelColor);

                GeometryModel3D triangleModel = new GeometryModel3D(
                    CircleMesh(normal, startPoint, radius), material);

                triangleModel.Freeze();
                return triangleModel;
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
开发者ID:kse-jp,项目名称:RM-3000,代码行数:25,代码来源:EllipseModel.cs

示例4: UpdateCurrentTile

        private void UpdateCurrentTile(PointCloudTile tile)
        {
            if (tile == null)
                return;

            List<PointCloudTile> tilesToLoad = new List<PointCloudTile>();
            int pointsToLoad = 0;

            Model3DGroup emptyModelGroup = new Model3DGroup();
            emptyModelGroup.Freeze();

            bool isDirty = false;

            int radius = 2;

            int xMin = Math.Max(0, tile.Col - radius);
            int xMax = Math.Min(tile.Col + radius + 1, CurrentTileSource.TileSet.Cols);
            int yMin = Math.Max(0, tile.Row - radius);
            int yMax = Math.Min(tile.Row + radius + 1, CurrentTileSource.TileSet.Rows);
            for (int x = xMin; x < xMax; x++)
            {
                for (int y = yMin; y < yMax; y++)
                {
                    PointCloudTile currentTile = CurrentTileSource.TileSet.GetTile(y, x);

                    if (currentTile != null)
                    {
                        if (!m_loadedTiles.ContainsKey(currentTile))
                        {
                            tilesToLoad.Add(currentTile);
                            pointsToLoad += currentTile.PointCount;

                            isDirty = true;
                        }
                    }
                }
            }

            PointCloudTile[] loadedTiles = m_loadedTiles.Keys.ToArray();
            SortByDistanceFromTile(loadedTiles, tile);
            Array.Reverse(loadedTiles);

            // drop loaded tiles that are the farthest from the center
            int totalAllowedPoints = MAX_BUFFER_SIZE_BYTES / CurrentTileSource.PointSizeBytes;
            int loadedPoints = loadedTiles.Sum(t => t.PointCount);

            int potentialTotalPoints = loadedPoints + pointsToLoad;

            Dictionary<PointCloudTile, TileInfo3D> alteredTiles = new Dictionary<PointCloudTile, TileInfo3D>();

            if (potentialTotalPoints > totalAllowedPoints)
            {
                int pointsToDrop = potentialTotalPoints - totalAllowedPoints;
                int i = 0;
                while (pointsToDrop > 0)
                {
                    PointCloudTile currentTile = loadedTiles[i];
                    TileInfo3D tileInfo = m_tileInfo[currentTile];
                    GeometryModel3D model = m_loadedTiles[currentTile];

                    m_meshTileMap.Remove(model);
                    m_loadedTiles.Remove(currentTile);
                    //m_loadedTileBuffers.Remove(currentTile);

                    // replace high-res tile with low-res geometry
                    int modelIndex = tileInfo.Tile.ValidIndex;
                    m_tileModelCollection[modelIndex] = tileInfo.LowResGeometry;
                    // clear stitching
                    m_stitchingModelCollection[modelIndex] = emptyModelGroup;
                    tileInfo.ClearGeometry();

                    alteredTiles.Add(currentTile, tileInfo);

                    pointsToDrop -= currentTile.PointCount;
                    ++i;
                }
            }

            Jacere.Core.Geometry.Point3D centerOfMass = CurrentTileSource.CenterOfMass;

            PointCloudTile[] tilesToLoadArray = tilesToLoad.ToArray();
            #warning sort so that disk reads are in order? or make a tile cache
            SortByDistanceFromTile(tilesToLoadArray, tile);
            foreach (PointCloudTile currentTile in tilesToLoadArray)
            {
                TileInfo3D tileInfo = m_tileInfo[currentTile];
                CurrentTileSource.LoadTileGrid(currentTile, m_buffer, m_gridHighRes, m_quantizedGridHighRes);
                if (ENABLE_HEIGHT_EXAGGERATION)
                    m_gridHighRes.Multiply(m_heightExaggerationFactor, (float)centerOfMass.Z);

                Jacere.Core.Geometry.Extent3D tileExtent = currentTile.Extent;
                MeshGeometry3D mesh = CurrentTileSource.GenerateMesh(m_gridHighRes, tileExtent);

                DiffuseMaterial material = new DiffuseMaterial();
                if (USE_HIGH_RES_TEXTURE)
                {
                    material.Brush = m_overviewTextureBrush;
                    mesh.TextureCoordinates = MeshUtils.GeneratePlanarTextureCoordinates(mesh, m_overallCenteredExtent, MathUtils.ZAxis);
                }
                else
//.........这里部分代码省略.........
开发者ID:jdauie,项目名称:cloudae,代码行数:101,代码来源:Preview3D.xaml.cs

示例5: CreateModel3D

        /// <summary>
        /// Creates a <see cref="Model3DGroup" /> from the loaded file.
        /// </summary>
        /// <returns>A <see cref="Model3DGroup" />.</returns>
        public Model3DGroup CreateModel3D()
        {
            Model3DGroup modelGroup = null;
            this.Dispatch(
                () =>
                {
                    modelGroup = new Model3DGroup();
                    var g = this.CreateMeshGeometry3D();
                    var gm = new GeometryModel3D { Geometry = g, Material = this.DefaultMaterial };
                    gm.BackMaterial = gm.Material;
                    if (this.Freeze)
                    {
                        gm.Freeze();
                    }

                    modelGroup.Children.Add(gm);
                    if (this.Freeze)
                    {
                        modelGroup.Freeze();
                    }
                });

            return modelGroup;
        }
开发者ID:ondrej11,项目名称:o106,代码行数:28,代码来源:OffReader.cs

示例6: GenerateTileStitching

        private Model3DGroup GenerateTileStitching(PointCloudTileSource tileSource, TileInfo3D tileInfo)
        {
            PointCloudTile tile = tileInfo.Tile;
            MeshGeometry3D mesh = GetTileMeshGeometry(tileInfo.CurrentGeometry);
            Grid<float> grid = tileInfo.CurrentGrid;

            //Model3DGroup stitchingGroup = new Model3DGroup();

            bool hasTop = false;
            bool hasLeft = false;

            Point3D topCornerPoint = default(Point3D);
            Point3D leftCornerPoint = default(Point3D);

            Vector3D topCornerNormal = default(Vector3D);
            Vector3D leftCornerNormal = default(Vector3D);

            // connect to left tile (if available)
            if (tile.Col > 0)
            {
                PointCloudTile leftTile = tileSource.TileSet.GetTile(tile.Row, tile.Col - 1);
                TileInfo3D leftTileInfo = null;
                if (leftTile != null && m_tileInfo.TryGetValue(leftTile, out leftTileInfo) && leftTileInfo.CurrentGrid == grid)
                {
                    MeshGeometry3D leftMesh = GetTileMeshGeometry(leftTileInfo.CurrentGeometry);
                    int leftPositionsStart = leftMesh.Positions.Count - grid.SizeY;

                    hasLeft = true;
                    leftCornerPoint = leftMesh.Positions[leftPositionsStart];
                    leftCornerNormal = leftMesh.Normals[leftPositionsStart];

                    if (!tileInfo.HasStitching(TileStitchingEdge.Left))
                    {
                        MeshGeometry3D stitchingMesh = new MeshGeometry3D();

                        int positionCount = grid.SizeY * 2;
                        Point3DCollection positions = new Point3DCollection(positionCount);
                        Vector3DCollection normals = new Vector3DCollection(positionCount);

                        for (int edgePosition = 0; edgePosition < grid.SizeY; edgePosition++)
                        {
                            positions.Add(leftMesh.Positions[leftPositionsStart + edgePosition]);
                            normals.Add(leftMesh.Normals[leftPositionsStart + edgePosition]);

                            positions.Add(mesh.Positions[edgePosition]);
                            normals.Add(mesh.Normals[edgePosition]);
                        }
                        stitchingMesh.Positions = positions;
                        stitchingMesh.Normals = normals;

                        Int32Collection indices = new Int32Collection((grid.SizeY - 1) * 6);
                        for (int i = 0; i < grid.SizeY - 1; i++)
                        {
                            int j = 2 * i;
                            indices.Add(j);
                            indices.Add(j + 1);
                            indices.Add(j + 2);

                            indices.Add(j + 2);
                            indices.Add(j + 1);
                            indices.Add(j + 3);
                        }
                        stitchingMesh.TriangleIndices = indices;

                        stitchingMesh.TextureCoordinates = MeshUtils.GeneratePlanarTextureCoordinates(stitchingMesh, m_overallCenteredExtent, MathUtils.ZAxis);

                        GeometryModel3D stitchingModel = new GeometryModel3D(stitchingMesh, m_overviewMaterial);
                        stitchingModel.Freeze();

                        tileInfo.UpdateStitching(stitchingModel, leftTileInfo.CurrentGrid, TileStitchingEdge.Left);
                        //stitchingGroup.Children.Add(stitchingModel);
                    }
                }
            }

            // connect to top tile (if available)
            if (tile.Row > 0)
            {
                PointCloudTile topTile = tileSource.TileSet.GetTile(tile.Row - 1, tile.Col);
                TileInfo3D topTileInfo = null;
                if (topTile != null && m_tileInfo.TryGetValue(topTile, out topTileInfo) && topTileInfo.CurrentGrid == grid)
                {
                    MeshGeometry3D topMesh = GetTileMeshGeometry(topTileInfo.CurrentGeometry);

                    hasTop = true;
                    topCornerPoint = topMesh.Positions[grid.SizeY - 1];
                    topCornerNormal = topMesh.Normals[grid.SizeY - 1];

                    if (!tileInfo.HasStitching(TileStitchingEdge.Top))
                    {
                        MeshGeometry3D stitchingMesh = new MeshGeometry3D();

                        int positionCount = grid.SizeX * 2;
                        Point3DCollection positions = new Point3DCollection(positionCount);
                        Vector3DCollection normals = new Vector3DCollection(positionCount);

                        for (int edgePosition = 0; edgePosition < mesh.Positions.Count; edgePosition += grid.SizeY)
                        {
                            positions.Add(topMesh.Positions[edgePosition + grid.SizeY - 1]);
                            normals.Add(topMesh.Normals[edgePosition + grid.SizeY - 1]);
//.........这里部分代码省略.........
开发者ID:jdauie,项目名称:cloudae,代码行数:101,代码来源:Preview3D.xaml.cs

示例7: OnBackgroundDoWork

        private void OnBackgroundDoWork(object sender, DoWorkEventArgs e)
        {
            PointCloudTileSource tileSource = e.Argument as PointCloudTileSource;
            Jacere.Core.Geometry.Extent3D extent = tileSource.Extent;

            m_overviewTextureBrush = new ImageBrush(tileSource.Preview.Image);
            m_overviewTextureBrush.ViewportUnits = BrushMappingMode.Absolute;
            m_overviewTextureBrush.Freeze();

            m_overviewMaterial = new DiffuseMaterial(m_overviewTextureBrush);
            m_overviewMaterial.Freeze();

            if (tileSource != null)
            {
                previewImageGrid.MouseMove -= OnViewportGridMouseMove;

                Action<string> logAction = value => Context.WriteLine(value);
                m_progressManager = new BackgroundWorkerProgressManager(m_backgroundWorker, e, logAction, null);

                m_gridDimensionLowRes = (ushort)Math.Sqrt(VERTEX_COUNT_FAST / tileSource.TileSet.ValidTileCount);
                //m_gridDimensionHighRes = (ushort)Math.Sqrt(VERTEX_COUNT_LARGE / tileSource.TileSet.ValidTileCount);

                m_gridDimensionHighRes = (ushort)(Math.Sqrt(tileSource.TileSet.Density.MedianTileCount) / 3);

                //m_gridDimensionLowRes = (ushort)20;
                //m_gridDimensionHighRes = (ushort)40;

                Jacere.Core.Geometry.Point3D centerOfMass = tileSource.CenterOfMass;
                m_overallCenteredExtent = new Rect3D(extent.MinX - extent.MidpointX, extent.MinY - extent.MidpointY, extent.MinZ - centerOfMass.Z, extent.RangeX, extent.RangeY, extent.RangeZ);

                // load tiles
                KeyValuePair<Grid<int>, Grid<float>> gridsLowRes = tileSource.GenerateGrid(m_gridDimensionLowRes);
                m_gridLowRes = gridsLowRes.Value;
                m_quantizedGridLowRes = gridsLowRes.Key;

                KeyValuePair<Grid<int>, Grid<float>> gridsHighRes = tileSource.GenerateGrid(m_gridDimensionHighRes);
                m_gridHighRes = gridsHighRes.Value;
                m_quantizedGridHighRes = gridsHighRes.Key;

                foreach (PointCloudTile tile in tileSource.TileSet)
                {
                    tileSource.LoadTileGrid(tile, m_buffer, m_gridLowRes, m_quantizedGridLowRes);
                    if (ENABLE_HEIGHT_EXAGGERATION)
                        m_gridLowRes.Multiply(m_heightExaggerationFactor, (float)centerOfMass.Z);

                    Jacere.Core.Geometry.Extent3D tileExtent = tile.Extent;
                    MeshGeometry3D mesh = tileSource.GenerateMesh(m_gridLowRes, tileExtent);

                    DiffuseMaterial material = new DiffuseMaterial();
                    if (USE_LOW_RES_TEXTURE)
                    {
                        material.Brush = m_overviewTextureBrush;
                        mesh.TextureCoordinates = MeshUtils.GeneratePlanarTextureCoordinates(mesh, m_overallCenteredExtent, MathUtils.ZAxis);
                    }
                    else
                    {
                        material.Brush = m_solidBrush;
                    }

                    material.Freeze();
                    GeometryModel3D geometryModel = new GeometryModel3D(mesh, material);
                    geometryModel.Freeze();

                    TileInfo3D tileInfo = new TileInfo3D(tile, geometryModel, m_gridLowRes);
                    m_tileInfo.Add(tile, tileInfo);

                    // add mappings
                    m_meshTileMap.Add(geometryModel, tile);
                    //m_lowResMap.Add(tile, geometryModel);

                    if (!m_progressManager.Update(tile, geometryModel))
                        break;
                }

                //// test
                //foreach (double level in new double[] { centerOfMass.Z })
                //{
                //    Grid<float> grid0 = new Grid<float>(20, 20, extent, false);
                //    grid0.FillVal = (float)level;
                //    grid0.Reset();
                //    grid0.FillVal = float.MinValue;
                //    MeshGeometry3D mesh0 = tileSource.GenerateMesh(grid0, extent);
                //    DiffuseMaterial material0 = new DiffuseMaterial(m_solidBrush);
                //    material0.Freeze();
                //    GeometryModel3D geometryModel0 = new GeometryModel3D(mesh0, material0);
                //    geometryModel0.Freeze();
                //    m_progressManager.Update(1.0f, geometryModel0);
                //}

                if (ENABLE_STITCHING)
                {
                    int validStitchingIndex = 0;
                    foreach (PointCloudTile tile in tileSource.TileSet)
                    {
                        TileInfo3D tileInfo = m_tileInfo[tile];
                        Model3DGroup stitchingGroup = GenerateTileStitching(tileSource, tileInfo);

                        if (stitchingGroup != null)
                            ++validStitchingIndex;

//.........这里部分代码省略.........
开发者ID:jdauie,项目名称:cloudae,代码行数:101,代码来源:Preview3D.xaml.cs

示例8: VisualizeBimPlusDataAsGenericElements

        public List<MeshIdandGeometry> VisualizeBimPlusDataAsGenericElements(List<GenericElement> baseElements, object sender)
        {
            if (InputPorts[0].Data == null)
                return null;

            var max = baseElements.Count;
            var m_i = 1;

            // Init some lists and containers
            var container = new ContainerUIElement3D();
            var geometry = new List<MeshIdandGeometry>();

            // Init the MeshBuilde
            var meshBuilder = new MeshBuilder(false, false);

            // Loop the items of each list
            foreach (var item in baseElements)
            {
                // Get the geometric data from the AttributeGroups
                var points = item.AttributeGroups["geometry"].Attributes["threejspoints"] as IList<Point3D>;
                var triangleindices = item.AttributeGroups["geometry"].Attributes["geometryindices"];
                var indices =
                    (from index in triangleindices as IList<uint> select Convert.ToInt32(index)).ToList();

                for (var i = 0; i < indices.Count; i++)
                {
                    if (indices[i] == 0)
                    {
                        meshBuilder.AddTriangle(points[indices[i + 1]], points[indices[i + 2]],
                            points[indices[i + 3]]);

                        i = i + 3;
                    }
                    else if (indices[i] == 1)
                    {
                        meshBuilder.AddQuad(points[indices[i + 1]], points[indices[i + 2]],
                            points[indices[i + 3]],
                            points[indices[i + 4]]);
                        i = i + 4;
                    }
                }

                // Get the color of each representation group
                var color = Convert.ToInt64(item.AttributeGroups["geometry"].Attributes["color"]);
                var tempcolor = Color.FromArgb((int)color);

                var col = new System.Windows.Media.Color
                {
                    A = tempcolor.A,
                    G = tempcolor.G,
                    R = tempcolor.R,
                    B = tempcolor.B
                };

                var myGeometryModel = new GeometryModel3D
                {
                    Material = new DiffuseMaterial(new SolidColorBrush(col)),
                    BackMaterial = new DiffuseMaterial(new SolidColorBrush(col)),
                    Geometry = meshBuilder.ToMesh(true),
                    Transform = new RotateTransform3D(new AxisAngleRotation3D(new Vector3D(1, 0, 0), 90))
                };

                myGeometryModel.Freeze();

                var meshAndId = new MeshIdandGeometry
                {
                    Id = item.Id,
                    Model3D = myGeometryModel,
                    Material = myGeometryModel.Material
                };

                geometry.Add(meshAndId);

                // Save the parsed information in the elements attribute group
                item.AttributeGroups["geometry"].Attributes["parsedGeometry"] = meshAndId;

                // Refresh the builder so that we do not duplicate the meshes 
                meshBuilder = new MeshBuilder(false, false);

                m_i++;
                var progressPercentage = Convert.ToInt32(((double)m_i / max) * 100);
                var backgroundWorker = sender as BackgroundWorker;
                backgroundWorker?.ReportProgress(progressPercentage, item.Id);
            }

            container.Children.Clear();
            return geometry;
        }
开发者ID:Dessix,项目名称:TUM.CMS.VPLControl,代码行数:88,代码来源:BimPlusWatch3DNode.cs

示例9: Worker4

        private void Worker4(object d)
        {
            var dispatcher = (Dispatcher)d;
            var m = MaterialHelper.CreateMaterial(Colors.Gold);
            Model3DGroup mg = null;
            dispatcher.Invoke(new Action(() => this.model4.Content = mg = new Model3DGroup()));

            Interlocked.Increment(ref this.runningWorkers);

            while (!this.source.IsCancellationRequested)
            {
                if (!this.AddToModelGroup || this.runningWorkers < 4)
                {
                    Thread.Yield();
                    continue;
                }

                for (int i = 1; i <= n; i++)
                {
                    var b = new MeshBuilder();
                    for (int j = 1; j <= n; j++)
                    {
                        for (int k = 1; k <= n; k++)
                        {
                            b.AddBox(new Point3D(-i, j, -k), 0.8, 0.8, 0.8);
                        }
                    }

                    var box = new GeometryModel3D { Geometry = b.ToMesh(false), Material = m };
                    box.Freeze();
                    dispatcher.Invoke(new Action(() => mg.Children.Add(box)));
                }
                dispatcher.Invoke((Action)(() => this.Count4++));
                dispatcher.Invoke((Action)(() => mg.Children.Clear()));
            }
        }
开发者ID:ORRNY66,项目名称:helix-toolkit,代码行数:36,代码来源:MainWindow.xaml.cs

示例10: Worker3

        private void Worker3(object d)
        {
            var dispatcher = (Dispatcher)d;
            var m = MaterialHelper.CreateMaterial(Colors.Green);
            Interlocked.Increment(ref this.runningWorkers);
            while (!this.source.IsCancellationRequested)
            {
                if (!this.AddFrozenModel || this.runningWorkers < 4)
                {
                    Thread.Yield();
                    continue;
                }

                for (int i = 1; i <= n; i++)
                {
                    var b = new MeshBuilder();
                    for (int j = 1; j <= n; j++)
                    {
                        for (int k = 1; k <= n; k++)
                        {
                            b.AddBox(new Point3D(i, j, -k), 0.8, 0.8, 0.8);
                        }
                    }

                    var box = new GeometryModel3D { Geometry = b.ToMesh(false), Material = m };
                    box.Freeze();

                    dispatcher.Invoke(new Action<Model3D, ModelVisual3D>(this.Add), box, this.model3);
                }

                dispatcher.Invoke((Action)(() => this.Count3++));
                dispatcher.Invoke(new Action<ModelVisual3D>(this.Clear), model3);
            }
        }
开发者ID:ORRNY66,项目名称:helix-toolkit,代码行数:34,代码来源:MainWindow.xaml.cs

示例11: VisualizeBimPlusDataAsGenericElements

        public List<MeshIdandGeometry> VisualizeBimPlusDataAsGenericElements(List<DtObject> baseElements, object sender, Color Color = default(Color), double transparency = 0)
        {
            if (InputPorts[0].Data == null)
                return null;

            var max = baseElements.Count;
            var m_i = 1;

            // Init some lists and containers
            var container = new ContainerUIElement3D();
            var geometry = new List<MeshIdandGeometry>();

            // Init the MeshBuilde
            var meshBuilder = new MeshBuilder(false, false);

            // Loop the items of each list
            foreach (var item in baseElements)
            {
                var color = item.AttributeGroups["geometry"].GetProperty("color") is System.Drawing.Color ? (System.Drawing.Color) item.AttributeGroups["geometry"].GetProperty("color") : new System.Drawing.Color();

                Color col;
                if (Color != default(Color))
                {
                    col = Color;
                }
                else
                {
                    // Check Color
                    col = new Color{A = color.A,G = color.G,R = color.R,B = color.B};
                }

                var brush = new SolidColorBrush { Color = col, Opacity = 1 - transparency };

                var myGeometryModel = new GeometryModel3D
                {
                    Material = new DiffuseMaterial(brush),
                    BackMaterial = new DiffuseMaterial(brush),
                    Geometry = MeshObject(item, meshBuilder),
                    Transform = new RotateTransform3D(new AxisAngleRotation3D(new Vector3D(1, 0, 0), 90))
                };

                myGeometryModel.Freeze();

                // Save the parsed data in the objects
                var meshAndId = new MeshIdandGeometry
                {
                    Id = item.Id,
                    Model3D = myGeometryModel,
                    Material = myGeometryModel.Material
                };

                geometry.Add(meshAndId);
                // Save the parsed information in the elements attribute group
                item.AttributeGroups["geometry"]["parsedGeometry"] = meshAndId;

                // Refresh the builder so that we do not duplicate the meshes 
                meshBuilder = new MeshBuilder(false, false);

                m_i++;
                var progressPercentage = Convert.ToInt32(((double)m_i / max) * 100);
                var backgroundWorker = sender as BackgroundWorker;
                backgroundWorker?.ReportProgress(progressPercentage, item.Id);
            }

            container.Children.Clear();
            return geometry;
        }
开发者ID:corneliuspreidel,项目名称:TUM.CMS.VPLControl,代码行数:67,代码来源:BimPlusWatch3DNode.cs

示例12: CreateMeshModel

        private List<ModelVisual3D> CreateMeshModel(OptFile opt, int meshIndex, int lodIndex, int version)
        {
            if (opt == null ||
                opt.Meshes.ElementAtOrDefault(meshIndex) == null ||
                opt.Meshes[meshIndex].Lods.ElementAtOrDefault(lodIndex) == null)
            {
                return new List<ModelVisual3D>();
            }

            var cache = this.Cache;

            var mesh = opt.Meshes[meshIndex];
            var lod = mesh.Lods[lodIndex];

            if (meshIndex >= cache.meshes.Length || lodIndex >= cache.meshes[meshIndex].Length || lod.FaceGroups.Count > cache.meshes[meshIndex][lodIndex].Length)
            {
                return new List<ModelVisual3D>();
            }

            List<ModelVisual3D> group = new List<ModelVisual3D>();

            for (int faceGroupIndex = 0; faceGroupIndex < lod.FaceGroups.Count; faceGroupIndex++)
            {
                var faceGroup = lod.FaceGroups[faceGroupIndex];

                Material texture = null;
                bool alpha = false;

                if (faceGroup.Textures.Count != 0)
                {
                    int currentVersion = version;

                    if (version < 0 || version >= faceGroup.Textures.Count)
                    {
                        currentVersion = faceGroup.Textures.Count - 1;
                    }

                    string textureName = faceGroup.Textures[currentVersion];

                    if (cache.textures.ContainsKey(textureName))
                    {
                        texture = cache.textures[textureName];
                        alpha = opt.Textures[textureName].HasAlpha;
                    }
                }

                var geometries = cache.meshes[meshIndex][lodIndex][faceGroupIndex];

                if (alpha)
                {
                    for (int i = 1; i < geometries.Length; i++)
                    {
                        GeometryModel3D model = new GeometryModel3D();

                        model.Geometry = geometries[i];
                        model.Material = texture == null ? cache.nullTexture : texture;
                        model.BackMaterial = texture == null ? cache.nullTexture : texture;

                        model.Freeze();

                        group.Add(new ModelVisual3D() { Content = model });

                        this.ModelToMeshLodFace.Add(model, new MeshLodFace(opt.Meshes[meshIndex], opt.Meshes[meshIndex].Lods[lodIndex], faceGroup));
                    }
                }
                else
                {
                    GeometryModel3D model = new GeometryModel3D();

                    model.Geometry = geometries[0];
                    model.Material = texture == null ? cache.nullTexture : texture;

                    model.Freeze();

                    group.Add(new ModelVisual3D() { Content = model });

                    this.ModelToMeshLodFace.Add(model, new MeshLodFace(opt.Meshes[meshIndex], opt.Meshes[meshIndex].Lods[lodIndex], faceGroup));
                }
            }

            return group;
        }
开发者ID:JeremyAnsel,项目名称:XwaOptEditor,代码行数:82,代码来源:OptVisual3D.cs


注:本文中的System.Windows.Media.Media3D.GeometryModel3D.Freeze方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。