Пример #1
0
		//internal override void SetTileSet( TileSet TileSet ) { this.TileSet = TileSet; }
		internal override void Render( Display render, ref Box ParentPosition )
		{
			Vector3 TopLeft, BottomRight, BarBottomRight;

			// Frame Position Computing
			if( Flag_Show_Master )
			{
				EffectivePosition.Position = ParentPosition.Position + Dimensions.Position;
				EffectivePosition.Size = Dimensions.Size;

				// Render this frame

				if( Flag_Show_Frame )
				{
					TopLeft = EffectivePosition.Position;
					BottomRight = EffectivePosition.Position + EffectivePosition.Size;
					BarBottomRight = BottomRight;
                    BarBottomRight.X = TopLeft.X + ( ( BottomRight.X - TopLeft.X ) * this.Factor / 100.0f );

			        {
						Vector3[] coords = new Vector3[4];
						coords[0] = TopLeft;
						coords[1] = TopLeft;
						coords[1].Y = BottomRight.Y;
						coords[2] = TopLeft;
						coords[2].X = BarBottomRight.X;
						coords[3] = BarBottomRight;
						coords[3].X = BarBottomRight.X;

						Vector4 c = new Vector4( 1 );
						render.simple_gui.Activate();
						render.simple_gui.DrawQuad( coords, ref c );
					}

					if( TileSet != null )
					{
						//TopLeft.z -= 1.0f;
						TileSet.RenderTile( render, ref TopLeft, ref BarBottomRight, 10, ref DrawColor );

						//TileSet.RenderTile(&TopLeft, &BottomRight, 8, &DrawColor);
					}
				}


				// Render child frames

				if( Flag_Show_Childs )
				{
					foreach( Frame frame in SubFrameList )
					{
						frame.Render( render, ref EffectivePosition );
					}
				}

			}

		}
Пример #2
0
		internal void RenderFont( Display render, ref Box EffectivePosition
			, ref Vector3 u, ref Vector3 v
			, float scale, string text
			, ref Vector4 color )
		{
			int c;
			uint rune;
			Display.EnableBlending( true );
			GL.Enable( EnableCap.DepthTest );
			render.simple_texture.Activate();
			render.simple_texture.SetUniforms( OpenGl_TextureRef, ref color );

			float[] quad = new float[12];
			float x_left, y_bottom;
			Vector3 o = EffectivePosition.Position;
			Vector3 topleft;
			Vector3 topright;
			Vector3 bottomleft;
			Vector3 bottomright;
			Vector3 tmp_x_left;
			Vector3 tmp_x_right;
			Vector3 tmp_y_top;
			Vector3 tmp_y_bottom;

			float x_del = 0;
			float y_del = 0;
			float x_right, yp;
			FontCharacter ch;
			for( c = 0; c < text.Length; c++ )
			{
				rune = GetUnicode( ref c, text );
				if( rune == '\n' )
				{
					y_del -= scale;
					x_del = 0;
				}
				else
				{
					ch = GetCharacter( rune );
					if( ch.width > 0 )
					{
						x_left = x_del + ( ch.leftSideBearing * scale / line_height );
						yp = y_del + ( ( ch.topSideBearing - descent ) * scale / line_height );//( ( ( line_height + ch.yOffset ) * scale ) / line_height );
						x_right = x_left + ( ch.width * scale / line_height );
						y_bottom = yp + ( ch.height * scale / line_height );

						Vector3.Multiply( ref u, x_left, out tmp_x_left );
						Vector3.Add( ref o, ref tmp_x_left, out topleft );
						Vector3.Multiply( ref v, yp, out tmp_y_top );
						Vector3.Add( ref topleft, ref tmp_y_top, out topleft );

						Vector3.Multiply( ref u, x_right, out tmp_x_right );
						Vector3.Add( ref o, ref tmp_x_right, out topright );
						Vector3.Add( ref topright, ref tmp_y_top, out topright );

						Vector3.Add( ref o, ref tmp_x_left, out bottomleft );
						Vector3.Multiply( ref v, y_bottom, out tmp_y_bottom );
						Vector3.Add( ref bottomleft, ref tmp_y_bottom, out bottomleft );

						Vector3.Add( ref o, ref tmp_x_right, out bottomright );
						Vector3.Add( ref bottomright, ref tmp_y_bottom, out bottomright );

						quad[0 * 3 + 0] = topleft.X;
						quad[0 * 3 + 1] = topleft.Y;
						quad[0 * 3 + 2] = topleft.Z;
						quad[1 * 3 + 0] = bottomleft.X;
						quad[1 * 3 + 1] = bottomleft.Y;
						quad[1 * 3 + 2] = bottomleft.Z;
						quad[2 * 3 + 0] = topright.X;
						quad[2 * 3 + 1] = topright.Y;
                        quad[2 * 3 + 2] = topright.Z;
                        quad[3 * 3 + 0] = bottomright.X;
						quad[3 * 3 + 1] = bottomright.Y;
						quad[3 * 3 + 2] = bottomright.Z;
						render.simple_texture.DrawQuad( quad, ch.uvs );
					}
					x_del += ( ch.advanceWidth * scale / line_height );
				}
			}
		}
Пример #3
0
		/// <summary>
		/// Draw a string.
		/// </summary>
		/// <param name="render">display to draw string in/on</param>
		/// <param name="EffectivePosition">Where to draw the text (size unused)</param>
		/// <param name="scale">how big to render the font...</param>
		/// <param name="text"></param>
		/// <param name="color"></param>
		internal void RenderFont( Display render, ref Box EffectivePosition
			, float scale, string text
			, ref Vector4 color )
		{
			int c;
			uint rune;
			Display.EnableBlending( true );
			GL.Enable( EnableCap.DepthTest );
			render.simple_gui_texture.Activate();
			render.simple_gui_texture.SetUniforms( OpenGl_TextureRef, ref color );
			float[] quad = new float[12];
			float x_left, y_bottom;
			float x = EffectivePosition.Position.X;
			float y = EffectivePosition.Position.Y;
			float z = EffectivePosition.Position.Z + EffectivePosition.Size.Z;
			float xp, yp;
			FontCharacter ch;
            for( c = 0; c < text.Length; c++ )
			{
				rune = GetUnicode( ref c, text );
				if( rune == '\n' )
				{
					y -= scale;
					x = EffectivePosition.Position.X;
				}
				else
				{
					ch = GetCharacter( rune );
					if( ch.width > 0 )
					{
						x_left = x + ( ch.leftSideBearing * scale / line_height );
						yp = y + ( ( ch.topSideBearing - descent) * scale / line_height );//( ( ( line_height + ch.yOffset ) * scale ) / line_height );
						xp = x_left + ( ch.width * scale / line_height );
						y_bottom = yp + ( ch.height * scale / line_height );

						quad[0 * 3 + 0] = x_left;
						quad[0 * 3 + 1] = yp;
						quad[0 * 3 + 2] = z;
						quad[1 * 3 + 0] = x_left;
						quad[1 * 3 + 1] = y_bottom;
						quad[1 * 3 + 2] = z;
						quad[2 * 3 + 0] = xp;
						quad[2 * 3 + 1] = yp;
						quad[2 * 3 + 2] = z;
						quad[3 * 3 + 0] = xp;
						quad[3 * 3 + 1] = y_bottom;
						quad[3 * 3 + 2] = z;
						render.simple_gui_texture.DrawQuad( quad, ch.uvs );
					}
					x = x + ( ch.advanceWidth * scale / line_height );
				}
			}
		}
Пример #4
0
		internal override void Render( Display render, ref Box ParentPosition )
		{

			Vector3 TopLeft, BottomRight;

			// Frame Position Computing
			if( Flag_Show_Master )
			{
				EffectivePosition.Position.X = ParentPosition.Position.X + Dimensions.Position.Y;
				EffectivePosition.Position.Y = ParentPosition.Position.Y + Dimensions.Position.Y;
				EffectivePosition.Position.Z = ParentPosition.Position.Z + Dimensions.Position.Z;
				EffectivePosition.Size.X = Dimensions.Size.X;
				EffectivePosition.Size.Y = Dimensions.Size.Y;
				EffectivePosition.Size.Z = Dimensions.Size.Z;

				if( this.Flag_Draging ) { EffectivePosition.Position.X = DragAbsolutePosition.X; EffectivePosition.Position.Y = DragAbsolutePosition.Y; EffectivePosition.Position.Z = ParentPosition.Position.Z + Dimensions.Position.Z + 2.0f; }

				// Render this frame

				if( Flag_Show_Frame )
				{
					TopLeft = EffectivePosition.Position;
					BottomRight = EffectivePosition.Position + EffectivePosition.Size;


					// if (TileSet) TileSet.RenderTile(&TopLeft, &BottomRight, Tile, &DrawColor);

					Vector2 P1, P2, P3, P4;

					P1.X = TopLeft.X; P1.Y = TopLeft.Y;
					P2.X = BottomRight.X; P2.Y = TopLeft.Y;
					P3.X = BottomRight.X; P3.Y = BottomRight.Y;
					P4.X = TopLeft.X; P4.Y = BottomRight.Y;


					int texture;
					Vector4 color;
					// Render
					float[] uvs = new float[2 * 4];
					if( activeEntry != null )
					{
						texture = render.game.World.TextureAtlas.OpenGl_TextureRef;
						uvs = VoxelTypeManager.VoxelTable[activeEntry.VoxelType].TextureUVs;
					}
					else
						texture = 0;
					if( activeEntry != null ) color = Vector4.One;
					else color = new Vector4( 0.4f, 0.4f, 0.4f, 0.6f ); //  glColor4f(0.7f, 0.7f, 0.7f, 0.9f);
					float[] verts = new float[3 * 4];
					verts[0 * 3 + 0] = P1.X;
					verts[0 * 3 + 1] = P1.Y;
					verts[0 * 3 + 2] = TopLeft.Z;
					verts[0 * 3 + 0] = P2.X;
					verts[0 * 3 + 1] = P2.Y;
					verts[0 * 3 + 2] = TopLeft.Z;
					verts[0 * 3 + 0] = P3.X;
					verts[0 * 3 + 1] = P3.Y;
					verts[0 * 3 + 2] = BottomRight.Z;
					verts[0 * 3 + 0] = P4.X;
					verts[0 * 3 + 1] = P4.Y;
					verts[0 * 3 + 2] = BottomRight.Z;
					render.simple_gui_texture.DrawQuad( verts, uvs );
					// Rendering Quantity


					if( activeEntry.Quantity > 1 )
					{
						String QuantityText;

						QuantityText = activeEntry.Quantity.ToString();

						Box FontBox;
						Vector2 Dim;

						TileStyle.TileSet.GetFontRenderSize( TileStyle, QuantityText, out Dim );

						FontBox.Position.X = BottomRight.X - Dim.X - 1.0f;
						FontBox.Position.Y = BottomRight.Y - Dim.Y - 1.0f;
						FontBox.Position.Z = TopLeft.Z + 2.0f;
						FontBox.Size.X = Dim.X;
						FontBox.Size.Y = Dim.Y;
						FontBox.Size.Z = 0.0f;
						Vector4 Color;
						Vector4 BkColor;
						Color = Vector4.One;
						BkColor = Vector4.Zero;
						TileStyle.TileSet.RenderFont( render, TileStyle, ref FontBox, QuantityText, ref Color );
						FontBox.Position.Z -= 1.0f;
						FontBox.Position.X -= Display.SclX(1.0f );
						FontBox.Position.Y -= Display.SclY(1.0f );

						TileStyle.TileSet.RenderFont( render, TileStyle, ref FontBox, QuantityText, ref BkColor );
					}
				}


				// Render child frames

				if( Flag_Show_Childs )
				{
					//SubFrameList.Dump();
					foreach( Frame frame in SubFrameList )
					{
						frame.Render( render, ref EffectivePosition );
					}
				}

			}

		}
Пример #5
0
		internal override void Render( Display render, ref Box ParentPosition )
		{
			if( Flag_Show_Master )
			{
				EffectivePosition.Position = ParentPosition.Position + Dimensions.Position;
				EffectivePosition.Position.Z -= 0.1f;
				EffectivePosition.Size = Dimensions.Size;
				if( Flag_Show_Frame )
				{
					if( font != null )
						font.RenderFont( render, ref EffectivePosition, line_height
						               , this.TextToDisplay, ref DrawColor );
				}

				// Render child frames
				if( Flag_Show_Childs )
				{
					//SubFrameList.Dump();
					foreach( Frame frame in SubFrameList )
					{
						frame.Render( render, ref EffectivePosition );
					}
				}

			}

		}
Пример #6
0
		public void Display_RenderFrame( object sender, OpenTK.FrameEventArgs e )
		{
#if BUILD_ANDROID
			if( !loaded ) {
				loaded = true;
				Display_Load( sender, e );
			}
#endif
			// render graphics
			frame++;
			GL.Clear( ClearBufferMask.ColorBufferBit | ClearBufferMask.DepthBufferBit );
			if( !game_loaded )
			{
				DrawProgress();
				return;
			}

			GL.Enable( EnableCap.DepthTest );
			Vector3[] verts = new Vector3[4];
			Vector2[] text = new Vector2[4];
			Vector4[] colors = new Vector4[4];
			verts[0].X = 0;
			verts[0].Y = 0;
			verts[0].Z = 10;
			text[0].X = 0;
			text[0].Y = 0;
			colors[0] = new Vector4( 0.3f, 0, 0, 1 );

			verts[1].X = 0;
			verts[1].Y = 10;
			verts[1].Z = 10;
			text[1].X = 0;
			text[1].Y = 3;
			colors[1] = new Vector4( 0, 0.3f, 0, 1 );

			verts[2].X = 10;
			verts[2].Y = 0;
			verts[2].Z = 10;
			text[2].X = 3;
			text[2].Y = 0;
			colors[2] = new Vector4( 0, 0, 0.3f, 1 );

			verts[3].X = 10;
			verts[3].Y = 10;
			verts[3].Z = 10;
			text[3].X = 3;
			text[3].Y = 3;
			colors[3] = new Vector4( 0, 0.5f, 0.7f, 1 );

			Vector4 color = new Vector4( 0.5f, 0.5f, 0.2f, 1 );
			Vector4 face_color = new Vector4( 0f, 0f, 1f, 1 );

			if( edge.Activate() )
			{
				Display.CheckErr();
				edge.DrawQuad( verts, text, ref face_color, ref color );

				for( int i = 0; i < 4; i++ )
				{
					text[i].X *= 2;
					text[i].Y *= 2;
					verts[i].X += 10;
				}
				face_color = new Vector4( 0.5f, 0.5f, 0.5f, 1 );
				color = new Vector4( 0.0f, 0.0f, 0.0f, 1 );
				edge.Activate();
				Display.CheckErr();
				edge.DrawQuad( verts, text, ref face_color, ref color );

				for( int i = 0; i < 4; i++ )
				{
					text[i].X *= 2;
					text[i].Y *= 2;
					verts[i].X += 10;
				}
				color = new Vector4( 0.0f, 0.5f, 0.9f, 1 );
				color_edge.Activate();
				Display.CheckErr();
				color_edge.DrawQuad( verts, text, ref face_color, colors, 800 );
				//edge.DrawQuad( verts, ref color );
				Display.CheckErr();
			}
			GL.UseProgram( 0 );
			DrawDebugCube();
			if( game.TileSetStyles != null ) {
				Box box = new Box();
				Vector4 DrawColor = new Vector4( 1 );
				box.Size.X = 1;
				box.Size.Y = 1;
				box.Size.Z = 0;
				Vector3 u; free_camera.location.GetRight( out u );

				//( Vector3.UnitZ + Vector3.UnitY ).Normalized();
				Vector3 v;  free_camera.location.GetUp( out v );
				//( -Vector3.UnitZ + Vector3.UnitY ).Normalized(); ;
				Vector2 string_size;
				game.default_font.GetFontRenderSize( "-5 X", 1, out string_size );
				box.Position.X = -5;
				box.Position.Y = 0;
				box.Position.Z = 0;
				box.Position -= u * string_size.X/2 + v * string_size.Y/2;
				game.default_font.RenderFont( this, ref box, ref u, ref v, 1, "-5 X", ref DrawColor );
				box.Position.X = 5;
				box.Position.Y = 0;
				box.Position.Z = 0;
				box.Position -= u * string_size.X / 2 + v * string_size.Y / 2;
				game.default_font.RenderFont( this, ref box, ref u, ref v, 1, "5 X", ref DrawColor );

				game.default_font.GetFontRenderSize( "5 X", 1, out string_size );
				box.Position.X = 0;
				box.Position.Y = -5;
				box.Position.Z = 0;
				box.Position -= u * string_size.X / 2 + v * string_size.Y / 2;
				game.default_font.RenderFont( this, ref box, ref u, ref v, 1, "-5 Y", ref DrawColor );
				box.Position.X = 0;
				box.Position.Y = 5;
				box.Position.Z = 0;
				box.Position -= u * string_size.X / 2 + v * string_size.Y / 2;
				game.default_font.RenderFont( this, ref box, ref u, ref v, 1, "5 Y", ref DrawColor );
				box.Position.X = 0;
				box.Position.Y = 0;
				box.Position.Z = -5;
				box.Position -= u * string_size.X / 2 + v * string_size.Y / 2;
				game.default_font.RenderFont( this, ref box, ref u, ref v, 1, "-5 Z", ref DrawColor );
				box.Position.X = 0;
				box.Position.Y = 0;
				box.Position.Z = 5;
				box.Position -= u * string_size.X / 2 + v * string_size.Y / 2;
				game.default_font.RenderFont( this, ref box, ref u, ref v, 1, "5 Z", ref DrawColor );
			}
			//Log.log( " Origin is " + free_camera.location.m_origin );
			Display.CheckErr();

			BEPUDebugDrawer.DrawSpace( this, game.Engine );
#if !USE_GLES2
			GL.MatrixMode( MatrixMode.Projection );
			GL.LoadMatrix( ref projection );
			GL.MatrixMode( MatrixMode.Modelview );
			unsafe
			{
				btMatrix3x3 tmp;
				free_camera.location.GetGLCameraMatrix( out tmp );
				//Log.log( tmp.ToString() );
					//Console.WriteLine( worldview.ToString() );
					//Console.WriteLine( tmp.ToString() );
					float * matrix_ptr = &tmp.m_el0.x;
				{
					GL.LoadMatrix( matrix_ptr );
				}
			}
			Shader.Deactivate();

			//GL.BindTexture( TextureTarget.Texture2D, frame %100 );
			GL.Begin( PrimitiveType.Triangles );
			GL.TexCoord2( 0, 1 );
			GL.Color3( 1.0f, 1.0f, 0.0f ); GL.Vertex3( -1.0f, -1.0f, 4.0f );
			GL.TexCoord2( 1, 1 );
			GL.Color3( 1.0f, 0.0f, 0.0f ); GL.Vertex3( 1.0f, -1.0f, 4.0f );
			GL.TexCoord2( 1, 0 );
			GL.Color3( 0.2f, 0.9f, 1.0f ); GL.Vertex3( 0.0f, 1.0f, 4.0f );

			GL.End();
#endif
			game.Draw( this, sw.ElapsedTicks / frequency );
			//SwapBuffers();
		}
Пример #7
0
		internal virtual void Render( Display render, ref Box ParentPosition )
		{
			quad P;

			// Frame Position Computing
			if( Flag_Show_Master )
			{
				EffectivePosition.Position = ParentPosition.Position + Dimensions.Position;
				EffectivePosition.Position.Z -= 0.1f;
				EffectivePosition.Size = Dimensions.Size;

				if( this.Flag_Draging ) { EffectivePosition.Position.X = DragAbsolutePosition.X; EffectivePosition.Position.Y = DragAbsolutePosition.Y; }

				// Render this frame

				if( Flag_Show_Frame )
				{
					P.P1.X = EffectivePosition.Position.X;                            P.P1.Y = EffectivePosition.Position.Y;                            P.P1.Z = EffectivePosition.Position.Z + EffectivePosition.Size.Z;
					P.P2.X = EffectivePosition.Position.X + EffectivePosition.Size.X; P.P2.Y = EffectivePosition.Position.Y;                            P.P2.Z = EffectivePosition.Position.Z + EffectivePosition.Size.Z;
					P.P3.X = EffectivePosition.Position.X + EffectivePosition.Size.X; P.P3.Y = EffectivePosition.Position.Y + EffectivePosition.Size.Y; P.P3.Z = EffectivePosition.Position.Z + EffectivePosition.Size.Z;
					P.P4.X = EffectivePosition.Position.X;                            P.P4.Y = EffectivePosition.Position.Y + EffectivePosition.Size.Y; P.P4.Z = EffectivePosition.Position.Z + EffectivePosition.Size.Z;

					int TextureRef = GuiManager.TextureManager.GetTextureEntry( this.TextureNum ).OpenGl_TextureRef;
					tex_coords[0] = 0.0f; tex_coords[1] = 1.0f; coords[0] = P.P1.X; coords[1] = P.P1.Y; coords[2] = P.P1.Z;
					tex_coords[2] = 1.0f; tex_coords[3] = 1.0f; coords[3] = P.P2.X; coords[4] = P.P2.Y; coords[5] = P.P2.Z;
					tex_coords[4] = 1.0f; tex_coords[5] = 0.0f; coords[6] = P.P3.X; coords[7] = P.P3.Y; coords[8] = P.P3.Z;
					tex_coords[6] = 1.0f; tex_coords[7] = 0.0f; coords[9] = P.P3.X; coords[10] = P.P3.Y; coords[11] = P.P3.Z;
					tex_coords[8] = 0.0f; tex_coords[9] = 0.0f; coords[12] = P.P4.X; coords[13] = P.P4.Y; coords[14] = P.P4.Z;
					tex_coords[10] = 0.0f; tex_coords[11] = 1.0f; coords[15] = P.P1.X; coords[16] = P.P1.Y; coords[17] = P.P1.Z;
					//lprintf( "%3d %g,%g,%g %g,%g,%g", TextureRef, P.P1.X, P.P1.Y, P.P1.Z, P.P3.X, P.P3.Y, P.P3.Z );

					render.simple_gui_texture.Activate();
					render.simple_gui_texture.SetUniforms( TextureRef, ref DrawColor );
					render.simple_gui_texture.DrawQuadTris( coords, tex_coords );
					render.simple_texture.Activate();
					render.simple_texture.SetUniforms( TextureRef, ref DrawColor );
					render.simple_texture.DrawQuadTris( coords, tex_coords );
				}
				// Render child frames
				if( Flag_Show_Childs )
				{
					lock ( SubFrameList )
					{
						foreach( Frame frame in SubFrameList )
							frame.Render( render, ref EffectivePosition );
					}
				}

			}

		}