示例#1
0
        /// <summary>
        /// </summary>
        /// <param name="bufferable">一种渲染方式</param>
        /// <param name="shaderCodes">各种类型的shader代码</param>
        /// <param name="propertyNameMap">关联<see cref="PropertyBufferPtr"/>和<see cref="shaderCode"/>中的属性</param>
        /// <param name="positionNameInIBufferable">描述顶点位置信息的buffer的名字</param>
        ///<param name="switches"></param>
        internal InnerPickableRenderer(IBufferable bufferable, ShaderCode[] shaderCodes,
                                       PropertyNameMap propertyNameMap, string positionNameInIBufferable,
                                       params GLSwitch[] switches)
            : base(bufferable, shaderCodes, propertyNameMap, switches)
        {
            this.positionNameInIBufferable = positionNameInIBufferable;

            {
                var polygonModeSwitch = new PolygonModeSwitch(PolygonModes.Filled);
                this.PolygonModeSwitch = polygonModeSwitch;
                this.switchList.Add(polygonModeSwitch);
            }
            {
                float min, max;
                OpenGL.LineWidthRange(out min, out max);
                var lineWidthSwitch = new LineWidthSwitch(max);
                this.LineWidthSwitch = lineWidthSwitch;
                this.switchList.Add(lineWidthSwitch);
            }
            {
                float min, max;
                OpenGL.PointSizeRange(out min, out max);
                var pointSizeSwitch = new PointSizeSwitch(max);
                this.PointSizeSwitch = pointSizeSwitch;
                this.switchList.Add(pointSizeSwitch);
            }
        }
示例#2
0
        /// <summary>
        /// 高亮显示指定的图元。
        /// </summary>
        /// <param name="bufferable">一种渲染方式</param>
        /// <param name="shaderCodes">各种类型的shader代码</param>
        /// <param name="propertyNameMap">关联<see cref="BufferPtr"/>和<see cref="ShaderCode"/>中的属性</param>
        /// <param name="positionNameInIBufferable">描述顶点位置信息的buffer的名字</param>
        ///<param name="switches"></param>
        public HighlightRenderer(IBufferable bufferable,
                                 string positionNameInIBufferable,
                                 params GLSwitch[] switches)
            : base(bufferable, HighlightShaderHelper.GetHighlightShaderCode(),
                   new PropertyNameMap("in_Position", positionNameInIBufferable),
                   switches)
        {
            this.Name = this.GetType().Name;

            this.positionNameInIBufferable = positionNameInIBufferable;
            var uniformHighlightColor = new UniformVec4("highlightColor");

            //another way: uniform.SetValue(new vec4(1, 1, 1, 1));
            uniformHighlightColor.Value = new vec4(1, 1, 1, 1);
            this.UniformVariables.Add(uniformHighlightColor);
            this.UniformVariables.Add(this.uniformMVP);
            var polygonModeSwitch = new PolygonModeSwitch(PolygonModes.Lines);

            this.SwitchList.Add(polygonModeSwitch);
            var lineWidthSwitch = new LineWidthSwitch(10.0f);

            this.SwitchList.Add(lineWidthSwitch);
            var pointSizeSwitch = new PointSizeSwitch(20.0f);

            this.SwitchList.Add(pointSizeSwitch);
            var polygonOffsetSwitch = new PolygonOffsetSwitch(PolugonOffset.Fill, true);

            this.SwitchList.Add(polygonOffsetSwitch);
            polygonOffsetSwitch = new PolygonOffsetSwitch(PolugonOffset.Point, true);
            this.SwitchList.Add(polygonOffsetSwitch);
        }
示例#3
0
        public static HighlightGeometryNode Create()
        {
            var model = new HighlightGeometryModel();
            var vs    = new VertexShader(vertexCode);
            var fs    = new FragmentShader(fragmentCode);
            var array = new ShaderArray(vs, fs);
            var map   = new AttributeMap();

            map.Add("inPosition", HighlightGeometryModel.strPosition);
            map.Add("inColor", HighlightGeometryModel.strColor);
            var polygonOffset = new PolygonOffsetFillSwitch();
            var polygonMode   = new PolygonModeSwitch(PolygonMode.Line);
            var lineWidth     = new LineWidthSwitch(5.0f);
            var pointSize     = new PointSizeSwitch(5.0f);
            var builder       = new RenderMethodBuilder(array, map, polygonOffset, polygonMode, lineWidth, pointSize);

            var node = new HighlightGeometryNode(model, builder);

            node.polygonOffset = polygonOffset;
            node.polygonMode   = polygonMode;
            node.lineWidth     = lineWidth;
            node.pointSize     = pointSize;

            node.Initialize();

            return(node);
        }