Пример #1
0
    // Start is called before the first frame update
    void Start()
    {
        Debug.Assert(P0 != null);   // Verify proper setting in the editor
        Debug.Assert(P1 != null);
        Debug.Assert(P2 != null);

        #region For visualizing the vectors
        // To support visualizing the vectors
        ShowV1 = new MyVector {
            VectorColor = Color.cyan
        };
        ShowV2 = new MyVector
        {
            VectorColor = Color.magenta
        };
        ShowProjected = new MyLineSegment
        {
            VectorColor = PositiveColor
        };
        ShowProjectedAlone = new MyLineSegment
        {
            VectorColor = PositiveColor,
            VectorAt    = Vector3.zero,
            Direction   = Vector3.up
        };
        #endregion
    }
Пример #2
0
    // Start is called before the first frame update
    void Start()
    {
        Debug.Assert(P0 != null);   // Verify proper setting in the editor
        Debug.Assert(P1 != null);
        Debug.Assert(P2 != null);

        #region For visualizing the vectors
        // To support visualizing the vectors
        ShowV1 = new MyVector {
            VectorColor = Color.cyan
        };
        ShowV2 = new MyVector
        {
            VectorColor = Color.magenta
        };
        ShowDot = new MyLineSegment
        {
            VectorAt  = Vector3.zero,
            LineWidth = 0.07f
        };
        ShowPlane = new MyXZPlane
        {
            PlaneColor = new Color(0.3f, 0.8f, 0.3f, 0.5f),
            XSize      = 0.5f,
            YSize      = 0.5f,
            ZSize      = 0.5f
        };
        #endregion
    }
Пример #3
0
    // Start is called before the first frame update
    void Start()
    {
        Debug.Assert(P0 != null);   // Verify proper setting in the editor
        Debug.Assert(P1 != null);
        Debug.Assert(Pt != null);
        Debug.Assert(Pon != null);

        #region For visualizing the lines
        // To support visualizing the lines
        ShowLine = new MyLineSegment
        {
            VectorColor = MyDrawObject.NoCollisionColor,
            LineWidth   = 0.6f
        };
        ShowVc = new MyLineSegment
        {
            VectorColor = Color.black,
            LineWidth   = 0.05f
        };
        ShowV1 = new MyVector
        {
            VectorColor = Color.green
        };
        #endregion
    }
Пример #4
0
    // Start is called before the first frame update
    void Start()
    {
        Debug.Assert(P0 != null);   // Verify proper setting in the editor
        Debug.Assert(P1 != null);
        Debug.Assert(Pt != null);
        Debug.Assert(Pon != null);

        #region For visualizing the vectors
        // To support visualizing the vectors
        ShowV1 = new MyVector {
            VectorColor = Color.green
        };
        ShowLine = new MyLineSegment
        {
            VectorColor = MyDrawObject.NoCollisionColor,
            LineWidth   = 0.6f
        };
        ShowPv = new MyLineSegment
        {
            VectorColor = Color.black,
            LineWidth   = 0.02f
        };
        ShowPa = new MyLineSegment
        {
            VectorColor = Color.black,
            LineWidth   = 0.02f
        };
        Pt.GetComponent <Renderer>().material.color  = Color.black;
        Pon.GetComponent <Renderer>().material.color = Color.black;
        #endregion
    }
Пример #5
0
    void Start()
    {
        Debug.Assert(P1 != null);   // Verify proper setting in the editor
        Debug.Assert(P2 != null);
        Debug.Assert(Pd_1 != null);
        Debug.Assert(Pa != null);
        Debug.Assert(Pb != null);
        Debug.Assert(Pd_a != null);

        #region For visualizing the line
        // To support visualizing the line
        ShowV1 = new MyLineSegment
        {
            VectorColor = Color.red,
            LineWidth   = 0.1f
        };
        ShowVa = new MyLineSegment
        {
            VectorColor = Color.blue,
            LineWidth   = 0.1f
        };
        ShowVp = new MyLineSegment
        {
            VectorColor = Color.black,
            LineWidth   = 0.05f
        };
        #endregion
    }
Пример #6
0
    // Start is called before the first frame update
    void Start()
    {
        Debug.Assert(Pn != null);   // Verify proper setting in the editor
        Debug.Assert(P0 != null);
        Debug.Assert(P1 != null);
        Debug.Assert(Pon != null);

        #region For visualizing the vectors
        // To support visualizing the vectors
        ShowNormal = new MyVector {
            VectorColor = Color.white
        };
        ShowPlane = new MyXZPlane
        {
            PlaneColor = new Color(0.8f, 0.3f, 0.3f, 1.0f),
            XSize      = 0.5f,
            YSize      = 0.5f,
            ZSize      = 0.5f
        };
        ShowLine = new MyLineSegment
        {
            VectorColor = Color.black,
            LineWidth   = 0.05f
        };
        ShowRestOfLine = new MyLineSegment
        {
            VectorColor = Color.red,
            LineWidth   = 0.05f
        };
        #endregion
    }
Пример #7
0
        //
        public void CalculateUserCharGlyphAdvancePos(ref TextBufferSpan textBufferSpan,
                                                     ILineSegmentList lineSegs,
                                                     RequestFont font,
                                                     int[] outputUserInputCharAdvance, out int outputTotalW, out int lineHeight)
        {
            //layout
            //from font
            //resolve for typeface
            //
            Typeface typeface = ResolveTypeface(font);

            _txtServices.SetCurrentFont(typeface, font.SizeInPoints);


            MyLineSegmentList mylineSegs = (MyLineSegmentList)lineSegs;
            float             scale      = typeface.CalculateScaleToPixelFromPointSize(font.SizeInPoints);

            outputTotalW = 0;
            int j   = mylineSegs.Count;
            int pos = 0; //start at 0

            _reusableTextBuffer.SetRawCharBuffer(textBufferSpan.GetRawCharBuffer());

            for (int i = 0; i < j; ++i)
            {
                //get each segment
                MyLineSegment lineSeg = (MyLineSegment)mylineSegs.GetSegment(i);
                //each line seg may has different script lang
                _txtServices.CurrentScriptLang = lineSeg.scriptLang;
                //
                //CACHING ...., reduce number of GSUB/GPOS
                //
                //we cache used line segment for a while
                //we ask for caching context for a specific typeface and font size
                GlyphPlanSequence seq = _txtServices.GetUnscaledGlyphPlanSequence(_reusableTextBuffer,
                                                                                  lineSeg.StartAt,
                                                                                  lineSeg.Length);

                int seqLen = seq.Count;

                for (int s = 0; s < seqLen; ++s)
                {
                    UnscaledGlyphPlan glyphPlan = seq[s];

                    double actualAdvX = glyphPlan.AdvanceX;

                    outputTotalW +=
                        outputUserInputCharAdvance[pos + glyphPlan.input_cp_offset] +=
                            (int)Math.Round(actualAdvX * scale);
                }
                pos += lineSeg.Length;
            }

            //

            lineHeight = (int)Math.Round(typeface.CalculateRecommendLineSpacing() * scale);

            _reusableTextBuffer.SetRawCharBuffer(null);
        }
Пример #8
0
    // Start is called before the first frame update
    void Start()
    {
        aLine             = new MyLineSegment();
        aLine.VectorColor = Color.red;

        lc                  = new Color(0.8f, 0f, 0.0f, alpha);
        LineDir             = new MyLineSegment();
        LineDir.VectorColor = lc;
        aVector             = new MyVector();
        aVector.VectorColor = Color.black;
    }
Пример #9
0
    private MyLineSegment ShowPtLine; // Line to Pt
    #endregion

    // Start is called before the first frame update
    void Start()
    {
        #region Identical to EX_6_2
        Debug.Assert(P0 != null);   // Verify proper setting in the editor
        Debug.Assert(P1 != null);
        Debug.Assert(P2 != null);
        Debug.Assert(Ds != null);
        Debug.Assert(Pn != null);
        Debug.Assert(Pt != null);
        Debug.Assert(Pon != null);
        #endregion

        Debug.Assert(P2p != null);

        #region For visualizing the vectors
        // To support visualizing the vectors
        ShowV1 = new MyVector
        {
            VectorColor = Color.cyan
        };
        ShowV2 = new MyVector
        {
            VectorColor = Color.magenta
        };
        ShowV3 = new MyVector
        {
            VectorColor = Color.green
        };
        ShowNormal = new MyVector {
            VectorColor = Color.white
        };
        ShowVn = new MyVector
        {
            VectorColor = Color.black
        };
        ShowPlane = new MyXZPlane
        {
            PlaneColor = new Color(0.8f, 0.3f, 0.3f, 1.0f),
            XSize      = 0.5f,
            YSize      = 0.5f,
            ZSize      = 0.5f
        };
        ShowPtLine = new MyLineSegment
        {
            VectorColor = Color.black,
            LineWidth   = 0.05f
        };
        #endregion
    }
Пример #10
0
        public ILineSegmentList BreakToLineSegments(ref TextBufferSpan textBufferSpan)
        {
            //a text buffer span is separated into multiple line segment list
            char[] str         = textBufferSpan.GetRawCharBuffer();
            int    cur_startAt = textBufferSpan.start;


            MyLineSegmentList lineSegments = MyLineSegmentList.GetFreeLineSegmentList();

            foreach (BreakSpan breakSpan in _txtServices.BreakToLineSegments(str, textBufferSpan.start, textBufferSpan.len))
            {
                MyLineSegment lineSeg = new MyLineSegment(lineSegments, breakSpan.startAt, breakSpan.len);
                lineSeg.scriptLang = breakSpan.scLang;
                lineSegments.AddLineSegment(lineSeg);
            }
            return(lineSegments);
        }
Пример #11
0
    private void Start()
    {
        Debug.Assert(P0 != null);   // Verify proper setting in the editor
        Debug.Assert(P1 != null);
        Debug.Assert(TheSphere != null);
        Debug.Assert(Pa != null);
        Debug.Assert(Pb != null);

        #region For visualizing the line
        // To support visualizing the line
        ShowTheLine = new MyLineSegment
        {
            VectorColor = Color.blue,
            LineWidth   = 0.08f
        };
        #endregion
    }
Пример #12
0
        public ILineSegmentList BreakToLineSegments(ref TextBufferSpan textBufferSpan)
        {
            _resuableLineSegments.Clear();

            //a text buffer span is separated into multiple line segment list

            char[] str = textBufferSpan.GetRawCharBuffer();

            MyLineSegmentList lineSegs = new MyLineSegmentList(textBufferSpan.start, textBufferSpan.len);
            int cur_startAt            = textBufferSpan.start;

            foreach (BreakSpan breakSpan in _txtServices.BreakToLineSegments(str, textBufferSpan.start, textBufferSpan.len))
            {
                MyLineSegment lineSeg = new MyLineSegment(lineSegs, breakSpan.startAt, breakSpan.len);
                lineSeg.scriptLang = breakSpan.scLang;
                _resuableLineSegments.Add(lineSeg);
            }

            //TODO: review here,
            //check if we need to create new array everytime?
            lineSegs.SetResultLineSegments(_resuableLineSegments.ToArray());
            _resuableLineSegments.Clear();
            return(lineSegs);
        }
Пример #13
0
        public void CalculateUserCharGlyphAdvancePos(ref TextBufferSpan textBufferSpan,
                                                     ILineSegmentList lineSegs, RequestFont font,
                                                     int[] outputUserInputCharAdvance, out int outputTotalW, out int lineHeight)
        {
            //layout
            //from font
            //resolve for typeface
            //
            Typeface typeface = ResolveTypeface(font);

            _txtServices.SetCurrentFont(typeface, font.SizeInPoints);


            MyLineSegmentList mylineSegs = (MyLineSegmentList)lineSegs;
            float             scale      = typeface.CalculateScaleToPixelFromPointSize(font.SizeInPoints);

            outputTotalW = 0;
            int j   = mylineSegs.Count;
            int pos = 0; //start at 0

            _reusableTextBuffer.SetRawCharBuffer(textBufferSpan.GetRawCharBuffer());

            for (int i = 0; i < j; ++i)
            {
                //userGlyphPlanList.Clear();
                //userCharToGlyphMapList.Clear();
                //get each segment
                MyLineSegment lineSeg = mylineSegs.GetSegment(i);
                //each line seg may has different script lang
                _txtServices.CurrentScriptLang = lineSeg.scriptLang;
                //
                //CACHING ...., reduce number of GSUB/GPOS
                //
                //we cache used line segment for a while
                //we ask for caching context for a specific typeface and font size
                GlyphPlanSequence seq = _txtServices.GetUnscaledGlyphPlanSequence(_reusableTextBuffer,
                                                                                  lineSeg.StartAt,
                                                                                  lineSeg.Length);


                //IMPORTANT
                //num of glyph may more or less than original user input char buffer
                //


                //float g_x = 0;
                //float g_y = 0;
                //int baseY = (int)Math.Round(y);
                //int n = glyphPlanSeq.len;
                //int endBefore = glyphPlanSeq.startAt + n;

                ////***
                //_glsx.SetAssociatedTextureInfo(_glBmp);

                //List<float> vboBufferList = new List<float>();
                //List<ushort> indexList = new List<ushort>();

                //for (int i = glyphPlanSeq.startAt; i < endBefore; ++i)
                //{
                //    GlyphPlanList glyphPlanList = GlyphPlanSequence.UnsafeGetInteralGlyphPlanList(glyphPlanSeq);
                //    GlyphPlan glyph = glyphPlanList[i];

                //    Typography.Rendering.TextureGlyphMapData glyphData;
                //    if (!_fontAtlas.TryGetGlyphDataByCodePoint(glyph.glyphIndex, out glyphData))
                //    {
                //        //if no glyph data, we should render a missing glyph ***
                //        continue;
                //    }
                //    //if (scaleFromTexture != 1)
                //    //{

                //    //}
                //    //--------------------------------------
                //    //TODO: review precise height in float
                //    //--------------------------------------
                //    PixelFarm.Drawing.Rectangle srcRect = ConvToRect(glyphData.Rect);
                //    g_x = (float)(x + (glyph.ExactX * scale - glyphData.TextureXOffset) * scaleFromTexture); //ideal x
                //    g_y = (float)(y + (glyph.ExactY * scale - glyphData.TextureYOffset + srcRect.Height) * scaleFromTexture);


                //    //for sharp glyph
                //    //we adjust g_x,g_y to integer value
                //    //float g_y2 = (float)Math.Floor(g_y);

                //    g_x = (float)Math.Round(g_x);
                //    g_y = (float)Math.Floor(g_y);


                //    switch (textureKind)
                //    {
                //        case TextureKind.Msdf:

                //            _glsx.DrawSubImageWithMsdf(_glBmp,
                //                ref srcRect,
                //                g_x,
                //                g_y,
                //                scaleFromTexture);

                //            break;
                //        case TextureKind.StencilGreyScale:

                //            //stencil gray scale with fill-color
                //            _glsx.DrawGlyphImageWithStecil(_glBmp,
                //             ref srcRect,
                //                g_x,
                //                g_y,
                //                scaleFromTexture);

                //            break;
                //        case TextureKind.Bitmap:
                //            _glsx.DrawSubImage(_glBmp,
                //             ref srcRect,
                //                g_x,
                //                g_y,
                //                scaleFromTexture);
                //            break;
                //        case TextureKind.StencilLcdEffect:
                //            _glsx.WriteVboToList(
                //              vboBufferList,
                //              indexList,
                //              ref srcRect,
                //              g_x,
                //              g_y,
                //              scaleFromTexture);
                //            break;
                //    }
                //}
                ////---------


                int seqLen = seq.Count;

                for (int s = 0; s < seqLen; ++s)
                {
                    UnscaledGlyphPlan glyphPlan = seq[s];

                    double actualAdvX = glyphPlan.AdvanceX;

                    outputTotalW +=
                        outputUserInputCharAdvance[pos + glyphPlan.input_cp_offset] +=
                            (int)Math.Round(actualAdvX * scale);
                }
                pos += lineSeg.Length;
            }

            //

            lineHeight = (int)Math.Round(typeface.CalculateRecommendLineSpacing() * scale);

            _reusableTextBuffer.SetRawCharBuffer(null);
        }
Пример #14
0
        public void CalculateUserCharGlyphAdvancePos(ref TextBufferSpan textBufferSpan,
                                                     ILineSegmentList lineSegs, RequestFont font,
                                                     int[] outputUserInputCharAdvance, out int outputTotalW, out int lineHeight)
        {
            //layout
            //from font
            //resolve for typeface
            //
            Typeface typeface = ResolveTypeface(font);

            _typographyTxtServices.SetCurrentFont(typeface, font.SizeInPoints);


            MyLineSegmentList mylineSegs = (MyLineSegmentList)lineSegs;
            float             scale      = typeface.CalculateScaleToPixelFromPointSize(font.SizeInPoints);

            outputTotalW = 0;
            int j   = mylineSegs.Count;
            int pos = 0; //start at 0

            _reusableTextBuffer.SetRawCharBuffer(textBufferSpan.GetRawCharBuffer());

            for (int i = 0; i < j; ++i)
            {
                //userGlyphPlanList.Clear();
                //userCharToGlyphMapList.Clear();
                //get each segment
                MyLineSegment lineSeg = mylineSegs.GetSegment(i);
                //each line seg may has different script lang
                _typographyTxtServices.CurrentScriptLang = lineSeg.scriptLang;
                //
                //CACHING ...., reduce number of GSUB/GPOS
                //
                //we cache used line segment for a while
                //we ask for caching context for a specific typeface and font size
                GlyphPlanSequence seq = _typographyTxtServices.GetUnscaledGlyphPlanSequence(_reusableTextBuffer,
                                                                                            lineSeg.StartAt,
                                                                                            lineSeg.Length);

                GlyphPlanList planList = GlyphPlanSequence.UnsafeGetInteralGlyphPlanList(seq);
                //IMPORTANT
                //num of glyph may more or less than original user input char buffer
                //


                int endAt       = seq.startAt + seq.len;
                int seq_startAt = seq.startAt;

                for (int s = seq_startAt; s < endAt; ++s)
                {
                    GlyphPlan glyphPlan  = planList[s];
                    float     tx         = glyphPlan.ExactX;
                    float     ty         = glyphPlan.ExactY;
                    double    actualAdvX = glyphPlan.AdvanceX;

                    outputTotalW +=
                        outputUserInputCharAdvance[pos + glyphPlan.input_cp_offset] +=
                            (int)Math.Round(actualAdvX * scale);
                }
                pos += lineSeg.Length;
            }

            //

            lineHeight = (int)Math.Round(typeface.CalculateRecommendLineSpacing() * scale);

            _reusableTextBuffer.SetRawCharBuffer(null);
        }