コード例 #1
0
        /// <summary>
        /// Initialization
        /// </summary>
        public override void Initialize()
        {
            base.Initialize();

            var dev = Game.GraphicsDevice;

            effect  = Game.Content.Load <Ubershader>("debugRender.hlsl");
            factory = new StateFactory(effect, typeof(RenderFlags), Primitive.LineList, VertexInputElement.FromStructure(typeof(LineVertex)), BlendState.AlphaBlend, RasterizerState.CullNone);

            constData   = new ConstData();
            constBuffer = new ConstantBuffer(dev, typeof(ConstData));


            //	create vertex buffer :
            vertexBuffer             = new VertexBuffer(dev, typeof(LineVertex), vertexBufferSize, VertexBufferOptions.Dynamic);
            vertexDataAccum.Capacity = vertexBufferSize;
        }
コード例 #2
0
ファイル: SortDemo.cs プロジェクト: demiurghg/FusionEngine
		/// <summary>
		/// Add services :
		/// </summary>
		protected override void Initialize ()
		{
			
			//	initialize services :
			base.Initialize();

			//	create structured buffers and shaders :
			buffer1		=	new StructuredBuffer( GraphicsDevice, typeof(Vector2), NumberOfElements  , StructuredBufferFlags.None );
			buffer2		=	new StructuredBuffer( GraphicsDevice, typeof(Vector2), NumberOfElements  , StructuredBufferFlags.None );
			paramsCB	=	new ConstantBuffer( GraphicsDevice, typeof(Params) );
			shader		=	Content.Load<Ubershader>("test");
			factory		=	new StateFactory( shader, typeof(ShaderFlags), Primitive.TriangleList, VertexInputElement.Empty );

			//
			//	Create and write data :
			//
			var	rand	=	new Random();
			var	input	=	Enumerable.Range(0, NumberOfElements).Select( i => new Vector2( rand.NextFloat(0,100), i ) ).ToArray();
			buffer1.SetData( input );
			
			//	add keyboard handler :
			InputDevice.KeyDown += InputDevice_KeyDown;
		}
コード例 #3
0
ファイル: PhysicsDemo.cs プロジェクト: demiurghg/FusionEngine
		/// <summary>
		/// Load content
		/// </summary>
		public void LoadContent ()
		{
			uberShader = Content.Load<Ubershader>("render");
			factory = new StateFactory(uberShader, typeof(RenderFlags), Primitive.TriangleList, VertexInputElement.FromStructure<CubeVertex>());
			texture = Content.Load<Texture2D>(@"Scenes\lena");

			vb = new VertexBuffer(GraphicsDevice, typeof(CubeVertex), 24);
			ib = new IndexBuffer(GraphicsDevice, 36);

			// create a new space with physics
			space = new Space();

			// update gravity force
			space.ForceUpdater.Gravity = new Vector3BEPU(0, -9.81f, 0);

			// add ground, ground has infinite mass
			Box ground = new Box(new Vector3BEPU(0, 0, 0), 50, 1, 50);
			space.Add(ground);

			// create boxes with random position and add color as a tag, then add box to space
			for ( int i = 0; i < numberOfBoxes; i++ ) {
				Vector3Fusion vector = RandomExt.NextVector3(random, new Vector3Fusion(-10, 20, -10), new Vector3Fusion(10, 80, 10));
				Box box = new Box(new Vector3BEPU(vector.X, vector.Y, vector.Z), 1, 1, 1, 1);

				box.Tag = RandomExt.NextColor(random);
				space.Add(box);
			}
		}
コード例 #4
0
ファイル: DebugRender.cs プロジェクト: temik911/audio
        /// <summary>
        /// Initialization
        /// </summary>
        public override void Initialize()
        {
            base.Initialize();

            var dev		= Game.GraphicsDevice;

            effect		= Game.Content.Load<Ubershader>("debugRender.hlsl");
            factory		= new StateFactory( effect, typeof(RenderFlags), Primitive.LineList, VertexInputElement.FromStructure( typeof(LineVertex) ), BlendState.AlphaBlend, RasterizerState.CullNone );

            constData	= new ConstData();
            constBuffer = new ConstantBuffer(dev, typeof(ConstData));

            //	create vertex buffer :
            vertexBuffer		= new VertexBuffer(dev, typeof(LineVertex), vertexBufferSize, VertexBufferOptions.Dynamic );
            vertexDataAccum.Capacity = vertexBufferSize;
        }
コード例 #5
0
ファイル: InstancingDemo.cs プロジェクト: temik911/audio
 /// <summary>
 /// 
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 void InstancingDemo_Reloading( object sender, EventArgs e )
 {
     SafeDispose( ref factory );
     us		=	Content.Load<Ubershader>("test");
     factory	=	new StateFactory( us, typeof(UberFlags), Primitive.TriangleList, VertexInputElement.FromStructure( typeof(Vertex) ), BlendState.Additive, RasterizerState.CullNone, DepthStencilState.None );
     tex		=	Content.Load<Texture2D>("block" );
 }
コード例 #6
0
ファイル: LightRenderer.cs プロジェクト: temik911/audio
 /// <summary>
 /// 
 /// </summary>
 void LoadContent()
 {
     SafeDispose( ref factory );
     lightingShader	=	Game.Content.Load<Ubershader>("lighting");
     factory			=	new StateFactory( lightingShader, typeof(LightingFlags), Primitive.TriangleList, VertexInputElement.Empty );
 }
コード例 #7
0
ファイル: ParticleSystemGS.cs プロジェクト: temik911/audio
        void Game_Reloading( object sender, EventArgs e )
        {
            SafeDispose( ref factory );

            texture		=	Game.Content.Load<Texture2D>("particle2");
            shader		=	Game.Content.Load<Ubershader>("test");
            factory		=	new StateFactory( shader, typeof(Flags), (ps,i) => EnumAction( ps, (Flags)i ) );
        }
コード例 #8
0
ファイル: GraphSystem.cs プロジェクト: Karnlie/almazovdata
        /// <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();
        }
コード例 #9
0
ファイル: SsaoFilter.cs プロジェクト: temik911/audio
		/// <summary>
		/// 
		/// </summary>
		void LoadContent ()
		{
			SafeDispose( ref factory );
			shader	=	Game.Content.Load<Ubershader>("ssao");
			factory	=	new StateFactory( shader, typeof(Flags), Primitive.TriangleList, VertexInputElement.Empty, BlendState.Opaque, RasterizerState.CullNone, DepthStencilState.None ); 
		}
コード例 #10
0
        /// <summary>
        /// Load content
        /// </summary>
        public void LoadContent()
        {
            SafeDispose( ref factory );
            SafeDispose( ref vertexBuffers );
            SafeDispose( ref indexBuffers );

            uberShader	=	Content.Load<Ubershader>("render");

            //factory		=	new StateFactory(
            //					uberShader,
            //					typeof(RenderFlags),
            //					Primitive.PatchList3CP,
            //					VertexColorTextureTBN.Elements,
            //					BlendState.Opaque,
            //					RasterizerState.CullCW,
            //					DepthStencilState.Default
            //				);

            factory = new StateFactory(uberShader, typeof(RenderFlags), (x, i) => EnumFunc(x, (RenderFlags)i));

            scene		=	Content.Load<Scene>(@"scene");

            vertexBuffers	=	scene.Meshes
                            .Select(m => VertexBuffer.Create(GraphicsDevice, m.Vertices.Select(VertexColorTextureTBN.Convert).ToArray()))
                            .ToArray();

            indexBuffers	=	scene.Meshes
                            .Select( m => IndexBuffer.Create( GraphicsDevice, m.GetIndices() ) )
                            .ToArray();

            textures = new Texture2D[5];
            textures[0] = Content.Load<Texture2D>("checker");
            textures[1] = Content.Load<Texture2D>(@"Textures\rockA");
            textures[2] = Content.Load<Texture2D>(@"Textures\rockA_local");
            textures[3] = Content.Load<Texture2D>(@"Textures\sandDune");
            textures[4] = Content.Load<Texture2D>(@"Textures\sandDune_local");

            worldMatricies	=	new Matrix[ scene.Nodes.Count ];
            scene.CopyAbsoluteTransformsTo( worldMatricies );

            Log.Message("{0}", scene.Nodes.Count( n => n.MeshIndex >= 0 ) );
        }
コード例 #11
0
ファイル: LayoutSystem.cs プロジェクト: mukhinaks/proteins
        // Constructor: ----------------------------------------------------------------------------------------
        public LayoutSystem(Game game, Ubershader ubershader)
        {
            env = game;
            shader = ubershader;
            device = env.GraphicsDevice;
            factory = new StateFactory(shader, typeof(ComputeFlags), (plState, comb) =>
            {
                plState.RasterizerState = RasterizerState.CullNone;
                plState.BlendState = BlendState.AlphaBlend; //BlendState.NegMultiply;
                plState.DepthStencilState = DepthStencilState.Readonly;
                plState.Primitive = Primitive.PointList;
            });

            paramsCB = new ConstantBuffer(env.GraphicsDevice, typeof(ComputeParams));

            categories		= new List<Category>();
            categoryIndices	= new List<int>();

            SpringTension = env.GetService<GraphSystem>().Config.SpringTension;
            StepMode	= env.GetService<GraphSystem>().Config.StepMode;
            calcAuto	= new CalculationSystemAuto(this);
            calcFixed	= new CalculationSystemFixed(this);
            calcWolfram = new CalculationSystemWolfram(this);
        }
コード例 #12
0
ファイル: ComputeDemo.cs プロジェクト: temik911/audio
		/// <summary>
		/// Add services :
		/// </summary>
		protected override void Initialize ()
		{
			
			//	initialize services :
			base.Initialize();

			//	create structured buffers and shaders :
			argA		=	new StructuredBuffer( GraphicsDevice, typeof(float), BufferSize  , StructuredBufferFlags.None );
			argB		=	new StructuredBuffer( GraphicsDevice, typeof(float), BufferSize  , StructuredBufferFlags.None );
			result		=	new StructuredBuffer( GraphicsDevice, typeof(Result), BufferSize , StructuredBufferFlags.None );
			paramsCB	=	new ConstantBuffer( GraphicsDevice, typeof(Params) );
			shader		=	Content.Load<Ubershader>("test");
			factory		=	new StateFactory( shader, typeof(ShaderFlags), Primitive.TriangleList, VertexInputElement.Empty );

			//	write data :
			var	rand	=	new Random();

			var	a		=	Enumerable.Range(0, BufferSize).Select( i => rand.NextFloat(-1000,1000) ).ToArray();
			var	b		=	Enumerable.Range(0, BufferSize).Select( i => rand.NextFloat(-1000,1000) ).ToArray();
			var r		=	Enumerable.Range(0, BufferSize).Select( i => new Result() ).ToArray();

			argA.SetData( a );
			argB.SetData( b );

			paramsCB.SetData( new Params(){ Size = BufferSize } );
			
			//	bind objects :
			GraphicsDevice.SetCSRWBuffer( 0, argA );
			GraphicsDevice.SetCSRWBuffer( 1, argB );
			GraphicsDevice.SetCSRWBuffer( 2, result );
			GraphicsDevice.ComputeShaderConstants[0]	= paramsCB ;
		
			//	set compute shader and dispatch threadblocks :
			GraphicsDevice.PipelineState	=	factory[0];

			GraphicsDevice.Dispatch( MathUtil.IntDivUp(BufferSize,256) );

			//	get data :
			result.GetData( r );

			Log.Message("    id :        Sum    Product   gID  gtID  dtID  gIdx");

			for (int i=0; i<BufferSize; i++) {
				Log.Message("[{0,4}] : {1}", i, r[i] );
			}
			
			
			//	add keyboard handler :
			InputDevice.KeyDown += InputDevice_KeyDown;
		}
コード例 #13
0
ファイル: Sky.cs プロジェクト: demiurghg/FusionEngine
		/// <summary>
		/// 
		/// </summary>
		void LoadContent ()
		{
			SafeDispose( ref factory );

			skySphere	=	Game.Content.Load<Scene>("skySphere");
			cloudSphere	=	Game.Content.Load<Scene>("cloudSphere");
			clouds		=	Game.Content.Load<Texture2D>("clouds|srgb");
			cirrus		=	Game.Content.Load<Texture2D>("cirrus|srgb");
			noise		=	Game.Content.Load<Texture2D>("cloudNoise");
			arrows		=	Game.Content.Load<Texture2D>("arrowsAll");


			vertexBuffers	=	skySphere.Meshes
							.Select( mesh => VertexBuffer.Create( Game.GraphicsDevice, mesh.Vertices.Select( v => VertexColorTextureTBN.Convert( v ) ).ToArray() ) )
							.ToArray();

			indexBuffers	=	skySphere.Meshes
							.Select( mesh => IndexBuffer.Create( Game.GraphicsDevice, mesh.GetIndices() ) )
							.ToArray();

			cloudVertexBuffers	=	cloudSphere.Meshes
							.Select( mesh => VertexBuffer.Create( Game.GraphicsDevice, mesh.Vertices.Select( v => VertexColorTextureTBN.Convert( v ) ).ToArray() ) )
							.ToArray();

			cloudIndexBuffers	=	cloudSphere.Meshes
							.Select( mesh => IndexBuffer.Create( Game.GraphicsDevice, mesh.GetIndices() ) )
							.ToArray();

			sky		=	Game.Content.Load<Ubershader>("sky");
			factory	=	new StateFactory( sky, typeof(SkyFlags), (ps,i) => EnumFunc(ps, (SkyFlags)i) );

		}
コード例 #14
0
ファイル: QuadDemo.cs プロジェクト: temik911/audio
        void LoadContent()
        {
            SafeDispose( ref factory );

            //texture		=	new Texture2D( GraphicsDevice, File.ReadAllBytes(@"D:\image.png"), false );
            texture		=	Content.Load<Texture2D>("lena.tga" );
            ubershader	=	Content.Load<Ubershader>("test.hlsl");
            factory		=	new StateFactory( ubershader, typeof(UberFlags), Primitive.TriangleList, VertexInputElement.FromStructure(typeof(Vertex) ) );
        }
コード例 #15
0
ファイル: GraphSystem.cs プロジェクト: mukhinaks/proteins
        /// <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();
        }