コード例 #1
0
		/// <summary>
		/// Creating dictionary from file<para/>
		/// Создание архива из существующего файла
		/// </summary>
		/// <param name="tf">TextureFile</param>
		public TextureDictionary(TextureFile tf, bool important = false, bool sendNow = false) {
			
			// If file is not ready - error
			// Если текстурный архив не прочитан - ошибка
			if (sendNow && tf.State != RenderWareFile.LoadState.Complete) {
				throw new Exception("[TextureDictionary] Trying to create texture dictionary from incomplete file");
			}
			
			File = tf;
			Important = important;

			if (sendNow) {
				BuildTextures();
				SendTextures();
			}
		}
コード例 #2
0
ファイル: StaticProxy.cs プロジェクト: clashbyte/openvice
			/// <summary>
			/// Process mesh internals<para/>
			/// Обработка данных меша
			/// </summary>
			public void Process(bool needed) {
				if (needed) {
					if (GroupModel != null) {
						if (GroupTextures != null) {
							if (GroupModel.State == Model.ReadyState.Complete && GroupTextures.State == TextureDictionary.ReadyState.Complete) {
								// Surface is ready to render
								// Поверхность готова к отрисовке
								Ready = true;
								Model.SubMesh[] subs = GroupModel.GetAllSubMeshes();
								Renderers = new StaticRenderer[subs.Length];
								Coords.Position = Coords.Position;
								for (int i = 0; i < Renderers.Length; i++) {
									Renderers[i] = new StaticRenderer() {
										BaseMatrix = Coords.Matrix,
										SubmeshMatrix = subs[i].Parent.Matrix,
										SubMesh = subs[i],
										Textures = GroupTextures,
										Fading = false,
										FadingDelta = 1
									};
								}
							} else {
								// Check for model state
								// Проверка состояния модели
								if (GroupModel.State != Model.ReadyState.Complete) {
									if (GroupModel.File.State == Files.RenderWareFile.LoadState.Complete) {
										if (!ModelManager.IsProcessing(GroupModel)) {
											ModelManager.ModelProcessQueue.Enqueue(GroupModel);
										}
									}
								}
								// Check for texture dictionary state
								// Проверка состояния архива текстур
								if (GroupTextures.State != TextureDictionary.ReadyState.Complete) {
									if (GroupTextures.File.State == Files.RenderWareFile.LoadState.Complete) {
										if (!TextureManager.IsProcessing(GroupTextures)) {
											TextureManager.TextureProcessQueue.Enqueue(GroupTextures);
										}
									}
								}
							}
						} else {
							// Texture not found - get it
							// Текстура не найдена - получаем её
							string tname = ObjectManager.Definitions[Definition.ID].TexDictionary;
							if (TextureManager.Cached.ContainsKey(tname)) {
								GroupTextures = TextureManager.Cached[tname];
							} else {
								TextureFile tf = null;
								if (TextureManager.CachedFiles.ContainsKey(tname)) {
									tf = TextureManager.CachedFiles[tname];
								} else {
									tf = new TextureFile(ArchiveManager.Get(tname + ".txd"), false);
									TextureManager.CachedFiles.TryAdd(tname, tf);
									TextureManager.TextureFileProcessQueue.Enqueue(tf);
								}
								GroupTextures = new TextureDictionary(tf);
								TextureManager.Cached.TryAdd(tname, GroupTextures);
							}
							GroupTextures.UseCount++;
						}
					} else {
						// Model not found - get it
						// Модель не найдена - получаем её
						string mname = ObjectManager.Definitions[Definition.ID].ModelName;
						if (ModelManager.Cached.ContainsKey(mname)) {
							GroupModel = ModelManager.Cached[mname];
						} else {
							ModelFile mf = null;
							if (ModelManager.CachedFiles.ContainsKey(mname)) {
								mf = ModelManager.CachedFiles[mname];
							} else {
								mf = new ModelFile(ArchiveManager.Get(mname + ".dff"), false);
								ModelManager.CachedFiles.TryAdd(mname, mf);
								ModelManager.ModelFileProcessQueue.Enqueue(mf);
							}
							GroupModel = new Model(mf);
							ModelManager.Cached.TryAdd(mname, GroupModel);
						}
						GroupModel.UseCount++;
					}
				} else {
					// Cleaning all the usings
					// Очистка использований
					if (GroupModel != null) {
						if (!GroupModel.Important) {
							GroupModel.UseCount--;
						}
						GroupModel = null;
					}
					if (GroupTextures != null) {
						if (!GroupTextures.Important) {
							GroupTextures.UseCount--;
						}
						GroupTextures = null;
					}
					if (Renderers!=null) {
						Renderers = null;
					}
					Ready = false;
				}
			}
コード例 #3
0
ファイル: TextureManager.cs プロジェクト: clashbyte/openvice
		/// <summary>
		/// Initialize predefined textures<para/>
		/// Инициализация предзаданных текстур
		/// </summary>
		public static void Init() {
			
			// Checking for extensions
			// Проверка расширений
			CompressionSupported = GLExtensions.Supported("GL_EXT_Texture_Compression_S3TC");
			FrameBufferSupported = GLExtensions.Supported("GL_ARB_Framebuffer_Object");

			// Load DAT-defined texture dictionaries
			// Загрузка предопределенных архивов текстур
			foreach (string TXD in FileManager.TextureFiles) {
				string name = Path.GetFileNameWithoutExtension(TXD).ToLower();
				string path = PathManager.GetAbsolute(TXD);
				TextureFile f = new TextureFile(path, true);
				CachedFiles.TryAdd(name, f);
				TextureDictionary td = new TextureDictionary(f, true, true);
				Cached.TryAdd(name, td);
			}

			// Starting TextureFile thread
			// Запуск потока чтения TextureFile
			fileReaderThread = new Thread(FileLoaderProcess);
			fileReaderThread.IsBackground = true;
			fileReaderThread.Priority = ThreadPriority.BelowNormal;
			fileReaderThread.Start();

			// Starting model builder thread
			// Запуск потока постройки Model
			textureBuilderThread = new Thread(TextureBuilderProcess);
			textureBuilderThread.IsBackground = true;
			textureBuilderThread.Priority = ThreadPriority.BelowNormal;
			textureBuilderThread.Start();
		}