/[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/02 03:33:24	26
+++ trunk/gr2lib_cpp/gr2lib_rigeditor_frm.h	2010/08/02 08:57:24	29
@@ -372,14 +372,15 @@
 		{
 			/*GR2LibPropertyWrapper->ExporterInfo->ExporterName = gcnew String(reinterpret_cast<const char*>(toolinfo->ExporterName));
 			GR2LibPropertyWrapper->ExporterInfo->Version = gcnew versiontype(
-				toolinfo->ExporterMajorRevision,
-				toolinfo->ExporterMinorRevision,
-				toolinfo->ExporterCustomization,
-				toolinfo->ExporterBuildNumber);*/
+			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>(
@@ -396,19 +397,20 @@
 					(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<granny_pixel_layout_bitshift_size;j++)
-					{
-						t->Layout->ShiftForComponent[j] =  toolinfo[i]->Layout.ShiftForComponent[j];
-						t->Layout->BitsForComponent[j] =  toolinfo[i]->Layout.BitsForComponent[j];
-					}
+				t->Layout->BytesPerPixel = toolinfo[i]->Layout.BytesPerPixel;
+				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];
+				}
+				t->Layout->NativePointer = *new IntPtr(&toolinfo[i]->Layout);
 
 				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();
@@ -426,7 +428,8 @@
 						{
 							gr2lib::core::coretypes::implementation::Pixel^ pix = gcnew gr2lib::core::coretypes::implementation::Pixel();
 							pix->UInt8 = bytes[l];
-							pix->ReferenceTexture =t;
+							pix->NativeTexture = t;
+							pix->NativeTexturePointer = *new IntPtr(toolinfo[i]);
 							mip->Pixels->Add(pix);
 						}
 
@@ -434,7 +437,7 @@
 					}
 
 					t->Images->Add(img);
-					t->NativePointer = *(new IntPtr(toolinfo[i]));
+					t->NativePointer =  *new IntPtr(toolinfo[i]);
 				}
 				GR2LibPropertyWrapper->Textures->Add(t);
 			}
@@ -494,8 +497,8 @@
 #pragma region Textures_ToNative
 	void Textures_ToNative()
 	{
-		_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->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++)
@@ -506,12 +509,13 @@
 			_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];
-			}
+				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);
@@ -527,16 +531,33 @@
 					_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);
-					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;
+						_grn_file->GrannyFileInfo->Textures[i]->Images[j].MIPLevels[k].PixelBytes[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);
+					//// try to compress texture?
+					//if (_grn_file->GrannyFileInfo->Textures[i]->Encoding == granny_texture_encoding::GrannyBinkTextureEncoding)
+					//{
+					//	granny_texture* src = _grn_file->GrannyFileInfo->Textures[i];
+					//	granny_texture* dest = new granny_texture();
+					//	GrannyBinkCompressTexture(
+					//		_grn_file->GrannyFileInfo->Textures[i]->Width,
+					//		_grn_file->GrannyFileInfo->Textures[i]->Height,
+					//		_grn_file->GrannyFileInfo->Textures[i]->Width * _grn_file->GrannyFileInfo->Textures[i]->Layout.BytesPerPixel,
+					//		src,
+					//		granny_bink_texture_flags::GrannyBinkEncodeAlpha,
+					//		granny_compression_type::GrannyNoCompression,
+					//		&dest);
+					//}
+				
 				}
 			}
+			//granny_pixel_layout _layout;
+			//GrannyGetRecommendedPixelLayout(_grn_file->GrannyFileInfo->Textures[i],&_layout);					
+			//_grn_file->GrannyFileInfo->Textures[i]->Layout = _layout;
 			_grn_file->GrannyFileInfo->Textures[i]->ExtendedData = *(new granny_variant());
 		}
 
@@ -552,7 +573,7 @@
 		 }
 private: System::Void mnuItemOpen_Click(System::Object^  sender, System::EventArgs^  e) 
 		 {
-			 
+
 
 			 System::Windows::Forms::DialogResult result = RigLoader->ShowDialog();
 			 if (result != System::Windows::Forms::DialogResult::OK) return;
@@ -570,8 +591,8 @@
 			 //_grn_file->_logger->SetLogFileName("c:\\gr2_logs",fn);
 			 _grn_file = new grannyfile(fn);
 
-			this->GR2LibPropertyWrapper = gcnew GR2LibWrapper();
-			ConvertToManaged();
+			 this->GR2LibPropertyWrapper = gcnew GR2LibWrapper();
+			 ConvertToManaged();
 			 propgrid->SelectedObject = this->GR2LibPropertyWrapper;
 		 }
 private: System::Void gr2lib_rigeditor_frm_FormClosed(System::Object^  sender, System::Windows::Forms::FormClosedEventArgs^  e) 
@@ -594,56 +615,56 @@
 			 VSDebugWriter 
 				 << "\n\n\tArtToolInfo ->"
 				 << "\n\t\tTool Name: " 
-					<< _grn_file->GrannyFileInfo->ArtToolInfo->FromArtToolName
+				 << _grn_file->GrannyFileInfo->ArtToolInfo->FromArtToolName
 				 << "\n\t\tTool Version: " 
-					<<  _grn_file->GrannyFileInfo->ArtToolInfo->ArtToolMajorRevision 
-					<< "." << _grn_file->GrannyFileInfo->ArtToolInfo->ArtToolMinorRevision
-				<< "\n\t\tUnits Per Meter: " 
-					<<  _grn_file->GrannyFileInfo->ArtToolInfo->UnitsPerMeter
-				<< "\n\t\tOrigin: " 
-					<< "\n\t\t\tX: " 
-						<< _grn_file->GrannyFileInfo->ArtToolInfo->Origin[0]
-					<< "\n\t\t\tY: " 
-						<< _grn_file->GrannyFileInfo->ArtToolInfo->Origin[1]
-					<< "\n\t\t\tZ: " 
-						<< _grn_file->GrannyFileInfo->ArtToolInfo->Origin[2]
-				<< "\n\t\tRight: " 
-					<< "\n\t\t\tX: " 
-						<< _grn_file->GrannyFileInfo->ArtToolInfo->RightVector[0]
-					<< "\n\t\t\tY: " 
-						<< _grn_file->GrannyFileInfo->ArtToolInfo->RightVector[1]
-					<< "\n\t\t\tZ: " 
-						<< _grn_file->GrannyFileInfo->ArtToolInfo->RightVector[2]
-				<< "\n\t\tUp: " 
-					<< "\n\t\t\tX: " 
-						<< _grn_file->GrannyFileInfo->ArtToolInfo->UpVector[0]
-					<< "\n\t\t\tY: " 
-						<< _grn_file->GrannyFileInfo->ArtToolInfo->UpVector[1]
-					<< "\n\t\t\tZ: " 
-						<< _grn_file->GrannyFileInfo->ArtToolInfo->UpVector[2]
-				<< "\n\t\tBack: " 
-					<< "\n\t\t\tX: " 
-						<< _grn_file->GrannyFileInfo->ArtToolInfo->BackVector[0]
-					<< "\n\t\t\tY: " 
-						<< _grn_file->GrannyFileInfo->ArtToolInfo->BackVector[1]
-					<< "\n\t\t\tZ: " 
-						<< _grn_file->GrannyFileInfo->ArtToolInfo->BackVector[2]
+				 <<  _grn_file->GrannyFileInfo->ArtToolInfo->ArtToolMajorRevision 
+				 << "." << _grn_file->GrannyFileInfo->ArtToolInfo->ArtToolMinorRevision
+				 << "\n\t\tUnits Per Meter: " 
+				 <<  _grn_file->GrannyFileInfo->ArtToolInfo->UnitsPerMeter
+				 << "\n\t\tOrigin: " 
+				 << "\n\t\t\tX: " 
+				 << _grn_file->GrannyFileInfo->ArtToolInfo->Origin[0]
+			 << "\n\t\t\tY: " 
+				 << _grn_file->GrannyFileInfo->ArtToolInfo->Origin[1]
+			 << "\n\t\t\tZ: " 
+				 << _grn_file->GrannyFileInfo->ArtToolInfo->Origin[2]
+			 << "\n\t\tRight: " 
+				 << "\n\t\t\tX: " 
+				 << _grn_file->GrannyFileInfo->ArtToolInfo->RightVector[0]
+			 << "\n\t\t\tY: " 
+				 << _grn_file->GrannyFileInfo->ArtToolInfo->RightVector[1]
+			 << "\n\t\t\tZ: " 
+				 << _grn_file->GrannyFileInfo->ArtToolInfo->RightVector[2]
+			 << "\n\t\tUp: " 
+				 << "\n\t\t\tX: " 
+				 << _grn_file->GrannyFileInfo->ArtToolInfo->UpVector[0]
+			 << "\n\t\t\tY: " 
+				 << _grn_file->GrannyFileInfo->ArtToolInfo->UpVector[1]
+			 << "\n\t\t\tZ: " 
+				 << _grn_file->GrannyFileInfo->ArtToolInfo->UpVector[2]
+			 << "\n\t\tBack: " 
+				 << "\n\t\t\tX: " 
+				 << _grn_file->GrannyFileInfo->ArtToolInfo->BackVector[0]
+			 << "\n\t\t\tY: " 
+				 << _grn_file->GrannyFileInfo->ArtToolInfo->BackVector[1]
+			 << "\n\t\t\tZ: " 
+				 << _grn_file->GrannyFileInfo->ArtToolInfo->BackVector[2]
 			 ;
 		 }
 private: System::Void mnuTestExporterInfoReturnValues_Click(System::Object^  sender, System::EventArgs^  e) 
 		 {
-			  // Convert ExporterInfo To Native, and ouput the values -> to check that they were updated correctly
-			ExporterInfo_ToNative();
+			 // Convert ExporterInfo To Native, and ouput the values -> to check that they were updated correctly
+			 ExporterInfo_ToNative();
 			 VSDebugWriterW VSDebugWriter;
 			 VSDebugWriter 
 				 << "\n\n\tExporterInfo ->"
 				 << "\n\t\tExporter Name: " 
-					<<  _grn_file->GrannyFileInfo->ExporterInfo->ExporterName
+				 <<  _grn_file->GrannyFileInfo->ExporterInfo->ExporterName
 				 << "\n\t\tExporter Version: " 
-					<< _grn_file->GrannyFileInfo->ExporterInfo->ExporterMajorRevision 
-					<< "." << _grn_file->GrannyFileInfo->ExporterInfo->ExporterMinorRevision
-					<< "." << _grn_file->GrannyFileInfo->ExporterInfo->ExporterCustomization
-					<< "." << _grn_file->GrannyFileInfo->ExporterInfo->ExporterBuildNumber
+				 << _grn_file->GrannyFileInfo->ExporterInfo->ExporterMajorRevision 
+				 << "." << _grn_file->GrannyFileInfo->ExporterInfo->ExporterMinorRevision
+				 << "." << _grn_file->GrannyFileInfo->ExporterInfo->ExporterCustomization
+				 << "." << _grn_file->GrannyFileInfo->ExporterInfo->ExporterBuildNumber
 					;
 		 }
 private: System::Void mnuItemSave_Click(System::Object^  sender, System::EventArgs^  e) 
@@ -655,7 +676,7 @@
 		 }
 private: System::Void mnuItemSaveAs_Click(System::Object^  sender, System::EventArgs^  e)
 		 {
-			  // convert Data to Native
+			 // convert Data to Native
 			 ConvertToNative();
 			 System::Windows::Forms::DialogResult result = RigSaver->ShowDialog();
 			 if (result != System::Windows::Forms::DialogResult::OK) return;
@@ -664,7 +685,7 @@
 		 }
 private: System::Void mnuItemClose_Click(System::Object^  sender, System::EventArgs^  e) 
 		 {
-			  propgrid->SelectedObject = NULL;
+			 propgrid->SelectedObject = NULL;
 		 }
 };
 //		}

 

  ViewVC Help
Powered by ViewVC 1.1.22