• R/O
  • SSH
  • HTTPS

vima19: Commit


Commit MetaInfo

Revision2069 (tree)
Time2023-03-20 00:40:03
Authorhgtterry

Log Message

GameDirectorSB 19-03-23 [v1.24] World_Viewer For World_Editor Loader

Change Summary

Incremental Difference

--- World_Viewer/World_Viewer/WV_Loader.cpp (revision 2068)
+++ World_Viewer/World_Viewer/WV_Loader.cpp (revision 2069)
@@ -25,11 +25,15 @@
2525 #include "WV_App.h"
2626 #include "WV_Loader.h"
2727
28+#include "RAM.h"
29+
2830 WV_Loader::WV_Loader(void)
2931 {
3032 FileName[0] = 0;
3133 Path_FileName[0] = 0;
3234 szSelectedDir[0] = 0;
35+
36+ NameCount = 0;
3337 }
3438
3539 WV_Loader::~WV_Loader(void)
@@ -89,11 +93,11 @@
8993
9094 // App->CL_Model->Model_Type = Enums::LoadedFile_Assimp;
9195
92- /*App->CL_Export_Ogre3D->Export_As_RF = 1;
96+ //App->CL_Export_Ogre3D->Export_As_RF = 1;
9397
94- App->CL_Equity_SB->LoadTextures_TXL();
98+ LoadTextures_TXL();
9599
96- App->CL_Import->Set_Equity();
100+ /*App->CL_Import->Set_Equity();
97101
98102 App->CL_Equity_SB->Adjust();
99103
@@ -106,6 +110,303 @@
106110 }
107111
108112 // *************************************************************************
113+// * LoadTextures_TXL Terry Flanigan *
114+// *************************************************************************
115+bool WV_Loader::LoadTextures_TXL()
116+{
117+ geVFile* VFS = NULL;
118+ geVFile_Finder* Finder = NULL;
119+ geVFile_Finder* FinderCount = NULL;
120+
121+ NameCount = 0;
122+
123+ VFS = geVFile_OpenNewSystem(NULL, GE_VFILE_TYPE_VIRTUAL, Txl_Path_FileName, NULL, GE_VFILE_OPEN_READONLY | GE_VFILE_OPEN_DIRECTORY);
124+ if (!VFS)
125+ {
126+ App->Say("Could not open file");
127+ return 0;
128+ }
129+
130+ FinderCount = geVFile_CreateFinder(VFS, "*.*");
131+ if (!FinderCount)
132+ {
133+ App->Say("Could not load textures from");
134+ geVFile_Close(VFS);
135+ return 0;
136+ }
137+
138+ while (geVFile_FinderGetNextFile(FinderCount) != GE_FALSE)
139+ {
140+
141+
142+ }
143+
144+ Finder = geVFile_CreateFinder(VFS, "*.*");
145+ if (!Finder)
146+ {
147+ App->Say("Could not load textures from 2 ");
148+ geVFile_Close(VFS);
149+ return 0;
150+ }
151+
152+ BitMap_Names.resize(100);
153+
154+ while (geVFile_FinderGetNextFile(Finder) != GE_FALSE)
155+ {
156+ geVFile_Properties Properties;
157+
158+ geVFile_FinderGetProperties(Finder, &Properties);
159+
160+ strcpy(BitMap_Names[NameCount].Name, Properties.Name);
161+
162+ NameCount++;
163+ }
164+
165+ Copy_Texture_Names();
166+
167+ Check_for_Textures(VFS);
168+
169+ geVFile_Close(VFS);
170+
171+ return 1;
172+}
173+
174+
175+// *************************************************************************
176+// * Copy_Texture_Names Terry Bernie *
177+// *************************************************************************
178+void WV_Loader::Copy_Texture_Names()
179+{
180+ int Count = 0;
181+ int GroupCount = App->CL_Model->GroupCount;
182+
183+ while (Count < GroupCount)
184+ {
185+ strcpy(App->CL_Model->Group[Count]->Text_FileName, App->CL_Model->Group[Count]->Equity_Text_FileName);
186+
187+ Count++;
188+ }
189+}
190+
191+// *************************************************************************
192+// * Check_for_Textures Terry Bernie *
193+// *************************************************************************
194+int WV_Loader::Check_for_Textures(geVFile* BaseFile)
195+{
196+ int Count = 0;
197+ int GroupCount = App->CL_Model->GroupCount;
198+
199+ char JustName[255];
200+
201+ while (Count < GroupCount)
202+ {
203+ strcpy(JustName, App->CL_Model->Group[Count]->Equity_Text_FileName);
204+ int Len = strlen(JustName);
205+ JustName[Len - 4] = 0;
206+
207+ bool test = Check_in_Txl(JustName);
208+
209+ if (test == 1)
210+ {
211+ if (!AddTexture(BaseFile, JustName, Count))
212+ {
213+ App->Say("Error");
214+ return 0;
215+ }
216+ }
217+ else
218+ {
219+ App->Say("unMatched");
220+ App->Say(JustName);
221+ }
222+
223+ Count++;
224+ }
225+
226+ return -1;
227+}
228+
229+// *************************************************************************
230+// * AddTexture 06/06/08 *
231+// *************************************************************************
232+bool WV_Loader::AddTexture(geVFile* BaseFile, const char* Path, int GroupIndex)
233+{
234+
235+ geBitmap* Bitmap;
236+
237+ geVFile* File;
238+ char FileName[_MAX_FNAME];
239+ char* Name;
240+
241+ Bitmap = NULL;
242+ File = NULL;
243+
244+ _splitpath(Path, NULL, NULL, FileName, NULL);
245+ Name = _strdup(FileName);
246+ if (!Name)
247+ {
248+ App->Say_Win("Memory allocation error processing %s");
249+ return FALSE;
250+ }
251+
252+ if (BaseFile)
253+ File = geVFile_Open(BaseFile, Path, GE_VFILE_OPEN_READONLY);
254+ else
255+ File = geVFile_OpenNewSystem(NULL, GE_VFILE_TYPE_DOS, Path, NULL, GE_VFILE_OPEN_READONLY);
256+
257+ if (!File)
258+ {
259+ //NonFatalError("Could not open %s", Path);
260+ App->Say_Win("Could not open %s");
261+ return TRUE;
262+ }
263+
264+
265+ Bitmap = geBitmap_CreateFromFile(File);
266+
267+ if (geBitmap_HasAlpha(Bitmap))
268+ {
269+ App->CL_Model->Group[GroupIndex]->RF_Bitmap = Bitmap;
270+ }
271+
272+
273+ HWND PreviewWnd;
274+ HBITMAP hbm;
275+ HDC hDC;
276+
277+ //PreviewWnd = GetDlgItem(App->CL_Groups->RightGroups_Hwnd, IDC_BASETEXTURE2);
278+ hDC = NULL;// GetDC(PreviewWnd);
279+ hbm = CreateHBitmapFromgeBitmap(Bitmap, hDC);
280+
281+ App->CL_Model->Group[GroupIndex]->Base_Bitmap = hbm;
282+
283+ //char TempTextureFile_BMP[1024];
284+ //strcpy(TempTextureFile_BMP, App->EquityDirecory_FullPath);
285+ //strcat(TempTextureFile_BMP, "\\");
286+ //strcat(TempTextureFile_BMP, "TextureLoad.bmp");
287+
288+ //App->CL_Textures->Genesis_WriteToBmp(Bitmap, TempTextureFile_BMP);
289+
290+ //App->CL_Textures->Soil_Load_Texture(App->CL_Ogre->RenderListener->g_Texture, TempTextureFile_BMP, GroupIndex);
291+
292+ geVFile_Close(File);
293+
294+ //DeleteFile((LPCTSTR)TempTextureFile_BMP);
295+
296+ return TRUE;
297+}
298+
299+// *************************************************************************
300+// * CreateHBitmapFromgeBitmap 06/06/08 *
301+// *************************************************************************
302+HBITMAP WV_Loader::CreateHBitmapFromgeBitmap(geBitmap* Bitmap, HDC hdc)
303+{
304+ geBitmap* Lock;
305+ gePixelFormat Format;
306+ geBitmap_Info info;
307+ HBITMAP hbm = NULL;
308+
309+ // <> choose format to be 8,16,or 24, whichever is closest to Bitmap
310+ Format = GE_PIXELFORMAT_24BIT_BGR;
311+
312+ if (geBitmap_GetBits(Bitmap))
313+ {
314+ Lock = Bitmap;
315+ }
316+ else
317+ {
318+ if (!geBitmap_LockForRead(Bitmap, &Lock, 0, 0, Format, GE_FALSE, 0))
319+ {
320+ return NULL;
321+ }
322+ }
323+
324+ geBitmap_GetInfo(Lock, &info, NULL);
325+
326+ if (info.Format != Format)
327+ return NULL;
328+
329+ {
330+ void* bits;
331+ BITMAPINFOHEADER bmih;
332+ int pelbytes;
333+
334+ pelbytes = gePixelFormat_BytesPerPel(Format);
335+ bits = geBitmap_GetBits(Lock);
336+
337+ bmih.biSize = sizeof(bmih);
338+ bmih.biHeight = -info.Height;
339+ bmih.biPlanes = 1;
340+ bmih.biBitCount = 24;
341+ bmih.biCompression = BI_RGB;
342+ bmih.biSizeImage = 0;
343+ bmih.biXPelsPerMeter = bmih.biYPelsPerMeter = 10000;
344+ bmih.biClrUsed = bmih.biClrImportant = 0;
345+
346+ if ((info.Stride * pelbytes) == (((info.Stride * pelbytes) + 3) & (~3)))
347+ {
348+ bmih.biWidth = info.Stride;
349+ hbm = CreateDIBitmap(hdc, &bmih, CBM_INIT, bits, (BITMAPINFO*)&bmih, DIB_RGB_COLORS);
350+ }
351+ else
352+ {
353+ void* newbits;
354+ int Stride;
355+
356+ bmih.biWidth = info.Width;
357+ Stride = (((info.Width * pelbytes) + 3) & (~3));
358+ newbits = geRam_Allocate(Stride * info.Height);
359+ if (newbits)
360+ {
361+ char* newptr, * oldptr;
362+ int y;
363+
364+ newptr = (char*)newbits;
365+ oldptr = (char*)bits;
366+ for (y = 0; y < info.Height; y++)
367+ {
368+ memcpy(newptr, oldptr, (info.Width) * pelbytes);
369+ oldptr += info.Stride * pelbytes;
370+ newptr += Stride;
371+ }
372+ hbm = CreateDIBitmap(hdc, &bmih, CBM_INIT, newbits, (BITMAPINFO*)&bmih, DIB_RGB_COLORS);
373+ geRam_Free(newbits);
374+ }
375+ }
376+ }
377+
378+ if (Lock != Bitmap)
379+ {
380+ geBitmap_UnLock(Lock);
381+ }
382+
383+ return hbm;
384+}
385+
386+// *************************************************************************
387+// * Check_in_Txl Terry Bernie *
388+// *************************************************************************
389+bool WV_Loader::Check_in_Txl(char* FileName)
390+{
391+ int loop = 0;
392+ int TxlNameCount = NameCount;
393+
394+ while (loop < TxlNameCount)
395+ {
396+ int Result = 1;
397+ Result = strcmp(FileName, BitMap_Names[loop].Name);
398+ if (Result == 0)
399+ {
400+ return 1;
401+ }
402+
403+ loop++;
404+ }
405+
406+ return 0;
407+}
408+
409+// *************************************************************************
109410 // * OpenFile:- Terry and Hazel Flanigan 2023 *
110411 // *************************************************************************
111412 bool WV_Loader::Open_File_Model(const char* Extension, const char* Title, const char* StartDirectory)
--- World_Viewer/World_Viewer/WV_Loader.h (revision 2068)
+++ World_Viewer/World_Viewer/WV_Loader.h (revision 2069)
@@ -23,6 +23,8 @@
2323 distribution.
2424 */
2525
26+typedef struct Char_type2 { char Name[256]; }Char_type2;
27+
2628 class WV_Loader
2729 {
2830 public:
@@ -47,6 +49,17 @@
4749
4850 protected:
4951
52+ bool LoadTextures_TXL();
53+ void Copy_Texture_Names();
54+ int Check_for_Textures(geVFile* BaseFile);
55+ bool Check_in_Txl(char* FileName);
56+ bool AddTexture(geVFile* BaseFile, const char* Path, int GroupIndex);
57+ HBITMAP CreateHBitmapFromgeBitmap(geBitmap* Bitmap, HDC hdc);
58+
59+ int NameCount;
60+
61+ std::vector<Char_type2> BitMap_Names;
62+
5063 OPENFILENAME ofn;
5164 };
5265
Show on old repository browser