/[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/14 08:06:32	71
+++ trunk/gr2lib_cpp/gr2lib_rigeditor_frm.h	2010/08/14 10:47:15	74
@@ -325,6 +325,8 @@
 		Textures_ToManaged(_grn_file->GrannyFileInfo->Textures,_grn_file->GrannyFileInfo->TextureCount);
 		// Material List
 		Materials_ToManaged(_grn_file->GrannyFileInfo->Materials,_grn_file->GrannyFileInfo->MaterialCount);
+		// Skeleton List
+		Skeletons_ToManaged(_grn_file->GrannyFileInfo->Skeletons, _grn_file->GrannyFileInfo->SkeletonCount);
 	}
 	void ConvertToNative()
 	{
@@ -336,6 +338,8 @@
 		Textures_ToNative();
 		// Material List
 		Materials_ToNative();
+		// Skeleton List
+		Skeletons_ToNative();
 	}
 #pragma endregion
 #pragma region MarshalToMananaged
@@ -484,6 +488,97 @@
 		}
 	}
 #pragma endregion
+#pragma region Skeletons_ToManaged
+	void Skeletons_ToManaged(granny_skeleton** toolinfo, granny_int32 SkeletonCount)
+	{
+		if (toolinfo != NULL)
+		{
+			GR2LibPropertyWrapper->Skeletons = gcnew List<Skeleton^>();
+			for(int i=0;i<SkeletonCount;i++)
+			{
+				Skeleton^ s = gcnew Skeleton();
+				s->Name = gcnew String(reinterpret_cast<const char*>(toolinfo[i]->Name));
+				s->LODType = toolinfo[i]->LODType;
+				List<Bone^>^ bones = gcnew List<Bone^>();
+				for(int j=0;j<toolinfo[i]->BoneCount;j++)
+				{
+					Bone^ b = gcnew Bone();
+
+					b->Name = gcnew String(reinterpret_cast<const char*>(toolinfo[i]->Bones[j].Name));
+					b->ParentIndex = toolinfo[i]->Bones[j].ParentIndex;
+
+					Transform^ _transform = gcnew Transform();
+					Matrix44^ _matrix44 = gcnew Matrix44(_transform->Matrix);				
+
+					_transform->Dimensions = toolinfo[i]->Bones[j].LocalTransform.Flags;
+					_transform->Origin = *gcnew Vector3(
+						toolinfo[i]->Bones[j].LocalTransform.Position[0],
+						toolinfo[i]->Bones[j].LocalTransform.Position[1],
+						toolinfo[i]->Bones[j].LocalTransform.Position[2]
+					);
+
+					_transform->Rotation = *gcnew Quaternion(
+						toolinfo[i]->Bones[j].LocalTransform.Orientation[0],
+						toolinfo[i]->Bones[j].LocalTransform.Orientation[1],
+						toolinfo[i]->Bones[j].LocalTransform.Orientation[2],
+						toolinfo[i]->Bones[j].LocalTransform.Orientation[3]
+					);
+					_transform->Scale = *gcnew Matrix33
+						(
+						*gcnew Vector3(
+						toolinfo[i]->Bones[j].LocalTransform.ScaleShear[0][0],
+						toolinfo[i]->Bones[j].LocalTransform.ScaleShear[0][1],
+						toolinfo[i]->Bones[j].LocalTransform.ScaleShear[0][2]),
+						*gcnew Vector3(
+						toolinfo[i]->Bones[j].LocalTransform.ScaleShear[1][0],
+						toolinfo[i]->Bones[j].LocalTransform.ScaleShear[1][1],
+						toolinfo[i]->Bones[j].LocalTransform.ScaleShear[1][2]),
+						*gcnew Vector3(
+						toolinfo[i]->Bones[j].LocalTransform.ScaleShear[2][0],
+						toolinfo[i]->Bones[j].LocalTransform.ScaleShear[2][1],
+						toolinfo[i]->Bones[j].LocalTransform.ScaleShear[2][2])
+						);
+
+					_matrix44->right = *gcnew Vector4(
+														toolinfo[i]->Bones[j].InverseWorld4x4[0][0],
+														toolinfo[i]->Bones[j].InverseWorld4x4[0][1],
+														toolinfo[i]->Bones[j].InverseWorld4x4[0][2],
+														toolinfo[i]->Bones[j].InverseWorld4x4[0][3]
+														);
+														
+					_matrix44->up = *gcnew Vector4(
+														toolinfo[i]->Bones[j].InverseWorld4x4[1][0],
+														toolinfo[i]->Bones[j].InverseWorld4x4[1][1],
+														toolinfo[i]->Bones[j].InverseWorld4x4[1][2],
+														toolinfo[i]->Bones[j].InverseWorld4x4[1][3]
+														);
+														
+					_matrix44->at = *gcnew Vector4(
+														toolinfo[i]->Bones[j].InverseWorld4x4[2][0],
+														toolinfo[i]->Bones[j].InverseWorld4x4[2][1],
+														toolinfo[i]->Bones[j].InverseWorld4x4[2][2],
+														toolinfo[i]->Bones[j].InverseWorld4x4[2][3]
+														);
+														
+					_matrix44->pos = *gcnew Vector4(
+														toolinfo[i]->Bones[j].InverseWorld4x4[3][0],
+														toolinfo[i]->Bones[j].InverseWorld4x4[3][1],
+														toolinfo[i]->Bones[j].InverseWorld4x4[3][2],
+														toolinfo[i]->Bones[j].InverseWorld4x4[3][3]
+														);
+
+					b->LocalTransform = _transform;
+					b->InverseWorld4x4 = *_matrix44;
+					b->LODError = toolinfo[i]->Bones[j].LODError;
+					b->ExtendedData = ExtendedData_ToManaged(toolinfo[i]->Bones[j].ExtendedData);
+					bones->Add(b);
+				}
+				s->Bones = bones;
+				GR2LibPropertyWrapper->Skeletons->Add(s);
+			}
+		}
+	}
+#pragma endregion
 #pragma endregion
 #pragma region MarshalToNative
 #pragma region ArtToolInfo_ToNative
@@ -595,6 +690,63 @@
 		}
 	}
 #pragma endregion
+#pragma region Skeletons_ToNative
+	void Skeletons_ToNative()
+	{
+		_grn_file->GrannyFileInfo->SkeletonCount = GR2LibPropertyWrapper->Skeletons->Count;
+		for(int i=0;i<_grn_file->GrannyFileInfo->SkeletonCount;i++)
+		{
+			_grn_file->GrannyFileInfo->Skeletons[i]->Name = (char*)Marshal::StringToHGlobalAnsi(GR2LibPropertyWrapper->Skeletons[i]->Name).ToPointer();
+			_grn_file->GrannyFileInfo->Skeletons[i]->LODType = GR2LibPropertyWrapper->Skeletons[i]->LODType;
+			_grn_file->GrannyFileInfo->Skeletons[i]->BoneCount = GR2LibPropertyWrapper->Skeletons[i]->Bones->Count;
+			for(int j=0;j<_grn_file->GrannyFileInfo->Skeletons[i]->BoneCount;j++)
+			{
+				_grn_file->GrannyFileInfo->Skeletons[i]->Bones[j].Name = (char*)Marshal::StringToHGlobalAnsi(GR2LibPropertyWrapper->Skeletons[i]->Bones[j]->Name).ToPointer();
+				_grn_file->GrannyFileInfo->Skeletons[i]->Bones[j].ParentIndex = GR2LibPropertyWrapper->Skeletons[i]->Bones[j]->ParentIndex;
+				
+				// Update LocalTransform
+				_grn_file->GrannyFileInfo->Skeletons[i]->Bones[j].LocalTransform.Flags = GR2LibPropertyWrapper->Skeletons[i]->Bones[j]->LocalTransform->Dimensions;
+
+				_grn_file->GrannyFileInfo->Skeletons[i]->Bones[j].LocalTransform.Position[0] = GR2LibPropertyWrapper->Skeletons[i]->Bones[j]->LocalTransform->Origin.x;
+				_grn_file->GrannyFileInfo->Skeletons[i]->Bones[j].LocalTransform.Position[1] = GR2LibPropertyWrapper->Skeletons[i]->Bones[j]->LocalTransform->Origin.y;
+				_grn_file->GrannyFileInfo->Skeletons[i]->Bones[j].LocalTransform.Position[2] = GR2LibPropertyWrapper->Skeletons[i]->Bones[j]->LocalTransform->Origin.z;				
+				_grn_file->GrannyFileInfo->Skeletons[i]->Bones[j].LocalTransform.Orientation[0] = GR2LibPropertyWrapper->Skeletons[i]->Bones[j]->LocalTransform->Rotation.v.x;
+				_grn_file->GrannyFileInfo->Skeletons[i]->Bones[j].LocalTransform.Orientation[1] = GR2LibPropertyWrapper->Skeletons[i]->Bones[j]->LocalTransform->Rotation.v.y;
+				_grn_file->GrannyFileInfo->Skeletons[i]->Bones[j].LocalTransform.Orientation[2] = GR2LibPropertyWrapper->Skeletons[i]->Bones[j]->LocalTransform->Rotation.v.z;
+				_grn_file->GrannyFileInfo->Skeletons[i]->Bones[j].LocalTransform.Orientation[3] = GR2LibPropertyWrapper->Skeletons[i]->Bones[j]->LocalTransform->Rotation.n;				
+				_grn_file->GrannyFileInfo->Skeletons[i]->Bones[j].LocalTransform.ScaleShear[0][0] = GR2LibPropertyWrapper->Skeletons[i]->Bones[j]->LocalTransform->Scale.right.x;
+				_grn_file->GrannyFileInfo->Skeletons[i]->Bones[j].LocalTransform.ScaleShear[0][1] = GR2LibPropertyWrapper->Skeletons[i]->Bones[j]->LocalTransform->Scale.right.y;
+				_grn_file->GrannyFileInfo->Skeletons[i]->Bones[j].LocalTransform.ScaleShear[0][2] = GR2LibPropertyWrapper->Skeletons[i]->Bones[j]->LocalTransform->Scale.right.z;
+				_grn_file->GrannyFileInfo->Skeletons[i]->Bones[j].LocalTransform.ScaleShear[1][0] = GR2LibPropertyWrapper->Skeletons[i]->Bones[j]->LocalTransform->Scale.up.x;
+				_grn_file->GrannyFileInfo->Skeletons[i]->Bones[j].LocalTransform.ScaleShear[1][1] = GR2LibPropertyWrapper->Skeletons[i]->Bones[j]->LocalTransform->Scale.up.y;
+				_grn_file->GrannyFileInfo->Skeletons[i]->Bones[j].LocalTransform.ScaleShear[1][2] = GR2LibPropertyWrapper->Skeletons[i]->Bones[j]->LocalTransform->Scale.up.z;
+				_grn_file->GrannyFileInfo->Skeletons[i]->Bones[j].LocalTransform.ScaleShear[2][0] = GR2LibPropertyWrapper->Skeletons[i]->Bones[j]->LocalTransform->Scale.at.x;
+				_grn_file->GrannyFileInfo->Skeletons[i]->Bones[j].LocalTransform.ScaleShear[2][1] = GR2LibPropertyWrapper->Skeletons[i]->Bones[j]->LocalTransform->Scale.at.y;
+				_grn_file->GrannyFileInfo->Skeletons[i]->Bones[j].LocalTransform.ScaleShear[2][2] = GR2LibPropertyWrapper->Skeletons[i]->Bones[j]->LocalTransform->Scale.at.z;
+				// Update InverseWorld4x4
+				_grn_file->GrannyFileInfo->Skeletons[i]->Bones[j].InverseWorld4x4[0][0] = GR2LibPropertyWrapper->Skeletons[i]->Bones[j]->InverseWorld4x4.right.x;
+				_grn_file->GrannyFileInfo->Skeletons[i]->Bones[j].InverseWorld4x4[0][1] = GR2LibPropertyWrapper->Skeletons[i]->Bones[j]->InverseWorld4x4.right.y;
+				_grn_file->GrannyFileInfo->Skeletons[i]->Bones[j].InverseWorld4x4[0][2] = GR2LibPropertyWrapper->Skeletons[i]->Bones[j]->InverseWorld4x4.right.z;
+				_grn_file->GrannyFileInfo->Skeletons[i]->Bones[j].InverseWorld4x4[0][3] = GR2LibPropertyWrapper->Skeletons[i]->Bones[j]->InverseWorld4x4.right.w;
+				_grn_file->GrannyFileInfo->Skeletons[i]->Bones[j].InverseWorld4x4[1][0] = GR2LibPropertyWrapper->Skeletons[i]->Bones[j]->InverseWorld4x4.up.x;
+				_grn_file->GrannyFileInfo->Skeletons[i]->Bones[j].InverseWorld4x4[1][1] = GR2LibPropertyWrapper->Skeletons[i]->Bones[j]->InverseWorld4x4.up.y;
+				_grn_file->GrannyFileInfo->Skeletons[i]->Bones[j].InverseWorld4x4[1][2] = GR2LibPropertyWrapper->Skeletons[i]->Bones[j]->InverseWorld4x4.up.z;
+				_grn_file->GrannyFileInfo->Skeletons[i]->Bones[j].InverseWorld4x4[1][3] = GR2LibPropertyWrapper->Skeletons[i]->Bones[j]->InverseWorld4x4.up.w;
+				_grn_file->GrannyFileInfo->Skeletons[i]->Bones[j].InverseWorld4x4[2][0] = GR2LibPropertyWrapper->Skeletons[i]->Bones[j]->InverseWorld4x4.at.x;
+				_grn_file->GrannyFileInfo->Skeletons[i]->Bones[j].InverseWorld4x4[2][1] = GR2LibPropertyWrapper->Skeletons[i]->Bones[j]->InverseWorld4x4.at.y;
+				_grn_file->GrannyFileInfo->Skeletons[i]->Bones[j].InverseWorld4x4[2][2] = GR2LibPropertyWrapper->Skeletons[i]->Bones[j]->InverseWorld4x4.at.z;
+				_grn_file->GrannyFileInfo->Skeletons[i]->Bones[j].InverseWorld4x4[2][3] = GR2LibPropertyWrapper->Skeletons[i]->Bones[j]->InverseWorld4x4.at.w;
+				_grn_file->GrannyFileInfo->Skeletons[i]->Bones[j].InverseWorld4x4[3][0] = GR2LibPropertyWrapper->Skeletons[i]->Bones[j]->InverseWorld4x4.pos.x;
+				_grn_file->GrannyFileInfo->Skeletons[i]->Bones[j].InverseWorld4x4[3][1] = GR2LibPropertyWrapper->Skeletons[i]->Bones[j]->InverseWorld4x4.pos.y;
+				_grn_file->GrannyFileInfo->Skeletons[i]->Bones[j].InverseWorld4x4[3][2] = GR2LibPropertyWrapper->Skeletons[i]->Bones[j]->InverseWorld4x4.pos.z;
+				_grn_file->GrannyFileInfo->Skeletons[i]->Bones[j].InverseWorld4x4[3][3] = GR2LibPropertyWrapper->Skeletons[i]->Bones[j]->InverseWorld4x4.pos.w;
+
+				_grn_file->GrannyFileInfo->Skeletons[i]->Bones[j].LODError =  GR2LibPropertyWrapper->Skeletons[i]->Bones[j]->LODError;
+				_grn_file->GrannyFileInfo->Skeletons[i]->Bones[j].ExtendedData = ExtendedData_ToNative( GR2LibPropertyWrapper->Skeletons[i]->Bones[j]->ExtendedData,_grn_file->GrannyFileInfo->Skeletons[i]->Bones[j].ExtendedData);
+			}
+		}
+	}
+#pragma endregion
 #pragma endregion
 #pragma region ExtendedDataToManagedNative
 #pragma region ExtendedData_ToManaged

 

  ViewVC Help
Powered by ViewVC 1.1.22