/[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/13 17:15:09	69
+++ trunk/gr2lib_cpp/gr2lib_rigeditor_frm.h	2010/08/14 08:06:32	71
@@ -1,6 +1,7 @@
 #define _CRT_SECURE_NO_WARNINGS
 #pragma warning( disable : 4100 ) // disable 'unreferenced formal parameter' warnings
 #pragma warning( disable : 4101 ) // disable 'unreferenced local variable' warnings
+#pragma warning( disable : 4482 ) // disable 'nonstandard extension used' warnings (related to case switch statements using enums)
 
 #define SHOW_DEBUG_MENU // if defined, will show the debug menu -> else it will not be shown
 
@@ -307,11 +308,12 @@
 	}
 #pragma endregion
 
-#pragma region MarshalToMananaged
+
+
+#pragma region MarshalToManagedNative
 	//ArtToolInfo^ _ArtToolInfo;
 	//ExporterInfo^ _ExporterInfo;
 	GR2LibWrapper^ GR2LibPropertyWrapper;
-
 #pragma region ManagedNativeParsing
 	void ConvertToManaged()
 	{
@@ -336,7 +338,7 @@
 		Materials_ToNative();
 	}
 #pragma endregion
-
+#pragma region MarshalToMananaged
 #pragma region ArtToolInfo_ToManaged
 	void ArtToolInfo_ToManaged(granny_art_tool_info* toolinfo)
 	{
@@ -368,6 +370,8 @@
 			GR2LibPropertyWrapper->ArtToolInfo->ToolVersion = gcnew ArtToolInfoVersion(toolinfo->ArtToolMajorRevision,toolinfo->ArtToolMinorRevision);
 			// Tool Units Per Meter
 			GR2LibPropertyWrapper->ArtToolInfo->UnitsPerMeter = toolinfo->UnitsPerMeter;
+			// Get Extended Data
+			GR2LibPropertyWrapper->ArtToolInfo->ExtendedData = ExtendedData_ToManaged(toolinfo->ExtendedData);
 		}
 	}
 #pragma endregion
@@ -384,7 +388,7 @@
 				toolinfo->ExporterCustomization,
 				toolinfo->ExporterBuildNumber);
 		}
-		//_ExporterInfo->ExtendedData = new IntPtr(toolinfo->ExtendedData.Object);
+		GR2LibPropertyWrapper->ExporterInfo->ExtendedData = ExtendedData_ToManaged(toolinfo->ExtendedData);
 	}
 #pragma endregion
 #pragma region Textures_ToManaged
@@ -392,12 +396,6 @@
 	{		
 		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++)
 			{
@@ -456,10 +454,11 @@
 							mip->Pixels->PixelBytes->Add(bytes[l]);
 						}
 						img->MIPLevels->Add(mip);
-						
+
 					}
 					t->Images->Add(img);
 					t->NativePointer =  *new IntPtr(toolinfo[i]);
+					t->ExtendedData = ExtendedData_ToManaged(toolinfo[i]->ExtendedData);
 				}
 				GR2LibPropertyWrapper->Textures->Add(t);
 			}
@@ -475,65 +474,18 @@
 			for(int i=0;i<MaterialCount;i++)
 			{
 				Material^ m = gcnew Material();
-				if (toolinfo[i]->Texture != NULL)
-				{
-					m = gcnew Material(*new IntPtr(&toolinfo[i]->Texture));
-				}
-				
-				m->Name = gcnew String(reinterpret_cast<const char*>(toolinfo[i]->Name));
-				/*m->Maps = gcnew List<Map^>(toolinfo[i]->MapCount);
-				for(int j=0;j<toolinfo[i]->MapCount;j++)
-				{
-					Map^ map = gcnew Map();
-
-					if(toolinfo[i]->Maps[j].Material != NULL)
-					{
-						map =  gcnew Map(*new IntPtr(&toolinfo[i]->Maps[j].Material));
-					}
-
-					map->Usage = gcnew String(reinterpret_cast<const char*>(toolinfo[i]->Maps[j].Usage));		
-					map->NativePointer = *new IntPtr(&toolinfo[i]->Maps[j]);
-					m->Maps->Add(map);
-				}*/
-
-				/*if (toolinfo[i]->Texture != NULL)
-				{
-					m->TexturePointer =  *new IntPtr(&toolinfo[i]->Texture);
-				}
-				else
-				{
-					m->TexturePointer =  IntPtr::Zero;
-				}*/
-
-
-				ExtendedDataWrapper* ExtendedDataWrapped = new ExtendedDataWrapper(toolinfo[i]->ExtendedData, _grn_file->_logger);
-				List<ExtendedDataMemberStruct^>^ _ExtendedDataMember = gcnew List<ExtendedDataMemberStruct^>(ExtendedDataWrapped->MemberCount);
-
-				for (int j=0;j<ExtendedDataWrapped->MemberCount;j++)
-				{
-					ExtendedDataMemberStruct^ _ExtendedDataMemberStruct = gcnew ExtendedDataMemberStruct();
-
-					_ExtendedDataMemberStruct->Index = ExtendedDataWrapped->ExtendedDataMembers[j].Index;
-					_ExtendedDataMemberStruct->Name = gcnew String(reinterpret_cast<const char*>(ExtendedDataWrapped->ExtendedDataMembers[j].Name.c_str()));
-					_ExtendedDataMemberStruct->Type = (gr2lib::core::typedefs::granny_member_type)(int)ExtendedDataWrapped->ExtendedDataMembers[j].Type;
-					_ExtendedDataMemberStruct->Value = ExtendedDataWrapped->GetRealExtendedDataMemberValue(_ExtendedDataMemberStruct->Index);
-					_ExtendedDataMember->Add(_ExtendedDataMemberStruct);
-				}
-
-				m->ExtendedData = gcnew GrannyExtendedData(_ExtendedDataMember);
-				
-				////System::Diagnostics::Debug::WriteLine("Granny Member Type: " + reinterpret_cast<int>(toolinfo[i]->ExtendedData.Type->Type));
-				//System::Diagnostics::Debug::WriteLine("Namee: " + gcnew String(reinterpret_cast<const char*>(toolinfo[i]->ExtendedData.Type->Name)));
+				if (toolinfo[i]->Texture != NULL) {	m = gcnew Material(*new IntPtr(&toolinfo[i]->Texture));	}
 
+				m->Name = gcnew String(reinterpret_cast<const char*>(toolinfo[i]->Name));
+				m->ExtendedData = ExtendedData_ToManaged(toolinfo[i]->ExtendedData);
 				m->NativePointer =  *new IntPtr(toolinfo[i]);
 				GR2LibPropertyWrapper->Materials->Add(m);
 			}
 		}
 	}
 #pragma endregion
-
+#pragma endregion
 #pragma region MarshalToNative
-
 #pragma region ArtToolInfo_ToNative
 	void ArtToolInfo_ToNative()
 	{
@@ -564,6 +516,8 @@
 		_grn_file->GrannyFileInfo->ArtToolInfo->BackVector[1] = GR2LibPropertyWrapper->ArtToolInfo->Vector->Back.y;
 		_grn_file->GrannyFileInfo->ArtToolInfo->BackVector[2] = GR2LibPropertyWrapper->ArtToolInfo->Vector->Back.z;
 
+		_grn_file->GrannyFileInfo->ArtToolInfo->ExtendedData = ExtendedData_ToNative(GR2LibPropertyWrapper->ArtToolInfo->ExtendedData,_grn_file->GrannyFileInfo->ArtToolInfo->ExtendedData);
+
 	}
 #pragma endregion
 #pragma region ExporterInfo_ToNative
@@ -578,7 +532,7 @@
 		_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
+		_grn_file->GrannyFileInfo->ExporterInfo->ExtendedData = ExtendedData_ToNative(GR2LibPropertyWrapper->ExporterInfo->ExtendedData,_grn_file->GrannyFileInfo->ExporterInfo->ExtendedData);
 	}
 #pragma endregion
 #pragma region Textures_ToNative
@@ -623,7 +577,7 @@
 					}
 				}
 			}
-			_grn_file->GrannyFileInfo->Textures[i]->ExtendedData = *(new granny_variant());
+			_grn_file->GrannyFileInfo->Textures[i]->ExtendedData = ExtendedData_ToNative(GR2LibPropertyWrapper->Textures[i]->ExtendedData,_grn_file->GrannyFileInfo->Textures[i]->ExtendedData);
 		}
 
 	}
@@ -635,20 +589,44 @@
 		for(int i=0;i<_grn_file->GrannyFileInfo->MaterialCount;i++)
 		{
 			_grn_file->GrannyFileInfo->Materials[i]->Name = (char*)Marshal::StringToHGlobalAnsi(GR2LibPropertyWrapper->Materials[i]->Name).ToPointer();
-
 			// update extended data
-			ExtendedDataWrapper* ExtendedDataWrapped = new ExtendedDataWrapper(_grn_file->GrannyFileInfo->Materials[i]->ExtendedData, _grn_file->_logger);
-			int MemberCount = GR2LibPropertyWrapper->Materials[i]->ExtendedData->ExtendedData->Count;
-			for(int j=0;j<MemberCount;j++)
-			{
-				Object^ value = GR2LibPropertyWrapper->Materials[i]->ExtendedData->ExtendedData[j]->Value;
+			_grn_file->GrannyFileInfo->Materials[i]->ExtendedData = ExtendedData_ToNative( GR2LibPropertyWrapper->Materials[i]->ExtendedData, _grn_file->GrannyFileInfo->Materials[i]->ExtendedData);
 
-				if (value->ToString() == (gcnew Object())->ToString()) continue;		 
+		}
+	}
+#pragma endregion
+#pragma endregion
+#pragma region ExtendedDataToManagedNative
+#pragma region ExtendedData_ToManaged
+	GrannyExtendedData^  ExtendedData_ToManaged(granny_variant NativeExtendedData)
+	{
+		ExtendedDataWrapper* ExtendedDataWrapped = new ExtendedDataWrapper(NativeExtendedData, _grn_file->_logger);
+		List<ExtendedDataMemberStruct^>^ _ExtendedDataMember = gcnew List<ExtendedDataMemberStruct^>(ExtendedDataWrapped->MemberCount);
+		for (int j=0;j<ExtendedDataWrapped->MemberCount;j++)
+		{
+			ExtendedDataMemberStruct^ _ExtendedDataMemberStruct = gcnew ExtendedDataMemberStruct();
+			_ExtendedDataMemberStruct->Index = ExtendedDataWrapped->ExtendedDataMembers[j].Index;
+			_ExtendedDataMemberStruct->Name = gcnew String(reinterpret_cast<const char*>(ExtendedDataWrapped->ExtendedDataMembers[j].Name.c_str()));
+			_ExtendedDataMemberStruct->Type = (gr2lib::core::typedefs::granny_member_type)(int)ExtendedDataWrapped->ExtendedDataMembers[j].Type;
+			_ExtendedDataMemberStruct->Value = ExtendedDataWrapped->GetRealExtendedDataMemberValue(_ExtendedDataMemberStruct->Index);
+			_ExtendedDataMember->Add(_ExtendedDataMemberStruct);
+		}
+		return gcnew GrannyExtendedData(_ExtendedDataMember);
+	}
+#pragma endregion
+#pragma region ExtendedData_ToNative
+	granny_variant ExtendedData_ToNative(GrannyExtendedData^ ManagedExtendedData, granny_variant NativeExtendedData)
+	{
 
-				
-				int MemberType = ExtendedDataWrapped->ExtendedDataMembers[j].Type;
-				switch(ExtendedDataWrapped->ExtendedDataMembers[j].Type)
-				{
+		ExtendedDataWrapper* ExtendedDataWrapped = new ExtendedDataWrapper(NativeExtendedData, _grn_file->_logger);
+		int MemberCount = ManagedExtendedData->ExtendedData->Count;
+		for(int j=0;j<MemberCount;j++)
+		{
+			Object^ value = ManagedExtendedData->ExtendedData[j]->Value;
+			if (value->ToString() == (gcnew Object())->ToString()) continue;	
+			int MemberType = ExtendedDataWrapped->ExtendedDataMembers[j].Type;
+			switch(ExtendedDataWrapped->ExtendedDataMembers[j].Type)
+			{
 				//	//case granny_member_type::GrannyEndMember: return new void*(); break;
 				//	//case granny_member_type::GrannyInlineMember: return new void*(); break;
 				//	//case granny_member_type::GrannyReferenceMember: return new void*(); break;
@@ -657,55 +635,51 @@
 				//	//case granny_member_type::GrannyVariantReferenceMember:  return new void*(); break;
 				//	//case granny_member_type::GrannyUnsupportedMemberType_Remove:  return new void*(); break;
 				//	//case granny_member_type::GrannyReferenceToVariantArrayMember:  return new void*(); break;
-				case granny_member_type::GrannyStringMember:  
-					char* _string;
-					_string = (char*)Marshal::StringToHGlobalAnsi((System::String^)value).ToPointer();
-					((char*(*)[MAX_GRANNY_MEMBER_COUNT])_grn_file->GrannyFileInfo->Materials[i]->ExtendedData.Object)[0][j] =  _string;
-					break;
-					//case granny_member_type::GrannyTransformMember: return new void*();break;		
-				case granny_member_type::GrannyReal32Member:  
-					((granny_real32(*)[MAX_GRANNY_MEMBER_COUNT])_grn_file->GrannyFileInfo->Materials[i]->ExtendedData.Object)[0][j] = (granny_real32)value; break;
-				case granny_member_type::GrannyInt8Member:  
-					((granny_int8(*)[MAX_GRANNY_MEMBER_COUNT])_grn_file->GrannyFileInfo->Materials[i]->ExtendedData.Object)[0][j] = (granny_int8)value; break;
-				case granny_member_type::GrannyUInt8Member: 
-					((granny_uint8(*)[MAX_GRANNY_MEMBER_COUNT])_grn_file->GrannyFileInfo->Materials[i]->ExtendedData.Object)[0][j] =(granny_uint8)value; break;
-				case granny_member_type::GrannyBinormalInt8Member:  
-					((granny_int8(*)[MAX_GRANNY_MEMBER_COUNT])_grn_file->GrannyFileInfo->Materials[i]->ExtendedData.Object)[0][j] = (granny_int8)value; break;
-				case granny_member_type::GrannyNormalUInt8Member:  
-					((granny_uint8(*)[MAX_GRANNY_MEMBER_COUNT])_grn_file->GrannyFileInfo->Materials[i]->ExtendedData.Object)[0][j] = (granny_uint8)value; break;
-				case granny_member_type::GrannyInt16Member: 
-					((granny_int16(*)[MAX_GRANNY_MEMBER_COUNT])_grn_file->GrannyFileInfo->Materials[i]->ExtendedData.Object)[0][j] = (granny_int16)value; break;
-				case granny_member_type::GrannyUInt16Member: 
-					((granny_uint16(*)[MAX_GRANNY_MEMBER_COUNT])_grn_file->GrannyFileInfo->Materials[i]->ExtendedData.Object)[0][j] = (granny_uint16)value; break;
-				case granny_member_type::GrannyBinormalInt16Member: 
-					((granny_int16(*)[MAX_GRANNY_MEMBER_COUNT])_grn_file->GrannyFileInfo->Materials[i]->ExtendedData.Object)[0][j] = (granny_int16)value; break;
-				case granny_member_type::GrannyNormalUInt16Member: 
-					((granny_uint16(*)[MAX_GRANNY_MEMBER_COUNT])_grn_file->GrannyFileInfo->Materials[i]->ExtendedData.Object)[0][j] = (granny_uint16)value; break;
-				case granny_member_type::GrannyInt32Member: 
-					((granny_int32(*)[MAX_GRANNY_MEMBER_COUNT])_grn_file->GrannyFileInfo->Materials[i]->ExtendedData.Object)[0][j] = (granny_int32)value; break;
-				case granny_member_type::GrannyUInt32Member: 
-					((granny_uint32(*)[MAX_GRANNY_MEMBER_COUNT])_grn_file->GrannyFileInfo->Materials[i]->ExtendedData.Object)[0][j] = (granny_uint32)value; break;
-				case granny_member_type::GrannyReal16Member: 
-					((granny_real16(*)[MAX_GRANNY_MEMBER_COUNT])_grn_file->GrannyFileInfo->Materials[i]->ExtendedData.Object)[0][j] = (granny_real16)value; break;
+			case granny_member_type::GrannyStringMember:  
+				char* _string;
+				_string = (char*)Marshal::StringToHGlobalAnsi((System::String^)value).ToPointer();
+				((char*(*)[MAX_GRANNY_MEMBER_COUNT])NativeExtendedData.Object)[0][j] =  _string;
+				break;
+				//case granny_member_type::GrannyTransformMember: return new void*();break;		
+			case granny_member_type::GrannyReal32Member:  
+				((granny_real32(*)[MAX_GRANNY_MEMBER_COUNT])NativeExtendedData.Object)[0][j] = (granny_real32)value; break;
+			case granny_member_type::GrannyInt8Member:  
+				((granny_int8(*)[MAX_GRANNY_MEMBER_COUNT])NativeExtendedData.Object)[0][j] = (granny_int8)value; break;
+			case granny_member_type::GrannyUInt8Member: 
+				((granny_uint8(*)[MAX_GRANNY_MEMBER_COUNT])NativeExtendedData.Object)[0][j] =(granny_uint8)value; break;
+			case granny_member_type::GrannyBinormalInt8Member:  
+				((granny_int8(*)[MAX_GRANNY_MEMBER_COUNT])NativeExtendedData.Object)[0][j] = (granny_int8)value; break;
+			case granny_member_type::GrannyNormalUInt8Member:  
+				((granny_uint8(*)[MAX_GRANNY_MEMBER_COUNT])NativeExtendedData.Object)[0][j] = (granny_uint8)value; break;
+			case granny_member_type::GrannyInt16Member: 
+				((granny_int16(*)[MAX_GRANNY_MEMBER_COUNT])NativeExtendedData.Object)[0][j] = (granny_int16)value; break;
+			case granny_member_type::GrannyUInt16Member: 
+				((granny_uint16(*)[MAX_GRANNY_MEMBER_COUNT])NativeExtendedData.Object)[0][j] = (granny_uint16)value; break;
+			case granny_member_type::GrannyBinormalInt16Member: 
+				((granny_int16(*)[MAX_GRANNY_MEMBER_COUNT])NativeExtendedData.Object)[0][j] = (granny_int16)value; break;
+			case granny_member_type::GrannyNormalUInt16Member: 
+				((granny_uint16(*)[MAX_GRANNY_MEMBER_COUNT])NativeExtendedData.Object)[0][j] = (granny_uint16)value; break;
+			case granny_member_type::GrannyInt32Member: 
+				((granny_int32(*)[MAX_GRANNY_MEMBER_COUNT])NativeExtendedData.Object)[0][j] = (granny_int32)value; break;
+			case granny_member_type::GrannyUInt32Member: 
+				((granny_uint32(*)[MAX_GRANNY_MEMBER_COUNT])NativeExtendedData.Object)[0][j] = (granny_uint32)value; break;
+			case granny_member_type::GrannyReal16Member: 
+				((granny_real16(*)[MAX_GRANNY_MEMBER_COUNT])NativeExtendedData.Object)[0][j] = (granny_real16)value; break;
 				//case granny_member_type::GrannyEmptyReferenceMember: 
 				//	((granny_int32(*)[MAX_GRANNY_MEMBER_COUNT])_grn_file->GrannyFileInfo->Materials[i]->ExtendedData.Object)[0][j] = value; break;
-					//case granny_member_type::GrannyOnePastLastMemberType: break;
-					//case granny_member_type::GrannyBool32Member: break;
-				default: throw gcnew System::InvalidOperationException("Encountered an Invalid Granny Member Type: " + MemberType);
-				}
-
-				
-		
-
-
+				//case granny_member_type::GrannyOnePastLastMemberType: break;
+				//case granny_member_type::GrannyBool32Member: break;
+			default: throw gcnew System::InvalidOperationException("Encountered an Invalid Granny Member Type: " + MemberType);
 			}
 		}
+
+		return NativeExtendedData;
 	}
 #pragma endregion
 #pragma endregion
-
 #pragma endregion
 
+
 #pragma region DoPostSave_Operations
 	void DoPostSave_Operations()
 	{

 

  ViewVC Help
Powered by ViewVC 1.1.22