Inheritance: Fusion.Engine.Common.GameModule
コード例 #1
0
ファイル: PolyBatch.cs プロジェクト: demiurghg/FusionEngine
		PolyGisLayer(Game engine, Gis.GeoPoint[] points, int[] indeces, bool isDynamic) : base(engine)
		{
			//Console.WriteLine(points.Length + " _ " + indeces.Length);
			Initialize(points, indeces, isDynamic);

			Flags = (int)(PolyFlags.VERTEX_SHADER | PolyFlags.PIXEL_SHADER | PolyFlags.DRAW_COLORED);
		}
コード例 #2
0
		public HeatMapLayer(Game engine, Gis.GeoPoint[] points, int[] indeces, int mapDimX, int mapDimY, bool isDynamic = false) : base(engine)
		{
			Initialize(points, indeces, isDynamic);

			factory = shader.CreateFactory( typeof(PolyFlags), Primitive.TriangleList, VertexInputElement.FromStructure<Gis.GeoPoint>(), BlendState.AlphaBlend, RasterizerState.CullNone, DepthStencilState.None);

			MapDimX = mapDimX;
			MapDimY = mapDimY;

			HeatTexture = new Texture2D(Game.GraphicsDevice, MapDimX, MapDimY, ColorFormat.R32F, false);
			Temp		= new RenderTarget2D(Game.GraphicsDevice, ColorFormat.R32F, MapDimX, MapDimY, true);
			FirstFinal	= new RenderTarget2D(Game.GraphicsDevice, ColorFormat.R32F, MapDimX, MapDimY, true);
			SecondFinal = new RenderTarget2D(Game.GraphicsDevice, ColorFormat.R32F, MapDimX, MapDimY, true);

			Final	= SecondFinal;
			Prev	= FirstFinal;

			Data = new float[MapDimX * MapDimY];

			//HeatMapPalettes		= new Texture2D[1];
			//HeatMapPalettes[0]	= Game.Content.Load<Texture2D>("palette");
			Palette = Game.Content.Load<Texture2D>("palette");

			//cb			= new ConstantBuffer(Game.GraphicsDevice, typeof(ConstData));
			//constData	= new ConstData();

			Flags = (int)(PolyFlags.PIXEL_SHADER | PolyFlags.VERTEX_SHADER | PolyFlags.DRAW_HEAT);

			blurFactory = shader.CreateFactory( typeof(PolyFlags), Primitive.TriangleList,
					null,
					BlendState.AlphaBlend,
					RasterizerState.CullNone,
					DepthStencilState.None);

			MaxHeatMapLevel = 100;
			MinHeatMapLevel = 0;
			HeatMapTransparency = 1.0f;
		}
コード例 #3
0
		void CalculateVertices(out Gis.GeoPoint[] vertices, out int[] indeces, int density, double left, double right, double top, double bottom)
		{
			int RowsCount		= density + 2;
			int ColumnsCount	= RowsCount;

			//var el = Game.GetService<LayerService>().ElevationLayer;
			var ms = CurrentMapSource;

			var		verts	= new List<Gis.GeoPoint>();
			float	step	= 1.0f / (density + 1);
			double	dStep	= 1.0 / (double)(density + 1);

			for (int row = 0; row < RowsCount; row++) {
				for (int col = 0; col < ColumnsCount; col++) {

					double xx = left * (1.0 - dStep * col) + right * dStep * col;
					double yy = top * (1.0 - dStep * row) + bottom * dStep * row;

					double lon, lat;
					var sc = ms.Projection.TileToWorldPos(xx, yy, 0);

					//float elev = 0.0f;
					//if (zoom > 8) elev = el.GetElevation(sc.X, sc.Y) / 1000.0f;

					lon = sc.X * Math.PI / 180.0;
					lat = sc.Y * Math.PI / 180.0;


					verts.Add(new Gis.GeoPoint {
						Tex0	= new Vector4(step * col, step * row, 0, 0),
						Lon		= lon,
						Lat		= lat
					});
				}

			}


			var tindexes = new List<int>();

			for (int row = 0; row < RowsCount - 1; row++)
			{
				for (int col = 0; col < ColumnsCount - 1; col++)
				{
					tindexes.Add(col + row * ColumnsCount);
					tindexes.Add(col + (row + 1) * ColumnsCount);
					tindexes.Add(col + 1 + row * ColumnsCount);

					tindexes.Add(col + 1 + row * ColumnsCount);
					tindexes.Add(col + (row + 1) * ColumnsCount);
					tindexes.Add(col + 1 + (row + 1) * ColumnsCount);
				}
			}

			vertices = verts.ToArray();
			indeces = tindexes.ToArray();
		}
コード例 #4
0
		/// <summary>
		/// 
		/// </summary>
		/// <param name="engine"></param>
		public RenderSystem ( Game Game ) : base(Game)
		{
			Counters	=	new RenderCounters();

			Width			=	1024;
			Height			=	768;
			Fullscreen		=	false;
			StereoMode		=	StereoMode.Disabled;
			InterlacingMode	=	InterlacingMode.HorizontalLR;
			UseDebugDevice	=	false;
			VSyncInterval	=	1;
			MsaaEnabled		=	false;
			UseFXAA			=	true;

			this.Device	=	Game.GraphicsDevice;

			viewLayers	=	new List<RenderLayer>();
			spriteEngine	=	new SpriteEngine( this );
			gis				=	new Gis(Game);
			filter			=	new Filter( Game );
			ssaoFilter		=	new SsaoFilter( Game );
			hdrFilter		=	new HdrFilter( Game );
			dofFilter		=	new DofFilter( Game );
			lightRenderer	=	new LightRenderer( Game );
			sceneRenderer	=	new SceneRenderer( Game, this );
			sky				=	new Sky( Game );
			bitonicSort		=	new BitonicSort( Game );

			Device.DisplayBoundsChanged += (s,e) => {
				var handler = DisplayBoundsChanged;
				if (handler!=null) {
					handler(s,e);
				}
			};
		}
コード例 #5
0
ファイル: PolyBatch.cs プロジェクト: demiurghg/FusionEngine
		protected void Initialize(Gis.GeoPoint[] points, int[] indeces, bool isDynamic)
		{
			shader		= Game.Content.Load<Ubershader>("globe.Poly.hlsl");
			factory		= shader.CreateFactory(typeof(PolyFlags), EnumFunc);
			factoryXray = shader.CreateFactory(typeof(PolyFlags), Primitive.TriangleList, VertexInputElement.FromStructure<Gis.GeoPoint>(), BlendState.Additive, RasterizerState.CullCW, DepthStencilState.None);

			var vbOptions = isDynamic ? VertexBufferOptions.Dynamic : VertexBufferOptions.Default;

			firstBuffer = new VertexBuffer(Game.GraphicsDevice, typeof(Gis.GeoPoint), points.Length, vbOptions);
			firstBuffer.SetData(points);
			currentBuffer = firstBuffer;

			indexBuffer = new IndexBuffer(Game.Instance.GraphicsDevice, indeces.Length);
			indexBuffer.SetData(indeces);

			PointsCpu = points;

			cb			= new ConstantBuffer(Game.GraphicsDevice, typeof(ConstData));
			constData	= new ConstData();
			constData.Data = Vector4.One;
		}
コード例 #6
0
ファイル: PolyBatch.cs プロジェクト: demiurghg/FusionEngine
		static protected void CalculateVertices(out Gis.GeoPoint[] vertices, out int[] indeces, int density, double leftLon, double rightLon, double topLat, double bottomLat, MapProjection projection)
		{
			int RowsCount		= density + 2;
			int ColumnsCount	= RowsCount;

			var ms		= projection;
			var verts	= new List<Gis.GeoPoint>();

			var leftTop		= ms.WorldToTilePos(leftLon, topLat, 0);
			var rightBottom = ms.WorldToTilePos(rightLon, bottomLat, 0);

			double left		= leftTop.X;
			double right	= rightBottom.X;
			double top		= leftTop.Y;
			double bottom	= rightBottom.Y;

			float	step	= 1.0f / (density + 1);
			double	dStep	= 1.0 / (double)(density + 1);

			for (int row = 0; row < RowsCount; row++) {
				for (int col = 0; col < ColumnsCount; col++) {
					double xx = left * (1.0 - dStep * col) + right * dStep * col;
					double yy = top * (1.0 - dStep * row) + bottom * dStep * row;

					var sc = ms.TileToWorldPos(xx, yy, 0);

					var lon = sc.X * Math.PI / 180.0;
					var lat = sc.Y * Math.PI / 180.0;

					verts.Add(new Gis.GeoPoint {
						Tex0	= new Vector4(step * col, step * row, 0, 0),
						Lon		= lon,
						Lat		= lat
					});
				}

			}


			var tindexes = new List<int>();

			for (int row = 0; row < RowsCount - 1; row++)
			{
				for (int col = 0; col < ColumnsCount - 1; col++)
				{
					tindexes.Add(col + row * ColumnsCount);
					tindexes.Add(col + (row + 1) * ColumnsCount);
					tindexes.Add(col + 1 + row * ColumnsCount);

					tindexes.Add(col + 1 + row * ColumnsCount);
					tindexes.Add(col + (row + 1) * ColumnsCount);
					tindexes.Add(col + 1 + (row + 1) * ColumnsCount);
				}
			}

			vertices = verts.ToArray();
			indeces = tindexes.ToArray();
		}