Example #1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="arg"></param>
        /// <param name="singleNodeVertexId"></param>
        /// <param name="stageVertexId"></param>
        /// <param name="picker"></param>
        /// <returns></returns>
        internal override uint[] Search(PickingEventArgs arg,
                                        uint singleNodeVertexId, uint stageVertexId, DrawArraysPicker picker)
        {
            var cmd = picker.DrawCommand as DrawArraysCmd;
            // when the temp index buffer could be long, it's no longer needed.
            // what a great OpenGL API design!
            DrawArraysCmd drawCmd = new DrawArraysCmd(DrawMode.LineLoop, cmd.MaxVertexCount, cmd.FirstVertex, cmd.VertexCount);

            picker.Node.Render4InnerPicking(arg, drawCmd);
            uint id = ColorCodedPicking.ReadStageVertexId(arg.X, arg.Y);

            uint baseId = stageVertexId - singleNodeVertexId;

            if (id == baseId + cmd.FirstVertex)
            {
                return(new uint[] { (uint)(baseId + cmd.FirstVertex + cmd.VertexCount - 1), id, });
            }
            else if (baseId + cmd.FirstVertex < id && id <= (uint)(baseId + cmd.FirstVertex + cmd.VertexCount - 1))
            {
                return(new uint[] { id - 1, id, });
            }
            else
            {
                throw new Exception("This should not happen!");
            }
        }
Example #2
0
        public IEnumerable <IDrawCommand> GetDrawCommand()
        {
            if (this.drawCmd == null)
            {
                int           uCount = GetUCount(interval);
                DrawArraysCmd buffer = new DrawArraysCmd(DrawMode.Points, 0, uCount);
                this.drawCmd = buffer;
            }

            yield return(this.drawCmd);
        }
Example #3
0
        /// <summary>
        ///
        /// </summary>
        /// <returns></returns>
        public IEnumerable <IDrawCommand> GetDrawCommand()
        {
            if (this.drawCmd == null)
            {
                var drawCmd = new DrawArraysCmd(DrawMode.Quads, this.Capacity * 4);
                // note: use IDrawCommand.Draw(ControlMode.Random) to enable this property.
                drawCmd.VertexCount = 0;
                this.drawCmd        = drawCmd;
            }

            yield return(this.drawCmd);
        }
Example #4
0
        /// <summary>
        ///
        /// </summary>
        /// <returns></returns>
        public IEnumerable <IDrawCommand> GetDrawCommand()
        {
            if (this.drawCmd == null)
            {
                int primCount  = 1;
                int frameCount = 1;
                var drawCmd    = new DrawArraysCmd(DrawMode.Quads, 0, this.Capacity * 4, primCount, frameCount);
                // note: use ZeroIndexBuffer.Draw(ControlMode.Random) to enable this property.
                drawCmd.RenderingVertexCount = 0;
                this.drawCmd = drawCmd;
            }

            yield return(this.drawCmd);
        }
        /// <summary>
        ///
        /// </summary>
        /// <param name="arg"></param>
        /// <param name="flatColorVertexId"></param>
        /// <param name="picker"></param>
        /// <returns></returns>
        internal override uint Search(PickingEventArgs arg,
                                      uint flatColorVertexId, DrawArraysPicker picker)
        {
            var cmd = picker.DrawCommand as DrawArraysCmd;
            // when the temp index buffer could be long, it's no longer needed.
            // what a great OpenGL API design!
            var drawCmd = new DrawArraysCmd(DrawMode.Points, cmd.MaxVertexCount, cmd.FirstVertex, cmd.VertexCount);

            picker.Node.Render4InnerPicking(arg, drawCmd);
            uint id = ColorCodedPicking.ReadStageVertexId(arg.X, arg.Y);

            if (cmd.FirstVertex <= id && id < cmd.FirstVertex + cmd.VertexCount)
            {
                return(id);
            }
            else
            {
                throw new Exception("This should not happen!");
            }
        }
        /// <summary>
        ///
        /// </summary>
        /// <param name="arg"></param>
        /// <param name="lastVertexId"></param>
        /// <param name="picker"></param>
        /// <returns></returns>
        internal override uint Search(PickingEventArgs arg,
                                      uint lastVertexId, DrawArraysPicker picker)
        {
            var zeroIndexBuffer = picker.DrawCommand as DrawArraysCmd;
            // when the temp index buffer could be long, it's no longer needed.
            // what a great OpenGL API design!
            var drawCmd = new DrawArraysCmd(DrawMode.Points, zeroIndexBuffer.FirstVertex, zeroIndexBuffer.RenderingVertexCount, zeroIndexBuffer.InstanceCount);

            picker.Node.Render4InnerPicking(arg, IndexAccessMode.ByFrame, drawCmd);
            uint id = ColorCodedPicking.ReadStageVertexId(arg.X, arg.Y);

            if (zeroIndexBuffer.FirstVertex <= id &&
                id < zeroIndexBuffer.FirstVertex + zeroIndexBuffer.RenderingVertexCount)
            {
                return(id);
            }
            else
            {
                throw new Exception("This should not happen!");
            }
        }
Example #7
0
 public ZeroIndexBufferController(DrawArraysCmd drawCmd)
 {
     this.drawCmd = drawCmd;
 }
Example #8
0
 /// <summary>
 /// Get picked geometry from a <see cref="PickableNode"/> with <see cref="DrawArraysCmd"/> as index buffer.
 /// </summary>
 /// <param name="node"></param>
 /// <param name="positionBuffer"></param>
 /// <param name="drawCommand"></param>
 public DrawArraysPicker(PickableNode node, VertexBuffer positionBuffer, DrawArraysCmd drawCommand)
     : base(node, positionBuffer)
 {
     this.DrawCommand = drawCommand;
 }