Пример #1
0
        public static Point GetTexCood(CameraRatio cameraRatio, Point3D transformedPt, double zDistance)
        {
            if (zDistance < 0.0f)
            {
                throw new Exception("Error: Incorrect camera orientation encountered. A camera position was found to be not in front of the model. It was either within the model or behind it");
            }

            var maxXRange = 0.0;
            var maxYRange = 0.0;

            //If the camera is at infinity then max values along x and y will remain the same
            //Confirm if xRangeAtInfinity is the total range or it is the range in either direction
            if (cameraRatio.XRangeAtInfinity > 0.0f)
            {
                maxXRange = cameraRatio.XRangeAtInfinity;
                maxYRange = cameraRatio.YRangeAtInfinity;
            }
            if (cameraRatio.XRatio > 0.0f) //The ranges have to be set for each vertex depending on their distance from the camera location
            {
                maxXRange = cameraRatio.XRatio * zDistance;
                maxYRange = cameraRatio.YRatio * zDistance;
            }

            return(GetTexCood(transformedPt, maxXRange, maxYRange));
        }
Пример #2
0
        public static IEnumerable <TexCoodAndImgIndex> GetTextureCoordinates(ImageSpecifics[] imageParameters, CameraRatio cameraRatio, Vector3DCollection meshNormals, Point3DCollection meshPositions)
        {
            var imageSelector = new PolyNormalBasedImageSelector(meshPositions, meshNormals, imageParameters, cameraRatio);

            var unmergedCoordinates = new List <TexCoodAndImgIndex>();

            for (var ctr = 0; ctr < meshPositions.Count; ctr++)
            {
                var selection = imageSelector.GetBestImageParams(ctr);

                //Assign the u,v values
                unmergedCoordinates.Add(new TexCoodAndImgIndex {
                    ImgIndex = selection.IndexOfImageToUse, TexCood = new Point(selection.TexCood.X, selection.TexCood.Y)
                });
            }

            return(unmergedCoordinates);
        }