예제 #1
0
		public VoxelType()
		{
			VoxelTypeManager = null;
			MainTexture = null;
			//OpenGl_TextureRef = 0;
			GameEnv = null;
		}
예제 #2
0
		internal override ScreenChoices ProcessScreen( VoxelGameEnvironment GameEnv )
		{
			if( GameEnv.page_up != page_id )
			{
				GameEnv.page_up = page_id;
				GameEnv.GuiManager.RemoveAllFrames();

				if( Frame_Loading == null )
				{
					Frame_Loading = new FontFrame();
					Frame_Loading.SetDisplayText( "LOADING..." );
					Frame_Loading.Font = GameEnv.menu_font;// SetStyle( GameEnv.TileSetStyles.GetStyle( 1 ) );
					Frame_Loading.FontSize = ( 2.0f / 10 );
					Vector2 Loading_Size;
					Frame_Loading.GetTextDisplaySize( out Loading_Size );
					Frame_Loading.SetPosition(  1-Loading_Size.X / 2.0f, 1-Loading_Size.Y / 2.0f );
					Frame_Loading.SetSize( Loading_Size.X + 1.0f, Loading_Size.Y );
					Frame_Loading.TextureNum = TextureID.OldFont;

					LoadProgress = new ProgressBar();
					LoadProgress.SetPosition( 0.5f, 0.5f );
					LoadProgress.SetSize( 1.0f, 0.2f );
				}

				//TitleBackground.AddFrame(&Frame_PlayGame);
				GameEnv.GuiManager.AddFrame( Frame_Loading );
				GameEnv.GuiManager.AddFrame( LoadProgress );
			}
			LoadProgress.SetCompletion( GameEnv.start_percent );
			return ( ScreenChoices.NONE );
		}
예제 #3
0
		public ScreenSlotSelect( VoxelGameEnvironment.Pages page_id ) : base( page_id )
		{
			LogoBlackvoxel = new Frame();
			Frame_MainTitle = new FontFrame();
			for( int i = 0; i < 16; i++ )
			{
				Slot[i] = new Frame();
				SlotTitle[i] = new FontFrame();
				SlotStatus[i] = new FontFrame();
			}
		}
예제 #4
0
		internal Game_Events()
		{
			uint i;
			Keyboard_Matrix = new byte[255];
			Mouse_Matrix = new bool[12];
			for( i = 0; i < 255; i++ ) Keyboard_Matrix[i] = 0;
			for( i = 0; i < 12; i++ ) Mouse_Matrix[i] = false;
			EnableMouseEvents = true;
			EventManager = null;
			GameEnv = null;
			LastFrameTime = 16.0;
		}
예제 #5
0
		internal FileSectorLoader( VoxelGameEnvironment GameEnv, IWorldGenesis Genesis )
		{
			for( int i = 0; i < 8; i++ )
				RequestList[i] = new SectorRequestRingList();
			this.GameEnv = GameEnv;
			SectorCreator = Genesis;
			ReadySectorList = new SectorRingList( 1024 * 1024 );
			EjectedSectorList = new SectorRingList( 1024 * 1024 );
			SectorRecycling = new Stack<VoxelSector>( 100 );
			VoxelTypeManager = null;
			UniverseNum = 1;
			WorkingEmptySector = new VoxelSector( null, (VoxelWorld)null );
			//GameEnv.Basic_Renderer.GetCuller().InitFaceCullData( WorkingEmptySector );
			WorkingEmptySector.Fill( 0 );
			WorkingFullSector = new VoxelSector( null, (VoxelWorld)null );
			//GameEnv.Basic_Renderer.GetCuller().InitFaceCullData( WorkingFullSector );
			WorkingFullSector.Fill( 1 );
			Thread = null;
			ThreadContinue = false;
		}
예제 #6
0
		internal override ScreenChoices ProcessScreen( VoxelGameEnvironment GameEnv )
		{
			if( GameEnv.page_up != page_id )
			{
				GameEnv.page_up = page_id;
				GameEnv.GuiManager.RemoveAllFrames();

				if( ServerList == null )
				{
					ServerList = new FrameListbox();
					ServerList.EffectivePosition.Position.X = Display.SclX( 100 );
					ServerList.EffectivePosition.Position.Y = Display.SclY( 100 );
					ServerList.EffectivePosition.Size.X = Display.SclX( 1920 - 200 );
					ServerList.EffectivePosition.Size.Y = Display.SclY( 1080 - 200 );
					ServerList.TextureNum = TextureID.DialogBackground;
				}

				GameEnv.GuiManager.AddFrame( ServerList );

			}
			return ResultCode;
		}
예제 #7
0
		internal override ScreenChoices ProcessScreen( VoxelGameEnvironment GameEnv )
		{
			if( GameEnv.page_up != page_id )
			{
				GameEnv.page_up = page_id;
				GameEnv.GuiManager.RemoveAllFrames();
				if( Frame_Connecting == null )
				{
					Frame_Connecting = new FontFrame();
					Frame_Connecting.Text = "Connecting...";
					Frame_Connecting.Font = GameEnv.menu_font;
					Frame_Connecting.FontSize = ( 2.0f / 10 );
					Frame_Connecting.SetPosition( 1 - Frame_Connecting.Dimensions.Size.X / 2.0f
												, 1 - Frame_Connecting.Dimensions.Size.Y / 2.0f );
				}

				if( Frame_ProgressBar == null )
				{
					Frame_ProgressBar = new ProgressBar();
					Frame_ProgressBar.SetPosition( 0.5f, 0.5f );
					Frame_ProgressBar.SetSize( 1.0f, 0.2f );
					Frame_ProgressBar.SetCompletion( 50 );
				}

				GameEnv.GuiManager.AddFrame( Frame_Connecting );
				Frame_Connecting.AddFrame( Frame_ProgressBar );

			}
			if( GameEnv.Master_Server_Connection.PercentToFail == 100 )
				return ScreenChoices.CHOICE_RETURN;
			if( GameEnv.Master_Server_Connection.Connected )
				return ScreenChoices.SELECT_SERVER;
			Frame_ProgressBar.SetCompletion( GameEnv.Master_Server_Connection.PercentToFail );

			return ResultCode;
		}
예제 #8
0
파일: Actor.cs 프로젝트: d3x0r/Voxelarium
		Actor()
		{
			int i;
			Next = Pred = null;
			VoxelSelectDistance = 6;
			Velocity.x = Velocity.y = Velocity.z = 0.0f;
			Deplacement.x = Deplacement.y = Deplacement.z = 0.0f;
			//Location.x = Location.y = Location.z = 0.0;
			//ViewDirection.yaw = ViewDirection.pitch = ViewDirection.roll = ViewDirection.Len = 0.0;
			CollideWithVoxels = false;
			CollideWithActors = false;
			Flag_ActivateAntiFall = false;
			TakesGravity = true;
			DammageThreshold = 599.0;
			LifePoints = 1000;
			JumpDebounce = 0;
			BuildingMaterial = 1;
			//for( i = 0; i < 8; i++ ) MouseButtonMatrix[i] = false;
#if FINISH_PORTING
			Inventory = null;
			Camera.ColoredVision.Activate = false;
			Camera.ColoredVision.Blue = 1.0f;
			Camera.ColoredVision.Red = 1.0f;
			Camera.ColoredVision.Green = 1.0f;
			PhysicsEngine = null;
#endif
			KeepControlOnJumping = true;
			IsDead = false;
			IsOnGround = false;

			order = false;
			DeathChronometer = 0.0;
			GameEnv = null;

			Time_TotalGameTime = 0;
			Time_ElapsedTimeSinceLastRespawn = 0;
			LearningModePage = 0;

		}
예제 #9
0
파일: Actor.cs 프로젝트: d3x0r/Voxelarium
		public virtual void SetGameEnv( VoxelGameEnvironment GameEnv ) { this.GameEnv = GameEnv; }
예제 #10
0
		public VoxelWorld( bool nogui, VoxelGameEnvironment GameEnv )
		{
			uint i;
			this.nogui = nogui;
			this.GameEnv = GameEnv;
			Display.OnInvalidate += Display_OnInvalidate;
			SectorEjectList = new SectorRingList( 256 * 256 * 32/*65536*/);
			if( !nogui )
				TextureAtlas = new TextureAtlas( 32, 64 );

			SectorTable = new VoxelSector[TableSize];

			for( i = 0; i < TableSize; i++ ) SectorTable[i] = null;

			SectorList = null;
			UniverseNum = 1;
			VoxelTypeManager = null;
		}
예제 #11
0
		internal ScreenLoading( VoxelGameEnvironment.Pages page_id ) : base( page_id )
		{
		}
예제 #12
0
		internal override ScreenMain.ScreenChoices ProcessScreen( VoxelGameEnvironment GameEnv )
		{
			Vector2 Size;
			int i;
			ScreenMain.ScreenChoices ChoosedSlot = ScreenChoices.NONE;

			// Effacer l'écran
			if( GameEnv.page_up != page_id )
			{
				GameEnv.page_up = page_id;
				// Régler la transparence

				// Enlever toutes les boites affichées

				GameEnv.GuiManager.RemoveAllFrames();

				// Définition et réglage de la boite du fond


				// Définition du titre

				Size.Y = 0.2f;
				Size.X = Size.Y * 10.0f;
				LogoBlackvoxel.SetPosition( 0.1f, 2-0.2f );
				LogoBlackvoxel.SetSize( Size.X, Size.Y );
				LogoBlackvoxel.SetTexture( TextureID.TitleBanner );
				GameEnv.GuiManager.AddFrame( LogoBlackvoxel );

				// Définition et réglage du sous-titre

				Frame_MainTitle.SetDisplayText( "GAME UNIVERSE SELECTION" );
				Frame_MainTitle.Font = GameEnv.default_font;// .SetStyle( GameEnv.TileSetStyles.GetStyle( 1 ) );
				Frame_MainTitle.FontSize = ( 2.0f / 20 );
				Frame_MainTitle.GetTextDisplaySize( out Size );
				Frame_MainTitle.SetPosition( 1 - Size.X/2, 2-0.4f );
				//Frame_MainTitle.SetPosition(2.0f / 2.0f - Size.X/2.0f, 2.0f / 2.0f - Size.Y / 2.0f);
				Frame_MainTitle.SetSize( Size.X, Size.Y );
				GameEnv.GuiManager.AddFrame( Frame_MainTitle );
				//Background.AddFrame(Frame_MainTitle);

				// Définition des variables et objets utilisés pour la suite


				// Récupération du chemin du répertoire de stockage des univers

				Directory = VoxelGlobalSettings.USERDATA_DIRECTORY;
                Directory += "/" + VoxelGlobalSettings.COMPILEOPTION_SAVEFOLDERNAME;
				Directory += "/Universes";

				// Boucle de réglages des boites de choix d'univers

				for( i = 0; i < 16; i++ )
				{
					// Tester si le slot est utilisé / Test if GameSlot is used

					FileName[i] = Directory;
					FileName[i] = Directory + "/" + (i+1) + "/PlayerInfo.dat";
					SlotUsed[i] = File.Exists( FileName[i] );

					// Régler les paramètres de la boite du slot univers

					Vector2 SlotPos, SlotSize;
					SlotPos.X = ( (float)( i % 4 ) ) * ( ( 2 ) / 4.25f ) + (float)2.0f * 0.045f;
					SlotPos.Y = 0.6f - ( i / 4 * ( 2.0f / 6.5f ) ) + (float)2.0f * 0.3f;
					//SlotPos.Y = (i / 4 * (2.0f / 4.3f)) + ( i/ 8 * (2.0f * 0.05f) ) + (float)2.0f * 0.025f;
					SlotSize.X = 2.0f / 5.0f;
					SlotSize.Y = 2.0f / 10.0f;
					Slot[i].SetTexture( TextureID.Title2 );

					if( SlotUsed[i] ) Slot[i].SetColor( 1.0f, 1.0f, 1.0f );
					else Slot[i].SetColor( 1.0f, 1.0f, 1.0f );

					Slot[i].SetPosition( SlotPos.X, SlotPos.Y );
					Slot[i].SetSize( SlotSize.X, SlotSize.Y );
					GameEnv.GuiManager.AddFrame( Slot[i] );
					//Background.AddFrame(Slot[i]);

					// Régler les paramètres de la boite du texte slot univers

					SlotString[i] = "UNIVERSE " + (i+1);
					SlotTitle[i].SetDisplayText( SlotString[i] );
					SlotTitle[i].Font = GameEnv.default_font;//.SetStyle( GameEnv.TileSetStyles.GetStyle( 3 ) );
					SlotTitle[i].FontSize = ( 2.0f / 30 );
					SlotTitle[i].SetTexture( TextureID.OldFont );
					SlotTitle[i].GetTextDisplaySize( out Size );
					SlotTitle[i].SetPosition( SlotSize.X * 0.07f, SlotSize.Y * 0.2f );
					// SlotTitle[i].SetPosition(SlotSize.X / 2 - Size.X/2, SlotSize.Y * 0.2f);
					SlotTitle[i].SetSize( Size.X + 1.0f, Size.Y );
					SlotTitle[i].SetColor( 1.0f, 1.0f, 1.0f );
					Slot[i].AddFrame( SlotTitle[i] );

					// Régler les paramètres de la boite du texte Used/Free

					if( SlotUsed[i] ) StatusString[i] = "USED";
					else StatusString[i] = "FREE";
					SlotStatus[i].SetDisplayText( StatusString[i] );
					SlotStatus[i].Font = GameEnv.default_font;//.SetStyle( GameEnv.TileSetStyles.GetStyle( 3 ) );
					SlotStatus[i].FontSize = ( 2.0f / 30 );
					SlotStatus[i].SetTexture( TextureID.OldFont );
					SlotStatus[i].GetTextDisplaySize( out Size );
					SlotStatus[i].SetPosition( SlotSize.X * 0.65f, SlotSize.Y * 0.65f );
					// SlotStatus[i].SetPosition(SlotSize.X / 2 - Size.X/2, SlotSize.Y * 0.45f);
					SlotStatus[i].SetSize( Size.X + 1.0f, Size.Y );
					if( SlotUsed[i] ) SlotStatus[i].SetColor( 1.0f, 0.0f, 0.0f );
					else SlotStatus[i].SetColor( 0.0f, 1.0f, 0.0f );
					// else            SlotStatus[i].SetColor(0.5f,0.5f,0.5f);
					Slot[i].AddFrame( SlotStatus[i] );
				}
			}
			// Boucle d'affichage et de gestion des évènements

			// for (Loop = true; Loop; )
			{
				// Effacer l'écran

				// glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT );

				// Gérer les évènements entrants (clics, déplacemets souris, frappe clavier)

				//Loop = GameEnv.EventManager.ProcessEvents();

				// Détecter les actions de l'utilisateur sur chaque boite slot univers et prendre les actions appropriées

				for( i = 0; i < 16; i++ )
				{
					if( Slot[i].Is_MouseIn() ) Slot[i].SetTexture( TextureID.Title3 );
					if( Slot[i].Is_MouseOut() ) Slot[i].SetTexture( TextureID.Title2 );
					if( Slot[i].Is_MouseClick() ) { ChoosedSlot = ScreenChoices.SlotChoice1+i; }
				}

				// Demander au gestionnaire de boite d'effectuer le rendu graphique

				//GameEnv.GuiManager.Render(  );

				// On montre à l'utilisateur ce qui a été rendu

				//SDL_GL_SwapBuffers();
				//SDL_GL_SwapWindow(GameEnv.screen);

				// On met le programme en pause pendant 10 millièmes de seconde

				//SDL_Delay(10);
			}

			// Enlever toutes les boites de l'affichage

			//GameEnv.GuiManager.RemoveAllFrames();

			// Retourner à l'appelant et lui donner le numéro de l'univers choisis

			return ( ChoosedSlot );
		}
예제 #13
0
		internal override void Render( Display display, VoxelGameEnvironment game, VoxelWorld world )
		{
			HighPerfTimer Timer = new HighPerfTimer();
			HighPerfTimer Timer_SectorRefresh = new HighPerfTimer();
			long Time;
			uint RenderedSectors;
			int i;
			int in_centerX, in_centerY, in_centerZ;

			Timer.Start();

			Stat_RenderDrawFaces = 0;
			Stat_FaceTop = 0;
			Stat_FaceBottom = 0;
			Stat_FaceLeft = 0;
			Stat_FaceRight = 0;
			Stat_FaceFront = 0;
			Stat_FaceBack = 0;

			// Stats reset
			GameStats Stat = GameEnv.GameStat;

			if( Stat == null )
				return;

			// Precomputing values for faster math

			// Update per cycle.
			int UpdatePerCycle = 2;
			int n;

			if( Stat_RefreshWaitingSectorCount < 50 ) UpdatePerCycle = 1;
			if( Stat_RefreshWaitingSectorCount < 500 ) UpdatePerCycle = 2;
			else if( Stat.SectorRefresh_TotalTime < 32 ) UpdatePerCycle = 5;
			Stat_RefreshWaitingSectorCount = 0;

			// Stat Reset

			Stat.SectorRefresh_Count = 0;
			Stat.SectorRefresh_TotalTime = 0;
			Stat.SectorRefresh_MinTime = 0;
			Stat.SectorRefresh_MaxTime = 0;
			Stat.SectorRender_Count = 0;
			Stat.SectorRender_TotalTime = 0;
			Stat.SectorRefresh_Waiting = 0;

			// Renderwaiting system

			for( i = 0; i < 64; i++ ) RefreshToDo[i] = 0;
			for( i = 63; i > 0; i-- )
			{
				n = RefreshWaiters[i];
				if( n > UpdatePerCycle ) n = UpdatePerCycle;
				UpdatePerCycle -= n;
				RefreshToDo[i] = n;
			}
			RefreshToDo[0] = UpdatePerCycle;

			for( i = 0; i < 64; i++ ) RefreshWaiters[i] = 0;

			// Computing Frustum and Setting up Projection
			int Sector_x, Sector_y, Sector_z;
			int x, y, z;

			VoxelSector Sector;
			int Priority, PriorityBoost;
			uint Sector_Refresh_Count;

			// Transforming Camera coords to sector coords. One Voxel is 256 observer units. One sector is 16x16x32.
			btVector3 origin;
			Camera.location.getOrigin( out origin );

			Sector_x = ( (int)origin.x >> ( world.VoxelBlockSizeBits + VoxelSector.ZVOXELBLOCSHIFT_X ) );
			Sector_y = ( (int)origin.y >> ( world.VoxelBlockSizeBits + VoxelSector.ZVOXELBLOCSHIFT_Y ) );
			Sector_z = ( (int)origin.z >> ( world.VoxelBlockSizeBits + VoxelSector.ZVOXELBLOCSHIFT_Z ) );

			in_centerX = (int)origin.x & VoxelSector.ZVOXELBLOCMASK_X;
			in_centerY = (int)origin.y & VoxelSector.ZVOXELBLOCMASK_Y;
			in_centerZ = (int)origin.z & VoxelSector.ZVOXELBLOCMASK_Z;


			// Rendering loop
			// Preparation and first rendering pass

			RenderedSectors = 0;
			Sector_Refresh_Count = 0;
			int voxelSizeBits = world.VoxelBlockSizeBits;
			float voxelSize = world.VoxelBlockSize;
			SectorSphere.SphereEntry SectorSphereEntry;
			uint SectorsToProcess = SectorSphere.GetEntryCount();

			btVector3 Cv;
			btVector3 Cv2;
			Cv2.w = 0;
			Cv.w = 0;

			for( int Entry = 0; Entry < SectorsToProcess; Entry++ )
			{
				SectorSphere.GetEntry( Entry, out SectorSphereEntry );

				x = SectorSphereEntry.x + Sector_x;
				y = SectorSphereEntry.y + Sector_y;
				z = SectorSphereEntry.z + Sector_z;

				// for (x = Start_x ; x <= End_x ; x++)
				// for (y = Start_y; y <= End_y ; y++)
				// for (z = Start_z; z <= End_z ; z++)

				// try to see if sector is visible

				bool SectorVisible;

				Cv.x = (float)( ( x ) << ( voxelSizeBits + VoxelSector.ZVOXELBLOCSHIFT_X ) );
				Cv.y = (float)( ( y ) << ( voxelSizeBits + VoxelSector.ZVOXELBLOCSHIFT_Y ) );
				Cv.z = (float)( ( z ) << ( voxelSizeBits + VoxelSector.ZVOXELBLOCSHIFT_Z ) );

				SectorVisible = false;
				Cv2.x = ( 0 * VoxelSector.ZVOXELBLOCSIZE_X * voxelSize ); Cv2.y = ( 0 * VoxelSector.ZVOXELBLOCSIZE_Y * voxelSize ); Cv2.z = ( 0 * VoxelSector.ZVOXELBLOCSIZE_Z * voxelSize );
				Cv2.Add( ref Cv, out Cv2 ); SectorVisible |= Is_PointVisible( ref Camera.location, ref Cv2 );
				Cv2.x = ( 1 * VoxelSector.ZVOXELBLOCSIZE_X * voxelSize ); Cv2.y = ( 0 * VoxelSector.ZVOXELBLOCSIZE_Y * voxelSize ); Cv2.z = ( 0 * VoxelSector.ZVOXELBLOCSIZE_Z * voxelSize );
				Cv2.Add( ref Cv, out Cv2 ); SectorVisible |= Is_PointVisible( ref Camera.location, ref Cv2 );
				Cv2.x = ( 1 * VoxelSector.ZVOXELBLOCSIZE_X * voxelSize ); Cv2.y = ( 0 * VoxelSector.ZVOXELBLOCSIZE_Y * voxelSize ); Cv2.z = ( 1 * VoxelSector.ZVOXELBLOCSIZE_Z * voxelSize );
				Cv2.Add( ref Cv, out Cv2 ); SectorVisible |= Is_PointVisible( ref Camera.location, ref Cv2 );
				Cv2.x = ( 0 * VoxelSector.ZVOXELBLOCSIZE_X * voxelSize ); Cv2.y = ( 0 * VoxelSector.ZVOXELBLOCSIZE_Y * voxelSize ); Cv2.z = ( 1 * VoxelSector.ZVOXELBLOCSIZE_Z * voxelSize );
				Cv2.Add( ref Cv, out Cv2 ); SectorVisible |= Is_PointVisible( ref Camera.location, ref Cv2 );
				Cv2.x = ( 0 * VoxelSector.ZVOXELBLOCSIZE_X * voxelSize ); Cv2.y = ( 1 * VoxelSector.ZVOXELBLOCSIZE_Y * voxelSize ); Cv2.z = ( 0 * VoxelSector.ZVOXELBLOCSIZE_Z * voxelSize );
				Cv2.Add( ref Cv, out Cv2 ); SectorVisible |= Is_PointVisible( ref Camera.location, ref Cv2 );
				Cv2.x = ( 1 * VoxelSector.ZVOXELBLOCSIZE_X * voxelSize ); Cv2.y = ( 1 * VoxelSector.ZVOXELBLOCSIZE_Y * voxelSize ); Cv2.z = ( 0 * VoxelSector.ZVOXELBLOCSIZE_Z * voxelSize );
				Cv2.Add( ref Cv, out Cv2 ); SectorVisible |= Is_PointVisible( ref Camera.location, ref Cv2 );
				Cv2.x = ( 1 * VoxelSector.ZVOXELBLOCSIZE_X * voxelSize ); Cv2.y = ( 1 * VoxelSector.ZVOXELBLOCSIZE_Y * voxelSize ); Cv2.z = ( 1 * VoxelSector.ZVOXELBLOCSIZE_Z * voxelSize );
				Cv2.Add( ref Cv, out Cv2 ); SectorVisible |= Is_PointVisible( ref Camera.location, ref Cv2 );
				Cv2.x = ( 0 * VoxelSector.ZVOXELBLOCSIZE_X * voxelSize ); Cv2.y = ( 1 * VoxelSector.ZVOXELBLOCSIZE_Y * voxelSize ); Cv2.z = ( 1 * VoxelSector.ZVOXELBLOCSIZE_Z * voxelSize );
				Cv2.Add( ref Cv, out Cv2 ); SectorVisible |= Is_PointVisible( ref Camera.location, ref Cv2 );

				Sector = world.FindSector( x, y, z );
				Priority = RadiusZones.GetZone( x - Sector_x, y - Sector_y, z - Sector_z );
				PriorityBoost = ( SectorVisible && Priority <= 2 ) ? 1 : 0;
				// Go = true;

				if( Sector != null )
				{
					if( Sector.transparent_geometry.transparent_render_sorting != SectorSphereEntry.relative_pos )
					{
						Sector.transparent_geometry.transparent_render_sorting = SectorSphereEntry.relative_pos;
						Sector.Flag_Render_Dirty_Transparent = true;
						Sector.transparent_geometry.sortedX = -1;
					}
					if( SectorSphereEntry.relative_pos == VoxelSector.RelativeVoxelOrds.INCENTER )
					{
						if( center_sorted_x != in_centerX
							|| center_sorted_y != in_centerY
							|| center_sorted_z != in_centerZ )
						{
							Sector.Flag_Render_Dirty_Transparent = true;
							BuildSortListInSector( in_centerX, in_centerY, in_centerZ );
						}
					}


					Sector.Flag_IsVisibleAtLastRendering = SectorVisible || Priority >= 3;
					// Display lists preparation
					if( ( Sector.Flag_Render_Dirty  || Sector.Flag_Render_Dirty_Transparent )
						&& GameEnv.Enable_NewSectorRendering )
					{

						// if (Sector_Refresh_Count < 5 || Priority==4)
						if( ( RefreshToDo[Sector.RefreshWaitCount] != 0 ) || Sector.Flag_HighPriorityRefresh )
						{

							if ( VoxelGlobalSettings.COMPILEOPTION_FINETIMINGTRACKING )
								Timer_SectorRefresh.Start();

							RefreshToDo[Sector.RefreshWaitCount]--;
							Sector.Flag_HighPriorityRefresh = false;

							//Log.log( "Draw sector geometry {0} {1} {2}", Sector.Pos_x, Sector.Pos_y, Sector.Pos_z );

							MakeSectorRenderingData( Sector );

							MakeSectorRenderingData_Sorted( Sector, SectorSphereEntry.relative_pos
														, in_centerX, in_centerY, in_centerZ );
							//Log.log( "Drew sector geometry {0} {1} {2}", Sector.Pos_x, Sector.Pos_y, Sector.Pos_z );

							Sector_Refresh_Count++;
							Sector.RefreshWaitCount = 0;
							Stat.SectorRefresh_Count++;

							if( VoxelGlobalSettings.COMPILEOPTION_FINETIMINGTRACKING )
							{
								Timer_SectorRefresh.End(); Time = Timer_SectorRefresh.GetResult(); Stat.SectorRefresh_TotalTime += (uint)Time;
								if( Time < Stat.SectorRefresh_MinTime ) Stat.SectorRefresh_MinTime = (uint)Time;
								if( Time > Stat.SectorRefresh_MaxTime ) Stat.SectorRefresh_MaxTime = (uint)Time;
							}
						}
						else
						{
							Sector.RefreshWaitCount++;
							if( Sector.RefreshWaitCount > 31 ) Sector.RefreshWaitCount = 31;
							if( Priority == 4 ) Sector.RefreshWaitCount++;
							RefreshWaiters[Sector.RefreshWaitCount]++;
							Stat_RefreshWaitingSectorCount++;
							Stat.SectorRefresh_Waiting++;
						}

					}


					// Rendering first pass
					if( Sector.Flag_IsVisibleAtLastRendering
						&& ( !Sector.Flag_Void_Regular )
						)
					{
						if( VoxelGlobalSettings.COMPILEOPTION_FINETIMINGTRACKING )
							Timer_SectorRefresh.Start();

						Sector.solid_geometry.SetupUniforms( world.TextureAtlas.OpenGl_TextureRef );
						Sector.solid_geometry.DrawBuffer();
						//glCallList( ( (ZRender_Interface_displaydata*)Sector.DisplayData ).DisplayList_Regular[current_gl_camera] );

						Stat.SectorRender_Count++; RenderedSectors++;

						if( VoxelGlobalSettings.COMPILEOPTION_FINETIMINGTRACKING ) {
							Timer_SectorRefresh.End(); Time = Timer_SectorRefresh.GetResult(); Stat.SectorRender_TotalTime += (uint)Time;
						}
					}
				}
				else
				{
					if( GameEnv.Enable_LoadNewSector )
						world.RequestSector( x, y, z, Priority + PriorityBoost );
					if( VoxelGlobalSettings.COMPILEOPTION_DRAW_MISSING_SECTORS )
					{
						GL.Disable( EnableCap.DepthTest );
						if( SectorVisible ) // culling 
							Render_EmptySector( display, world, x, y, z, 1.0f, 0.3f, 0.1f );
						GL.Enable( EnableCap.DepthTest );
					}
					//return;
				}
			}

			// Second pass rendering
			//GL.Disable( EnableCap.DepthTest );
			//GL.DepthMask( false );
			//glDepthMask( GL_FALSE );

#if !USE_GLES2
			GL.AlphaFunc( AlphaFunction.Greater, 0.2f );
			GL.Enable( EnableCap.AlphaTest );
#endif
			Display.EnableBlending( true );

			for( int Entry = 0; Entry < SectorsToProcess; Entry++ )
			{
				SectorSphere.GetEntry( Entry, out SectorSphereEntry );

				x = SectorSphereEntry.x + Sector_x;
				y = SectorSphereEntry.y + Sector_y;
				z = SectorSphereEntry.z + Sector_z;

				Sector = world.FindSector( x, y, z );
				// printf("Sector : %ld %ld %ld %lu\n", x, y, z, (uint)(Sector != 0));9
				if( Sector != null )
				{
					if( Sector.Flag_IsVisibleAtLastRendering
					   && ( !Sector.Flag_Void_Transparent )
					   )
					{
						if( VoxelGlobalSettings.COMPILEOPTION_FINETIMINGTRACKING )
							Timer_SectorRefresh.Start();

						Sector.transparent_geometry.SetupUniforms( world.TextureAtlas.OpenGl_TextureRef );
						Sector.transparent_geometry.DrawBuffer();
						//glCallList( ( (ZRender_Interface_displaydata*)Sector.DisplayData ).DisplayList_Transparent[current_gl_camera] );
						Stat.SectorRender_Count++;

						if( VoxelGlobalSettings.COMPILEOPTION_FINETIMINGTRACKING )
						{
							Timer_SectorRefresh.End(); Time = Timer_SectorRefresh.GetResult();
							Stat.SectorRender_TotalTime += (uint)Time;
						}
					}

				}
			}
			GL.Enable( EnableCap.DepthTest );
			Display.EnableBlending( false );

			Timer.End();

			/*printf("Frame Time : %lu Rend Sects: %lu Draw Faces :%lu Top:%lu Bot:%lu Le:%lu Ri:%lu Front:%lu Back:%lu\n",Timer.GetResult(), RenderedSectors, Stat_RenderDrawFaces, Stat_FaceTop, Stat_FaceBottom,
				   Stat_FaceLeft,Stat_FaceRight,Stat_FaceFront,Stat_FaceBack);*/

			//printf("RenderedSectors : %lu\n",RenderedSectors);
			//SDL_GL_SwapBuffers( );
		}
예제 #14
0
		internal void SetGameEnv( VoxelGameEnvironment GameEnv ) { this.GameEnv = GameEnv; }
예제 #15
0
파일: Screen.cs 프로젝트: d3x0r/Voxelarium
		internal Screen( VoxelGameEnvironment.Pages Page_id ) { page_id = Page_id; ResultCode = ScreenChoices.NONE; }
예제 #16
0
파일: Display.cs 프로젝트: d3x0r/Voxelarium
		public Display( VoxelGameEnvironment game )
		{
			Exit = CannotExit;
			this.game = game;
			//string versionOpenGL = GL.GetString(StringName.Version);
			//GL.Get
			//display_width = Width;// = Settings.Read( "GL.Width", System.Windows.Forms.Screen.PrimaryScreen.WorkingArea.Width );
			//display_height = Height;// = Settings.Read( "GL.Height", System.Windows.Forms.Screen.PrimaryScreen.WorkingArea.Height );
			//mouse_x = display_width / 2;
			//mouse_y = display_height / 2;
			Width = 1080;
			Height = 1920;
#if !USE_GLES2
			System.Windows.Forms.Cursor.Position = new Point( display_x + ( display_width ) / 2, display_y + display_height / 2 );
#endif

			//GL.Viewport( 0, 0, Width, Height );
#if !USE_GLES2
			GL.Enable( EnableCap.Multisample );
#endif
			Matrix4.CreatePerspectiveFieldOfView( (float)( System.Math.PI / 2 ), (float)Width / (float)Height, 0.01f, 10000, out projection );
			//projection = Matrix4.Identity;

			// generic fly camera not attached to any object
			free_camera = new Voxels.UI.Camera();
			active_camera = free_camera; // default to freecam;
			free_camera.MoveTo( 0, 4, 0 );
			free_camera.MoveTo( 1799, 4, 0 );
			debug_cube_transform = btTransform.Identity;

		}
예제 #17
0
		internal VoxelTypeManager()
		{
			GameEnv = null;
			LoadedTexturesCount = 0;
			VoxelTable = new VoxelType[65536];
		}
예제 #18
0
		internal abstract void Render( Display display, VoxelGameEnvironment game, VoxelWorld world );
예제 #19
0
		public VoxelSector( VoxelGameEnvironment GameEnv, VoxelWorld world, int x = 0, int y = 0, int z = 0 )
		{
			//Console.WriteLine( "Sectors in memory : " + SectorsInMemory + " at " + x + ","+y+","+z );
			Pos_x = x;
			Pos_y = y;
			Pos_z = z;
			this.world = world;

			ModifTracker.Init( ZVOXELBLOCSIZE_X * ZVOXELBLOCSIZE_Y * ZVOXELBLOCSIZE_Z );
			DefaultInit();

			if( world != null )
			{
				physics = new PhysicsEngine.Sector( GameEnv.Engine, world, this );
			}
		}
예제 #20
0
파일: Screen.cs 프로젝트: d3x0r/Voxelarium
		internal abstract ScreenChoices ProcessScreen( VoxelGameEnvironment GameEnv );
예제 #21
0
		internal ScreenMain(VoxelGameEnvironment.Pages page_id ) : base( page_id )
		{
		}
예제 #22
0
		internal ScreenConnecting( VoxelGameEnvironment.Pages page_id ) : base( page_id )
		{
		}
예제 #23
0
		internal override ScreenChoices ProcessScreen( VoxelGameEnvironment GameEnv )
		{
			ResultCode = ScreenChoices.NONE;
			if( GameEnv.page_up != page_id )
			{
				float screen_x = GameEnv.GuiManager.FirstFrame.Dimensions.Size.X;
				float screen_y = GameEnv.GuiManager.FirstFrame.Dimensions.Size.Y;
				GameEnv.page_up = page_id;
				GameEnv.GuiManager.RemoveAllFrames();

				TitleBackground.SetPosition( 0, 0 );
				TitleBackground.SetSize( screen_x, screen_y );
				TitleBackground.SetTexture( TextureID.MainMenuBackground );
				GameEnv.GuiManager.AddFrame( TitleBackground );

				Title_Size.X = 1.8f; Title_Size.Y = 0.2f;
				Title.SetPosition( ( screen_x - Title_Size.X ) / 2.0f, screen_y - 1 / 5.0f );
				Title.SetSize( Title_Size.X, Title_Size.Y );
				Title.SetTexture( TextureID.TitleBanner );
				TitleBackground.AddFrame( Title );


				Version_Size.X = 0.25f; Version_Size.Y = 0.010f;
				Frame_Version.SetPosition( screen_x - Version_Size.X, Version_Size.Y );
				Frame_Version.SetSize( SclX( 53.0f * 8.0f + 1.0f ), SclY( 100.0f ) );
				Frame_Version.SetDisplayText( VoxelGlobalSettings.COMPILEOPTION_VERSIONSTRING );
				Frame_Version.TextureNum = TextureID.OldFont;
				Frame_Version.Font = GameEnv.default_font;// SetStyle( GameEnv.TileSetStyles.GetStyle( 0 ) );
				Frame_Version.FontSize = ( 2.0f / 60 );
				TitleBackground.AddFrame( Frame_Version );


				Frame_PlayGame.Text = "Play Game";
				Frame_PlayGame.Font = GameEnv.menu_font;// .SetStyle( GameEnv.TileSetStyles.GetStyle( 1 ) );
				Frame_PlayGame.FontSize = ( 2.0f / 10 );
				Frame_PlayGame.GetTextDisplaySize( out PlayGame_Size );
				Frame_PlayGame.SetPosition( screen_x / 2.0f - PlayGame_Size.X / 2.0f
											, screen_y *3f/ 4f );
				Frame_PlayGame.SetSize( PlayGame_Size.X + SclX( 128.0f ), PlayGame_Size.Y );
				Frame_PlayGame.TextureNum = TextureID.OldFont;
				TitleBackground.AddFrame( Frame_PlayGame );

				Frame_Options.SetDisplayText( "Options" );
				Frame_Options.Font = GameEnv.menu_font;// .SetStyle( GameEnv.TileSetStyles.GetStyle( 1 ) );
				Frame_Options.FontSize = ( 2.0f / 10 );
				Frame_Options.GetTextDisplaySize( out Options_Size );
				Frame_Options.SetPosition( screen_x / 2.0f - Options_Size.X / 2.0f
									,  screen_y *3f/4f - PlayGame_Size.Y );
				Frame_Options.SetSize( Options_Size.X + 1.0f, Options_Size.Y );
				Frame_Options.TextureNum = TextureID.OldFont;
				TitleBackground.AddFrame( Frame_Options );


				Frame_Quit.SetDisplayText( "Quit" );
				Frame_Quit.Font = GameEnv.menu_font;// .SetStyle( GameEnv.TileSetStyles.GetStyle( 1 ) );
				Frame_Quit.FontSize = ( 2.0f / 10 );
				Frame_Quit.GetTextDisplaySize( out Quit_Size );
				Frame_Quit.SetPosition( screen_x / 2.0f - Quit_Size.X / 2.0f
					,  screen_y * 3f/ 4f - (PlayGame_Size.Y + Options_Size.Y) );
				Frame_Quit.SetSize( Quit_Size.X + 1.0f, Quit_Size.Y );
				Frame_Quit.TextureNum = TextureID.OldFont;

				TitleBackground.AddFrame( Frame_Quit );
				//printf("FrameAdress : %lx\n",(unsigned int)&Frame_PlayGame);
			}
			{
				if( Frame_PlayGame.Is_MouseIn() ) { Frame_PlayGame.SetColor( 0.5f, 0.5f, 1.0f ); }
				if( Frame_PlayGame.Is_MouseOut() ) { Frame_PlayGame.SetColor( 1.0f, 1.0f, 1.0f ); }
				if( Frame_Options.Is_MouseIn() ) { Frame_Options.SetColor( 0.5f, 0.5f, 1.0f ); }
				if( Frame_Options.Is_MouseOut() ) { Frame_Options.SetColor( 1.0f, 1.0f, 1.0f ); }
				if( Frame_Quit.Is_MouseIn() ) { Frame_Quit.SetColor( 0.5f, 0.5f, 1.0f ); }
				if( Frame_Quit.Is_MouseOut() ) { Frame_Quit.SetColor( 1.0f, 1.0f, 1.0f ); }
				if( Frame_PlayGame.Is_MouseClick() ) { ResultCode = ScreenChoices.PLAYGAME; }
				if( Frame_Options.Is_MouseClick() ) { ResultCode = ScreenChoices.OPTIONS; }
				if( Frame_Quit.Is_MouseClick() ) { ResultCode = ScreenChoices.QUIT; }
			}

			return ( ResultCode );
		}
예제 #24
0
        internal NetworkSectorLoader( VoxelGameEnvironment game, ClientConnection connection )
		{
			this.game = game;
		}
예제 #25
0
		internal ScreenSelectServer( VoxelGameEnvironment.Pages page_id ) : base( page_id )
		{
		}