예제 #1
0
파일: Align.cs 프로젝트: yisea123/KMotionX
        public int AlignTarget(Alignment_Type AlignType, int[] XProfile, int[] YProfile, ref EDGEBUF EdgeBufX, ref EDGEBUF EdgeBufY, ref TARGBUF TargetX, ref TARGBUF TargetY,
                               double DesiredTrgtBarWidthX, double DesiredTrgtBarWidthY, double TargetWidthTolX, double TargetWidthTolY, double EdgeThresholdX, double EdgeThresholdY, ref String err)
        {
            err = "";

            EdgeBufX.EdgesFound = EdgeBufY.EdgesFound = 0;
            TargetX.TargetFound = TargetY.TargetFound = false;

            if (EdgeExtract(XProfile, ref EdgeBufX, EdgeThresholdX) != 0)
            {
                return(1);
            }

            if (EdgeExtract(YProfile, ref EdgeBufY, EdgeThresholdY) != 0)
            {
                return(1);
            }

            TargetLocate(EdgeBufX, DesiredTrgtBarWidthX, TargetWidthTolX, EdgeThresholdX, XProfile.Length, ref TargetX, AlignType);
            TargetLocate(EdgeBufY, DesiredTrgtBarWidthY, TargetWidthTolY, EdgeThresholdY, YProfile.Length, ref TargetY, AlignType);

            if (!TargetX.TargetFound && !TargetY.TargetFound)
            {
                err = "Error Finding X and Y Targets";
                return(1);
            }
            else if (!TargetX.TargetFound)
            {
                err = "Error Finding X Target";
                return(1);
            }
            else if (!TargetY.TargetFound)
            {
                err = "Error Finding Y Target";
                return(1);
            }

            return(0);
        }
예제 #2
0
	/// <summary>
	/// Sets the alignment of the text (left, right, center).
	/// </summary>
	/// <param name="a">The alignment to use.</param>
	public void SetAlignment(Alignment_Type a)
	{
		alignment = a;
		LayoutText();
	}
예제 #3
0
	/// <summary>
	/// Duplicates the settings of another SpriteText object.
	/// </summary>
	/// <param name="s">The SpriteText object to be copied.</param>
	public virtual void Copy(SpriteText s)
	{
		offsetZ = s.offsetZ;
		characterSize = s.characterSize;
		lineSpacing = s.lineSpacing;
		lineSpaceSize = s.lineSpaceSize;
		anchor = s.anchor;
		alignment = s.alignment;
		tabSize = s.tabSize;
		multiline = s.multiline;
		maxWidth = s.maxWidth;
		removeUnsupportedCharacters = s.removeUnsupportedCharacters;
		parseColorTags = s.parseColorTags;
		password = s.password;
		maskingCharacter = s.maskingCharacter;
		ignoreClipping = s.ignoreClipping;

		texture = s.texture;
		SetPixelToUV(texture);
		
		font = s.font;
		spriteFont = FontStore.GetFont(font);

		lineSpaceSize = lineSpacing * spriteFont.LineHeight * worldUnitsPerTexel;
		
		color = s.color;
		text = s.text;
		ProcessString(text);
		pixelPerfect = s.pixelPerfect;
		dynamicLength = s.dynamicLength;
		SetCamera(s.renderCamera);
		hideAtStart = s.hideAtStart;
		m_hidden = s.m_hidden;
		Hide(m_hidden);
	}
예제 #4
0
파일: Align.cs 프로젝트: yisea123/KMotionX
        /*******************************************************************************/
        /*                                                                             */
        /*    Returns 0       if successful                                            */
        /*            nonzero if unsuccessful                                          */
        /*                                                                             */
        /*  HowToLook = ONLYTARGET this parameter informs the target finding routine   */
        /*                           that there may be no reticle in view and that the */
        /*                           reticle has not been located.                     */
        /*            = INSIDERET  this informs the target finding routine to          */
        /*                           only look for the target inside the reticle       */
        /*                           edges that have been found                        */
        /*                                                                             */
        /*******************************************************************************/
        private int TargetLocate(EDGEBUF edges, double DesiredWidth, double TargetWidthTol, double Threshold, int Length, ref TARGBUF tar, Alignment_Type AlignType)
        {
            int    lei, rei, BeginningOfTargetEdges = 0, EndOfTargetEdges = 0;
            double HRatio, WRatio, TargetWidth;
            double MeritValue, MaxMeritValue = -1.0F;
            int    Polarity = AlignType == Alignment_Type.ALGN_BLK_BAR ? 1 : -1;

            tar.TargetFound        = false;
            BeginningOfTargetEdges = 0;
            EndOfTargetEdges       = edges.EdgesFound - 1;

            if (EndOfTargetEdges <= BeginningOfTargetEdges)   // we need at least 2 edges for the target
            {
                return(1);
            }

            lei = BeginningOfTargetEdges;
            do
            {
                rei = EndOfTargetEdges;
                do
                {
                    HRatio = (float)Math.Abs((float)(edges.EdgeH[lei]) / (float)(edges.EdgeH[rei]));
                    if (HRatio > 1.0F)
                    {
                        HRatio = 1.0F / HRatio;
                    }


                    if ((edges.EdgeH[lei] * Polarity < -Threshold) &&
                        (edges.EdgeH[rei] * Polarity > Threshold) &&
                        (HRatio > 0.33333F))
                    {
                        TargetWidth = (edges.EdgeC[rei]) - (edges.EdgeC[lei]);
                        if ((TargetWidth >= DesiredWidth / TargetWidthTol) &&
                            (TargetWidth <= DesiredWidth * TargetWidthTol))
                        {
                            //
                            // Valid Target found, compute merit value
                            //
                            WRatio = TargetWidth / (float)DesiredWidth;
                            if (WRatio > 1.0F)
                            {
                                WRatio = 1.0F / WRatio;
                            }
                            MeritValue = (edges.EdgeH[rei] - edges.EdgeH[lei]) * Polarity * WRatio * HRatio;
                            if (MeritValue > MaxMeritValue)  // best so far ??
                            {
                                MaxMeritValue   = MeritValue;
                                tar.TargetFound = true;
                                tar.TargetL     = lei;
                                tar.TargetR     = rei;
                            }
                        }
                    }
                } while (--rei > lei);
            } while (++lei < EndOfTargetEdges);

            if (tar.TargetFound)
            {
                tar.TargetC = (edges.EdgeC[tar.TargetL] +
                               edges.EdgeC[tar.TargetR]) / 2;

                tar.Adj = tar.TargetC - 0.5f * Length;
                tar.ImageSizeInPixels = Length;

                return(0);
            }
            else
            {
                return(1);
            }
        }
예제 #5
0
	/// <summary>
	/// Duplicates the settings of another SpriteText object.
	/// </summary>
	/// <param name="s">The SpriteText object to be copied.</param>
	public virtual void Copy(SpriteText s)
	{
		offsetZ = s.offsetZ;
		characterSize = s.characterSize;
		lineSpacing = s.lineSpacing;
		lineSpaceSize = s.lineSpaceSize;
		anchor = s.anchor;
		alignment = s.alignment;
		tabSize = s.tabSize;

		texture = s.texture;
		SetPixelToUV(texture);
		
		font = s.font;
		spriteFont = FontStore.GetFont(font);

		lineSpaceSize = lineSpacing * spriteFont.LineHeight * worldUnitsPerTexel;
		
		color = s.color;
		text = s.text;
		ProcessString(text);
		pixelPerfect = s.pixelPerfect;
		dynamicLength = s.dynamicLength;
		SetCamera(s.renderCamera);
		hideAtStart = s.hideAtStart;
		m_hidden = s.m_hidden;
		Hide(m_hidden);
	}