コード例 #1
0
        /// <summary>
        /// binary insertion sort.
        /// </summary>
        /// <param name="billboard"></param>
        /// <param name="viewMat"></param>
        private void Insert(TextBillboardNode billboard, mat4 viewMat)
        {
            vec3 viewPosition = billboard.GetAbsoluteViewPosition(viewMat);
            int  left = 0, right = this.depthList.Count - 1;

            while (left <= right)
            {
                int   middle = (left + right) / 2;
                float value  = this.depthList[middle];
                if (value < viewPosition.z)
                {
                    left = middle + 1;
                }
                else if (value == viewPosition.z)
                {
                    left = middle;
                    break;
                }
                else //(viewPosition.z < value)
                {
                    right = middle - 1;
                }
            }

            this.depthList.Insert(left, viewPosition.z);
            this.billboardList.Insert(left, billboard);
        }
コード例 #2
0
ファイル: TextBillboardNode.cs プロジェクト: tfart/CSharpGL
        /// <summary>
        /// Creates a billboard in 3D world. Its size is described by Width\Height(in pixels).
        /// </summary>
        /// <param name="textureSource"></param>
        /// <param name="width"></param>
        /// <param name="height"></param>
        /// <returns></returns>
        public static TextBillboardNode Create(ITextureSource textureSource, int width, int height)
        {
            var vs       = new VertexShader(vertexCode);// this vertex shader has no vertex attributes.
            var fs       = new FragmentShader(fragmentCode);
            var provider = new ShaderArray(vs, fs);
            var map      = new AttributeMap();
            var builder  = new RenderMethodBuilder(provider, map);
            var node     = new TextBillboardNode(textureSource, width, height, new TextBillboard(), builder);

            node.Initialize();

            return(node);
        }
コード例 #3
0
        /// <summary>
        /// Creates a billboard in 3D world. Its size is described by Width\Height(in pixels).
        /// </summary>
        /// <param name="width"></param>
        /// <param name="height"></param>
        /// <param name="capacity">Maximum characters count.</param>
        /// <param name="glyphServer"></param>
        /// <returns></returns>
        public static TextBillboardNode Create(int width, int height, int capacity, GlyphServer glyphServer = null)
        {
            var vs = new VertexShader(vertexCode);// this vertex shader has no vertex attributes.
            var fs = new FragmentShader(fragmentCode);
            var provider = new ShaderArray(vs, fs);
            var map = new AttributeMap();
            map.Add(inPosition, GlyphsModel.position);
            map.Add(inSTR, GlyphsModel.STR);
            var blendState = new BlendFuncSwitch(BlendSrcFactor.SrcAlpha, BlendDestFactor.OneMinusSrcAlpha);
            var builder = new RenderMethodBuilder(provider, map, blendState);
            var node = new TextBillboardNode(width, height, new GlyphsModel(capacity), builder, glyphServer);
            node.Initialize();
            node.blend = blendState;

            return node;
        }