Beispiel #1
0
        private int AddModelFaces(Matrix3D parentMatrix, Model3D model)
        {
            if (model.Transform != null)
            {
                parentMatrix = model.Transform.Value * parentMatrix;
            }

            int          result = 0;
            Model3DGroup models = (model as Model3DGroup);

            if (models != null)
            {
                // This is a group.  Recurse through the children
                foreach (Model3D m in models.Children)
                {
                    result += AddModelFaces(parentMatrix, m);
                }
            }
            else
            {
                if (!(model is GeometryModel3D))
                {
                    throw new InvalidOperationException("Current only GeometryModel3D models supported for TerrianCollisionMask3D.");
                }

                Geometry3D geometry = ((GeometryModel3D)model).Geometry;

                IList <Point3D> meshPoints = GeometryHelper.GetGeometryPoints((MeshGeometry3D)geometry, parentMatrix);
                if (meshPoints != null)
                {
                    AddFaces(meshPoints, 3, false);
                    result = meshPoints.Count;
                }
            }

            return(result);
        }