Пример #1
0
        private Geometry3D GetGeometry()
        {
            var mesh = new MeshGeometry3D();
            mesh.Positions = new Point3DCollection
                {
                    new Point3D(-0.5, -0.5, 0),
                    new Point3D(0.5, -0.5, 0),
                    new Point3D(0.5, 0.5, 0),
                    new Point3D(-0.5, 0.5, 0),

                    new Point3D(-0.5, -0.5, 0.1),
                    new Point3D(0.5, -0.5, 0.1),
                    new Point3D(0.5, 0.5, 0.1),
                    new Point3D(-0.5, 0.5, 0.1)
                };

            mesh.TriangleIndices = new System.Windows.Media.Int32Collection
                {
                    0, 3, 1,  1, 3, 2,
                    0, 4, 3,  4, 7, 3,
                    4, 6, 7,  4, 5, 6,
                    0, 1, 4,  1, 5, 4,
                    1, 2, 6,  6, 5, 1,
                    2, 3, 7,  7, 6, 2
                };

            return mesh;
        }
Пример #2
0
        public static PointCollection GeneratePlanarTextureCoordinates(MeshGeometry3D mesh, Vector3D dir)
        {
            if (mesh == null)
                return null;

            return GeneratePlanarTextureCoordinates(mesh, mesh.Bounds, dir);
        }
Пример #3
0
        static CubeBuilder()
        {
            quadMesh = new MeshGeometry3D();
            quadMesh.Positions.Add(new Point3D(-0.5, 0.5, 0));
            quadMesh.Positions.Add(new Point3D(-0.5, -0.5, 0));
            quadMesh.Positions.Add(new Point3D(0.5, -0.5, 0));
            quadMesh.Positions.Add(new Point3D(0.5, 0.5, 0));

            quadMesh.TextureCoordinates.Add(new Point(0, 0));
            quadMesh.TextureCoordinates.Add(new Point(0, 1));
            quadMesh.TextureCoordinates.Add(new Point(1, 1));
            quadMesh.TextureCoordinates.Add(new Point(1, 0));

            quadMesh.Normals.Add(new Vector3D(0, 0, 1));
            quadMesh.Normals.Add(new Vector3D(0, 0, 1));
            quadMesh.Normals.Add(new Vector3D(0, 0, 1));
            quadMesh.Normals.Add(new Vector3D(0, 0, 1));

            quadMesh.TriangleIndices.Add(0);
            quadMesh.TriangleIndices.Add(1);
            quadMesh.TriangleIndices.Add(2);
            quadMesh.TriangleIndices.Add(0);
            quadMesh.TriangleIndices.Add(2);
            quadMesh.TriangleIndices.Add(3);

            visualHostMaterial = new DiffuseMaterial(
                new SolidColorBrush(Colors.White));
            visualHostMaterial.SetValue(
                Viewport2DVisual3D.IsVisualHostMaterialProperty, true);
        }
        public Model3DGroup CreateTriangleModel(Point3D p0, Point3D p1, Point3D p2)
        {
            MeshGeometry3D mesh = new MeshGeometry3D();
            mesh.Positions.Add(p0);
            mesh.Positions.Add(p1);
            mesh.Positions.Add(p2);

            for (int i = 0; i < 3; i++)
            {
                mesh.TriangleIndices.Add(i);
            }

            Vector3D normal = CalculateNormal(p0, p1, p2);

            for (int i = 0; i < 3; i++)
            {
                mesh.Normals.Add(normal);
            }

            Material material = new DiffuseMaterial(new SolidColorBrush(Colors.DarkCyan));
            GeometryModel3D model = new GeometryModel3D(mesh, material);
            Model3DGroup group = new Model3DGroup();
            group.Children.Add(model);
            return group;
        }
Пример #5
0
        /// <summary>
        /// Calculates the texture for the specified model.
        /// </summary>
        /// <param name="model">
        /// The model.
        /// </param>
        /// <param name="mesh">
        /// The mesh.
        /// </param>
        public override void Calculate(TerrainModel model, MeshGeometry3D mesh)
        {
            var normals = MeshGeometryHelper.CalculateNormals(mesh);
            var texcoords = new PointCollection();
            var up = new Vector3D(0, 0, 1);
            for (int i = 0; i < normals.Count; i++)
            {
                double slope = Math.Acos(Vector3D.DotProduct(normals[i], up)) * 180 / Math.PI;
                double u = slope / 40;
                if (u > 1)
                {
                    u = 1;
                }

                if (u < 0)
                {
                    u = 0;
                }

                texcoords.Add(new Point(u, u));
            }

            this.TextureCoordinates = texcoords;
            this.Material = MaterialHelper.CreateMaterial(this.Brush);
        }
Пример #6
0
        private MeshGeometry3D CreateMesh()
        {
            var geometry = new MeshGeometry3D();
            int nx = solver.Width;
            int ny = solver.Height;
            int ij = 0;
            for (int i = 0; i < ny; i++)
            {
                for (int j = 0; j < nx; j++)
                {
                    double z = (double)solver.ImageBuffer[ij] / solver.MaxIterations;
                    geometry.Positions.Add(new Point3D(solver.Xvalues[ij], solver.Yvalues[ij], z * HeightFactor));
                    double u = z * 0.854;
                    geometry.TextureCoordinates.Add(new Point(u, 0));
                    ij++;
                }
            }

            ij = 0;
            for (int i = 0; i < ny - 1; i++)
            {
                for (int j = 0; j < nx - 1; j++)
                {
                    geometry.TriangleIndices.Add(ij);
                    geometry.TriangleIndices.Add(ij + 1);
                    geometry.TriangleIndices.Add(ij + nx);
                    geometry.TriangleIndices.Add(ij + 1);
                    geometry.TriangleIndices.Add(ij + 1 + nx);
                    geometry.TriangleIndices.Add(ij + nx);
                    ij++;
                }
                ij++;
            }
            return geometry;
        }
Пример #7
0
        private Geometry3D CreateGeometry()
        {
            MeshGeometry3D mesh = new MeshGeometry3D();

            mesh.Positions.Add(UL);
            mesh.Positions.Add(LL);
            mesh.Positions.Add(UR);

            mesh.TriangleIndices.Add(0);
            mesh.TriangleIndices.Add(1);
            mesh.TriangleIndices.Add(2);

            Vector3D verticalDirection = LL - UL;
            Vector3D horizontalDirection = UR - UL;

            Point3D LR = UL + verticalDirection + horizontalDirection;

            mesh.Positions.Add(UR);
            mesh.Positions.Add(LL);
            mesh.Positions.Add(LR);

            mesh.TriangleIndices.Add(3);
            mesh.TriangleIndices.Add(4);
            mesh.TriangleIndices.Add(5);

            mesh.Freeze();
            return mesh;
        }
        public static GeometryModel3D CreateNormalizedCube(Material material)
        {
            MeshGeometry3D geometry = new MeshGeometry3D();

            var farPoint = new Point3D(-0.5, -0.5, -0.5);
            var nearPoint = new Point3D(0.5, 0.5, 0.5);

            var cube = new Model3DGroup();
            var p0 = new Point3D(farPoint.X, farPoint.Y, farPoint.Z);
            var p1 = new Point3D(nearPoint.X, farPoint.Y, farPoint.Z);
            var p2 = new Point3D(nearPoint.X, farPoint.Y, nearPoint.Z);
            var p3 = new Point3D(farPoint.X, farPoint.Y, nearPoint.Z);
            var p4 = new Point3D(farPoint.X, nearPoint.Y, farPoint.Z);
            var p5 = new Point3D(nearPoint.X, nearPoint.Y, farPoint.Z);
            var p6 = new Point3D(nearPoint.X, nearPoint.Y, nearPoint.Z);
            var p7 = new Point3D(farPoint.X, nearPoint.Y, nearPoint.Z);
            int startIndex = 0;
            startIndex = AddTriangleFace(geometry, p3, p2, p6, startIndex);
            startIndex = AddTriangleFace(geometry, p3, p6, p7, startIndex);
            startIndex = AddTriangleFace(geometry, p2, p1, p5, startIndex);
            startIndex = AddTriangleFace(geometry, p2, p5, p6, startIndex);
            startIndex = AddTriangleFace(geometry, p1, p0, p4, startIndex);
            startIndex = AddTriangleFace(geometry, p1, p4, p5, startIndex);
            startIndex = AddTriangleFace(geometry, p0, p3, p7, startIndex);
            startIndex = AddTriangleFace(geometry, p0, p7, p4, startIndex);
            startIndex = AddTriangleFace(geometry, p7, p6, p5, startIndex);
            startIndex = AddTriangleFace(geometry, p7, p5, p4, startIndex);
            startIndex = AddTriangleFace(geometry, p2, p3, p0, startIndex);
            startIndex = AddTriangleFace(geometry, p2, p0, p1, startIndex);

            return new GeometryModel3D(geometry, material);
        }
Пример #9
0
        protected override Geometry3D CreateMesh()
        {
            this.radius = this.Radius;
            this.position = this.Position;

            var mesh = new MeshGeometry3D();
            var prevPoint = this.PointForAngle(0);
            var normal = new Vector3D(0, 0, 1);

            int div = 180;

            for (var i = 1; i <= div; ++i)
            {
                var angle = 2 * Math.PI / div * i;
                var newPoint = this.PointForAngle(angle);
                mesh.Positions.Add(prevPoint);
                mesh.Positions.Add(this.position);
                mesh.Positions.Add(newPoint);
                mesh.Normals.Add(normal);
                mesh.Normals.Add(normal);
                mesh.Normals.Add(normal);
                prevPoint = newPoint;
            }

            mesh.Freeze();
            return mesh;
        }
 private void CreateGeometry()
 {
     var builder = new MeshBuilder();
     builder.AddSphere(new Point3D(0, 0, 0), Diameter/2, ThetaDiv, PhiDiv);
     _sphere = builder.ToMesh();
     _sphere.Freeze();
 }
Пример #11
0
        public static Model3D GetSkeletonModel(AnimData animData, int frameNo)
        {
            if (null == animData) {
                return null;
            }

            GeometryModel3D model = new GeometryModel3D();
            MeshGeometry3D mesh = new MeshGeometry3D();

            Point3D[] parentPoints = new Point3D[64];
            parentPoints[0] = new Point3D(0, 0, 0);

            for (int jointNum = 0; jointNum < animData.skeletonDef.GetLength(0); ++jointNum)
            {
                int parentIndex = animData.skeletonDef[jointNum];
                // Binding position
                Point3D pos = animData.bindingPose[jointNum];

                if (frameNo >= 0)
                {
                    AnimMeshPose pose = animData.perFrameFKPoses[frameNo, jointNum];
                    pos = pose.Position;
                }
                parentPoints[parentIndex + 1] = pos;
                AddBone(mesh, parentPoints[parentIndex], pos);
            }

            model.Geometry = mesh;

            DiffuseMaterial dm = new DiffuseMaterial();
            dm.Brush = new SolidColorBrush(Colors.DarkGreen);
            model.Material = dm;

            return model;
        }
        private void simpleButtonClick(object sender, RoutedEventArgs e)
        {
            MeshGeometry3D triagleMesh = new MeshGeometry3D();
            Point3D p0 = new Point3D(0, 0, 0);
            Point3D p1 = new Point3D(5, 0, 0);
            Point3D p2 = new Point3D(0, 0, 5);

            triagleMesh.Positions.Add(p0);
            triagleMesh.Positions.Add(p1);
            triagleMesh.Positions.Add(p2);

            triagleMesh.TriangleIndices.Add(0);
            triagleMesh.TriangleIndices.Add(2);
            triagleMesh.TriangleIndices.Add(1);

            Vector3D normal = new Vector3D(0, 1, 0);
            triagleMesh.Normals.Add(normal);
            triagleMesh.Normals.Add(normal);
            triagleMesh.Normals.Add(normal);

            Material material = new DiffuseMaterial(new SolidColorBrush(Colors.LawnGreen));
            GeometryModel3D triangleModel = new GeometryModel3D(triagleMesh, material);

            ModelVisual3D model = new ModelVisual3D();
            model.Content = triangleModel;
            this.mainViewport.Children.Add(model);
        }
Пример #13
0
        private MeshGeometry3D BuildMesh(Point3D p0, Point3D p1, Point3D p2, Point3D p3,
            Point2D q0, Point2D q1, Point2D q2, Point2D q3)
        {
            var mesh = new MeshGeometry3D();
            mesh.Positions.Add(p0);
            mesh.Positions.Add(p1);
            mesh.Positions.Add(p2);
            mesh.Positions.Add(p3);

            var normal = CalculateNormal(p0, p1, p2);
            mesh.TriangleIndices.Add(0);
            mesh.TriangleIndices.Add(1);
            mesh.TriangleIndices.Add(2);
            mesh.Normals.Add(normal);
            mesh.Normals.Add(normal);
            mesh.Normals.Add(normal);
            mesh.TextureCoordinates.Add(q3);
            mesh.TextureCoordinates.Add(q2);
            mesh.TextureCoordinates.Add(q1);

            normal = CalculateNormal(p2, p3, p0);
            mesh.TriangleIndices.Add(2);
            mesh.TriangleIndices.Add(3);
            mesh.TriangleIndices.Add(0);
            mesh.Normals.Add(normal);
            mesh.Normals.Add(normal);
            mesh.Normals.Add(normal);
            mesh.TextureCoordinates.Add(q0);
            mesh.TextureCoordinates.Add(q1);
            mesh.TextureCoordinates.Add(q2);

            mesh.Freeze();
            return mesh;
        }
Пример #14
0
 public bool Matches(MeshGeometry3D mesh)
 {
     foreach (GeometryModel3D part in modelGroup.Children)
         if (part.Geometry == mesh)
             return true;
     return false;
 }
        protected override Geometry3D CreateMesh()
        {
            this.radius = this.Radius;
            this.position = this.Position;

            MeshGeometry3D mesh = new MeshGeometry3D();
            Point3D prevPoint = this.PointForAngle(0);
            Vector3D normal = new Vector3D(0, 0, 1);

            for (int i = 1; i <= Divider; ++i)
            {
                double angle = 2 * Math.PI / Divider * i;
                Point3D newPoint = this.PointForAngle(angle);
                mesh.Positions.Add(prevPoint);
                mesh.Positions.Add(this.position);
                mesh.Positions.Add(newPoint);
                mesh.Normals.Add(normal);
                mesh.Normals.Add(normal);
                mesh.Normals.Add(normal);
                prevPoint = newPoint;
            }

            mesh.Freeze();
            return mesh;
        }
Пример #16
0
        /// <summary>   Adds a point combined. </summary>
        ///
        /// <param name="point">    The point. </param>
        /// <param name="mesh">     The mesh. </param>
        /// <param name="normal">   The normal. </param>
        public static void addPointCombined(Point3D point, MeshGeometry3D mesh, Vector3D normal)
        {
            bool found = false;

            int i = 0;

            foreach (Point3D p in mesh.Positions)
            {
                if (p.Equals(point))
                {
                    found = true;
                    mesh.TriangleIndices.Add(i);
                    mesh.Positions.Add(point);
                    mesh.Normals.Add(normal);
                    break;
                }

                i++;
            }

            if (!found)
            {
                mesh.Positions.Add(point);
                mesh.TriangleIndices.Add(mesh.TriangleIndices.Count);
                mesh.Normals.Add(normal);
            }

        }
Пример #17
0
        public void addToMesh(MeshGeometry3D mesh, bool combineVertices)
        {
            if (sphereCirces[0].Points.Count > 2)
            {
                List<Point3D> ListOfPoints = new List<Point3D>();
                for (int i = 0; i <= 2*nStacks - 2; i++)
                {
                    foreach (Point3D p in sphereCirces[i].Points)
                    {
                        ListOfPoints.Add(p);
                    }
                    ListOfPoints.Add(sphereCirces[i].Points[0]);
                }

                MessageBox.Show(ListOfPoints.Count.ToString());
                MessageBox.Show(sphereCirces[0].Points.Count.ToString());
                for (int i = 0; i <= 2 * nStacks -3; i++)
                {
                    for (int j = 1; j < sphereCirces[i].Points.Count + 1 ; j++)
                    {
                        Triangle.addTriangleToMesh(ListOfPoints[(j - 1) + i * (sphereCirces[i].Points.Count + 1)],
                            ListOfPoints[(j - 1) + (i + 1) * (sphereCirces[i].Points.Count + 1)],
                            ListOfPoints[j + i * (sphereCirces[8].Points.Count + 1)], mesh, combineVertices);
                        Triangle.addTriangleToMesh(ListOfPoints[j + i * (sphereCirces[i].Points.Count + 1)],
                            ListOfPoints[(j - 1) + (i + 1) * (sphereCirces[i].Points.Count + 1)],
                            ListOfPoints[(j) + (i + 1) * (sphereCirces[i].Points.Count + 1)], mesh, combineVertices);
                    }
                }
            }
        }
        // highlight the selection
        public override void HighlightSelection(System.Windows.Media.Media3D.MeshGeometry3D meshGeometry, System.Windows.Media.Color selectColor)
        {
            int nDotNo = GetDataNo();

            if (nDotNo == 0)
            {
                return;
            }

            Point mapPt;

            for (int i = 0; i < nDotNo; i++)
            {
                if (m_vertices[i].selected)
                {
                    mapPt = TextureMapping.GetMappingPosition(selectColor, false);
                }
                else
                {
                    mapPt = TextureMapping.GetMappingPosition(m_vertices[i].color, false);
                }
                int nMin = m_vertices[i].nMinI;
                int nMax = m_vertices[i].nMaxI;
                for (int j = nMin; j <= nMax; j++)
                {
                    meshGeometry.TextureCoordinates[j] = mapPt;
                }
            }
        }
        public Model3DGroup CreatePolygonModel(Point3D[] points)
        {
            MeshGeometry3D mesh = new MeshGeometry3D();
            int indexPoints = 0;
            int totalPoints = points.Count();

            for (indexPoints = 0; indexPoints < totalPoints; indexPoints++)
            {
                mesh.Positions.Add(points.ElementAt(indexPoints));
            }

            //Solo se necesitan tres puntos para poder obtener la normal del triangulo
            for (int i = 0; i < 3; i++)
            {
                mesh.TriangleIndices.Add(i);
            }

            //Para obtener el vector normal solo se necesitan tres puntos del plano
            Vector3D normal = CalculateNormal(points.ElementAt(0), points.ElementAt(1), points.ElementAt(2));

            //¿Checar por que se agrega 3 veces la normal?
            //for (int i = 0; i < 3; i++)
            //{
            mesh.Normals.Add(normal);
            //}

            Material material = new DiffuseMaterial(new SolidColorBrush(Colors.DarkCyan));
            GeometryModel3D model = new GeometryModel3D(mesh, material);
            Model3DGroup group = new Model3DGroup();
            group.Children.Add(model);
            return group;
        }
Пример #20
0
        private ModelVisual3D makeTriangle(double x1, double y1, double z1, double x2, double y2, double z2, double x3, double y3, double z3)
        {
            MeshGeometry3D triangleMesh = new MeshGeometry3D();

            Point3D point0 = new Point3D(x1, y1, z1);
            Point3D point1 = new Point3D(x2, y2, z2);
            Point3D point2 = new Point3D(x3, y3, z3);

            triangleMesh.Positions.Add(point0);
            triangleMesh.Positions.Add(point1);
            triangleMesh.Positions.Add(point2);

            triangleMesh.TriangleIndices.Add(0); // Важно - порядок обхода
            triangleMesh.TriangleIndices.Add(2);
            triangleMesh.TriangleIndices.Add(1);

            Vector3D normal = new Vector3D(0, 1, 0);
            triangleMesh.Normals.Add(normal);
            triangleMesh.Normals.Add(normal);
            triangleMesh.Normals.Add(normal);

            Material material = new DiffuseMaterial(new SolidColorBrush(Colors.Red));

            return new ModelVisual3D { Content = new GeometryModel3D(triangleMesh, material) };
        }
Пример #21
0
        public ExplodingMesh(MeshGeometry3D inputMesh, Point3D hitpos)
        {
            var mesh = MeshGeometryHelper.NoSharedVertices(inputMesh);

            double cx, cy, cz;
            cx = cy = cz = 0;
            for (int i = 0; i < mesh.Positions.Count; i++)
            {
                cx += mesh.Positions[i].X;
                cy += mesh.Positions[i].Y;
                cz += mesh.Positions[i].Z;
            }
            int n = mesh.Positions.Count;
            var center = new Point3D(cx / n, cy / n, cz / n);

            integrator = new VerletIntegrator();
            integrator.Resize(mesh.Positions.Count);
            var r = new Random();
            for (int i = 0; i < mesh.Positions.Count; i++)
            {
                var delta = mesh.Positions[i] - center;
                delta.Normalize();
                integrator.Positions[i] = mesh.Positions[i] + delta * (1 + r.NextDouble() * 2);
                integrator.Positions0[i] = mesh.Positions[i];
                integrator.Accelerations[i] = new Vector3D(0, 0, -1000);
                integrator.InverseMass[i] = 0.01;
            }

            integrator.CreateConstraintsByMesh(mesh, 0.7);
            integrator.AddFloor(0.3);
            this.Mesh = mesh;
            watch.Start();
        }
Пример #22
0
        public void addToMesh(MeshGeometry3D mesh, bool encloseLoop, bool combineVertices)
        {
            if (uppSide.Points.Count > 2)
            {
                List<Point3D> uppSidePoints = new List<Point3D>();
                foreach (Point3D p in uppSide.Points)
                {
                    uppSidePoints.Add(p);
                }
                uppSidePoints.Add(uppSide.Points[0]);
                List<Point3D> downSidePoints = new List<Point3D>();
                foreach (Point3D p in downSide.Points)
                {
                    downSidePoints.Add(p);
                }
                downSidePoints.Add(downSide.Points[0]);

                for (int i = 1; i < uppSidePoints.Count; i++)
                {
                    Triangle.addTriangleToMesh(uppSidePoints[i - 1], downSidePoints[i - 1], uppSidePoints[i], mesh, combineVertices);
                    Triangle.addTriangleToMesh(uppSidePoints[i], downSidePoints[i - 1], downSidePoints[i], mesh, combineVertices);
                }

                if (encloseLoop)
                {
                    uppSide.addToMesh(mesh, false);
                    downSide.addToMesh(mesh, false);
                }
            }
        }
        void CreateGeometry()
        {

            double r = Diameter / 2;
            double l = HeadLength * Diameter;

            // arrowhead
            var pc = new PointCollection();
            pc.Add(new Point(-l, r));
            pc.Add(new Point(-l, r * 2));
            pc.Add(new Point(0, 0));

            var headBuilder = new MeshBuilder();
            headBuilder.AddRevolvedGeometry(pc, new Point3D(0, 0, 0), new Vector3D(0, 0, 1), ThetaDiv);
            _head = headBuilder.ToMesh();
            _head.Freeze(); 
            

            // body
            pc = new PointCollection();
            pc.Add(new Point(0, 0));
            pc.Add(new Point(0, r));
            pc.Add(new Point(1, r));

            var bodyBuilder = new MeshBuilder();
            bodyBuilder.AddRevolvedGeometry(pc, new Point3D(0, 0, 0), new Vector3D(0, 0, 1), ThetaDiv);
            _body = bodyBuilder.ToMesh();
            _body.Freeze();
        }
Пример #24
0
        private void CreateBottomFace(int width, int height)
        {
            MeshGeometry3D mesh = new MeshGeometry3D();

            mesh.Positions.Add(new Point3D(-width, height, -10));
            mesh.Positions.Add(new Point3D(width, height, -10));
            mesh.Positions.Add(new Point3D(width, height, +1000));
            mesh.Positions.Add(new Point3D(-width, height, +1000));

            mesh.TriangleIndices.Add(0);
            mesh.TriangleIndices.Add(1);
            mesh.TriangleIndices.Add(3);
            mesh.TriangleIndices.Add(1);
            mesh.TriangleIndices.Add(2);
            mesh.TriangleIndices.Add(3);

            // These are the lines you need to allow an image to be painted onto the 3d model
            mesh.TextureCoordinates.Add(new Point(0, 0));
            mesh.TextureCoordinates.Add(new Point(1, 0));
            mesh.TextureCoordinates.Add(new Point(1, 1));
            mesh.TextureCoordinates.Add(new Point(0, 1));

            GeometryModel3D geometry = new GeometryModel3D(mesh, new DiffuseMaterial(new SolidColorBrush(Colors.Red)));

            group.Children.Add(geometry);
        }
Пример #25
0
 // Public parameterless constructor
 public ModelVisualBase()
 {
     meshgeo = new MeshGeometry3D();
     geomodel = new GeometryModel3D();
     Geometry = meshgeo;
     Content = geomodel;
 }
Пример #26
0
        public static MeshGeometry3D AddPlaneToMesh(MeshGeometry3D mesh, Vector3D normal, Point3D upperLeft, Point3D lowerLeft, Point3D lowerRight, Point3D upperRight)
        {
            int offset = mesh.Positions.Count;

            mesh.Positions.Add(upperLeft);
            mesh.Positions.Add(lowerLeft);
            mesh.Positions.Add(lowerRight);
            mesh.Positions.Add(upperRight);

            mesh.Normals.Add(normal);
            mesh.Normals.Add(normal);
            mesh.Normals.Add(normal);
            mesh.Normals.Add(normal);

            mesh.TextureCoordinates.Add(new Point(0, 0));
            mesh.TextureCoordinates.Add(new Point(0, 1));
            mesh.TextureCoordinates.Add(new Point(1, 1));
            mesh.TextureCoordinates.Add(new Point(1, 0));

            mesh.TriangleIndices.Add(offset + 0);
            mesh.TriangleIndices.Add(offset + 1);
            mesh.TriangleIndices.Add(offset + 2);
            mesh.TriangleIndices.Add(offset + 0);
            mesh.TriangleIndices.Add(offset + 2);
            mesh.TriangleIndices.Add(offset + 3);

            return mesh;
        }
Пример #27
0
        protected override Geometry3D CreateMesh()
        {
            _radius = Radius;
            _position = Position;

            MeshGeometry3D mesh = new MeshGeometry3D();
            Point3D prevPoint = PointForAngle(0);
            Vector3D normal = new Vector3D(0, 0, 1);

            const int div = 180;
            for (int i = 1; i <= div; ++i)
            {
                double angle = 2 * Math.PI / div * i;
                Point3D newPoint = PointForAngle(angle);
                mesh.Positions.Add(prevPoint);
                mesh.Positions.Add(_position);
                mesh.Positions.Add(newPoint);
                mesh.Normals.Add(normal);
                mesh.Normals.Add(normal);
                mesh.Normals.Add(normal);
                prevPoint = newPoint;
            }

            mesh.Freeze();
            return mesh;
        }
Пример #28
0
        void System.Windows.Markup.IComponentConnector.Connect(int connectionId, object target)
        {
            switch (connectionId)
            {
            case 1:
                this.hxViewport3D = ((HelixToolkit.Wpf.HelixViewport3D)(target));
                return;

            case 2:
                this.modelVisual3D = ((System.Windows.Media.Media3D.ModelVisual3D)(target));
                return;

            case 3:
                this.model2 = ((System.Windows.Media.Media3D.GeometryModel3D)(target));
                return;

            case 4:
                this.meshMain = ((System.Windows.Media.Media3D.MeshGeometry3D)(target));
                return;

            case 5:
                this.matDiffuseMain = ((System.Windows.Media.Media3D.DiffuseMaterial)(target));
                return;

            case 6:
                this.textEdit = ((System.Windows.Controls.RichTextBox)(target));
                return;

            case 7:
                this.debugOutput = ((System.Windows.Controls.RichTextBox)(target));
                return;
            }
            this._contentLoaded = true;
        }
Пример #29
0
        static Creature()
        {
            var egg = new MeshBuilder();
            egg.AddSphere(new Point3D(0, 0, 0.2), 0.2, 24, 12);
            eggGeometry = egg.ToMesh();

            var child = new MeshBuilder();
            child.AddSphere(new Point3D(0, 0, 1), 1, 24, 12);
            child.AddSphere(new Point3D(1, 0, 1), 0.5, 24, 12);
            child.AddSphere(new Point3D(1.5, 0.2, 1), 0.1, 24, 12);
            child.AddSphere(new Point3D(1.5, -0.2, 1), 0.1, 24, 12);
            childGeometry = child.ToMesh();

            var creature = new MeshBuilder();
            creature.AddSphere(new Point3D(0, 0, 1), 1, 24, 12);
            creature.AddSphere(new Point3D(0, 0, 2), 0.5, 24, 12);
            creature.AddSphere(new Point3D(0.5, 0.2, 2), 0.1, 24, 12);
            creature.AddSphere(new Point3D(0.5, -0.2, 2), 0.1, 24, 12);
            creatureGeometry = creature.ToMesh();

            var coffin = new MeshBuilder();
            coffin.AddBox(new Point3D(0, 0, 0.25), 1, 1, 1);
            deadGeometry = coffin.ToMesh();

            maleMaterial = MaterialHelper.CreateMaterial(Brushes.Blue);
            femaleMaterial = MaterialHelper.CreateMaterial(Brushes.IndianRed);
            eggMaterial = MaterialHelper.CreateMaterial(Brushes.AntiqueWhite);
            deadMaterial = MaterialHelper.CreateMaterial(Brushes.Black);

        }
Пример #30
0
        static Predator()
        {
            var egg = new MeshBuilder();
            egg.AddPyramid(new Point3D(0, 0, 0), 0.2, 0.4);
            eggGeometry = egg.ToMesh();

            var child = new MeshBuilder();
            child.AddBox(new Point3D(0, 0, 0.5), 1, 1, 1);
            child.AddSphere(new Point3D(0.2, 0.2, 1), 0.2, 12, 24);
            child.AddSphere(new Point3D(0.2, -0.2, 1), 0.2, 12, 24);
            childGeometry = child.ToMesh();

            var creature = new MeshBuilder();
            creature.AddBox(new Point3D(0, 0, 0.5), 1, 1, 1);
            creature.AddCone(new Point3D(0.2, 0.2, 1), new Vector3D(0, 0, 1), 0.16, 0.04, 0.3, false, true, 12);
            creature.AddCone(new Point3D(0.2, -0.2, 1), new Vector3D(0, 0, 1), 0.16, 0.04, 0.3, false, true, 12);
            creatureGeometry = creature.ToMesh();

            var coffin = new MeshBuilder();
            coffin.AddCylinder(new Point3D(0, 0, 0), new Point3D(0, 0, 0.25), 1, 12);
            deadGeometry = coffin.ToMesh();

            maleMaterial = MaterialHelper.CreateMaterial(Brushes.Navy);
            femaleMaterial = MaterialHelper.CreateMaterial(Brushes.Violet);
            eggMaterial = MaterialHelper.CreateMaterial(Brushes.AntiqueWhite);
            deadMaterial = MaterialHelper.CreateMaterial(Brushes.Black);

        }
Пример #31
0
        protected override Geometry3D Tessellate()
        {
            MeshGeometry3D mesh = new MeshGeometry3D();

            mesh.Positions.Add(new Point3D(-0.5, 0.5, 0));
            mesh.Positions.Add(new Point3D(-0.5, -0.5, 0));
            mesh.Positions.Add(new Point3D(0.5, -0.5, 0));
            mesh.Positions.Add(new Point3D(0.5, 0.5, 0));

            mesh.TextureCoordinates.Add(new Point(0, 0));
            mesh.TextureCoordinates.Add(new Point(0, 1));
            mesh.TextureCoordinates.Add(new Point(1, 1));
            mesh.TextureCoordinates.Add(new Point(1, 0));

            mesh.TriangleIndices.Add(0);
            mesh.TriangleIndices.Add(1);
            mesh.TriangleIndices.Add(2);
            mesh.TriangleIndices.Add(0);
            mesh.TriangleIndices.Add(2);
            mesh.TriangleIndices.Add(3);

            mesh.Normals.Add(new Vector3D(0, 0, 1));
            mesh.Normals.Add(new Vector3D(0, 0, 1));
            mesh.Normals.Add(new Vector3D(0, 0, 1));
            mesh.Normals.Add(new Vector3D(0, 0, 1));

            return mesh;
        }
Пример #32
0
        /// <summary>
        /// Generates a flat mesh starting at origin with sides equal to u and v vecotrs
        /// </summary>
        /// <param name="origin"></param>
        /// <param name="u"></param>
        /// <param name="v"></param>
        /// <param name="usteps"></param>
        /// <param name="vsteps"></param>
        /// <param name="textureBounds"></param>
        /// <returns></returns>
        public static MeshGeometry3D CreateMesh(Point3D origin, Vector3D u, Vector3D v, int usteps, int vsteps, Rect textureBounds)
        {
            u = 1.0 / usteps * u;
            v = 1.0 / vsteps * v;

            MeshGeometry3D mesh = new MeshGeometry3D();

            for (int i = 0; i <= usteps; i++)
            {
                for (int j = 0; j <= vsteps; j++)
                {
                    mesh.Positions.Add(origin + i * u + j * v);

                    mesh.TextureCoordinates.Add(new Point(textureBounds.X + textureBounds.Width * i / usteps,
                                                          textureBounds.Y + textureBounds.Height * j / vsteps));

                    if (i > 0 && j > 0)
                    {
                        mesh.TriangleIndices.Add((i - 1) * (vsteps + 1) + (j - 1));
                        mesh.TriangleIndices.Add((i - 0) * (vsteps + 1) + (j - 0));
                        mesh.TriangleIndices.Add((i - 0) * (vsteps + 1) + (j - 1));

                        mesh.TriangleIndices.Add((i - 1) * (vsteps + 1) + (j - 1));
                        mesh.TriangleIndices.Add((i - 1) * (vsteps + 1) + (j - 0));
                        mesh.TriangleIndices.Add((i - 0) * (vsteps + 1) + (j - 0));
                    }
                }
            }
            return mesh;
        }
Пример #33
0
        public static MeshGeometry3D ReadStlascii(Stream stream)
        {
            MeshGeometry3D output = new System.Windows.Media.Media3D.MeshGeometry3D();;
            var            reader = new StreamReader(stream);

            try
            {
                while (!reader.EndOfStream)
                {
                    var line = reader.ReadLine();
                    if (line == null)
                    {
                        continue;
                    }

                    line = line.Trim();
                    if (line.Length == 0 || line.StartsWith("\0") || line.StartsWith("#") || line.StartsWith("!") ||
                        line.StartsWith("$"))
                    {
                        continue;
                    }

                    string id, values;
                    ParseLine(line, out id, out values);
                    switch (id)
                    {
                    case "solid":
                        _header = values.Trim();
                        break;

                    case "facet":
                        List <Point3D> pts = ReadFace(reader, values);
                        foreach (var v in pts)
                        {
                            output.Positions.Add(v);
                        }
                        break;

                    case "endsolid":
                        break;
                    }
                }
            }
            catch
            {
            }

            if (output.Positions.Count > 3)
            {
                for (int i = 0; i < output.Positions.Count; i++)
                {
                    output.TriangleIndices.Add(i);
                }
            }

            return(output);
        }
Пример #34
0
        void System.Windows.Markup.IComponentConnector.Connect(int connectionId, object target)
        {
            switch (connectionId)
            {
            case 1:
                this.tbValues = ((System.Windows.Controls.TextBlock)(target));
                return;

            case 2:
                this.btnGo = ((System.Windows.Controls.Button)(target));

            #line 25 "..\..\Window1.xaml"
                this.btnGo.Click += new System.Windows.RoutedEventHandler(this.btnGo_Click);

            #line default
            #line hidden
                return;

            case 3:
                this.tbAccVals = ((System.Windows.Controls.TextBox)(target));
                return;

            case 4:
                this.viewport3D1 = ((System.Windows.Controls.Viewport3D)(target));
                return;

            case 5:
                this.camMain = ((System.Windows.Media.Media3D.PerspectiveCamera)(target));
                return;

            case 6:
                this.dirLightMain = ((System.Windows.Media.Media3D.DirectionalLight)(target));
                return;

            case 7:
                this.MyModel = ((System.Windows.Media.Media3D.ModelVisual3D)(target));
                return;

            case 8:
                this.meshMain = ((System.Windows.Media.Media3D.MeshGeometry3D)(target));
                return;

            case 9:
                this.matDiffuseMain = ((System.Windows.Media.Media3D.DiffuseMaterial)(target));
                return;

            case 10:
                this.rotate = ((System.Windows.Media.Media3D.AxisAngleRotation3D)(target));
                return;

            case 11:
                this.slider1 = ((System.Windows.Controls.Slider)(target));
                return;
            }
            this._contentLoaded = true;
        }
Пример #35
0
        void System.Windows.Markup.IComponentConnector.Connect(int connectionId, object target)
        {
            switch (connectionId)
            {
            case 1:
                this.mainViewport = ((System.Windows.Controls.Viewport3D)(target));
                return;

            case 2:
                this.camera = ((System.Windows.Media.Media3D.PerspectiveCamera)(target));
                return;

            case 3:
                this.MyModel = ((System.Windows.Media.Media3D.ModelVisual3D)(target));
                return;

            case 4:
                this.scale = ((System.Windows.Media.Media3D.ScaleTransform3D)(target));
                return;

            case 5:
                this.rotateY = ((System.Windows.Media.Media3D.AxisAngleRotation3D)(target));
                return;

            case 6:
                this.rotateX = ((System.Windows.Media.Media3D.AxisAngleRotation3D)(target));
                return;

            case 7:
                this.translate = ((System.Windows.Media.Media3D.TranslateTransform3D)(target));
                return;

            case 8:
                this.model3DGroup = ((System.Windows.Media.Media3D.Model3DGroup)(target));
                return;

            case 9:
                this.geometryModel = ((System.Windows.Media.Media3D.GeometryModel3D)(target));
                return;

            case 10:
                this.meshMain = ((System.Windows.Media.Media3D.MeshGeometry3D)(target));
                return;

            case 11:
                this.meshBack = ((System.Windows.Media.Media3D.MeshGeometry3D)(target));
                return;
            }
            this._contentLoaded = true;
        }
Пример #36
0
        void System.Windows.Markup.IComponentConnector.Connect(int connectionId, object target)
        {
            switch (connectionId)
            {
            case 1:
                this.WorkG = ((System.Windows.Controls.Grid)(target));

            #line 9 "..\..\..\View\View.xaml"
                this.WorkG.MouseWheel += new System.Windows.Input.MouseWheelEventHandler(this.WorkGrid_MouseWheel);

            #line default
            #line hidden

            #line 9 "..\..\..\View\View.xaml"
                this.WorkG.MouseLeftButtonDown += new System.Windows.Input.MouseButtonEventHandler(this.WorkGrid_MouseLeftButtonDown);

            #line default
            #line hidden
                return;

            case 2:
                this.port3d = ((System.Windows.Controls.Viewport3D)(target));

            #line 10 "..\..\..\View\View.xaml"
                this.port3d.MouseWheel += new System.Windows.Input.MouseWheelEventHandler(this.WorkGrid_MouseWheel);

            #line default
            #line hidden

            #line 10 "..\..\..\View\View.xaml"
                this.port3d.MouseLeftButtonDown += new System.Windows.Input.MouseButtonEventHandler(this.port3d_MouseLeftButtonDown);

            #line default
            #line hidden
                return;

            case 3:
                this.Perspective = ((System.Windows.Media.Media3D.PerspectiveCamera)(target));
                return;

            case 4:
                this.Trig = ((System.Windows.Media.Media3D.MeshGeometry3D)(target));
                return;

            case 5:
                this.Trig2 = ((System.Windows.Media.Media3D.MeshGeometry3D)(target));
                return;
            }
            this._contentLoaded = true;
        }
Пример #37
0
        /// <summary>
        /// 儲存模型檔案,第一個參數指定路徑,第二個參數指定是否要儲存轉移後的模型
        /// </summary>
        public void SaveModel(string filepath, bool isSavedTransform)
        {
            HelixToolkit.Wpf.SharpDX.MeshGeometry3D geometry = Geometry as HelixToolkit.Wpf.SharpDX.MeshGeometry3D;

            if (geometry == null)
            {
                return;
            }


            System.Windows.Media.Media3D.MeshGeometry3D mesh = new System.Windows.Media.Media3D.MeshGeometry3D
            {
                Positions       = new Point3DCollection(),
                Normals         = new Vector3DCollection(),
                TriangleIndices = new Int32Collection()
            };

            foreach (Vector3 position in geometry.Positions)
            {
                mesh.Positions.Add(new Point3D(position.X, position.Y, position.Z));
            }
            foreach (Vector3 normal in geometry.Normals)
            {
                mesh.Normals.Add(new Vector3D(normal.X, normal.Y, normal.Z));
            }
            foreach (int triangleindice in geometry.TriangleIndices)
            {
                mesh.TriangleIndices.Add(triangleindice);
            }

            GeometryModel3D model = new GeometryModel3D
            {
                Geometry = mesh,
            };

            if (isSavedTransform)
            {
                model.Transform = Transform;
            }


            StlExporter export = new StlExporter();

            using (var fileStream = File.Create(System.IO.Path.Combine(filepath, SafeFileName)))
            {
                export.Export(model, fileStream);
            }
        }
Пример #38
0
        void System.Windows.Markup.IComponentConnector.Connect(int connectionId, object target)
        {
            switch (connectionId)
            {
            case 1:

            #line 6 "..\..\..\MainWindow.xaml"
                ((Microsoft.Samples.Kinect.HDFaceBasics.MainWindow)(target)).Loaded += new System.Windows.RoutedEventHandler(this.Window_Loaded);

            #line default
            #line hidden
                return;

            case 2:
                this.layoutGrid = ((System.Windows.Controls.Grid)(target));
                return;

            case 3:
                this.txt_Status = ((System.Windows.Controls.TextBlock)(target));
                return;

            case 4:

            #line 31 "..\..\..\MainWindow.xaml"
                ((System.Windows.Controls.Button)(target)).Click += new System.Windows.RoutedEventHandler(this.StartCapture_Button_Click);

            #line default
            #line hidden
                return;

            case 5:
                this.viewport3d = ((System.Windows.Controls.Viewport3D)(target));
                return;

            case 6:
                this.theGeometry = ((System.Windows.Media.Media3D.MeshGeometry3D)(target));
                return;

            case 7:
                this.theMaterial = ((System.Windows.Media.Media3D.DiffuseMaterial)(target));
                return;
            }
            this._contentLoaded = true;
        }
Пример #39
0
        void System.Windows.Markup.IComponentConnector.Connect(int connectionId, object target)
        {
            switch (connectionId)
            {
            case 1:
                this.viewport = ((System.Windows.Controls.Viewport3D)(target));
                return;

            case 2:
                this.camera = ((System.Windows.Media.Media3D.PerspectiveCamera)(target));
                return;

            case 3:
                this.ringVisual = ((System.Windows.Media.Media3D.ModelUIElement3D)(target));

            #line 16 "..\..\HitTesting.xaml"
                this.ringVisual.MouseDown += new System.Windows.Input.MouseButtonEventHandler(this.ringVisual_MouseDown);

            #line default
            #line hidden
                return;

            case 4:
                this.Scene = ((System.Windows.Media.Media3D.Model3DGroup)(target));
                return;

            case 5:
                this.ringModel = ((System.Windows.Media.Media3D.GeometryModel3D)(target));
                return;

            case 6:
                this.ringMesh = ((System.Windows.Media.Media3D.MeshGeometry3D)(target));
                return;

            case 7:
                this.axisRotation = ((System.Windows.Media.Media3D.AxisAngleRotation3D)(target));
                return;
            }
            this._contentLoaded = true;
        }
Пример #40
0
        void System.Windows.Markup.IComponentConnector.Connect(int connectionId, object target)
        {
            switch (connectionId)
            {
            case 1:
                this.ColorImage = ((System.Windows.Controls.Image)(target));
                return;

            case 2:
                this.viewport3d = ((System.Windows.Controls.Viewport3D)(target));
                return;

            case 3:
                this.theGeometry = ((System.Windows.Media.Media3D.MeshGeometry3D)(target));
                return;

            case 4:
                this.theMaterial = ((System.Windows.Media.Media3D.DiffuseMaterial)(target));
                return;
            }
            this._contentLoaded = true;
        }
Пример #41
0
        void System.Windows.Markup.IComponentConnector.Connect(int connectionId, object target)
        {
            switch (connectionId)
            {
            case 1:
                this.viewport3D1 = ((System.Windows.Controls.Viewport3D)(target));
                return;

            case 2:
                this.camMain = ((System.Windows.Media.Media3D.PerspectiveCamera)(target));
                return;

            case 3:
                this.dirLightMain = ((System.Windows.Media.Media3D.DirectionalLight)(target));
                return;

            case 4:
                this.MyModel = ((System.Windows.Media.Media3D.ModelVisual3D)(target));
                return;

            case 5:
                this.meshMain = ((System.Windows.Media.Media3D.MeshGeometry3D)(target));
                return;

            case 6:
                this.matDiffuseMain = ((System.Windows.Media.Media3D.DiffuseMaterial)(target));
                return;

            case 7:
                this.rotate = ((System.Windows.Media.Media3D.AxisAngleRotation3D)(target));
                return;

            case 8:
                this.slider1 = ((System.Windows.Controls.Slider)(target));
                return;
            }
            this._contentLoaded = true;
        }
Пример #42
0
        public int LoadModel(String FilePath)
        {
            MeshGeometryModel3D m_model = new MeshGeometryModel3D();

            //ModelGeometry已經有幾何模型存在內部 及 阻擋檔案不存在的情況
            if (/*IsLoaded ||*/ !File.Exists(FilePath))  ///What the F**k is IsLoaded ??????
            {
                return(1);
            }
            //利用helixtoolkit.wpf裡面提供的StlReader讀檔案,後續要轉成wpf.sharpdx可用的格式
            StLReader reader = new StLReader();

            Model3DGroup ModelContainer = reader.Read(FilePath);

            Rect3D bound = ModelContainer.Bounds;


            var ModelCenter = new Vector3(Convert.ToSingle(bound.X + bound.SizeX / 2.0),
                                          Convert.ToSingle(bound.Y + bound.SizeY / 2.0),
                                          Convert.ToSingle(bound.Z + bound.SizeZ / 2.0));

            HelixToolkit.Wpf.SharpDX.MeshGeometry3D modelGeometry = new HelixToolkit.Wpf.SharpDX.MeshGeometry3D
            {
                Normals   = new Vector3Collection(),
                Positions = new Vector3Collection(),
                Indices   = new IntCollection()
            };



            foreach (System.Windows.Media.Media3D.Model3D model in ModelContainer.Children)
            {
                var geometryModel = model as System.Windows.Media.Media3D.GeometryModel3D;

                System.Windows.Media.Media3D.MeshGeometry3D mesh = geometryModel?.Geometry as System.Windows.Media.Media3D.MeshGeometry3D;

                if (mesh == null)
                {
                    continue;
                }

                //將從stlreader讀到的資料轉入
                foreach (Point3D position in mesh.Positions)
                {
                    modelGeometry.Positions.Add(new Vector3(
                                                    Convert.ToSingle(position.X)
                                                    , Convert.ToSingle(position.Y)
                                                    , Convert.ToSingle(position.Z)));
                }
                int i = 0;
                foreach (Vector3D normal in mesh.Normals)
                {
                    //Vector3D v1 = new Vector3D((modelGeometry.Positions[i + 1].X - modelGeometry.Positions[i].X), (modelGeometry.Positions[i + 1].Y - modelGeometry.Positions[i].Y), (modelGeometry.Positions[i + 1].Z - modelGeometry.Positions[i].Z));
                    //Vector3D v2 = new Vector3D((modelGeometry.Positions[i + 2].X - modelGeometry.Positions[i].X), (modelGeometry.Positions[i + 2].Y - modelGeometry.Positions[i].Y), (modelGeometry.Positions[i + 2].Z - modelGeometry.Positions[i].Z));
                    //Vector3D n = Vector3D.CrossProduct(v1, v2);
                    //modelGeometry.Normals.Add(new Vector3(
                    //     Convert.ToSingle(n.X)
                    //    , Convert.ToSingle(n.Y)
                    //    , Convert.ToSingle(n.Z)));
                    modelGeometry.Normals.Add(new Vector3(
                                                  Convert.ToSingle(normal.X)
                                                  , Convert.ToSingle(normal.Y)
                                                  , Convert.ToSingle(normal.Z)));
                }
                foreach (Int32 triangleindice in mesh.TriangleIndices)
                {
                    modelGeometry.Indices.Add(triangleindice);
                }
                //    MessageBox.Show(mesh.Normals.Count.ToString());
            }



            SetModelMaterial(m_model);

            m_model.Geometry = modelGeometry;


            ModelGroup.Children.Add(m_model);

            m_group.Add(m_model);

            ResetCameraPosition(bound);

            return(0);
        }
Пример #43
0
        private void button_Click_2(object sender, RoutedEventArgs e)
        {
            //ball的模型
            Model3DGroup ballGroup = new Model3DGroup();

            foreach (BallModel model in MainViewModel.ProjData.BallCollection)
            {
                System.Windows.Media.Media3D.MeshGeometry3D ballMesh = new System.Windows.Media.Media3D.MeshGeometry3D
                {
                    Positions       = new Point3DCollection(),
                    Normals         = new Vector3DCollection(),
                    TriangleIndices = new Int32Collection()
                };
                HelixToolkit.Wpf.SharpDX.MeshGeometry3D geometry = model.Geometry as HelixToolkit.Wpf.SharpDX.MeshGeometry3D;

                if (geometry == null)
                {
                    return;
                }

                foreach (Vector3 position in geometry.Positions)
                {
                    ballMesh.Positions.Add(new Point3D(position.X, position.Y, position.Z));
                }
                foreach (Vector3 normal in geometry.Normals)
                {
                    ballMesh.Normals.Add(new Vector3D(normal.X, normal.Y, normal.Z));
                }
                foreach (int triangleindice in geometry.TriangleIndices)
                {
                    ballMesh.TriangleIndices.Add(triangleindice);
                }
                System.Windows.Media.Media3D.GeometryModel3D ballModel = new System.Windows.Media.Media3D.GeometryModel3D
                {
                    Geometry = ballMesh,
                };

                ballGroup.Children.Add(ballModel);
            }

            StlExporter export1 = new StlExporter();
            string      name1   = "ball.stl";

            using (var fileStream = File.Create("D:\\Desktop\\test\\" + name1))
            {
                export1.Export(ballGroup, fileStream);
            }



            //存球資料
            FileStream   fs = new FileStream("D:\\Desktop\\test\\balldata.txt", FileMode.Create);
            StreamWriter sw = new StreamWriter(fs);

            foreach (BallModel model in MainViewModel.ProjData.BallCollection)
            {
                sw.Write(model.BallCenter.X + " " + model.BallCenter.Y + " " + model.BallCenter.Z + "\r\n");
            }
            //清空緩衝區
            sw.Flush();
            //關閉流
            sw.Close();
            fs.Close();
        }
Пример #44
0
        //用來輸入文字文件,然後輸出球的模型檔案
        private void SaveBall()
        {
            string path = "D:\\Desktop\\新文字文件.txt";

            try
            {
                string   fileContent  = File.ReadAllText(path);
                string[] contentArray = fileContent.Split((string[])null, StringSplitOptions.RemoveEmptyEntries);
                float[]  pointInfo    = Array.ConvertAll(contentArray, float.Parse);
                if (pointInfo.Length % 3 != 0)
                {
                    throw new Exception();
                }

                var ballContainer = new HelixToolkit.Wpf.SharpDX.MeshBuilder();
                for (int i = 0; i < pointInfo.Length / 3; i++)
                {
                    ballContainer.AddSphere(new Vector3(pointInfo[i * 3], pointInfo[i * 3 + 1], pointInfo[i * 3 + 2]), 1.5);
                }

                System.Windows.Media.Media3D.MeshGeometry3D ballMesh = new System.Windows.Media.Media3D.MeshGeometry3D
                {
                    Positions       = new Point3DCollection(),
                    Normals         = new Vector3DCollection(),
                    TriangleIndices = new Int32Collection()
                };
                HelixToolkit.Wpf.SharpDX.MeshGeometry3D geometry = ballContainer.ToMeshGeometry3D();

                foreach (Vector3 position in geometry.Positions)
                {
                    ballMesh.Positions.Add(new Point3D(position.X, position.Y, position.Z));
                }
                foreach (Vector3 normal in geometry.Normals)
                {
                    ballMesh.Normals.Add(new Vector3D(normal.X, normal.Y, normal.Z));
                }
                foreach (int triangleindice in geometry.TriangleIndices)
                {
                    ballMesh.TriangleIndices.Add(triangleindice);
                }

                System.Windows.Media.Media3D.GeometryModel3D ballModel = new System.Windows.Media.Media3D.GeometryModel3D
                {
                    Geometry = ballMesh,
                };

                Model3DGroup ballGroup = new Model3DGroup();


                ballGroup.Children.Add(ballModel);

                StlExporter export1 = new StlExporter();
                string      name1   = "ball.stl";
                using (var fileStream = File.Create("D:\\Desktop\\" + name1))
                {
                    export1.Export(ballGroup, fileStream);
                }
            }
            catch
            {
                System.Windows.MessageBox.Show("點的讀取錯誤");
            }
        }
        void System.Windows.Markup.IComponentConnector.Connect(int connectionId, object target)
        {
            switch (connectionId)
            {
            case 1:

            #line 6 "..\..\..\MainWindow.xaml"
                ((FFEA.MainWindow)(target)).Loaded += new System.Windows.RoutedEventHandler(this.Window_Loaded);

            #line default
            #line hidden
                return;

            case 2:
                this.layoutGrid = ((System.Windows.Controls.Grid)(target));
                return;

            case 3:
                this.Tabs = ((System.Windows.Controls.TabControl)(target));
                return;

            case 4:
                this.viewport3d = ((System.Windows.Controls.Viewport3D)(target));
                return;

            case 5:
                this.theGeometry = ((System.Windows.Media.Media3D.MeshGeometry3D)(target));
                return;

            case 6:
                this.theMaterial = ((System.Windows.Media.Media3D.DiffuseMaterial)(target));
                return;

            case 7:
                this.Button_Recording = ((System.Windows.Controls.Button)(target));

            #line 129 "..\..\..\MainWindow.xaml"
                this.Button_Recording.Click += new System.Windows.RoutedEventHandler(this.Button_Record_Click);

            #line default
            #line hidden
                return;

            case 8:
                this.saveFootage = ((System.Windows.Controls.Button)(target));

            #line 130 "..\..\..\MainWindow.xaml"
                this.saveFootage.Click += new System.Windows.RoutedEventHandler(this.SaveFootage_Click);

            #line default
            #line hidden
                return;

            case 9:
                this.label1 = ((System.Windows.Controls.Label)(target));
                return;

            case 10:
                this.label1_Copy = ((System.Windows.Controls.Label)(target));
                return;

            case 11:
                this.label1_Copy1 = ((System.Windows.Controls.Label)(target));
                return;

            case 12:
                this.label1_Copy2 = ((System.Windows.Controls.Label)(target));
                return;

            case 13:
                this.label1_Copy3 = ((System.Windows.Controls.Label)(target));
                return;

            case 14:
                this.ExpressioncomboBox = ((System.Windows.Controls.ComboBox)(target));
                return;

            case 15:
                this.IDtextBox = ((System.Windows.Controls.TextBox)(target));
                return;

            case 16:
                this.AgeTextBox = ((System.Windows.Controls.TextBox)(target));
                return;

            case 17:
                this.RaceTextBox = ((System.Windows.Controls.TextBox)(target));
                return;

            case 18:
                this.MaleButton = ((System.Windows.Controls.RadioButton)(target));
                return;

            case 19:
                this.FemaleButton = ((System.Windows.Controls.RadioButton)(target));
                return;

            case 20:
                this.loadFootage = ((System.Windows.Controls.Button)(target));

            #line 151 "..\..\..\MainWindow.xaml"
                this.loadFootage.Click += new System.Windows.RoutedEventHandler(this.loadFootage_Click);

            #line default
            #line hidden
                return;

            case 21:
                this.loadedFileName = ((System.Windows.Controls.Label)(target));
                return;

            case 22:
                this.label2 = ((System.Windows.Controls.Label)(target));
                return;

            case 23:
                this.Savepattern = ((System.Windows.Controls.Button)(target));

            #line 154 "..\..\..\MainWindow.xaml"
                this.Savepattern.Click += new System.Windows.RoutedEventHandler(this.saveAsPattern_clicked);

            #line default
            #line hidden
                return;

            case 24:
                this.reviewFootage = ((System.Windows.Controls.Image)(target));
                return;

            case 25:
                this.playBack = ((System.Windows.Controls.Button)(target));

            #line 171 "..\..\..\MainWindow.xaml"
                this.playBack.Click += new System.Windows.RoutedEventHandler(this.PlayBack_Click);

            #line default
            #line hidden
                return;

            case 26:
                this.playForward = ((System.Windows.Controls.Button)(target));

            #line 172 "..\..\..\MainWindow.xaml"
                this.playForward.Click += new System.Windows.RoutedEventHandler(this.playFootage_Click);

            #line default
            #line hidden
                return;

            case 27:
                this.Mthods = ((System.Windows.Controls.Label)(target));
                return;

            case 28:
                this.analysisOne = ((System.Windows.Controls.Button)(target));

            #line 185 "..\..\..\MainWindow.xaml"
                this.analysisOne.Click += new System.Windows.RoutedEventHandler(this.analysis_clicked);

            #line default
            #line hidden
                return;

            case 29:
                this.TextBox_Library = ((System.Windows.Controls.TextBox)(target));

            #line 186 "..\..\..\MainWindow.xaml"
                this.TextBox_Library.TextChanged += new System.Windows.Controls.TextChangedEventHandler(this.TextBox_Library_TextChanged);

            #line default
            #line hidden
                return;

            case 30:
                this.library = ((System.Windows.Controls.Label)(target));
                return;

            case 31:
                this.refresh = ((System.Windows.Controls.Button)(target));

            #line 188 "..\..\..\MainWindow.xaml"
                this.refresh.Click += new System.Windows.RoutedEventHandler(this.refresh_library_clicked);

            #line default
            #line hidden
                return;

            case 32:
                this.croseValidation = ((System.Windows.Controls.TextBox)(target));
                return;

            case 33:
                this.CrossValidateAU = ((System.Windows.Controls.Button)(target));

            #line 190 "..\..\..\MainWindow.xaml"
                this.CrossValidateAU.Click += new System.Windows.RoutedEventHandler(this.AUCrossValidate_Clicked);

            #line default
            #line hidden
                return;

            case 34:
                this.label = ((System.Windows.Controls.Label)(target));
                return;

            case 35:
                this.label_Copy = ((System.Windows.Controls.Label)(target));
                return;

            case 36:
                this.database = ((System.Windows.Controls.Button)(target));

            #line 193 "..\..\..\MainWindow.xaml"
                this.database.Click += new System.Windows.RoutedEventHandler(this.Database_Click);

            #line default
            #line hidden
                return;

            case 37:
                this.KvalueBox = ((System.Windows.Controls.ComboBox)(target));
                return;

            case 38:
                this.k1 = ((System.Windows.Controls.ComboBoxItem)(target));
                return;

            case 39:
                this.k2 = ((System.Windows.Controls.ComboBoxItem)(target));
                return;

            case 40:
                this.k3 = ((System.Windows.Controls.ComboBoxItem)(target));
                return;

            case 41:
                this.k4 = ((System.Windows.Controls.ComboBoxItem)(target));
                return;

            case 42:
                this.k5 = ((System.Windows.Controls.ComboBoxItem)(target));
                return;

            case 43:
                this.k6 = ((System.Windows.Controls.ComboBoxItem)(target));
                return;

            case 44:
                this.checkSVM = ((System.Windows.Controls.RadioButton)(target));
                return;

            case 45:
                this.checkKNN = ((System.Windows.Controls.RadioButton)(target));
                return;

            case 46:
                this.TestExpression = ((System.Windows.Controls.TextBox)(target));
                return;

            case 47:
                this.Load_expression = ((System.Windows.Controls.Button)(target));

            #line 221 "..\..\..\MainWindow.xaml"
                this.Load_expression.Click += new System.Windows.RoutedEventHandler(this.Load_expression_Click);

            #line default
            #line hidden
                return;

            case 48:
                this.dataGridAU = ((System.Windows.Controls.DataGrid)(target));

            #line 222 "..\..\..\MainWindow.xaml"
                this.dataGridAU.SelectionChanged += new System.Windows.Controls.SelectionChangedEventHandler(this.DataGridAU_SelectionChanged);

            #line default
            #line hidden
                return;

            case 49:
                this.ExpressionValidation = ((System.Windows.Controls.Button)(target));

            #line 227 "..\..\..\MainWindow.xaml"
                this.ExpressionValidation.Click += new System.Windows.RoutedEventHandler(this.ExpressionValidation_Click);

            #line default
            #line hidden
                return;

            case 50:
                this.guessButton = ((System.Windows.Controls.Button)(target));

            #line 228 "..\..\..\MainWindow.xaml"
                this.guessButton.Click += new System.Windows.RoutedEventHandler(this.GuessExpression_Click);

            #line default
            #line hidden
                return;

            case 51:
                this.results = ((System.Windows.Controls.TextBox)(target));
                return;

            case 52:
                this.loadfile = ((System.Windows.Controls.Label)(target));
                return;

            case 53:
                this.ExpressionImg = ((System.Windows.Controls.Image)(target));
                return;

            case 54:
                this.ExpressionKvalue = ((System.Windows.Controls.ComboBox)(target));
                return;

            case 55:
                this.SVMSelcted = ((System.Windows.Controls.RadioButton)(target));
                return;

            case 56:
                this.KNNSelected = ((System.Windows.Controls.RadioButton)(target));
                return;
            }
            this._contentLoaded = true;
        }
        internal static MeshGeometry3D AddAgentGeometry(System.Windows.Media.Media3D.Point3D position, System.Windows.Media.Media3D.Size3D size, System.Windows.Media.Media3D.MeshGeometry3D mesh)
        {
            Point3D p1 = new Point3D(position.X + 0, position.Y + 0, position.Z + 0);
            Point3D p2 = new Point3D(position.X + size.X, position.Y + 0, position.Z + 0);
            Point3D p3 = new Point3D(position.X + size.X, position.Y + 0, position.Z + size.Z);
            Point3D p4 = new Point3D(position.X + 0, position.Y + 0, position.Z + size.Z);
            Point3D p5 = new Point3D(position.X + 0, position.Y + size.Y, position.Z + 0);
            Point3D p6 = new Point3D(position.X + size.X, position.Y + size.Y, position.Z + 0);
            Point3D p7 = new Point3D(position.X + size.X, position.Y + size.Y, position.Z + size.Z);
            Point3D p8 = new Point3D(position.X + 0, position.Y + size.Y, position.Z + size.Z);

            return(CubeModel(p1, p2, p3, p4, p5, p6, p7, p8, mesh));
        }
Пример #47
0
        void System.Windows.Markup.IComponentConnector.Connect(int connectionId, object target)
        {
            switch (connectionId)
            {
            case 1:

            #line 7 "..\..\..\MainWindow.xaml"
                ((ThreeDFaces.MainWindow)(target)).Loaded += new System.Windows.RoutedEventHandler(this.Window_Loaded);

            #line default
            #line hidden

            #line 7 "..\..\..\MainWindow.xaml"
                ((ThreeDFaces.MainWindow)(target)).StateChanged += new System.EventHandler(this.Window_StateChanged);

            #line default
            #line hidden
                return;

            case 2:

            #line 12 "..\..\..\MainWindow.xaml"
                ((System.Windows.Controls.MenuItem)(target)).Click += new System.Windows.RoutedEventHandler(this.miEdit_Click);

            #line default
            #line hidden
                return;

            case 3:

            #line 14 "..\..\..\MainWindow.xaml"
                ((System.Windows.Controls.MenuItem)(target)).Click += new System.Windows.RoutedEventHandler(this.miDelete_Click);

            #line default
            #line hidden
                return;

            case 4:

            #line 17 "..\..\..\MainWindow.xaml"
                ((System.Windows.Controls.MenuItem)(target)).Click += new System.Windows.RoutedEventHandler(this.m_iMapping_Click);

            #line default
            #line hidden
                return;

            case 5:

            #line 18 "..\..\..\MainWindow.xaml"
                ((System.Windows.Controls.MenuItem)(target)).Click += new System.Windows.RoutedEventHandler(this.m_iMapping_Click);

            #line default
            #line hidden
                return;

            case 6:

            #line 19 "..\..\..\MainWindow.xaml"
                ((System.Windows.Controls.MenuItem)(target)).Click += new System.Windows.RoutedEventHandler(this.m_iMapping_Click);

            #line default
            #line hidden
                return;

            case 7:
                this.layoutGrid = ((System.Windows.Controls.Grid)(target));
                return;

            case 8:
                this.RefImage = ((System.Windows.Controls.Image)(target));

            #line 52 "..\..\..\MainWindow.xaml"
                this.RefImage.MouseLeftButtonDown += new System.Windows.Input.MouseButtonEventHandler(this.RefImage_MouseLeftButtonDown1);

            #line default
            #line hidden
                return;

            case 9:
                this.checkNoStretch = ((System.Windows.Controls.CheckBox)(target));

            #line 54 "..\..\..\MainWindow.xaml"
                this.checkNoStretch.Checked += new System.Windows.RoutedEventHandler(this.checkNoStretch_Checked);

            #line default
            #line hidden

            #line 54 "..\..\..\MainWindow.xaml"
                this.checkNoStretch.Unchecked += new System.Windows.RoutedEventHandler(this.checkNoStretch_Unchecked);

            #line default
            #line hidden
                return;

            case 10:
                this.internallayout = ((System.Windows.Controls.Grid)(target));
                return;

            case 11:
                this.Text1 = ((System.Windows.Controls.TextBox)(target));
                return;

            case 12:
                this.Text2 = ((System.Windows.Controls.TextBox)(target));
                return;

            case 13:
                this.Button1 = ((System.Windows.Controls.Button)(target));

            #line 89 "..\..\..\MainWindow.xaml"
                this.Button1.Click += new System.Windows.RoutedEventHandler(this.Button1_Click);

            #line default
            #line hidden
                return;

            case 14:
                this.sliderx = ((System.Windows.Controls.Slider)(target));

            #line 96 "..\..\..\MainWindow.xaml"
                this.sliderx.ValueChanged += new System.Windows.RoutedPropertyChangedEventHandler <double>(this.slider_ValueChanged);

            #line default
            #line hidden
                return;

            case 15:
                this.slidery = ((System.Windows.Controls.Slider)(target));

            #line 104 "..\..\..\MainWindow.xaml"
                this.slidery.ValueChanged += new System.Windows.RoutedPropertyChangedEventHandler <double>(this.slider_ValueChanged);

            #line default
            #line hidden
                return;

            case 16:
                this.sliderz = ((System.Windows.Controls.Slider)(target));

            #line 113 "..\..\..\MainWindow.xaml"
                this.sliderz.ValueChanged += new System.Windows.RoutedPropertyChangedEventHandler <double>(this.slider_ValueChanged);

            #line default
            #line hidden
                return;

            case 17:
                this.Button3 = ((System.Windows.Controls.Button)(target));

            #line 115 "..\..\..\MainWindow.xaml"
                this.Button3.Click += new System.Windows.RoutedEventHandler(this.Button3_Click);

            #line default
            #line hidden
                return;

            case 18:
                this.Button4 = ((System.Windows.Controls.Button)(target));

            #line 117 "..\..\..\MainWindow.xaml"
                this.Button4.Click += new System.Windows.RoutedEventHandler(this.Button4_Click);

            #line default
            #line hidden
                return;

            case 19:
                this.Button5 = ((System.Windows.Controls.Button)(target));

            #line 118 "..\..\..\MainWindow.xaml"
                this.Button5.Click += new System.Windows.RoutedEventHandler(this.Button5_Click);

            #line default
            #line hidden

            #line 118 "..\..\..\MainWindow.xaml"
                this.Button5.MouseRightButtonDown += new System.Windows.Input.MouseButtonEventHandler(this.Button5_MouseRightButtonDown);

            #line default
            #line hidden
                return;

            case 20:
                this.Button6 = ((System.Windows.Controls.Button)(target));

            #line 119 "..\..\..\MainWindow.xaml"
                this.Button6.Click += new System.Windows.RoutedEventHandler(this.Button6_Click);

            #line default
            #line hidden

            #line 119 "..\..\..\MainWindow.xaml"
                this.Button6.MouseRightButtonDown += new System.Windows.Input.MouseButtonEventHandler(this.Button6_MouseRightButtonDown);

            #line default
            #line hidden
                return;

            case 21:
                this.Button7 = ((System.Windows.Controls.Button)(target));

            #line 120 "..\..\..\MainWindow.xaml"
                this.Button7.Click += new System.Windows.RoutedEventHandler(this.Button7_Click);

            #line default
            #line hidden
                return;

            case 22:
                this.sliderBrightness = ((System.Windows.Controls.Slider)(target));

            #line 121 "..\..\..\MainWindow.xaml"
                this.sliderBrightness.ValueChanged += new System.Windows.RoutedPropertyChangedEventHandler <double>(this.slider_ValueChanged);

            #line default
            #line hidden
                return;

            case 23:
                this.sliderContrast = ((System.Windows.Controls.Slider)(target));

            #line 129 "..\..\..\MainWindow.xaml"
                this.sliderContrast.ValueChanged += new System.Windows.RoutedPropertyChangedEventHandler <double>(this.slider_ValueChanged);

            #line default
            #line hidden
                return;

            case 24:
                this.ImageMesh = ((System.Windows.Controls.Image)(target));

            #line 147 "..\..\..\MainWindow.xaml"
                this.ImageMesh.MouseLeftButtonDown += new System.Windows.Input.MouseButtonEventHandler(this.ImageMesh_MouseLeftButtonDown);

            #line default
            #line hidden
                return;

            case 25:
                this.chkImageMesh = ((System.Windows.Controls.CheckBox)(target));

            #line 150 "..\..\..\MainWindow.xaml"
                this.chkImageMesh.Checked += new System.Windows.RoutedEventHandler(this.chkImageMesh_Checked);

            #line default
            #line hidden

            #line 150 "..\..\..\MainWindow.xaml"
                this.chkImageMesh.Unchecked += new System.Windows.RoutedEventHandler(this.chkImageMesh_Unchecked);

            #line default
            #line hidden
                return;

            case 26:
                this.chkGrid = ((System.Windows.Controls.CheckBox)(target));

            #line 151 "..\..\..\MainWindow.xaml"
                this.chkGrid.Checked += new System.Windows.RoutedEventHandler(this.chkGrid_Checked);

            #line default
            #line hidden

            #line 151 "..\..\..\MainWindow.xaml"
                this.chkGrid.Unchecked += new System.Windows.RoutedEventHandler(this.chkGrid_Unchecked);

            #line default
            #line hidden
                return;

            case 27:
                this.sliderRed = ((System.Windows.Controls.Slider)(target));

            #line 163 "..\..\..\MainWindow.xaml"
                this.sliderRed.ValueChanged += new System.Windows.RoutedPropertyChangedEventHandler <double>(this.sliderColor_ValueChanged);

            #line default
            #line hidden
                return;

            case 28:
                this.sliderGreen = ((System.Windows.Controls.Slider)(target));

            #line 166 "..\..\..\MainWindow.xaml"
                this.sliderGreen.ValueChanged += new System.Windows.RoutedPropertyChangedEventHandler <double>(this.sliderColor_ValueChanged);

            #line default
            #line hidden
                return;

            case 29:
                this.sliderBlue = ((System.Windows.Controls.Slider)(target));

            #line 169 "..\..\..\MainWindow.xaml"
                this.sliderBlue.ValueChanged += new System.Windows.RoutedPropertyChangedEventHandler <double>(this.sliderColor_ValueChanged);

            #line default
            #line hidden
                return;

            case 30:
                this.labelColor = ((System.Windows.Controls.Label)(target));
                return;

            case 31:
                this.sliderAmb = ((System.Windows.Controls.Slider)(target));

            #line 173 "..\..\..\MainWindow.xaml"
                this.sliderAmb.ValueChanged += new System.Windows.RoutedPropertyChangedEventHandler <double>(this.sliderColor_ValueChanged);

            #line default
            #line hidden
                return;

            case 32:
                this.vscrollz = ((System.Windows.Controls.Slider)(target));

            #line 189 "..\..\..\MainWindow.xaml"
                this.vscrollz.ValueChanged += new System.Windows.RoutedPropertyChangedEventHandler <double>(this.slider_ValueChanged);

            #line default
            #line hidden
                return;

            case 33:
                this.vscroll = ((System.Windows.Controls.Slider)(target));

            #line 198 "..\..\..\MainWindow.xaml"
                this.vscroll.ValueChanged += new System.Windows.RoutedPropertyChangedEventHandler <double>(this.slider_ValueChanged);

            #line default
            #line hidden
                return;

            case 34:
                this.GridVSnap = ((System.Windows.Controls.Grid)(target));

            #line 200 "..\..\..\MainWindow.xaml"
                this.GridVSnap.PreviewMouseWheel += new System.Windows.Input.MouseWheelEventHandler(this.GridVSnap_PreviewMouseWheel);

            #line default
            #line hidden
                return;

            case 35:
                this.VSnap0 = ((System.Windows.Controls.Image)(target));

            #line 209 "..\..\..\MainWindow.xaml"
                this.VSnap0.MouseRightButtonDown += new System.Windows.Input.MouseButtonEventHandler(this.VSnap_MouseRightButtonDown);

            #line default
            #line hidden

            #line 209 "..\..\..\MainWindow.xaml"
                this.VSnap0.MouseLeftButtonDown += new System.Windows.Input.MouseButtonEventHandler(this.VSnap_MouseLeftButtonDown);

            #line default
            #line hidden
                return;

            case 36:
                this.VSnap1 = ((System.Windows.Controls.Image)(target));

            #line 210 "..\..\..\MainWindow.xaml"
                this.VSnap1.MouseRightButtonDown += new System.Windows.Input.MouseButtonEventHandler(this.VSnap_MouseRightButtonDown);

            #line default
            #line hidden

            #line 210 "..\..\..\MainWindow.xaml"
                this.VSnap1.MouseLeftButtonDown += new System.Windows.Input.MouseButtonEventHandler(this.VSnap_MouseLeftButtonDown);

            #line default
            #line hidden
                return;

            case 37:
                this.VSnap2 = ((System.Windows.Controls.Image)(target));

            #line 211 "..\..\..\MainWindow.xaml"
                this.VSnap2.MouseRightButtonDown += new System.Windows.Input.MouseButtonEventHandler(this.VSnap_MouseRightButtonDown);

            #line default
            #line hidden

            #line 211 "..\..\..\MainWindow.xaml"
                this.VSnap2.MouseLeftButtonDown += new System.Windows.Input.MouseButtonEventHandler(this.VSnap_MouseLeftButtonDown);

            #line default
            #line hidden
                return;

            case 38:
                this.VSnap3 = ((System.Windows.Controls.Image)(target));

            #line 212 "..\..\..\MainWindow.xaml"
                this.VSnap3.MouseRightButtonDown += new System.Windows.Input.MouseButtonEventHandler(this.VSnap_MouseRightButtonDown);

            #line default
            #line hidden

            #line 212 "..\..\..\MainWindow.xaml"
                this.VSnap3.MouseLeftButtonDown += new System.Windows.Input.MouseButtonEventHandler(this.VSnap_MouseLeftButtonDown);

            #line default
            #line hidden
                return;

            case 39:
                this.VSnap4 = ((System.Windows.Controls.Image)(target));

            #line 213 "..\..\..\MainWindow.xaml"
                this.VSnap4.MouseRightButtonDown += new System.Windows.Input.MouseButtonEventHandler(this.VSnap_MouseRightButtonDown);

            #line default
            #line hidden

            #line 213 "..\..\..\MainWindow.xaml"
                this.VSnap4.MouseLeftButtonDown += new System.Windows.Input.MouseButtonEventHandler(this.VSnap_MouseLeftButtonDown);

            #line default
            #line hidden
                return;

            case 40:
                this.VSnap5 = ((System.Windows.Controls.Image)(target));

            #line 214 "..\..\..\MainWindow.xaml"
                this.VSnap5.MouseRightButtonDown += new System.Windows.Input.MouseButtonEventHandler(this.VSnap_MouseRightButtonDown);

            #line default
            #line hidden

            #line 214 "..\..\..\MainWindow.xaml"
                this.VSnap5.MouseLeftButtonDown += new System.Windows.Input.MouseButtonEventHandler(this.VSnap_MouseLeftButtonDown);

            #line default
            #line hidden
                return;

            case 41:
                this.GridFModel = ((System.Windows.Controls.Grid)(target));

            #line 217 "..\..\..\MainWindow.xaml"
                this.GridFModel.PreviewMouseWheel += new System.Windows.Input.MouseWheelEventHandler(this.GridFModel_PreviewMouseWheel);

            #line default
            #line hidden
                return;

            case 42:
                this.FModel0 = ((System.Windows.Controls.Image)(target));

            #line 226 "..\..\..\MainWindow.xaml"
                this.FModel0.MouseLeftButtonDown += new System.Windows.Input.MouseButtonEventHandler(this.Image_Face_MouseLeftButtonDown);

            #line default
            #line hidden

            #line 227 "..\..\..\MainWindow.xaml"
                this.FModel0.MouseRightButtonDown += new System.Windows.Input.MouseButtonEventHandler(this.Image_Face_MouseRightButtonDown);

            #line default
            #line hidden
                return;

            case 43:
                this.FModel1 = ((System.Windows.Controls.Image)(target));

            #line 228 "..\..\..\MainWindow.xaml"
                this.FModel1.MouseLeftButtonDown += new System.Windows.Input.MouseButtonEventHandler(this.Image_Face_MouseLeftButtonDown);

            #line default
            #line hidden

            #line 229 "..\..\..\MainWindow.xaml"
                this.FModel1.MouseRightButtonDown += new System.Windows.Input.MouseButtonEventHandler(this.Image_Face_MouseRightButtonDown);

            #line default
            #line hidden
                return;

            case 44:
                this.FModel2 = ((System.Windows.Controls.Image)(target));

            #line 230 "..\..\..\MainWindow.xaml"
                this.FModel2.MouseLeftButtonDown += new System.Windows.Input.MouseButtonEventHandler(this.Image_Face_MouseLeftButtonDown);

            #line default
            #line hidden

            #line 231 "..\..\..\MainWindow.xaml"
                this.FModel2.MouseRightButtonDown += new System.Windows.Input.MouseButtonEventHandler(this.Image_Face_MouseRightButtonDown);

            #line default
            #line hidden
                return;

            case 45:
                this.FModel3 = ((System.Windows.Controls.Image)(target));

            #line 232 "..\..\..\MainWindow.xaml"
                this.FModel3.MouseLeftButtonDown += new System.Windows.Input.MouseButtonEventHandler(this.Image_Face_MouseLeftButtonDown);

            #line default
            #line hidden

            #line 233 "..\..\..\MainWindow.xaml"
                this.FModel3.MouseRightButtonDown += new System.Windows.Input.MouseButtonEventHandler(this.Image_Face_MouseRightButtonDown);

            #line default
            #line hidden
                return;

            case 46:
                this.FModel4 = ((System.Windows.Controls.Image)(target));

            #line 234 "..\..\..\MainWindow.xaml"
                this.FModel4.MouseLeftButtonDown += new System.Windows.Input.MouseButtonEventHandler(this.Image_Face_MouseLeftButtonDown);

            #line default
            #line hidden

            #line 235 "..\..\..\MainWindow.xaml"
                this.FModel4.MouseRightButtonDown += new System.Windows.Input.MouseButtonEventHandler(this.Image_Face_MouseRightButtonDown);

            #line default
            #line hidden
                return;

            case 47:
                this.FModel5 = ((System.Windows.Controls.Image)(target));

            #line 236 "..\..\..\MainWindow.xaml"
                this.FModel5.MouseLeftButtonDown += new System.Windows.Input.MouseButtonEventHandler(this.Image_Face_MouseLeftButtonDown);

            #line default
            #line hidden

            #line 237 "..\..\..\MainWindow.xaml"
                this.FModel5.MouseRightButtonDown += new System.Windows.Input.MouseButtonEventHandler(this.Image_Face_MouseRightButtonDown);

            #line default
            #line hidden
                return;

            case 48:
                this.MainGrid = ((System.Windows.Controls.Grid)(target));
                return;

            case 49:
                this.ColorImage = ((System.Windows.Controls.Image)(target));

            #line 240 "..\..\..\MainWindow.xaml"
                this.ColorImage.MouseLeftButtonDown += new System.Windows.Input.MouseButtonEventHandler(this.ColorImage_MouseLeftButtonDown);

            #line default
            #line hidden
                return;

            case 50:
                this.MeshGrid = ((System.Windows.Controls.Grid)(target));
                return;

            case 51:
                this.MeshImage = ((System.Windows.Controls.Image)(target));

            #line 242 "..\..\..\MainWindow.xaml"
                this.MeshImage.MouseLeftButtonDown += new System.Windows.Input.MouseButtonEventHandler(this.MeshImage_MouseLeftButtonDown);

            #line default
            #line hidden

            #line 242 "..\..\..\MainWindow.xaml"
                this.MeshImage.MouseRightButtonDown += new System.Windows.Input.MouseButtonEventHandler(this.MeshImage_MouseRightButtonDown);

            #line default
            #line hidden
                return;

            case 52:
                this.viewport3d = ((System.Windows.Controls.Viewport3D)(target));

            #line 244 "..\..\..\MainWindow.xaml"
                this.viewport3d.MouseDown += new System.Windows.Input.MouseButtonEventHandler(this.viewport3d_MouseDown);

            #line default
            #line hidden

            #line 244 "..\..\..\MainWindow.xaml"
                this.viewport3d.MouseRightButtonDown += new System.Windows.Input.MouseButtonEventHandler(this.viewport3d_MouseRightButtonDown);

            #line default
            #line hidden
                return;

            case 53:
                this.amlight = ((System.Windows.Media.Media3D.AmbientLight)(target));
                return;

            case 54:
                this.dirlight = ((System.Windows.Media.Media3D.DirectionalLight)(target));
                return;

            case 55:
                this.theGeometry = ((System.Windows.Media.Media3D.MeshGeometry3D)(target));
                return;

            case 56:
                this.theMaterial = ((System.Windows.Media.Media3D.DiffuseMaterial)(target));
                return;

            case 57:
                this.hscroll = ((System.Windows.Controls.Slider)(target));

            #line 373 "..\..\..\MainWindow.xaml"
                this.hscroll.ValueChanged += new System.Windows.RoutedPropertyChangedEventHandler <double>(this.slider_ValueChanged);

            #line default
            #line hidden
                return;
            }
            this._contentLoaded = true;
        }
Пример #48
0
        void System.Windows.Markup.IComponentConnector.Connect(int connectionId, object target)
        {
            switch (connectionId)
            {
            case 1:
                this.griddnnmm = ((System.Windows.Controls.Grid)(target));

            #line 10 "..\..\MainWindow.xaml"
                this.griddnnmm.MouseWheel += new System.Windows.Input.MouseWheelEventHandler(this.grdm);

            #line default
            #line hidden
                return;

            case 2:
                this.viewport3D1 = ((System.Windows.Controls.Viewport3D)(target));
                return;

            case 3:
                this.camusernnn = ((System.Windows.Media.Media3D.PerspectiveCamera)(target));
                return;

            case 4:
                this.dirLightMain = ((System.Windows.Media.Media3D.DirectionalLight)(target));
                return;

            case 5:
                this.MyModel = ((System.Windows.Media.Media3D.ModelVisual3D)(target));
                return;

            case 6:
                this.meshMain = ((System.Windows.Media.Media3D.MeshGeometry3D)(target));
                return;

            case 7:
                this.diffuseennn = ((System.Windows.Media.Media3D.DiffuseMaterial)(target));
                return;

            case 8:
                this.cangroupname = ((System.Windows.Media.Media3D.Transform3DGroup)(target));
                return;

            case 9:
                this.rotate = ((System.Windows.Media.Media3D.AxisAngleRotation3D)(target));
                return;

            case 10:
                this.rotatey = ((System.Windows.Media.Media3D.AxisAngleRotation3D)(target));
                return;

            case 11:
                this.rotatez = ((System.Windows.Media.Media3D.AxisAngleRotation3D)(target));
                return;

            case 12:
                this.viewport3D12 = ((System.Windows.Controls.Viewport3D)(target));
                return;

            case 13:
                this.camusermmm = ((System.Windows.Media.Media3D.PerspectiveCamera)(target));
                return;

            case 14:
                this.dirLightMain2 = ((System.Windows.Media.Media3D.DirectionalLight)(target));
                return;

            case 15:
                this.MyModel2 = ((System.Windows.Media.Media3D.ModelVisual3D)(target));
                return;

            case 16:
                this.wtfrmodel = ((System.Windows.Media.Media3D.GeometryModel3D)(target));
                return;

            case 17:
                this.tr = ((System.Windows.Media.Media3D.MeshGeometry3D)(target));
                return;

            case 18:
                this.diffuseemmm = ((System.Windows.Media.Media3D.DiffuseMaterial)(target));
                return;

            case 19:
                this.rotate2 = ((System.Windows.Media.Media3D.AxisAngleRotation3D)(target));
                return;

            case 20:
                this.rotatey2 = ((System.Windows.Media.Media3D.AxisAngleRotation3D)(target));
                return;

            case 21:
                this.rotatez2 = ((System.Windows.Media.Media3D.AxisAngleRotation3D)(target));
                return;

            case 22:
                this.slider1 = ((System.Windows.Controls.Slider)(target));

            #line 146 "..\..\MainWindow.xaml"
                this.slider1.DataContextChanged += new System.Windows.DependencyPropertyChangedEventHandler(this.cngs);

            #line default
            #line hidden
                return;

            case 23:
                this.slider1y = ((System.Windows.Controls.Slider)(target));
                return;

            case 24:
                this.slider1z = ((System.Windows.Controls.Slider)(target));
                return;

            case 25:
                this.label = ((System.Windows.Controls.Label)(target));
                return;

            case 26:
                this.label1 = ((System.Windows.Controls.Label)(target));
                return;

            case 27:
                this.label1_Copy = ((System.Windows.Controls.Label)(target));
                return;

            case 28:
                this.label1_Copy1 = ((System.Windows.Controls.Label)(target));
                return;

            case 29:
                this.slider1_Copy = ((System.Windows.Controls.Slider)(target));
                return;

            case 30:
                this.slider1y_Copy = ((System.Windows.Controls.Slider)(target));
                return;

            case 31:
                this.slider1z_Copy = ((System.Windows.Controls.Slider)(target));
                return;

            case 32:
                this.label_Copy = ((System.Windows.Controls.Label)(target));
                return;

            case 33:
                this.label_Copy1 = ((System.Windows.Controls.Label)(target));
                return;

            case 34:
                this.button = ((System.Windows.Controls.Button)(target));

            #line 179 "..\..\MainWindow.xaml"
                this.button.Click += new System.Windows.RoutedEventHandler(this.Button_Click);

            #line default
            #line hidden
                return;

            case 35:
                this.button_Copy = ((System.Windows.Controls.Button)(target));

            #line 180 "..\..\MainWindow.xaml"
                this.button_Copy.Click += new System.Windows.RoutedEventHandler(this.Button_Copy_Click);

            #line default
            #line hidden
                return;

            case 36:
                this.button_Copy1 = ((System.Windows.Controls.Button)(target));

            #line 181 "..\..\MainWindow.xaml"
                this.button_Copy1.Click += new System.Windows.RoutedEventHandler(this.Button_Copy1_Click);

            #line default
            #line hidden
                return;

            case 37:
                this.label_Copy2 = ((System.Windows.Controls.Label)(target));
                return;
            }
            this._contentLoaded = true;
        }
 // highlight selected model
 public virtual void HighlightSelection(System.Windows.Media.Media3D.MeshGeometry3D meshGeometry, System.Windows.Media.Color selectColor)
 {
 }
Пример #50
0
        void System.Windows.Markup.IComponentConnector.Connect(int connectionId, object target)
        {
            switch (connectionId)
            {
            case 1:

            #line 5 "..\..\MainWindow.xaml"
                ((Processes_Manage.MainWindow)(target)).Loaded += new System.Windows.RoutedEventHandler(this.Window_Loaded);

            #line default
            #line hidden
                return;

            case 2:

            #line 9 "..\..\MainWindow.xaml"
                ((System.Windows.Media.Animation.Storyboard)(target)).Completed += new System.EventHandler(this.zoomInStoryboardCompleted);

            #line default
            #line hidden
                return;

            case 3:

            #line 33 "..\..\MainWindow.xaml"
                ((System.Windows.Media.Animation.Storyboard)(target)).Completed += new System.EventHandler(this.zoomOutStoryboardCompleted);

            #line default
            #line hidden
                return;

            case 4:
                this.newTask_MenuItem = ((System.Windows.Controls.MenuItem)(target));

            #line 67 "..\..\MainWindow.xaml"
                this.newTask_MenuItem.Click += new System.Windows.RoutedEventHandler(this.newTask_MenuItem_Click);

            #line default
            #line hidden
                return;

            case 5:
                this.quit_MenuItem = ((System.Windows.Controls.MenuItem)(target));

            #line 69 "..\..\MainWindow.xaml"
                this.quit_MenuItem.Click += new System.Windows.RoutedEventHandler(this.quit_MenuItem_Click);

            #line default
            #line hidden
                return;

            case 6:
                this.topmost_MenuItem = ((System.Windows.Controls.MenuItem)(target));

            #line 73 "..\..\MainWindow.xaml"
                this.topmost_MenuItem.Click += new System.Windows.RoutedEventHandler(this.topmost_MenuItem_Click);

            #line default
            #line hidden
                return;

            case 7:
                this.set_MenuItem = ((System.Windows.Controls.MenuItem)(target));

            #line 77 "..\..\MainWindow.xaml"
                this.set_MenuItem.Click += new System.Windows.RoutedEventHandler(this.set_MenuItem_Click);

            #line default
            #line hidden
                return;

            case 8:
                this.about_MenuItem = ((System.Windows.Controls.MenuItem)(target));

            #line 80 "..\..\MainWindow.xaml"
                this.about_MenuItem.Click += new System.Windows.RoutedEventHandler(this.about_MenuItem_Click);

            #line default
            #line hidden
                return;

            case 9:
                this.FirstPageRadioButton = ((System.Windows.Controls.RadioButton)(target));

            #line 88 "..\..\MainWindow.xaml"
                this.FirstPageRadioButton.Checked += new System.Windows.RoutedEventHandler(this.pageSelected);

            #line default
            #line hidden
                return;

            case 10:

            #line 89 "..\..\MainWindow.xaml"
                ((System.Windows.Controls.RadioButton)(target)).Checked += new System.Windows.RoutedEventHandler(this.pageSelected);

            #line default
            #line hidden
                return;

            case 11:

            #line 90 "..\..\MainWindow.xaml"
                ((System.Windows.Controls.RadioButton)(target)).Checked += new System.Windows.RoutedEventHandler(this.pageSelected);

            #line default
            #line hidden
                return;

            case 12:

            #line 91 "..\..\MainWindow.xaml"
                ((System.Windows.Controls.RadioButton)(target)).Checked += new System.Windows.RoutedEventHandler(this.pageSelected);

            #line default
            #line hidden
                return;

            case 13:

            #line 92 "..\..\MainWindow.xaml"
                ((System.Windows.Controls.RadioButton)(target)).Checked += new System.Windows.RoutedEventHandler(this.pageSelected);

            #line default
            #line hidden
                return;

            case 14:
                this.myViewport3D = ((System.Windows.Controls.Viewport3D)(target));
                return;

            case 15:
                this.myPlane = ((System.Windows.Media.Media3D.GeometryModel3D)(target));
                return;

            case 16:
                this.myGeometry = ((System.Windows.Media.Media3D.MeshGeometry3D)(target));
                return;

            case 17:
                this.myHorizontalRotation = ((System.Windows.Media.Media3D.RotateTransform3D)(target));
                return;

            case 18:
                this.MyHorizontalAxisAngleRotation3D = ((System.Windows.Media.Media3D.AxisAngleRotation3D)(target));
                return;

            case 19:
                this.MyScaleTransform3D = ((System.Windows.Media.Media3D.ScaleTransform3D)(target));
                return;

            case 20:
                this.scrollViewerBorder = ((System.Windows.Controls.Border)(target));
                return;

            case 21:
                this.myScrollViewer = ((System.Windows.Controls.ScrollViewer)(target));
                return;

            case 22:
                this.mainFrame = ((System.Windows.Controls.Frame)(target));

            #line 182 "..\..\MainWindow.xaml"
                this.mainFrame.ContentRendered += new System.EventHandler(this.frameContentRendered);

            #line default
            #line hidden
                return;

            case 23:
                this.processesNums_Now = ((System.Windows.Controls.TextBlock)(target));
                return;

            case 24:
                this.cpu_Rate = ((System.Windows.Controls.TextBlock)(target));
                return;

            case 25:
                this.memory_Rate = ((System.Windows.Controls.TextBlock)(target));
                return;

            case 26:
                this.gpu_temperature = ((System.Windows.Controls.TextBlock)(target));
                return;
            }
            this._contentLoaded = true;
        }
Пример #51
0
        void System.Windows.Markup.IComponentConnector.Connect(int connectionId, object target)
        {
            switch (connectionId)
            {
            case 1:

            #line 5 "..\..\Window1.xaml"
                ((WaveSim.Window1)(target)).MouseWheel += new System.Windows.Input.MouseWheelEventHandler(this.Window_MouseWheel);

            #line default
            #line hidden
                return;

            case 2:
                this.grid1 = ((System.Windows.Controls.Grid)(target));
                return;

            case 3:
                this.btnStart = ((System.Windows.Controls.Button)(target));

            #line 11 "..\..\Window1.xaml"
                this.btnStart.Click += new System.Windows.RoutedEventHandler(this.btnStart_Click);

            #line default
            #line hidden
                return;

            case 4:
                this.viewport3D1 = ((System.Windows.Controls.Viewport3D)(target));
                return;

            case 5:
                this.camMain = ((System.Windows.Media.Media3D.PerspectiveCamera)(target));
                return;

            case 6:
                this.vis3DLighting = ((System.Windows.Media.Media3D.ModelVisual3D)(target));
                return;

            case 7:
                this.dirLightMain = ((System.Windows.Media.Media3D.DirectionalLight)(target));
                return;

            case 8:
                this.gmodMain = ((System.Windows.Media.Media3D.GeometryModel3D)(target));
                return;

            case 9:
                this.meshMain = ((System.Windows.Media.Media3D.MeshGeometry3D)(target));
                return;

            case 10:
                this.matDiffuseMain = ((System.Windows.Media.Media3D.DiffuseMaterial)(target));
                return;

            case 11:
                this.slidPeakHeight = ((System.Windows.Controls.Slider)(target));

            #line 53 "..\..\Window1.xaml"
                this.slidPeakHeight.ValueChanged += new System.Windows.RoutedPropertyChangedEventHandler <double>(this.slidPeakHeight_ValueChanged);

            #line default
            #line hidden
                return;

            case 12:
                this.lblDropDepth = ((System.Windows.Controls.Label)(target));
                return;

            case 13:
                this.slidNumDrops = ((System.Windows.Controls.Slider)(target));

            #line 55 "..\..\Window1.xaml"
                this.slidNumDrops.ValueChanged += new System.Windows.RoutedPropertyChangedEventHandler <double>(this.slidNumDrops_ValueChanged);

            #line default
            #line hidden
                return;

            case 14:
                this.label1 = ((System.Windows.Controls.Label)(target));
                return;
            }
            this._contentLoaded = true;
        }
Пример #52
0
        void System.Windows.Markup.IComponentConnector.Connect(int connectionId, object target)
        {
            switch (connectionId)
            {
            case 1:

            #line 9 "..\..\MainWindow.xaml"
                ((linearAlgebra.MainWindow)(target)).KeyDown += new System.Windows.Input.KeyEventHandler(this.OnKeyDown);

            #line default
            #line hidden
                return;

            case 2:
                this.viewport3D = ((System.Windows.Controls.Viewport3D)(target));
                return;

            case 3:
                this.camMain = ((System.Windows.Media.Media3D.PerspectiveCamera)(target));
                return;

            case 4:
                this.dirLightMain = ((System.Windows.Media.Media3D.DirectionalLight)(target));
                return;

            case 5:
                this.MyModel = ((System.Windows.Media.Media3D.ModelVisual3D)(target));
                return;

            case 6:
                this.cube = ((System.Windows.Media.Media3D.MeshGeometry3D)(target));
                return;

            case 7:
                this.matDiffuseMain = ((System.Windows.Media.Media3D.DiffuseMaterial)(target));
                return;

            case 8:
                this.Color = ((System.Windows.Media.SolidColorBrush)(target));
                return;

            case 9:
                this.Model2 = ((System.Windows.Media.Media3D.ModelVisual3D)(target));
                return;

            case 10:
                this.cone = ((System.Windows.Media.Media3D.MeshGeometry3D)(target));
                return;

            case 11:
                this.matDiffuseMain2 = ((System.Windows.Media.Media3D.DiffuseMaterial)(target));
                return;

            case 12:
                this.Color2 = ((System.Windows.Media.SolidColorBrush)(target));
                return;

            case 13:
                this.textBox = ((System.Windows.Controls.TextBox)(target));
                return;
            }
            this._contentLoaded = true;
        }