/[Sims3RigEditor]/trunk/gr2lib_cpp/gr2lib_rigeditor_frm.h
ViewVC logotype

Diff of /trunk/gr2lib_cpp/gr2lib_rigeditor_frm.h

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

--- trunk/gr2lib_cpp/gr2lib_rigeditor_frm.h	2010/08/01 06:33:06	22
+++ trunk/gr2lib_cpp/gr2lib_rigeditor_frm.h	2010/08/02 02:24:50	23
@@ -1,4 +1,7 @@
 #define SHOW_DEBUG_MENU // if defined, will show the debug menu -> else it will not be shown
+
+#define granny_pixel_layout_bitshift_size 4
+
 #pragma once
 //#include "gr2lib_core.h"
 //#include "gr2lib_core_imports.h"
@@ -276,6 +279,7 @@
 
 	}
 #pragma endregion
+
 #pragma region MarshalToMananaged
 	//ArtToolInfo^ _ArtToolInfo;
 	//ExporterInfo^ _ExporterInfo;
@@ -297,6 +301,8 @@
 		ArtToolInfo_ToNative();
 		// Exporter Info
 		ExporterInfo_ToNative();
+		// Texture List
+		Textures_ToNative();
 	}
 #pragma endregion
 
@@ -382,7 +388,7 @@
 					(gr2lib::core::typedefs::granny_pixel_layout)toolinfo[i]->SubFormat);
 				t->Layout = gcnew gr2lib::core::coretypes::implementation::Layout();
 					t->Layout->BytesPerPixel = toolinfo[i]->Layout.BytesPerPixel;
-					for(int j=0;j<4;j++)
+					for(int j=0;j<granny_pixel_layout_bitshift_size;j++)
 					{
 						t->Layout->ShiftForComponent[j] =  toolinfo[i]->Layout.ShiftForComponent[j];
 						t->Layout->BitsForComponent[j] =  toolinfo[i]->Layout.BitsForComponent[j];
@@ -479,16 +485,56 @@
 #pragma region Textures_ToNative
 	void Textures_ToNative()
 	{
-		if (_grn_file->GrannyFileInfo->Textures == NULL)
+		_grn_file->GrannyFileInfo->Textures = (granny_texture**)malloc(GR2LibPropertyWrapper->Textures->Count);
+		for(int i=0;i<GR2LibPropertyWrapper->Textures->Count;i++) { _grn_file->GrannyFileInfo->Textures[i] = new granny_texture(); }
+
+		_grn_file->GrannyFileInfo->TextureCount = GR2LibPropertyWrapper->Textures->Count;
+		for(int i=0;i<_grn_file->GrannyFileInfo->TextureCount;i++)
 		{
-			_grn_file->GrannyFileInfo->Textures = new granny_texture*();
+			_grn_file->GrannyFileInfo->Textures[i]->FromFileName = (char*)Marshal::StringToHGlobalAnsi(GR2LibPropertyWrapper->Textures[i]->FromFileName->FullPath).ToPointer();
+			_grn_file->GrannyFileInfo->Textures[i]->TextureType = (granny_int32)GR2LibPropertyWrapper->Textures[i]->TextureType->Value;
+			_grn_file->GrannyFileInfo->Textures[i]->Width = GR2LibPropertyWrapper->Textures[i]->Width;
+			_grn_file->GrannyFileInfo->Textures[i]->Height = GR2LibPropertyWrapper->Textures[i]->Height;
+			_grn_file->GrannyFileInfo->Textures[i]->Encoding = (granny_int32)GR2LibPropertyWrapper->Textures[i]->Encoding->Value;
+			_grn_file->GrannyFileInfo->Textures[i]->SubFormat = (granny_int32)GR2LibPropertyWrapper->Textures[i]->SubFormat->Value;
+			_grn_file->GrannyFileInfo->Textures[i]->Layout.BytesPerPixel =  (granny_int32)GR2LibPropertyWrapper->Textures[i]->Layout->BytesPerPixel;
+			for(int j=0;j<granny_pixel_layout_bitshift_size;j++)
+			{
+				_grn_file->GrannyFileInfo->Textures[i]->Layout.ShiftForComponent[j] = GR2LibPropertyWrapper->Textures[i]->Layout->ShiftForComponent[j];
+				_grn_file->GrannyFileInfo->Textures[i]->Layout.BitsForComponent[j] = GR2LibPropertyWrapper->Textures[i]->Layout->BitsForComponent[j];
+			}
+
+			_grn_file->GrannyFileInfo->Textures[i]->ImageCount = GR2LibPropertyWrapper->Textures[i]->Images->Count;
+			_grn_file->GrannyFileInfo->Textures[i]->Images = (granny_texture_image*)malloc(_grn_file->GrannyFileInfo->Textures[i]->ImageCount);
+			for(int k=0;k<_grn_file->GrannyFileInfo->Textures[i]->ImageCount;k++) { _grn_file->GrannyFileInfo->Textures[i]->Images[k] = *(new granny_texture_image()); }
+
+			for(int j=0;j<_grn_file->GrannyFileInfo->Textures[i]->ImageCount;j++)
+			{
+				_grn_file->GrannyFileInfo->Textures[i]->Images[j].MIPLevelCount = GR2LibPropertyWrapper->Textures[i]->Images[j]->MIPLevels->Count;
+				_grn_file->GrannyFileInfo->Textures[i]->Images[j].MIPLevels = (granny_texture_mip_level*)malloc(_grn_file->GrannyFileInfo->Textures[i]->Images[j].MIPLevelCount);
+				for(int k=0;k<_grn_file->GrannyFileInfo->Textures[i]->Images[j].MIPLevelCount;k++) { _grn_file->GrannyFileInfo->Textures[i]->Images[j].MIPLevels[k] = *(new granny_texture_mip_level()); }
+				for(int k=0;k<_grn_file->GrannyFileInfo->Textures[i]->Images[j].MIPLevelCount;k++) 
+				{
+					_grn_file->GrannyFileInfo->Textures[i]->Images[j].MIPLevels[k].Stride =  GR2LibPropertyWrapper->Textures[i]->Images[j]->MIPLevels[k]->Stride;
+					_grn_file->GrannyFileInfo->Textures[i]->Images[j].MIPLevels[k].PixelByteCount = GR2LibPropertyWrapper->Textures[i]->Images[j]->MIPLevels[k]->Pixels->Count;
+					_grn_file->GrannyFileInfo->Textures[i]->Images[j].MIPLevels[k].PixelBytes = (unsigned char*)malloc(_grn_file->GrannyFileInfo->Textures[i]->Images[j].MIPLevels[k].PixelByteCount);
+					/*for (int l=0;l<_grn_file->GrannyFileInfo->Textures[i]->Images[j].MIPLevels[k].PixelByteCount;l++)
+					{
+						_grn_file->GrannyFileInfo->Textures[i]->Images[j].MIPLevels[k].PixelBytes[l] = 0;
+					}*/
+					array<unsigned char>^ pix_bytes = gcnew array<unsigned char>(_grn_file->GrannyFileInfo->Textures[i]->Images[j].MIPLevels[k].PixelByteCount);
+					for (int l=0;l<_grn_file->GrannyFileInfo->Textures[i]->Images[j].MIPLevels[k].PixelByteCount;l++)
+					{
+						pix_bytes[l] = GR2LibPropertyWrapper->Textures[i]->Images[j]->MIPLevels[k]->Pixels[l]->UInt8;
+					}
+
+					IntPtr PixelBytesPTR = *(new IntPtr(_grn_file->GrannyFileInfo->Textures[i]->Images[j].MIPLevels[k].PixelBytes));
+					Marshal::Copy(pix_bytes,0,PixelBytesPTR,_grn_file->GrannyFileInfo->Textures[i]->Images[j].MIPLevels[k].PixelByteCount);
+				}
+			}
+			_grn_file->GrannyFileInfo->Textures[i]->ExtendedData = *(new granny_variant());
 		}
-		//_grn_file->GrannyFileInfo->ExporterInfo->ExporterName = (char*)Marshal::StringToHGlobalAnsi(GR2LibPropertyWrapper->ExporterInfo->ExporterName).ToPointer();
-		//_grn_file->GrannyFileInfo->ExporterInfo->ExporterMajorRevision = GR2LibPropertyWrapper->ExporterInfo->Version->major;
-		//_grn_file->GrannyFileInfo->ExporterInfo->ExporterMinorRevision = GR2LibPropertyWrapper->ExporterInfo->Version->minor;
-		//_grn_file->GrannyFileInfo->ExporterInfo->ExporterCustomization = GR2LibPropertyWrapper->ExporterInfo->Version->customization;
-		//_grn_file->GrannyFileInfo->ExporterInfo->ExporterBuildNumber = GR2LibPropertyWrapper->ExporterInfo->Version->build;
-		////_grn_file->GrannyFileInfo->ExporterInfo->ExtendedData
+
 	}
 #pragma endregion
 #pragma endregion

 

  ViewVC Help
Powered by ViewVC 1.1.22