• R/O
  • SSH
  • HTTPS

vima19: Commit


Commit MetaInfo

Revision2068 (tree)
Time2023-03-20 00:21:05
Authorhgtterry

Log Message

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

Change Summary

Incremental Difference

--- World_Viewer/World_Viewer/Base_Group.cpp (revision 2067)
+++ World_Viewer/World_Viewer/Base_Group.cpp (revision 2068)
@@ -24,7 +24,6 @@
2424 #include "stdafx.h"
2525 #include "Base_Group.h"
2626
27-
2827 Base_Group::Base_Group()
2928 {
3029 GroupName[0] = 0;
@@ -45,6 +44,7 @@
4544 Soil_TextureIndex = 0;
4645
4746 Base_Bitmap = NULL;
47+ RF_Bitmap = NULL;
4848 ListView_Item = NULL;
4949 }
5050
--- World_Viewer/World_Viewer/Base_Group.h (revision 2067)
+++ World_Viewer/World_Viewer/Base_Group.h (revision 2068)
@@ -74,6 +74,7 @@
7474 int BoneAssignMentCount; // Ogre
7575
7676 HBITMAP Base_Bitmap;
77+ geBitmap* RF_Bitmap;
7778
7879 HTREEITEM ListView_Item;
7980 };
--- World_Viewer/World_Viewer/WV_Export_Ogre3D.cpp (revision 2067)
+++ World_Viewer/World_Viewer/WV_Export_Ogre3D.cpp (revision 2068)
@@ -15,6 +15,14 @@
1515
1616 #include "WV_Export_Ogre3D.h"
1717
18+#include "il.h"
19+#include "ilu.h"
20+#include "ilut.h"
21+
22+#include "bitmap.h"
23+#include "bitmap._h"
24+#include "bitmap.__h"
25+
1826 #pragma warning( disable : 4101)
1927
2028 WV_Export_Ogre::WV_Export_Ogre()
@@ -70,13 +78,6 @@
7078 strcpy(Directory_Name, App->CL_Model->JustName);
7179 strcat(Directory_Name, "_Ogre");
7280
73- strcpy(App->CL_Loader->BrowserMessage, "Select Folder To Place Ogre Files a sub folder will be created");
74- /*int Test = App->CL_FileIO->StartBrowser(App->CL_Model->Model_FolderPath);
75- if (Test == 0) { return 1; }*/
76-
77- /*App->CL_Export->Start_Export_Dlg();
78- if (App->CL_Export->Is_Canceled == 1) { return 1; }*/
79-
8081 strcpy(App->CL_Loader->szSelectedDir, App->CL_Model->Model_FolderPath);
8182
8283 App->CL_PB->StartNewProgressBar();
@@ -94,8 +95,6 @@
9495 strcpy(mOgreSkellFileName, App->CL_Model->JustName);
9596 strcpy(mOgreSkellTagName, App->CL_Model->JustName);
9697
97-
98-
9998 strcat(mOgreMeshFileName, ".mesh");
10099 strcat(mOgreScriptFileName, ".material");
101100 strcat(mOgreSkellFileName, ".skeleton");
@@ -643,74 +642,6 @@
643642 }
644643
645644 // *************************************************************************
646-// * DecompileTextures:- Terry and Hazel Flanigan 2023 *
647-// *************************************************************************
648-bool WV_Export_Ogre::DecompileTextures(void)
649-{
650- //int MatCount = App->CL_Model->GroupCount;
651-
652- //char FileName[255];
653-
654- //int Loop = 0;
655- //while (Loop<MatCount)
656- //{
657- // strcpy(FileName, App->CL_Model->Group[Loop]->Text_FileName);
658-
659- // HBITMAP Data;
660-
661- // Data = App->CL_Model->Group[Loop]->Base_Bitmap;
662-
663- // if (_stricmp(FileName + strlen(FileName) - 4, ".tga") == 0)
664- // {
665- //
666- // char mDirectory[MAX_PATH];
667- // _getcwd(mDirectory, MAX_PATH);
668- // strcat(mDirectory, "\\");
669- // strcat(mDirectory, FileName);
670- //
671- // App->CL_Texture_Lib->WriteTGA(mDirectory, App->CL_Model->Group[Loop]->RF_Bitmap);
672-
673- // //int Len = strlen(FileName);
674- // //FileName[Len - 4] = 0;
675- // //strcat(FileName, ".jpg");
676- // //
677- // //App->CL_Textures->HBITMAP_TO_BmpFile(Data, FileName, "");
678- // //geBitmap* Bitmap = geBitmap_CreateFromFile(FileName);
679- //
680- // //App->CL_Textures->Jpg_To_Tga24(FileName);
681-
682- // }
683- // else if (_stricmp(FileName + strlen(FileName) - 4, ".png") == 0)
684- // {
685- // int Len = strlen(FileName);
686- // FileName[Len - 4] = 0;
687- // strcat(FileName, ".jpg");
688-
689- // App->CL_Textures->HBITMAP_TO_BmpFile(Data, FileName, "");
690- // App->CL_Textures->Jpg_To_png24(FileName);
691- // }
692- // else if (_stricmp(FileName + strlen(FileName) - 4, ".jpg") == 0)
693- // {
694- // int Len = strlen(FileName);
695- // FileName[Len - 4] = 0;
696- // strcat(FileName, ".bmp");
697-
698- // App->CL_Textures->HBITMAP_TO_BmpFile(Data, FileName, "");
699- // App->CL_Textures->Bmp_To_Jpg(FileName);
700- // }
701- // else
702- // {
703-
704- // App->CL_Textures->HBITMAP_TO_BmpFile(Data, FileName, "");
705- // }
706-
707- // Loop++;
708- //}
709-
710- return 1;
711-}
712-
713-// *************************************************************************
714645 // * CreateMaterialFile:- Terry and Hazel Flanigan 2023 *
715646 // *************************************************************************
716647 void WV_Export_Ogre::CreateMaterialFile(char* MatFileName)
@@ -1015,3 +946,362 @@
1015946
1016947 return 1;
1017948 }
949+
950+// *************************************************************************
951+// * DecompileTextures:- Terry and Hazel Flanigan 2023 *
952+// *************************************************************************
953+bool WV_Export_Ogre::DecompileTextures(void)
954+{
955+ int MatCount = App->CL_Model->GroupCount;
956+
957+ char FileName[255];
958+
959+ int Loop = 0;
960+ while (Loop < MatCount)
961+ {
962+ strcpy(FileName, App->CL_Model->Group[Loop]->Text_FileName);
963+
964+ HBITMAP Data;
965+
966+ Data = App->CL_Model->Group[Loop]->Base_Bitmap;
967+
968+ if (_stricmp(FileName + strlen(FileName) - 4, ".tga") == 0)
969+ {
970+
971+ char mDirectory[MAX_PATH];
972+ _getcwd(mDirectory, MAX_PATH);
973+ strcat(mDirectory, "\\");
974+ strcat(mDirectory, FileName);
975+
976+ WriteTGA(mDirectory, App->CL_Model->Group[Loop]->RF_Bitmap);
977+ }
978+ else if (_stricmp(FileName + strlen(FileName) - 4, ".png") == 0)
979+ {
980+ int Len = strlen(FileName);
981+ FileName[Len - 4] = 0;
982+ strcat(FileName, ".jpg");
983+
984+ HBITMAP_TO_BmpFile(Data, FileName, "");
985+ Jpg_To_png24(FileName);
986+ }
987+ else if (_stricmp(FileName + strlen(FileName) - 4, ".jpg") == 0)
988+ {
989+ int Len = strlen(FileName);
990+ FileName[Len - 4] = 0;
991+ strcat(FileName, ".bmp");
992+
993+ HBITMAP_TO_BmpFile(Data, FileName, "");
994+ Bmp_To_Jpg(FileName);
995+ }
996+ else
997+ {
998+
999+ HBITMAP_TO_BmpFile(Data, FileName, "");
1000+ }
1001+
1002+ Loop++;
1003+ }
1004+
1005+ return 1;
1006+}
1007+
1008+// *************************************************************************
1009+// * Jpg_To_png24 *
1010+// *************************************************************************
1011+bool WV_Export_Ogre::Jpg_To_png24(char* File)
1012+{
1013+ char OldFile[1024];
1014+ strcpy(OldFile, File);
1015+
1016+ ilLoadImage(File);
1017+
1018+ int Len = strlen(File);
1019+ File[Len - 4] = 0;
1020+ strcat(File, ".png");
1021+
1022+ ilSaveImage(File);
1023+
1024+ remove(OldFile);
1025+ return 1;
1026+}
1027+
1028+// *************************************************************************
1029+// * Bmp_To_Jpg *
1030+// *************************************************************************
1031+bool WV_Export_Ogre::Bmp_To_Jpg(char* File)
1032+{
1033+ char OldFile[1024];
1034+ strcpy(OldFile, File);
1035+
1036+ bool test = ilLoadImage(File);
1037+ if (test == 0)
1038+ {
1039+ App->Say("Failed to load Texture Bmp_To_Jpg");
1040+ }
1041+
1042+ int Len = strlen(File);
1043+ File[Len - 4] = 0;
1044+ strcat(File, ".jpg");
1045+
1046+ ilSaveImage(File);
1047+
1048+ remove(OldFile);
1049+ return 1;
1050+}
1051+
1052+// *************************************************************************
1053+// * HBITMAP_TO_BmpFile *
1054+// *************************************************************************
1055+bool WV_Export_Ogre::HBITMAP_TO_BmpFile(HBITMAP Bitmap, char* Filename, char* SaveFolder)
1056+{
1057+ HDC hDC;
1058+ int iBits;
1059+ WORD wBitCount;
1060+ DWORD dwPaletteSize = 0, dwBmBitsSize = 0, dwDIBSize = 0, dwWritten = 0;
1061+ BITMAP Bitmap0;
1062+ BITMAPFILEHEADER bmfHdr;
1063+ BITMAPINFOHEADER bi;
1064+ LPBITMAPINFOHEADER lpbi;
1065+ HANDLE fh, hDib, hPal, hOldPal2 = NULL;
1066+ hDC = CreateDC(TEXT("DISPLAY"), NULL, NULL, NULL);
1067+ iBits = GetDeviceCaps(hDC, BITSPIXEL) * GetDeviceCaps(hDC, PLANES);
1068+ DeleteDC(hDC);
1069+ if (iBits <= 1)
1070+ wBitCount = 1;
1071+ else if (iBits <= 4)
1072+ wBitCount = 4;
1073+ else if (iBits <= 8)
1074+ wBitCount = 8;
1075+ else
1076+ wBitCount = 24;
1077+ GetObject(Bitmap, sizeof(Bitmap0), (LPSTR)&Bitmap0);
1078+ bi.biSize = sizeof(BITMAPINFOHEADER);
1079+ bi.biWidth = Bitmap0.bmWidth;
1080+ bi.biHeight = -Bitmap0.bmHeight;
1081+ bi.biPlanes = 1;
1082+ bi.biBitCount = wBitCount;
1083+ bi.biCompression = BI_RGB;
1084+ bi.biSizeImage = 0;
1085+ bi.biXPelsPerMeter = 0;
1086+ bi.biYPelsPerMeter = 0;
1087+ bi.biClrImportant = 0;
1088+ bi.biClrUsed = 256;
1089+ dwBmBitsSize = ((Bitmap0.bmWidth * wBitCount + 31) & ~31) / 8
1090+ * Bitmap0.bmHeight;
1091+ hDib = GlobalAlloc(GHND, dwBmBitsSize + dwPaletteSize + sizeof(BITMAPINFOHEADER));
1092+ lpbi = (LPBITMAPINFOHEADER)GlobalLock(hDib);
1093+ *lpbi = bi;
1094+
1095+ hPal = GetStockObject(DEFAULT_PALETTE);
1096+ if (hPal)
1097+ {
1098+ hDC = GetDC(NULL);
1099+ hOldPal2 = SelectPalette(hDC, (HPALETTE)hPal, FALSE);
1100+ RealizePalette(hDC);
1101+ }
1102+
1103+
1104+ GetDIBits(hDC, Bitmap, 0, (UINT)Bitmap0.bmHeight, (LPSTR)lpbi + sizeof(BITMAPINFOHEADER)
1105+ + dwPaletteSize, (BITMAPINFO*)lpbi, DIB_RGB_COLORS);
1106+
1107+ if (hOldPal2)
1108+ {
1109+ SelectPalette(hDC, (HPALETTE)hOldPal2, TRUE);
1110+ RealizePalette(hDC);
1111+ ReleaseDC(NULL, hDC);
1112+ }
1113+
1114+ fh = CreateFile(Filename, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS,
1115+ FILE_ATTRIBUTE_NORMAL | FILE_FLAG_SEQUENTIAL_SCAN, NULL);
1116+
1117+ if (fh == INVALID_HANDLE_VALUE)
1118+ return FALSE;
1119+
1120+ bmfHdr.bfType = 0x4D42; // "BM"
1121+ dwDIBSize = sizeof(BITMAPFILEHEADER) + sizeof(BITMAPINFOHEADER) + dwPaletteSize + dwBmBitsSize;
1122+ bmfHdr.bfSize = dwDIBSize;
1123+ bmfHdr.bfReserved1 = 0;
1124+ bmfHdr.bfReserved2 = 0;
1125+ bmfHdr.bfOffBits = (DWORD)sizeof(BITMAPFILEHEADER) + (DWORD)sizeof(BITMAPINFOHEADER) + dwPaletteSize;
1126+
1127+ WriteFile(fh, (LPSTR)&bmfHdr, sizeof(BITMAPFILEHEADER), &dwWritten, NULL);
1128+
1129+ WriteFile(fh, (LPSTR)lpbi, dwDIBSize, &dwWritten, NULL);
1130+ GlobalUnlock(hDib);
1131+ GlobalFree(hDib);
1132+ CloseHandle(fh);
1133+
1134+ return 1;
1135+}
1136+
1137+// *************************************************************************
1138+// * WriteTGA:- Terry and Hazel Flanigan 2023 *
1139+// *************************************************************************
1140+int WV_Export_Ogre::WriteTGA(const char* pszFile, geBitmap* pBitmap)
1141+{
1142+ geBitmap* pLock = NULL;
1143+ geBitmap* pLockA = NULL;
1144+ gePixelFormat Format;
1145+ gePixelFormat FormatA;
1146+ geBitmap_Info BitmapInfo;
1147+ int nErrorCode = TPACKERROR_UNKNOWN; // Return code
1148+ TGAHEADER tgah;
1149+ long footer = 0;
1150+ char signature[18] = "TRUEVISION-XFILE.";
1151+
1152+ uint8* pPixelData;
1153+ uint8* pPixelDataA;
1154+
1155+ int i, j;
1156+ HANDLE hFile = NULL;
1157+ DWORD nBytesWritten;
1158+
1159+ // Create the .TGA file.
1160+ hFile = CreateFile(pszFile,
1161+ GENERIC_READ | GENERIC_WRITE,
1162+ (DWORD)0,
1163+ NULL,
1164+ CREATE_ALWAYS,
1165+ FILE_ATTRIBUTE_NORMAL,
1166+ (HANDLE)NULL);
1167+
1168+ if (hFile == INVALID_HANDLE_VALUE)
1169+ return TPACKERROR_CREATEFILE;
1170+
1171+ // get 24-bit bitmap
1172+ Format = GE_PIXELFORMAT_24BIT_BGR;
1173+ FormatA = GE_PIXELFORMAT_8BIT_GRAY;
1174+
1175+ if (geBitmap_GetBits(pBitmap))
1176+ {
1177+ pLock = pBitmap;
1178+ }
1179+ else
1180+ {
1181+ if (!geBitmap_LockForRead(pBitmap, &pLock, 0, 0, Format, GE_FALSE, 0))
1182+ {
1183+ return FALSE;
1184+ }
1185+ }
1186+
1187+ if (geBitmap_GetBits(geBitmap_GetAlpha(pBitmap)))
1188+ {
1189+ pLockA = geBitmap_GetAlpha(pBitmap);
1190+ }
1191+ else
1192+ {
1193+ if (!geBitmap_LockForRead(geBitmap_GetAlpha(pBitmap), &pLockA, 0, 0, FormatA, GE_FALSE, 0))
1194+ {
1195+ return FALSE;
1196+ }
1197+ }
1198+
1199+ geBitmap_GetInfo(pLock, &BitmapInfo, NULL);
1200+ if (BitmapInfo.Format != Format)
1201+ {
1202+ nErrorCode = TPACKERROR_UNKNOWN;
1203+ goto ExitWriteBitmap;
1204+ }
1205+
1206+
1207+ tgah.IDLength = 0;
1208+ tgah.ColorMapType = 0;
1209+ tgah.ImageType = 2; // we create an uncompressed, true color image
1210+ tgah.CMFirstEntry = 0;
1211+ tgah.CMLength = 0;
1212+ tgah.CMEntrySize = 0;
1213+ tgah.Xorigin = 0;
1214+ tgah.Yorigin = 0;
1215+
1216+ tgah.Width = (uint16)BitmapInfo.Width;
1217+ tgah.Height = (uint16)BitmapInfo.Height;
1218+
1219+ tgah.PixelDepth = 32;
1220+ tgah.ImageDescriptor = 8; //00001000 - not flipped, 8 alpha bits
1221+
1222+
1223+ pPixelData = (uint8*)geBitmap_GetBits(pLock);
1224+
1225+ pPixelDataA = (uint8*)geBitmap_GetBits(pLockA);
1226+
1227+ // Write the tga header
1228+ if (!WriteFile(hFile, (LPVOID)&tgah, sizeof(TGAHEADER), (LPDWORD)&nBytesWritten, (NULL)))
1229+ {
1230+ nErrorCode = TPACKERROR_WRITE;
1231+ goto ExitWriteBitmap;
1232+ }
1233+
1234+ // write pixels
1235+ pPixelData += 3 * tgah.Width * (tgah.Height - 1);
1236+ pPixelDataA += tgah.Width * (tgah.Height - 1);
1237+ for (i = 0; i < tgah.Height; i++)
1238+ {
1239+ for (j = 0; j < tgah.Width; j++)
1240+ {
1241+ if (!WriteFile(hFile, (LPVOID)pPixelData, 3, (LPDWORD)&nBytesWritten, (NULL)))
1242+ {
1243+ nErrorCode = TPACKERROR_WRITE;
1244+ goto ExitWriteBitmap;
1245+ }
1246+
1247+ pPixelData += 3;
1248+
1249+
1250+ if (!WriteFile(hFile, (LPVOID)pPixelDataA, 1, (LPDWORD)&nBytesWritten, (NULL)))
1251+ {
1252+ nErrorCode = TPACKERROR_WRITE;
1253+ goto ExitWriteBitmap;
1254+ }
1255+ pPixelDataA++;
1256+ }
1257+
1258+ pPixelData -= 2 * 3 * tgah.Width;
1259+ pPixelDataA -= 2 * tgah.Width;
1260+ }
1261+
1262+ // write the signature
1263+ if (!WriteFile(hFile, (LPVOID)&footer, 4, (LPDWORD)&nBytesWritten, (NULL)))
1264+ {
1265+ nErrorCode = TPACKERROR_WRITE;
1266+ goto ExitWriteBitmap;
1267+ }
1268+
1269+ if (!WriteFile(hFile, (LPVOID)&footer, 4, (LPDWORD)&nBytesWritten, (NULL)))
1270+ {
1271+ nErrorCode = TPACKERROR_WRITE;
1272+ goto ExitWriteBitmap;
1273+ }
1274+
1275+ if (!WriteFile(hFile, (LPVOID)signature, 18, (LPDWORD)&nBytesWritten, (NULL)))
1276+ {
1277+ nErrorCode = TPACKERROR_WRITE;
1278+ goto ExitWriteBitmap;
1279+ }
1280+
1281+ CloseHandle(hFile);
1282+ hFile = NULL;
1283+
1284+ // Success!
1285+ nErrorCode = TPACKERROR_OK;
1286+
1287+ExitWriteBitmap:
1288+
1289+ // Clean-up
1290+ //------------------------------------
1291+ // Make sure the file gets closed
1292+ if (hFile)
1293+ CloseHandle(hFile);
1294+
1295+ // Unlock the geBitmap
1296+ if (pLock != pBitmap)
1297+ {
1298+ geBitmap_UnLock(pLock);
1299+ }
1300+
1301+ if (pLockA != geBitmap_GetAlpha(pBitmap))
1302+ {
1303+ geBitmap_UnLock(pLockA);
1304+ }
1305+
1306+ return nErrorCode;
1307+}
--- World_Viewer/World_Viewer/WV_Export_Ogre3D.h (revision 2067)
+++ World_Viewer/World_Viewer/WV_Export_Ogre3D.h (revision 2068)
@@ -12,7 +12,6 @@
1212
1313 using namespace std;
1414 using namespace Ogre;
15-
1615 #define MAX_VERTICES 100000
1716 #define MAX_POLYGONS 100000
1817
@@ -61,6 +60,30 @@
6160 Serializer::Endian endian;
6261 };
6362
63+#define TPACKERROR_OK 0
64+#define TPACKERROR_UNKNOWN (TPACKERROR_OK - 1)
65+#define TPACKERROR_WRITE (TPACKERROR_OK - 2)
66+#define TPACKERROR_MEMORYALLOCATION (TPACKERROR_OK - 3)
67+#define TPACKERROR_CREATEFILE (TPACKERROR_OK - 4)
68+
69+#pragma pack(1)
70+typedef struct TGAHEADER
71+{
72+ char IDLength;
73+ char ColorMapType;
74+ char ImageType;
75+ Ogre::uint16 CMFirstEntry;
76+ Ogre::uint16 CMLength;
77+ char CMEntrySize;
78+ Ogre::uint16 Xorigin;
79+ Ogre::uint16 Yorigin;
80+ Ogre::uint16 Width;
81+ Ogre::uint16 Height;
82+ char PixelDepth;
83+ char ImageDescriptor;
84+} TGAHEADER;
85+#pragma pack()
86+
6487 class WV_Export_Ogre
6588 {
6689 public:
@@ -87,6 +110,11 @@
87110 XmlOptions parseArgs();
88111 void XMLToBinary(XmlOptions opts);
89112
113+ bool HBITMAP_TO_BmpFile(HBITMAP Bitmap, char* Filename, char* SaveFolder);
114+ int WriteTGA(const char* pszFile, geBitmap* pBitmap);
115+ bool Jpg_To_png24(char* File);
116+ bool Bmp_To_Jpg(char* File);
117+
90118 char mDecompileFolder[1024];
91119 char mOgreMeshFileName[255];
92120 char mOgreScriptFileName[255];
--- World_Viewer/World_Viewer/WV_Loader.h (revision 2067)
+++ World_Viewer/World_Viewer/WV_Loader.h (revision 2068)
@@ -43,7 +43,6 @@
4343 char Ogre_Path[MAX_PATH];
4444 char WE_Path_FileName[MAX_PATH];
4545
46- char BrowserMessage[MAX_PATH];
4746 TCHAR szSelectedDir[MAX_PATH];
4847
4948 protected:
--- World_Viewer/World_Viewer/stdafx.h (revision 2067)
+++ World_Viewer/World_Viewer/stdafx.h (revision 2068)
@@ -30,6 +30,7 @@
3030
3131 #define NOMINMAX
3232 #include <windows.h>
33+#include "Genesis.h"
3334 #include "btBulletDynamicsCommon.h"
3435
3536 // C RunTime Header Files
@@ -60,6 +61,8 @@
6061 #include <gl/gl.h>
6162 #include <gl/glu.h>
6263
64+
65+
6366 namespace Enums
6467 {
6568 enum Camera
Show on old repository browser