示例#1
0
 public CalculationSystemAuto(LayoutSystem host)
     : base(host)
 {
     stepLength    = 0.01f;
     stepStability = 0;
     checkSum      = 0;
 }
 public CalculationSystemAuto(LayoutSystem host)
     : base(host)
 {
     stepLength		= 0.01f;
     stepStability	= 0;
     checkSum		= 0;
 }
 public CalculationSystemWolfram(LayoutSystem host)
     : base(host)
 {
     stepLength		= 1.0f;
     checkSum = 0;
     energy = 0;
     deltaEnergy = 0;
     progress = 0;
 }
 public CalculationSystemWolfram(LayoutSystem host)
     : base(host)
 {
     stepLength  = 1.0f;
     checkSum    = 0;
     energy      = 0;
     deltaEnergy = 0;
     progress    = 0;
 }
示例#5
0
        /// <summary>
        ///
        /// </summary>
        public override void Initialize()
        {
            particleTex   = Game.Content.Load <Texture2D>("smaller");
            highlightTex  = Game.Content.Load <Texture2D>("selection");
            sparkTex      = Game.Content.Load <Texture2D>("spark");
            renderShader  = Game.Content.Load <Ubershader>("Render");
            computeShader = Game.Content.Load <Ubershader>("Compute");

            atlas = Game.Content.Load <TextureAtlas>("protein_textures");

            // creating the layout system:
            lay          = new LayoutSystem(Game, computeShader);
            lay.UseGPU   = Config.UseGPU;
            lay.RunPause = LayoutSystem.State.PAUSE;

            factory = new StateFactory(renderShader, typeof(RenderFlags), (plState, comb) =>
            {
                plState.RasterizerState   = RasterizerState.CullNone;
                plState.BlendState        = BlendMode;
                plState.DepthStencilState = DepthStencilState.Readonly;
                plState.Primitive         = Primitive.PointList;
            });

            paramsCB     = new ConstantBuffer(Game.GraphicsDevice, typeof(Params));
            particleMass = 1.0f;
            edgeSize     = 1000.0f;

            edgeList       = new List <Link>();
            nodeList       = new List <Particle3d>();
            edgeIndexLists = new List <List <int> >();
            sparkList      = new List <Spark>();
            commandQueue   = new Queue <int>();

            referenceNodeIndex = 0;

            Game.InputDevice.KeyDown += keyboardHandler;

            base.Initialize();
        }
示例#6
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);
        }
示例#7
0
        /// <summary>
        /// 
        /// </summary>
        public override void Initialize()
        {
            particleTex		=	Game.Content.Load<Texture2D>("smaller");
            selectionTex	=	Game.Content.Load<Texture2D>("selection");
            renderShader	=	Game.Content.Load<Ubershader>("Render");
            computeShader	=	Game.Content.Load<Ubershader>("Compute");

            // creating the layout system:
            lay = new LayoutSystem(Game, computeShader);
            lay.UseGPU = Config.UseGPU;
            lay.RunPause = LayoutSystem.State.PAUSE;

            factory = new StateFactory( renderShader, typeof(RenderFlags), ( plState, comb ) =>
            {
                plState.RasterizerState	= RasterizerState.CullNone;
                plState.BlendState = BlendState.Screen;// на черном фоне будет белым BlendState.Multiply (Neg)
                plState.DepthStencilState = DepthStencilState.Readonly;
                plState.Primitive		= Primitive.PointList;
            } );

            paramsCB			=	new ConstantBuffer( Game.GraphicsDevice, typeof(Params) );
            particleMass		=	1.0f;
            edgeSize			=	1000.0f;
            edgeList			=	new List<Link>();
            nodeList		=	new List<Particle3d>();
            edgeIndexLists		=	new List<List<int> >();
            commandQueue		=	new Queue<int>();

            numSelectedNodes	=	0;
            numSelectedEdges	=	0;
            referenceNodeIndex	=	0;

            Game.InputDevice.KeyDown += keyboardHandler;

            base.Initialize();
        }
示例#8
0
 public CalculationSystemFixed(LayoutSystem host)
     : base(host)
 {
     stepLength = HostSystem.Environment.GetService <GraphSystem>().Config.StepSize;
 }
 public CalculationSystemFixed(LayoutSystem host)
     : base(host)
 {
     stepLength = HostSystem.Environment.GetService<GraphSystem>().Config.StepSize;
 }
示例#10
0
 public CalculationSystem(LayoutSystem host)
 {
     HostSystem = host;
     numIterations = 0;
 }
示例#11
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);
            }
        }
示例#12
0
 public CalculationSystem(LayoutSystem host)
 {
     HostSystem    = host;
     numIterations = 0;
 }
示例#13
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);
            }
        }
示例#14
0
        /// <summary>
        /// 
        /// </summary>
        public override void Initialize()
        {
            particleTex		=	Game.Content.Load<Texture2D>("smaller");
            highlightTex	=	Game.Content.Load<Texture2D>("selection");
            sparkTex		=	Game.Content.Load<Texture2D>("spark");
            renderShader	=	Game.Content.Load<Ubershader>("Render");
            computeShader	=	Game.Content.Load<Ubershader>("Compute");

            atlas			=	Game.Content.Load<TextureAtlas>("protein_textures");

            // creating the layout system:
            lay = new LayoutSystem(Game, computeShader);
            lay.UseGPU = Config.UseGPU;
            lay.RunPause = LayoutSystem.State.PAUSE;

            factory = new StateFactory( renderShader, typeof(RenderFlags), ( plState,  comb ) => Enum( plState, (RenderFlags) comb) );

            paramsCB			=	new ConstantBuffer( Game.GraphicsDevice, typeof(Params) );
            particleMass		=	1.0f;
            edgeSize			=	1000.0f;

            edgeList			=	new List<Link>();
            nodeList			=	new List<Particle3d>();
            edgeIndexLists		=	new List<List<int>>();
            sparkList			=	new List<Spark>();
            commandQueue		=	new Queue<int>();

            referenceNodeIndex	=	0;

            Game.InputDevice.KeyDown += keyboardHandler;

            base.Initialize();
        }