Example #1
0
        void render( GraphicsDevice device, LayoutSystem ls, Params parameters )
        {
            parameters.MaxParticles	= lay.ParticleCount;
            parameters.edgeOpacity	= Config.EdgeOpacity;
            parameters.nodeScale	= Config.NodeScale;
            parameters.highNodeColor = HighlightNodeColor;
            parameters.highEdgeColor = HighlightEdgeColor;

            device.ResetStates();
            device.ClearBackbuffer(Color.Black); //background
            device.SetTargets( null, device.BackbufferColor );
            paramsCB.SetData(parameters);

            device.ComputeShaderConstants	[0] = paramsCB;
            device.VertexShaderConstants	[0] = paramsCB;
            device.GeometryShaderConstants	[0] = paramsCB;
            device.PixelShaderConstants		[0] = paramsCB;

            device.PixelShaderSamplers		[0] = SamplerState.LinearWrap;

            // draw points: ------------------------------------------------------------------------
            device.PipelineState = factory[(int)RenderFlags.DRAW|(int)RenderFlags.POINT];
            device.SetCSRWBuffer( 0, null );
            device.PixelShaderResources		[0] = particleTex;
            device.GeometryShaderResources	[2] = ls.CurrentStateBuffer;
            device.Draw( nodeList.Count, 0 );

            // draw lines: -------------------------------------------------------------------------
            device.PipelineState = factory[(int)RenderFlags.DRAW|(int)RenderFlags.LINE];
            device.GeometryShaderResources	[2] = ls.CurrentStateBuffer;
            device.GeometryShaderResources	[3] = ls.LinksBuffer;
            device.Draw( edgeList.Count, 0 );

            // draw selected points: ---------------------------------------------------------------
            device.PipelineState = factory[(int)RenderFlags.DRAW | (int)RenderFlags.SELECTION];
            device.PixelShaderResources		[1] = selectionTex;
            device.GeometryShaderResources	[4] = selectedNodesBuffer;
            device.Draw(numSelectedNodes, 0);

            // draw selected lines: ----------------------------------------------------------------
            device.PipelineState = factory[(int)RenderFlags.DRAW | (int)RenderFlags.HIGH_LINE];
            device.GeometryShaderResources	[5] = selectedEdgesBuffer;
            device.Draw(numSelectedEdges, 0);
        }
Example #2
0
        void render(GraphicsDevice device, LayoutSystem ls, Params parameters, GameTime gameTime)
        {
            parameters.MaxParticles	= lay.ParticleCount;
            parameters.edgeOpacity	= Config.EdgeOpacity;
            parameters.nodeScale	= Config.NodeScale;
            parameters.highNodeColor = HighlightNodeColor;
            parameters.highEdgeColor = HighlightEdgeColor;

            device.ResetStates();
            device.ClearBackbuffer( BackgroundColor );
            device.SetTargets( null, device.BackbufferColor );
            paramsCB.SetData(parameters);

            device.ComputeShaderConstants	[0] = paramsCB;
            device.VertexShaderConstants	[0] = paramsCB;
            device.GeometryShaderConstants	[0] = paramsCB;
            device.PixelShaderConstants		[0] = paramsCB;

            device.PixelShaderSamplers		[0] = SamplerState.LinearWrap;

            int anchorFlag = (AnchorToNodes ? (int)RenderFlags.RELATIVE_POS : (int)RenderFlags.ABSOLUTE_POS);

            // draw points: ---------------------------------------------------------------------------
            device.PipelineState = factory[(int)RenderFlags.DRAW|(int)RenderFlags.POINT|anchorFlag];
            device.SetCSRWBuffer( 0, null );
            device.GeometryShaderResources	[2] = ls.CurrentStateBuffer;

            //			device.PixelShaderResources		[0] = particleTex;
            device.PixelShaderResources		[0] = atlas.Texture;
            device.Draw(nodeList.Count, 0);

            // draw lines: ----------------------------------------------------------------------------
            device.PipelineState = factory[(int)RenderFlags.DRAW|(int)RenderFlags.LINE|anchorFlag];
            device.GeometryShaderResources	[2] = ls.CurrentStateBuffer;
            device.GeometryShaderResources	[3] = ls.LinksBuffer;
            device.Draw( edgeList.Count, 0 );

            // draw highlighted points: ---------------------------------------------------------------
            device.PipelineState = factory[(int)RenderFlags.DRAW | (int)RenderFlags.SELECTION|anchorFlag];
            device.PixelShaderResources		[0] = highlightTex;

            foreach (var high in highlightNodesList)
            {
                device.GeometryShaderResources[4] = high.Item1;
                parameters.highNodeColor = high.Item2.color.ToVector4();
                paramsCB.SetData(parameters);
                int num = high.Item2.number;
                device.Draw(num, 0);
            }

            // draw highlighted lines: ----------------------------------------------------------------
            //		device.PipelineState = factory[(int)RenderFlags.DRAW | (int)RenderFlags.HIGH_LINE|anchorFlag];
            //		device.GeometryShaderResources	[5] = highlightedEdgesBuffer;
            //		device.Draw(highlightedEdgesBuffer.GetStructureCount(), 0);

            // draw sparks: ---------------------------------------------------------------------------
            List<Spark> updSparks = new List<Spark>();
            foreach (var sp in sparkList)
            {
                Spark updSp = sp;
                updSp.Parameter = sp.Parameter + gameTime.Elapsed.Milliseconds / sp.Time;
                if (updSp.Parameter < 1.0f)
                {
                    updSparks.Add(updSp);
                }
            }
            sparkList = updSparks;

            if (sparkBuffer != null && updSparks.Count > 0)
            {
                sparkBuffer.SetData(updSparks.ToArray());

                device.PipelineState = factory[(int)RenderFlags.DRAW | (int)RenderFlags.SPARKS | anchorFlag];
                device.PixelShaderResources		[0] = sparkTex;
                device.GeometryShaderResources	[2] = ls.CurrentStateBuffer;
                device.GeometryShaderResources	[6] = sparkBuffer;
                device.Draw(sparkList.Count, 0);
            }
        }