/[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 04:23:29	20
+++ trunk/gr2lib_cpp/gr2lib_rigeditor_frm.h	2010/08/01 06:33:06	22
@@ -20,6 +20,8 @@
 using namespace gr2lib::core;
 using namespace gr2lib::core::coretypes::implementation;
 using namespace gr2lib::core::apiversion;
+using namespace gr2lib::core::ui::helpers;
+using namespace gr2lib::core::helpers;
 using namespace System;
 using namespace System::ComponentModel;
 using namespace System::Collections;
@@ -163,7 +165,7 @@
 		this->propgrid->Dock = System::Windows::Forms::DockStyle::Fill;
 		this->propgrid->Location = System::Drawing::Point(0, 24);
 		this->propgrid->Name = L"propgrid";
-		this->propgrid->PropertySort = System::Windows::Forms::PropertySort::NoSort;
+		this->propgrid->PropertySort = System::Windows::Forms::PropertySort::Categorized;
 		this->propgrid->Size = System::Drawing::Size(558, 456);
 		this->propgrid->TabIndex = 4;
 		this->propgrid->ToolbarVisible = false;
@@ -286,6 +288,8 @@
 		ArtToolInfo_ToManaged(_grn_file->GrannyFileInfo->ArtToolInfo);
 		// Exporter Info
 		ExporterInfo_ToManaged(_grn_file->GrannyFileInfo->ExporterInfo);
+		// Texture List
+		Textures_ToManaged(_grn_file->GrannyFileInfo->Textures,_grn_file->GrannyFileInfo->TextureCount);
 	}
 	void ConvertToNative()
 	{
@@ -346,6 +350,82 @@
 		//_ExporterInfo->ExtendedData = new IntPtr(toolinfo->ExtendedData.Object);
 	}
 #pragma endregion
+#pragma region Textures_ToManaged
+	void Textures_ToManaged(granny_texture** toolinfo, granny_int32 TextureCount)
+	{		
+		if (toolinfo != NULL)
+		{
+			/*GR2LibPropertyWrapper->ExporterInfo->ExporterName = gcnew String(reinterpret_cast<const char*>(toolinfo->ExporterName));
+			GR2LibPropertyWrapper->ExporterInfo->Version = gcnew versiontype(
+				toolinfo->ExporterMajorRevision,
+				toolinfo->ExporterMinorRevision,
+				toolinfo->ExporterCustomization,
+				toolinfo->ExporterBuildNumber);*/
+			GR2LibPropertyWrapper->Textures = gcnew List<Texture^>();
+			for(int i=0;i<TextureCount;i++)
+			{
+				Texture^ t = gcnew Texture();
+				t->FromFileName = gcnew FilePath(gcnew String(reinterpret_cast<const char*>(toolinfo[i]->FromFileName)));
+				t->TextureType = gcnew NameValuePair<String^,gr2lib::core::typedefs::granny_texture_type>(
+					::coreapi::EnumToStringSupport::GetGrannyEnumTypeString<gr2lib::core::typedefs::granny_texture_type>(
+					(gr2lib::core::typedefs::granny_texture_type)toolinfo[i]->TextureType),
+					(gr2lib::core::typedefs::granny_texture_type)toolinfo[i]->TextureType);
+				t->Width = toolinfo[i]->Width;
+				t->Height = toolinfo[i]->Height;
+				t->Encoding = gcnew NameValuePair<String^,gr2lib::core::typedefs::granny_texture_encoding>(
+					::coreapi::EnumToStringSupport::GetGrannyEnumTypeString<gr2lib::core::typedefs::granny_texture_encoding>(
+					(gr2lib::core::typedefs::granny_texture_encoding)toolinfo[i]->Encoding),
+					(gr2lib::core::typedefs::granny_texture_encoding)toolinfo[i]->Encoding);
+				t->SubFormat = gcnew NameValuePair<String^,gr2lib::core::typedefs::granny_pixel_layout>(
+					::coreapi::EnumToStringSupport::GetGrannyEnumTypeString<gr2lib::core::typedefs::granny_pixel_layout>(
+					(gr2lib::core::typedefs::granny_pixel_layout)toolinfo[i]->SubFormat),
+					(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++)
+					{
+						t->Layout->ShiftForComponent[j] =  toolinfo[i]->Layout.ShiftForComponent[j];
+						t->Layout->BitsForComponent[j] =  toolinfo[i]->Layout.BitsForComponent[j];
+					}
+
+				t->Images = gcnew List<gr2lib::core::coretypes::implementation::Image^>();
+				for(int j=0;j<toolinfo[i]->ImageCount;j++)
+				{
+					gr2lib::core::coretypes::implementation::Image^ img = gcnew gr2lib::core::coretypes::implementation::Image();
+					img->MIPLevels = gcnew List<gr2lib::core::coretypes::implementation::MIPLevel^>();					
+					
+					for(int k=0;k<toolinfo[i]->Images[j].MIPLevelCount;k++)
+					{
+						gr2lib::core::coretypes::implementation::MIPLevel^ mip = gcnew gr2lib::core::coretypes::implementation::MIPLevel();
+						mip->Stride = toolinfo[i]->Images[j].MIPLevels[k].Stride;
+						mip->Pixels = gcnew List<gr2lib::core::coretypes::implementation::Pixel^>();	
+
+						unsigned char* bytes = (unsigned char*)malloc(toolinfo[i]->Images[j].MIPLevels[k].PixelByteCount);	
+						for(int l =0;l<toolinfo[i]->Images[j].MIPLevels[k].PixelByteCount;l++)
+						{
+							bytes[l] =0;
+						}
+						bytes = (unsigned char*)toolinfo[i]->Images[j].MIPLevels[k].PixelBytes;
+
+						for(int l =0;l<toolinfo[i]->Images[j].MIPLevels[k].PixelByteCount;l++)
+						{
+							gr2lib::core::coretypes::implementation::Pixel^ pix = gcnew gr2lib::core::coretypes::implementation::Pixel();
+							pix->UInt8 = bytes[l];
+							pix->ReferenceTexture =t;
+							mip->Pixels->Add(pix);
+						}
+
+						img->MIPLevels->Add(mip);
+					}
+
+					t->Images->Add(img);
+					t->NativePointer = *(new IntPtr(toolinfo[i]));
+				}
+				GR2LibPropertyWrapper->Textures->Add(t);
+			}
+		}
+	}
+#pragma endregion
 
 #pragma region MarshalToNative
 
@@ -396,6 +476,21 @@
 		//_grn_file->GrannyFileInfo->ExporterInfo->ExtendedData
 	}
 #pragma endregion
+#pragma region Textures_ToNative
+	void Textures_ToNative()
+	{
+		if (_grn_file->GrannyFileInfo->Textures == NULL)
+		{
+			_grn_file->GrannyFileInfo->Textures = new granny_texture*();
+		}
+		//_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
 
 #pragma endregion

 

  ViewVC Help
Powered by ViewVC 1.1.22