/[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/12 19:05:46	59
+++ trunk/gr2lib_cpp/gr2lib_rigeditor_frm.h	2010/08/13 17:15:09	69
@@ -11,6 +11,7 @@
 //#include "gr2lib_core_imports.h"
 #ifndef GR2LIB_RIGEDITOR_FRM_H
 #define GR2LIB_RIGEDITOR_FRM_H
+#include "..\gr2lib_cpp_typedefs\core.h"
 #include "grannyfile.h"
 //#include "guicon.h"
 #include "VSDebugOutput.h"
@@ -24,6 +25,7 @@
 #include <vcclr.h>
 using namespace std;
 
+using namespace gr2lib_cpp::typedefs;
 using namespace gr2lib::core;
 using namespace gr2lib::core::coretypes::implementation;
 using namespace gr2lib::core::apiversion;
@@ -319,6 +321,8 @@
 		ExporterInfo_ToManaged(_grn_file->GrannyFileInfo->ExporterInfo);
 		// Texture List
 		Textures_ToManaged(_grn_file->GrannyFileInfo->Textures,_grn_file->GrannyFileInfo->TextureCount);
+		// Material List
+		Materials_ToManaged(_grn_file->GrannyFileInfo->Materials,_grn_file->GrannyFileInfo->MaterialCount);
 	}
 	void ConvertToNative()
 	{
@@ -328,6 +332,8 @@
 		ExporterInfo_ToNative();
 		// Texture List
 		Textures_ToNative();
+		// Material List
+		Materials_ToNative();
 	}
 #pragma endregion
 
@@ -452,7 +458,6 @@
 						img->MIPLevels->Add(mip);
 						
 					}
-
 					t->Images->Add(img);
 					t->NativePointer =  *new IntPtr(toolinfo[i]);
 				}
@@ -461,6 +466,71 @@
 		}
 	}
 #pragma endregion
+#pragma region Materials_ToManaged
+	void Materials_ToManaged(granny_material** toolinfo, granny_int32 MaterialCount)
+	{
+		if (toolinfo != NULL)
+		{
+			GR2LibPropertyWrapper->Materials = gcnew List<Material^>();
+			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)));
+
+				m->NativePointer =  *new IntPtr(toolinfo[i]);
+				GR2LibPropertyWrapper->Materials->Add(m);
+			}
+		}
+	}
+#pragma endregion
 
 #pragma region MarshalToNative
 
@@ -558,6 +628,80 @@
 
 	}
 #pragma endregion
+#pragma region Materials_ToNative
+	void Materials_ToNative()
+	{
+		_grn_file->GrannyFileInfo->MaterialCount = GR2LibPropertyWrapper->Materials->Count;
+		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;
+
+				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;
+				//	//case granny_member_type::GrannyReferenceToArrayMember:  return new void*();break;
+				//	//case granny_member_type::GrannyArrayOfReferencesMember: return new void*(); break;
+				//	//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::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);
+				}
+
+				
+		
+
+
+			}
+		}
+	}
+#pragma endregion
 #pragma endregion
 
 #pragma endregion

 

  ViewVC Help
Powered by ViewVC 1.1.22