public static List<Vector2[]> ApplySkinBlend(Uni2DMesh2D a_rMesh2D, Transform[] a_rJointCurrentTransforms, Transform a_rOriginTransform, SkinQuality a_eSkinQuality = SkinQuality.Auto) { List<Vector2[]> oBlendedShapeVertices = new List<Vector2[]>(); int iShapeIndex = 0; foreach(Uni2DMeshShape2D rShape in a_rMesh2D.shapes) { Vector2[] rVertices = rShape.vertices; int iVertexCount = rVertices.Length; Vector3[] oVertices3D = new Vector3[iVertexCount]; for(int i = 0; i < iVertexCount; ++i) { oVertices3D[i] = (Vector3)rVertices[i]; } Vector3[] oBlendedVertices3D = new Vector3[iVertexCount]; ApplySkinBlend(ref oBlendedVertices3D, oVertices3D, a_rMesh2D.bindposes, rShape.GetBoneWeightStructs(), a_rJointCurrentTransforms, a_rOriginTransform, a_eSkinQuality); Vector2[] oBlendedVertices = new Vector2[iVertexCount]; for(int i = 0; i < iVertexCount; ++i) { oBlendedVertices[i] = (Vector2)oBlendedVertices3D[i]; } oBlendedShapeVertices.Add(oBlendedVertices); ++iShapeIndex; } return oBlendedShapeVertices; }
public static Vector2[] ApplySkinBlend(Uni2DMesh2D a_rMesh2D, Transform[] a_rJointCurrentTransforms, Transform a_rOriginTransform, SkinQuality a_eSkinQuality = SkinQuality.Auto) { Vector2[] rVertices = a_rMesh2D.vertices; int iVertexCount = rVertices.Length; Vector3[] oVertices3D = new Vector3[iVertexCount]; for(int i = 0; i < iVertexCount; ++i) { oVertices3D[i] = (Vector3)rVertices[i]; } Vector3[] oBlendedVertices3D = new Vector3[iVertexCount]; ApplySkinBlend(ref oBlendedVertices3D, oVertices3D, a_rMesh2D.bindposes, a_rMesh2D.GetBoneWeightStructs(), a_rJointCurrentTransforms, a_rOriginTransform, a_eSkinQuality); Vector2[] oBlendedVertices = new Vector2[iVertexCount]; for(int i = 0; i < iVertexCount; ++i) { oBlendedVertices[i] = (Vector2)oBlendedVertices3D[i]; } return oBlendedVertices; }
public static void ApplySkinBlend( ref Vector3[] a_rBlendedVertices, Vector3[] a_rVertices, Matrix4x4[] a_rBindPoses, BoneWeight[] a_rBoneWeights, Transform[] a_rJointCurrentTransforms, Transform a_rOriginTransform, SkinQuality a_eSkinQuality = SkinQuality.Auto) { if(a_rJointCurrentTransforms.Length <= 0) { return; } // The skin quality is either 1, 2 or 4 bones int iSkinQuality; switch(a_eSkinQuality) { case SkinQuality.Bone1: { iSkinQuality = 1; } break; case SkinQuality.Bone2: { iSkinQuality = 2; } break; case SkinQuality.Bone4: { iSkinQuality = 4; } break; case SkinQuality.Auto: default: { switch(QualitySettings.blendWeights) { case BlendWeights.OneBone: { iSkinQuality = 1; } break; case BlendWeights.TwoBones: { iSkinQuality = 2; } break; case BlendWeights.FourBones: default: { iSkinQuality = 4; } break; } } break; } int iVertexCount = a_rVertices.Length; for(int i = 0; i < iVertexCount; i++) { Vector3 f3VertexPosition = a_rVertices[i]; BoneWeight oBoneWeight = a_rBoneWeights[i]; Vector3 f3NewVertexPosition = Vector3.zero; // Get the bone weight components into an array float[] oBoneWeightValues = new float[iSkinQuality]; int[] oBoneIndices = new int[iSkinQuality]; for(int k = 0; k < iSkinQuality; k++) { float fBoneWeightValue = 0.0f; int iBoneIndex = 0; switch(k) { case 0: { fBoneWeightValue = oBoneWeight.weight0; iBoneIndex = oBoneWeight.boneIndex0; } break; case 1: { fBoneWeightValue = oBoneWeight.weight1; iBoneIndex = oBoneWeight.boneIndex1; } break; case 2: { fBoneWeightValue = oBoneWeight.weight2; iBoneIndex = oBoneWeight.boneIndex2; } break; case 3: { fBoneWeightValue = oBoneWeight.weight3; iBoneIndex = oBoneWeight.boneIndex3; } break; } oBoneWeightValues[k] = fBoneWeightValue; oBoneIndices[k] = iBoneIndex; } // Normalize the bone weights float fTotalWeightValue = 0.0f; for(int k = 0; k < iSkinQuality; k++) { fTotalWeightValue += oBoneWeightValues[k]; } if(fTotalWeightValue != 0.0f) { for(int k = 0; k < iSkinQuality; k++) { oBoneWeightValues[k] /= fTotalWeightValue; } } // Transform the point for(int k = 0; k < iSkinQuality; k++) { int iBoneIndex = oBoneIndices[k]; Transform rBoneTransform = a_rJointCurrentTransforms[iBoneIndex]; Vector3 f3VertexPositionInfluencedByCurrentBone; if(rBoneTransform == null) { f3VertexPositionInfluencedByCurrentBone = f3VertexPosition; } else { Matrix4x4 oBoneCurrentPose = a_rOriginTransform.worldToLocalMatrix * rBoneTransform.localToWorldMatrix; Matrix4x4 oBindPose = a_rBindPoses[iBoneIndex]; f3VertexPositionInfluencedByCurrentBone = (oBoneCurrentPose * oBindPose).MultiplyPoint(f3VertexPosition); } f3NewVertexPosition += f3VertexPositionInfluencedByCurrentBone * oBoneWeightValues[k]; } a_rBlendedVertices[i] = f3NewVertexPosition; } }
public static void ApplySkinBlend(ref Vector3[] a_rBlendedVertices, Mesh a_rMesh, Transform[] a_rJointCurrentTransforms, Transform a_rOriginTransform, SkinQuality a_eSkinQuality = SkinQuality.Auto) { ApplySkinBlend(ref a_rBlendedVertices, a_rMesh.vertices, a_rMesh.bindposes, a_rMesh.boneWeights, a_rJointCurrentTransforms, a_rOriginTransform, a_eSkinQuality); }
public void OnGUI() { EditorGUILayout.LabelField("要检测的文件夹:"); m_TargetDirectory = EditorGUILayout.TextField(m_TargetDirectory); GUI.SetNextControlName("Browse"); if (GUILayout.Button("Browse", GUILayout.Width(60f))) { string pathTarget = EditorUtility.OpenFolderPanel("Open Target Directory", m_TargetDirectory, ""); m_TargetDirectory = pathTarget.Length > 0 ? pathTarget : m_TargetDirectory; GUI.FocusControl("Browse"); } EditorGUILayout.Space(); EditorGUILayout.Space(); checkType = (CheckType)GUILayout.Toolbar((int)checkType, checkTypeLabel); if (checkType == CheckType.TEXTURE) { EditorGUILayout.HelpBox("支持文件名后缀为 PSD、JPG、PNG、TGA", MessageType.Info, true); EditorGUILayout.BeginHorizontal(); GUILayout.Label("图片幂指数检索:", GUILayout.Width(80f), GUILayout.Height(30f)); is_Mizhi = EditorGUILayout.Toggle(is_Mizhi, GUILayout.Width(40f), GUILayout.Height(30f)); EditorGUILayout.EndHorizontal(); EditorGUILayout.BeginHorizontal(); GUILayout.Label("宽高不相等检索:", GUILayout.Width(80f), GUILayout.Height(30f)); is_WidHei = EditorGUILayout.Toggle(is_WidHei, GUILayout.Width(40f)); EditorGUILayout.EndHorizontal(); EditorGUILayout.BeginHorizontal(); is_Width = EditorGUILayout.Toggle(is_Width, GUILayout.Width(40f), GUILayout.Height(30f)); GUILayout.Label("图片宽检索:", GUILayout.Width(80f), GUILayout.Height(30f)); widthWarning = EditorGUILayout.IntField("宽度像素(警告):", widthWarning); widthErroring = EditorGUILayout.IntField("宽度像素(错误):", widthErroring); EditorGUILayout.EndHorizontal(); EditorGUILayout.BeginHorizontal(); is_Height = EditorGUILayout.Toggle(is_Height, GUILayout.Width(40f), GUILayout.Height(30f)); GUILayout.Label("图片高检索:", GUILayout.Width(80f), GUILayout.Height(30f)); heightWarning = EditorGUILayout.IntField("高度像素(警告):", heightWarning); heightErroring = EditorGUILayout.IntField("高度像素(错误):", heightErroring); EditorGUILayout.EndHorizontal(); } if (checkType == CheckType.VERTEX_AND_FACE) { EditorGUILayout.HelpBox("支持文件名后缀为 FBX", MessageType.Info, true); EditorGUILayout.BeginHorizontal(); is_Vertex = EditorGUILayout.Toggle(is_Vertex, GUILayout.Width(40f), GUILayout.Height(30f)); GUILayout.Label("模型顶点检索:", GUILayout.Width(80f), GUILayout.Height(30f)); vertexWarning = EditorGUILayout.IntField("顶点数(警告):", vertexWarning); vertexErroring = EditorGUILayout.IntField("顶点数(错误):", vertexErroring); EditorGUILayout.EndHorizontal(); EditorGUILayout.BeginHorizontal(); is_face = EditorGUILayout.Toggle(is_face, GUILayout.Width(40f), GUILayout.Height(30f)); GUILayout.Label("模型面检索:", GUILayout.Width(80f), GUILayout.Height(30f)); faceWarning = EditorGUILayout.IntField("面数(警告):", faceWarning); faceErroring = EditorGUILayout.IntField("面数(错误):", faceErroring); EditorGUILayout.EndHorizontal(); } if (checkType == CheckType.TANGENT) { EditorGUILayout.HelpBox("支持文件名后缀为 FBX", MessageType.Info, true); EditorGUILayout.BeginHorizontal(); is_set_tangent = EditorGUILayout.Toggle("修改为:", is_set_tangent); modelTangentOption = (ModelImporterTangentSpaceMode)EditorGUILayout.EnumPopup(modelTangentOption); EditorGUILayout.EndHorizontal(); } if (checkType == CheckType.BONE_AMOUNT) { EditorGUILayout.HelpBox("支持文件名后缀为 FBX", MessageType.Info, true); EditorGUILayout.BeginHorizontal(); ignoreZeroBone = EditorGUILayout.Toggle("忽略0骨骼", ignoreZeroBone); EditorGUILayout.EndHorizontal(); } if (checkType == CheckType.BONE_QUALITY) { EditorGUILayout.HelpBox("检测 Prefab", MessageType.Info, true); EditorGUILayout.BeginHorizontal(); is_set_boneQuality = EditorGUILayout.Toggle("修改为:", is_set_boneQuality); boneQuality = (SkinQuality)EditorGUILayout.EnumPopup(boneQuality); EditorGUILayout.EndHorizontal(); } EditorGUILayout.BeginHorizontal(); if (GUILayout.Button("Go", GUILayout.Width(80f), GUILayout.Height(30f))) { if (allFiles == null) { try { if (m_TargetDirectory == "") { string str = "设置要检测的文件夹"; GUIContent content = new GUIContent(str); window.ShowNotification(content); } if (m_TargetDirectory != "") { allFiles = new List<FileInfo>(); GetAllFiles(new DirectoryInfo(m_TargetDirectory)); progressTotal = allFiles.Count; progressCurrent = 0; meshInfo.Clear(); meshInfoNoSort.Clear(); pictureInfo.Clear(); PictureRedWid.Clear(); PictureGreenWid.Clear(); PictureYellowWid.Clear(); PictureRedHei.Clear(); PictureGreenHei.Clear(); PictureYellowHei.Clear(); PictureWidHei.Clear(); ModelMeshRedVer.Clear(); ModelMeshGreenVer.Clear(); ModelMeshYellowVer.Clear(); ModelMeshRedFac.Clear(); ModelMeshGreenFac.Clear(); ModelMeshYellowFac.Clear(); ModelTangentMsg.Clear(); ModelBoneMsg.Clear(); BoneQualityMsg.Clear(); } } catch (Exception e) { Debug.LogError(e.Message); Debug.LogError(e.StackTrace); } } } EditorGUILayout.EndHorizontal(); { float progressValue = progressTotal == 0 ? 0 : (float)progressCurrent / (float)progressTotal; EditorGUI.ProgressBar(new Rect(5, position.height - 22, position.width - 10, 20), progressValue, progressCurrent + "/" + progressTotal); } if (allFiles != null) { if (allFiles.Count > 0) { if (progressCount >= 1) { progressCount = -1; ProgressCoroutine(); } ++progressCount; this.Repaint(); } else { allFiles = null; m_RootDirectory = Application.persistentDataPath; string resultPath = m_RootDirectory + htmlstr; ConstructOutput(); ConstructHTML(); UnityEditor.EditorUtility.OpenWithDefaultApp(resultPath); } } }
public void Add(Vector3[] a_Vertices, Vector3[] a_Normals, Vector4[] a_Tangents, Color[] a_Colors, Vector2[] a_UVs, Vector2[] a_UV2s, BoneWeight[] a_BoneWeights, int[] a_Triangles, Transform[] a_Bones, Matrix4x4[] a_BindPoses, SkinQuality a_SkinQuality, Matrix4x4 a_WorldToMeshMatrix, Matrix4x4 a_MeshToWorldMatrix) { SkinnedDecalProjectorBase activeDecalProjector = base.ActiveDecalProjector; if (activeDecalProjector == null) { throw new NullReferenceException("The active decal projector is not allowed to be null as mesh data should be added!"); } if ((base.m_Decals.CurrentUVMode == UVMode.Project) || (base.m_Decals.CurrentUVMode == UVMode.ProjectWrapped)) { if (Edition.IsDecalSystemFree && (base.m_Decals.CurrentTextureAtlasType == TextureAtlasType.Reference)) { throw new InvalidOperationException("Texture atlas references can only be used with Decal System Pro."); } if ((0 > activeDecalProjector.UV1RectangleIndex) || (activeDecalProjector.UV1RectangleIndex >= base.m_Decals.uvRectangles.Length)) { throw new IndexOutOfRangeException("The uv rectangle index of the active projector is not a valid index within the decals uv rectangles array!"); } } if ((base.m_Decals.CurrentUV2Mode == UV2Mode.Project) || (base.m_Decals.CurrentUV2Mode == UV2Mode.ProjectWrapped)) { if (Edition.IsDecalSystemFree && (base.m_Decals.CurrentTextureAtlasType == TextureAtlasType.Reference)) { throw new InvalidOperationException("Texture atlas references can only be used with Decal System Pro."); } if ((0 > activeDecalProjector.UV2RectangleIndex) || (activeDecalProjector.UV2RectangleIndex >= base.m_Decals.uv2Rectangles.Length)) { throw new IndexOutOfRangeException("The uv2 rectangle index of the active projector is not a valid index within the decals uv2 rectangles array!"); } } if (base.m_Decals.UseVertexColors && Edition.IsDecalSystemFree) { throw new InvalidOperationException("Vertex colors are only supported in Decal System Pro."); } if (a_Vertices == null) { throw new ArgumentNullException("The vertices parameter is not allowed to be null!"); } if (a_Normals == null) { throw new ArgumentNullException("The normals parameter is not allowed to be null!"); } if (a_Triangles == null) { throw new ArgumentNullException("The triangles parameter is not allowed to be null!"); } if (a_Vertices.Length != a_Normals.Length) { throw new FormatException("The number of vertices does not match the number of normals!"); } if (a_Bones == null) { throw new NullReferenceException("The bones are null!"); } if (a_BindPoses == null) { throw new NullReferenceException("The bind poses are null!"); } if (a_Bones.Length != a_BindPoses.Length) { throw new FormatException("The number of bind poses does not match the number of bones!"); } if (base.m_Decals.CurrentTangentsMode == TangentsMode.Target) { if (a_Tangents == null) { throw new ArgumentNullException("The tangents parameter is not allowed to be null!"); } if (a_Vertices.Length != a_Tangents.Length) { throw new FormatException("The number of vertices does not match the number of tangents!"); } } if ((base.m_Decals.CurrentUVMode == UVMode.TargetUV) || (base.m_Decals.CurrentUVMode == UVMode.TargetUV2)) { if (a_UVs == null) { throw new ArgumentNullException("The uv parameter is not allowed to be null!"); } if (a_Vertices.Length != a_UVs.Length) { throw new FormatException("The number of vertices does not match the number of uv's!"); } } else if ((base.m_Decals.CurrentUV2Mode == UV2Mode.TargetUV) || (base.m_Decals.CurrentUV2Mode == UV2Mode.TargetUV2)) { if (a_UV2s == null) { throw new NullReferenceException("The uv2 parameter is not allowed to be null!"); } if (a_Vertices.Length != a_UV2s.Length) { throw new FormatException("The number of vertices does not match the number of uv2's!"); } } if (base.m_Decals.UseVertexColors && ((a_Colors != null) && ((a_Colors.Length != 0) && (a_Vertices.Length != a_Colors.Length)))) { throw new FormatException("The number of vertices does not macht the number of colors!"); } Vector3 v = new Vector3(0f, 1f, 0f); Matrix4x4 worldToLocalMatrix = base.m_Decals.CachedTransform.worldToLocalMatrix; v = (worldToLocalMatrix * activeDecalProjector.ProjectorToWorldMatrix).inverse.transpose.MultiplyVector(v).normalized; Matrix4x4 matrixx5 = worldToLocalMatrix * a_MeshToWorldMatrix; Matrix4x4 transpose = matrixx5.inverse.transpose; float num = Mathf.Cos(activeDecalProjector.CullingAngle * 0.01745329f); int count = base.m_Vertices.Count; int num3 = this.l_Bones.Count; for (int i = 0; i < a_Bones.Length; i++) { this.l_Bones.Add(a_Bones[i]); this.m_BindPoses.Add(a_BindPoses[i] * matrixx5.inverse); } this.InternalAdd(a_Vertices, a_Normals, a_Tangents, a_Colors, a_UVs, a_UV2s, a_BoneWeights, a_Triangles, num3, a_BindPoses, a_SkinQuality, v, num, worldToLocalMatrix, matrixx5, transpose); if (a_WorldToMeshMatrix.Determinant() >= 0f) { for (int j = 0; j < a_Triangles.Length; j += 3) { int num7 = a_Triangles[j]; int num8 = a_Triangles[j + 1]; int num9 = a_Triangles[j + 2]; if (!base.m_RemovedIndices.IsRemovedIndex(num7) && (!base.m_RemovedIndices.IsRemovedIndex(num8) && !base.m_RemovedIndices.IsRemovedIndex(num9))) { num7 = count + base.m_RemovedIndices.AdjustedIndex(num7); num8 = count + base.m_RemovedIndices.AdjustedIndex(num8); num9 = count + base.m_RemovedIndices.AdjustedIndex(num9); base.m_Triangles.Add(num7); base.m_Triangles.Add(num8); base.m_Triangles.Add(num9); } } } else { for (int j = 0; j < a_Triangles.Length; j += 3) { int num11 = a_Triangles[j]; int num12 = a_Triangles[j + 1]; int num13 = a_Triangles[j + 2]; if (!base.m_RemovedIndices.IsRemovedIndex(num11) && (!base.m_RemovedIndices.IsRemovedIndex(num12) && !base.m_RemovedIndices.IsRemovedIndex(num13))) { num11 = count + base.m_RemovedIndices.AdjustedIndex(num11); num12 = count + base.m_RemovedIndices.AdjustedIndex(num12); num13 = count + base.m_RemovedIndices.AdjustedIndex(num13); base.m_Triangles.Add(num12); base.m_Triangles.Add(num11); base.m_Triangles.Add(num13); } } } base.m_RemovedIndices.Clear(); activeDecalProjector.DecalsMeshUpperVertexIndex = base.m_Vertices.Count - 1; activeDecalProjector.DecalsMeshUpperTriangleIndex = base.m_Triangles.Count - 1; activeDecalProjector.DecalsMeshUpperBonesIndex = this.l_Bones.Count - 1; activeDecalProjector.IsTangentProjectionCalculated = false; activeDecalProjector.IsUV1ProjectionCalculated = false; activeDecalProjector.IsUV2ProjectionCalculated = false; }
public void EnableSkinnedMeshRenderers(SkinQuality enable) { if (mSkinnedMeshRenderers == null) return; for (int i = 0; i < mSkinnedMeshRenderers.Length; i++) { mSkinnedMeshRenderers[i].enabled = true; mSkinnedMeshRenderers[i].quality = (SkinQuality)enable; } }
public static void ApplySkinBlend(ref Vector3[] a_rBlendedVertices, Vector3[] a_rVertices, Matrix4x4[] a_rBindPoses, BoneWeight[] a_rBoneWeights, Transform[] a_rJointCurrentTransforms, Transform a_rOriginTransform, SkinQuality a_eSkinQuality = SkinQuality.Auto) { if (a_rJointCurrentTransforms.Length <= 0) { return; } // The skin quality is either 1, 2 or 4 bones int iSkinQuality; switch (a_eSkinQuality) { case SkinQuality.Bone1: { iSkinQuality = 1; } break; case SkinQuality.Bone2: { iSkinQuality = 2; } break; case SkinQuality.Bone4: { iSkinQuality = 4; } break; case SkinQuality.Auto: default: { switch (QualitySettings.blendWeights) { case BlendWeights.OneBone: { iSkinQuality = 1; } break; case BlendWeights.TwoBones: { iSkinQuality = 2; } break; case BlendWeights.FourBones: default: { iSkinQuality = 4; } break; } } break; } int iVertexCount = a_rVertices.Length; for (int i = 0; i < iVertexCount; i++) { Vector3 f3VertexPosition = a_rVertices[i]; BoneWeight oBoneWeight = a_rBoneWeights[i]; Vector3 f3NewVertexPosition = Vector3.zero; // Get the bone weight components into an array float[] oBoneWeightValues = new float[iSkinQuality]; int[] oBoneIndices = new int[iSkinQuality]; for (int k = 0; k < iSkinQuality; k++) { float fBoneWeightValue = 0.0f; int iBoneIndex = 0; switch (k) { case 0: { fBoneWeightValue = oBoneWeight.weight0; iBoneIndex = oBoneWeight.boneIndex0; } break; case 1: { fBoneWeightValue = oBoneWeight.weight1; iBoneIndex = oBoneWeight.boneIndex1; } break; case 2: { fBoneWeightValue = oBoneWeight.weight2; iBoneIndex = oBoneWeight.boneIndex2; } break; case 3: { fBoneWeightValue = oBoneWeight.weight3; iBoneIndex = oBoneWeight.boneIndex3; } break; } oBoneWeightValues[k] = fBoneWeightValue; oBoneIndices[k] = iBoneIndex; } // Normalize the bone weights float fTotalWeightValue = 0.0f; for (int k = 0; k < iSkinQuality; k++) { fTotalWeightValue += oBoneWeightValues[k]; } if (fTotalWeightValue != 0.0f) { for (int k = 0; k < iSkinQuality; k++) { oBoneWeightValues[k] /= fTotalWeightValue; } } // Transform the point for (int k = 0; k < iSkinQuality; k++) { int iBoneIndex = oBoneIndices[k]; Transform rBoneTransform = a_rJointCurrentTransforms[iBoneIndex]; Vector3 f3VertexPositionInfluencedByCurrentBone; if (rBoneTransform == null) { f3VertexPositionInfluencedByCurrentBone = f3VertexPosition; } else { Matrix4x4 oBoneCurrentPose = a_rOriginTransform.worldToLocalMatrix * rBoneTransform.localToWorldMatrix; Matrix4x4 oBindPose = a_rBindPoses[iBoneIndex]; f3VertexPositionInfluencedByCurrentBone = (oBoneCurrentPose * oBindPose).MultiplyPoint(f3VertexPosition); } f3NewVertexPosition += f3VertexPositionInfluencedByCurrentBone * oBoneWeightValues[k]; } a_rBlendedVertices[i] = f3NewVertexPosition; } }
public void OnGUI() { EditorGUILayout.LabelField("要检测的文件夹:"); m_TargetDirectory = EditorGUILayout.TextField(m_TargetDirectory); GUI.SetNextControlName("Browse"); if (GUILayout.Button("Browse", GUILayout.Width(60f))) { string pathTarget = EditorUtility.OpenFolderPanel("Open Target Directory", m_TargetDirectory, ""); m_TargetDirectory = pathTarget.Length > 0 ? pathTarget : m_TargetDirectory; GUI.FocusControl("Browse"); } EditorGUILayout.Space(); EditorGUILayout.Space(); checkType = (CheckType)GUILayout.Toolbar((int)checkType, checkTypeLabel); if (checkType == CheckType.TEXTURE) { EditorGUILayout.HelpBox("支持文件名后缀为 PSD、JPG、PNG、TGA", MessageType.Info, true); EditorGUILayout.BeginHorizontal(); GUILayout.Label("图片幂指数检索:", GUILayout.Width(80f), GUILayout.Height(30f)); is_Mizhi = EditorGUILayout.Toggle(is_Mizhi, GUILayout.Width(40f), GUILayout.Height(30f)); EditorGUILayout.EndHorizontal(); EditorGUILayout.BeginHorizontal(); GUILayout.Label("宽高不相等检索:", GUILayout.Width(80f), GUILayout.Height(30f)); is_WidHei = EditorGUILayout.Toggle(is_WidHei, GUILayout.Width(40f)); EditorGUILayout.EndHorizontal(); EditorGUILayout.BeginHorizontal(); is_Width = EditorGUILayout.Toggle(is_Width, GUILayout.Width(40f), GUILayout.Height(30f)); GUILayout.Label("图片宽检索:", GUILayout.Width(80f), GUILayout.Height(30f)); widthWarning = EditorGUILayout.IntField("宽度像素(警告):", widthWarning); widthErroring = EditorGUILayout.IntField("宽度像素(错误):", widthErroring); EditorGUILayout.EndHorizontal(); EditorGUILayout.BeginHorizontal(); is_Height = EditorGUILayout.Toggle(is_Height, GUILayout.Width(40f), GUILayout.Height(30f)); GUILayout.Label("图片高检索:", GUILayout.Width(80f), GUILayout.Height(30f)); heightWarning = EditorGUILayout.IntField("高度像素(警告):", heightWarning); heightErroring = EditorGUILayout.IntField("高度像素(错误):", heightErroring); EditorGUILayout.EndHorizontal(); } if (checkType == CheckType.VERTEX_AND_FACE) { EditorGUILayout.HelpBox("支持文件名后缀为 FBX", MessageType.Info, true); EditorGUILayout.BeginHorizontal(); is_Vertex = EditorGUILayout.Toggle(is_Vertex, GUILayout.Width(40f), GUILayout.Height(30f)); GUILayout.Label("模型顶点检索:", GUILayout.Width(80f), GUILayout.Height(30f)); vertexWarning = EditorGUILayout.IntField("顶点数(警告):", vertexWarning); vertexErroring = EditorGUILayout.IntField("顶点数(错误):", vertexErroring); EditorGUILayout.EndHorizontal(); EditorGUILayout.BeginHorizontal(); is_face = EditorGUILayout.Toggle(is_face, GUILayout.Width(40f), GUILayout.Height(30f)); GUILayout.Label("模型面检索:", GUILayout.Width(80f), GUILayout.Height(30f)); faceWarning = EditorGUILayout.IntField("面数(警告):", faceWarning); faceErroring = EditorGUILayout.IntField("面数(错误):", faceErroring); EditorGUILayout.EndHorizontal(); } if (checkType == CheckType.TANGENT) { EditorGUILayout.HelpBox("支持文件名后缀为 FBX", MessageType.Info, true); EditorGUILayout.BeginHorizontal(); is_set_tangent = EditorGUILayout.Toggle("修改为:", is_set_tangent); modelTangentOption = (ModelImporterTangentSpaceMode)EditorGUILayout.EnumPopup(modelTangentOption); EditorGUILayout.EndHorizontal(); } if (checkType == CheckType.BONE_AMOUNT) { EditorGUILayout.HelpBox("支持文件名后缀为 FBX", MessageType.Info, true); EditorGUILayout.BeginHorizontal(); ignoreZeroBone = EditorGUILayout.Toggle("忽略0骨骼", ignoreZeroBone); EditorGUILayout.EndHorizontal(); } if (checkType == CheckType.BONE_QUALITY) { EditorGUILayout.HelpBox("检测 Prefab", MessageType.Info, true); EditorGUILayout.BeginHorizontal(); is_set_boneQuality = EditorGUILayout.Toggle("修改为:", is_set_boneQuality); boneQuality = (SkinQuality)EditorGUILayout.EnumPopup(boneQuality); EditorGUILayout.EndHorizontal(); } EditorGUILayout.BeginHorizontal(); if (GUILayout.Button("Go", GUILayout.Width(80f), GUILayout.Height(30f))) { if (allFiles == null) { try { if (m_TargetDirectory == "") { string str = "设置要检测的文件夹"; GUIContent content = new GUIContent(str); window.ShowNotification(content); } if (m_TargetDirectory != "") { allFiles = new List <FileInfo>(); GetAllFiles(new DirectoryInfo(m_TargetDirectory)); progressTotal = allFiles.Count; progressCurrent = 0; meshInfo.Clear(); meshInfoNoSort.Clear(); pictureInfo.Clear(); PictureRedWid.Clear(); PictureGreenWid.Clear(); PictureYellowWid.Clear(); PictureRedHei.Clear(); PictureGreenHei.Clear(); PictureYellowHei.Clear(); PictureWidHei.Clear(); ModelMeshRedVer.Clear(); ModelMeshGreenVer.Clear(); ModelMeshYellowVer.Clear(); ModelMeshRedFac.Clear(); ModelMeshGreenFac.Clear(); ModelMeshYellowFac.Clear(); ModelTangentMsg.Clear(); ModelBoneMsg.Clear(); BoneQualityMsg.Clear(); } } catch (Exception e) { Debug.LogError(e.Message); Debug.LogError(e.StackTrace); } } } EditorGUILayout.EndHorizontal(); { float progressValue = progressTotal == 0 ? 0 : (float)progressCurrent / (float)progressTotal; EditorGUI.ProgressBar(new Rect(5, position.height - 22, position.width - 10, 20), progressValue, progressCurrent + "/" + progressTotal); } if (allFiles != null) { if (allFiles.Count > 0) { if (progressCount >= 1) { progressCount = -1; ProgressCoroutine(); } ++progressCount; this.Repaint(); } else { allFiles = null; m_RootDirectory = Application.persistentDataPath; string resultPath = m_RootDirectory + htmlstr; ConstructOutput(); ConstructHTML(); UnityEditor.EditorUtility.OpenWithDefaultApp(resultPath); } } }
public void EnableSkinMeshRenderer(SkinQuality enable) { if (_ABLoadGoMono != null) _ABLoadGoMono.EnableSR = enable; }
private static void RestoreDefaults( ) { Uni2DEditorPreferences.ActiveBoneGizmoColor = Color.green; Uni2DEditorPreferences.ActiveRootBoneGizmoColor = Color.green; Uni2DEditorPreferences.EditableBoneGizmoColor = Color.yellow; Uni2DEditorPreferences.EditableRootBoneGizmoColor = Color.magenta; Uni2DEditorPreferences.SelectedBoneGizmoColor = Color.green; Uni2DEditorPreferences.SelectedRootBoneGizmoColor = Color.green; Uni2DEditorPreferences.UnselectedBoneGizmoColor = Color.blue; Uni2DEditorPreferences.UnselectedRootBoneGizmoColor = Color.cyan; Uni2DEditorPreferences.InnerBoneDiscHandleColor = Color.white; Uni2DEditorPreferences.InnerRootBoneDiscHandleColor = Color.white; Uni2DEditorPreferences.OuterBoneDiscHandleColor = Color.red; Uni2DEditorPreferences.OuterRootBoneDiscHandleColor = Color.magenta; Uni2DEditorPreferences.SelectedBoneGizmoColor = Color.green; Uni2DEditorPreferences.SelectedRootBoneDiscHandleOutlineColor = Color.magenta; Uni2DEditorPreferences.SmoothBindingDefaultSkinQuality = SkinQuality.Bone4; }
public static void ShowUni2DPreferences( ) { GUILayoutOption oMaxWidthOption = GUILayout.MaxWidth( 135.0f ); GUILayoutOption oMaxColorPickedWidthOption = GUILayout.MaxWidth( 100.0f ); //EditorGUILayout.HelpBox( "Uni2D Beta", MessageType.Warning, true ); EditorGUILayout.BeginVertical( ); { // Header EditorGUILayout.BeginHorizontal( ); { EditorGUILayout.LabelField( "Bone Gizmo State", EditorStyles.boldLabel, oMaxWidthOption ); EditorGUILayout.LabelField( "Bone", EditorStyles.boldLabel, oMaxColorPickedWidthOption ); EditorGUILayout.LabelField( "Root Bone", EditorStyles.boldLabel, oMaxColorPickedWidthOption ); } EditorGUILayout.EndHorizontal( ); // Unselected EditorGUILayout.BeginHorizontal( ); { EditorGUILayout.LabelField( "Unselected", oMaxWidthOption ); Uni2DEditorPreferences.UnselectedBoneGizmoColor = EditorGUILayout.ColorField( Uni2DEditorPreferences.UnselectedBoneGizmoColor, oMaxColorPickedWidthOption ); Uni2DEditorPreferences.UnselectedRootBoneGizmoColor = EditorGUILayout.ColorField( Uni2DEditorPreferences.UnselectedRootBoneGizmoColor, oMaxColorPickedWidthOption ); } EditorGUILayout.EndHorizontal( ); // Selected EditorGUILayout.BeginHorizontal( ); { EditorGUILayout.LabelField( "Selected", oMaxWidthOption ); Uni2DEditorPreferences.SelectedBoneGizmoColor = EditorGUILayout.ColorField( Uni2DEditorPreferences.SelectedBoneGizmoColor, oMaxColorPickedWidthOption ); Uni2DEditorPreferences.SelectedRootBoneGizmoColor = EditorGUILayout.ColorField( Uni2DEditorPreferences.SelectedRootBoneGizmoColor, oMaxColorPickedWidthOption ); } EditorGUILayout.EndHorizontal( ); // Editable EditorGUILayout.BeginHorizontal( ); { EditorGUILayout.LabelField( "Editable", oMaxWidthOption ); Uni2DEditorPreferences.EditableBoneGizmoColor = EditorGUILayout.ColorField( Uni2DEditorPreferences.EditableBoneGizmoColor, oMaxColorPickedWidthOption ); Uni2DEditorPreferences.EditableRootBoneGizmoColor = EditorGUILayout.ColorField( Uni2DEditorPreferences.EditableRootBoneGizmoColor, oMaxColorPickedWidthOption ); } EditorGUILayout.EndHorizontal( ); // Active EditorGUILayout.BeginHorizontal( ); { EditorGUILayout.LabelField( "Active", oMaxWidthOption ); Uni2DEditorPreferences.ActiveBoneGizmoColor = EditorGUILayout.ColorField( Uni2DEditorPreferences.ActiveBoneGizmoColor, oMaxColorPickedWidthOption ); Uni2DEditorPreferences.ActiveRootBoneGizmoColor = EditorGUILayout.ColorField( Uni2DEditorPreferences.ActiveRootBoneGizmoColor, oMaxColorPickedWidthOption ); } EditorGUILayout.EndHorizontal( ); EditorGUILayout.Space( ); // Header EditorGUILayout.BeginHorizontal( ); { EditorGUILayout.LabelField( "Disc Handle", EditorStyles.boldLabel, oMaxWidthOption ); EditorGUILayout.LabelField( "Bone", EditorStyles.boldLabel, oMaxColorPickedWidthOption ); EditorGUILayout.LabelField( "Root Bone", EditorStyles.boldLabel, oMaxColorPickedWidthOption ); } EditorGUILayout.EndHorizontal( ); // Inner disc handle EditorGUILayout.BeginHorizontal( ); { EditorGUILayout.LabelField( "Inner", oMaxWidthOption ); Uni2DEditorPreferences.InnerBoneDiscHandleColor = EditorGUILayout.ColorField( Uni2DEditorPreferences.InnerBoneDiscHandleColor, oMaxColorPickedWidthOption ); Uni2DEditorPreferences.InnerRootBoneDiscHandleColor = EditorGUILayout.ColorField( Uni2DEditorPreferences.InnerRootBoneDiscHandleColor, oMaxColorPickedWidthOption ); } EditorGUILayout.EndHorizontal( ); // Outer disc handle EditorGUILayout.BeginHorizontal( ); { EditorGUILayout.LabelField( "Outer", oMaxWidthOption ); Uni2DEditorPreferences.OuterBoneDiscHandleColor = EditorGUILayout.ColorField( Uni2DEditorPreferences.OuterBoneDiscHandleColor, oMaxColorPickedWidthOption ); Uni2DEditorPreferences.OuterRootBoneDiscHandleColor = EditorGUILayout.ColorField( Uni2DEditorPreferences.OuterRootBoneDiscHandleColor, oMaxColorPickedWidthOption ); } EditorGUILayout.EndHorizontal( ); // Selected disc handle outline EditorGUILayout.BeginHorizontal( ); { EditorGUILayout.LabelField( "Outline (when selected)", oMaxWidthOption ); Uni2DEditorPreferences.SelectedBoneGizmoColor = EditorGUILayout.ColorField( Uni2DEditorPreferences.SelectedBoneDiscHandleOutlineColor, oMaxColorPickedWidthOption ); Uni2DEditorPreferences.SelectedRootBoneGizmoColor = EditorGUILayout.ColorField( Uni2DEditorPreferences.SelectedRootBoneDiscHandleOutlineColor, oMaxColorPickedWidthOption ); } EditorGUILayout.EndHorizontal( ); EditorGUILayout.Space( ); } EditorGUILayout.EndVertical( ); Uni2DEditorPreferences.SmoothBindingDefaultSkinQuality = (SkinQuality) EditorGUILayout.EnumPopup( "Default Skin Quality", Uni2DEditorPreferences.SmoothBindingDefaultSkinQuality ); EditorGUILayout.Space( ); EditorGUILayout.BeginHorizontal( ); { if( GUILayout.Button( "Use Default" ) ) { Uni2DEditorPreferences.RestoreDefaults( ); } GUILayout.FlexibleSpace( ); } EditorGUILayout.EndHorizontal( ); EditorGUILayout.Space( ); // Asset table rebuild EditorGUILayout.BeginVertical( ); { EditorGUILayout.LabelField( "Rebuild the Uni2D asset table if you think Uni2D is not handling your assets properly.", EditorStyles.wordWrappedLabel ); if( GUILayout.Button( "Rebuild Uni2D Asset Table" ) ) { Uni2DEditorAssetTable rAssetTable = Uni2DEditorAssetTable.Instance; rAssetTable.Rebuild( ); } } EditorGUILayout.EndVertical( ); }
private void InternalAdd(Vector3[] a_Vertices, Vector3[] a_Normals, Vector4[] a_Tangents, Color[] a_Colors, Vector2[] a_UVs, Vector2[] a_UV2s, BoneWeight[] a_BoneWeights, int[] a_Triangles, int a_BoneIndexOffset, Matrix4x4[] a_BindPoses, SkinQuality a_SkinQuality, Vector3 a_ReversedProjectionNormal, float a_CullingDotProduct, Matrix4x4 a_WorldToDecalsMatrix, Matrix4x4 a_MeshToDecalsMatrix, Matrix4x4 a_MeshToDecalsMatrixInvertedTransposed) { if ((a_SkinQuality == SkinQuality.Bone1) || ((a_SkinQuality == SkinQuality.Auto) && (QualitySettings.blendWeights == BlendWeights.OneBone))) { this.AddSkinQuality1(a_Vertices, a_Normals, a_Tangents, a_Colors, a_UVs, a_UV2s, a_BoneWeights, a_Triangles, a_BoneIndexOffset, a_BindPoses, a_ReversedProjectionNormal, a_CullingDotProduct, a_WorldToDecalsMatrix, a_MeshToDecalsMatrix, a_MeshToDecalsMatrixInvertedTransposed); } else if ((a_SkinQuality == SkinQuality.Bone2) || ((a_SkinQuality == SkinQuality.Auto) && (QualitySettings.blendWeights == BlendWeights.TwoBones))) { this.AddSkinQuality2(a_Vertices, a_Normals, a_Tangents, a_Colors, a_UVs, a_UV2s, a_BoneWeights, a_Triangles, a_BoneIndexOffset, a_BindPoses, a_ReversedProjectionNormal, a_CullingDotProduct, a_WorldToDecalsMatrix, a_MeshToDecalsMatrix, a_MeshToDecalsMatrixInvertedTransposed); } else if ((a_SkinQuality == SkinQuality.Bone4) || ((a_SkinQuality == SkinQuality.Auto) && (QualitySettings.blendWeights == BlendWeights.FourBones))) { this.AddSkinQuality4(a_Vertices, a_Normals, a_Tangents, a_Colors, a_UVs, a_UV2s, a_BoneWeights, a_Triangles, a_BoneIndexOffset, a_BindPoses, a_ReversedProjectionNormal, a_CullingDotProduct, a_WorldToDecalsMatrix, a_MeshToDecalsMatrix, a_MeshToDecalsMatrixInvertedTransposed); } }
public void Add(Mesh a_Mesh, Transform[] a_Bones, SkinQuality a_SkinQuality, Matrix4x4 a_WorldToMeshMatrix, Matrix4x4 a_MeshToWorldMatrix) { SkinnedDecalProjectorBase activeDecalProjector = base.ActiveDecalProjector; if (activeDecalProjector == null) { throw new NullReferenceException("The active decal projector is not allowed to be null as mesh data should be added!"); } if ((base.m_Decals.CurrentUVMode == UVMode.Project) || (base.m_Decals.CurrentUVMode == UVMode.ProjectWrapped)) { if (Edition.IsDecalSystemFree && (base.m_Decals.CurrentTextureAtlasType == TextureAtlasType.Reference)) { throw new InvalidOperationException("Texture atlas references can only be used with Decal System Pro."); } if ((0 > activeDecalProjector.UV1RectangleIndex) || (activeDecalProjector.UV1RectangleIndex >= base.m_Decals.uvRectangles.Length)) { throw new IndexOutOfRangeException("The uv rectangle index of the active projector is not a valid index within the decals uv rectangles array!"); } } if ((base.m_Decals.CurrentUV2Mode == UV2Mode.Project) || (base.m_Decals.CurrentUV2Mode == UV2Mode.ProjectWrapped)) { if (Edition.IsDecalSystemFree && (base.m_Decals.CurrentTextureAtlasType == TextureAtlasType.Reference)) { throw new InvalidOperationException("Texture atlas references can only be used with Decal System Pro."); } if ((0 > activeDecalProjector.UV2RectangleIndex) || (activeDecalProjector.UV2RectangleIndex >= base.m_Decals.uv2Rectangles.Length)) { throw new IndexOutOfRangeException("The uv2 rectangle index of the active projector is not a valid index within the decals uv2 rectangles array!"); } } if (a_Mesh == null) { throw new ArgumentNullException("The mesh parameter is not allowed to be null!"); } if (!a_Mesh.isReadable) { throw new ArgumentException("The mesh is not readable!"); } Vector3[] vertices = a_Mesh.vertices; Vector3[] normals = a_Mesh.normals; Vector4[] tangents = null; Color[] colors = null; Vector2[] uv = null; Vector2[] uv = null; BoneWeight[] boneWeights = a_Mesh.boneWeights; int[] triangles = a_Mesh.triangles; Transform[] transformArray = a_Bones; Matrix4x4[] bindposes = a_Mesh.bindposes; if (triangles == null) { throw new NullReferenceException("The triangles in the mesh are null!"); } if (transformArray == null) { throw new NullReferenceException("The bones are null!"); } if (bindposes == null) { throw new NullReferenceException("The bind poses in the mesh are null!"); } if (transformArray.Length != bindposes.Length) { throw new FormatException("The number of bind poses in the mesh does not match the number of bones!"); } if (vertices != null) { bool flag = false; if ((normals == null) || (normals.Length == 0)) { flag = true; a_Mesh.RecalculateNormals(); normals = a_Mesh.normals; } else if (vertices.Length != normals.Length) { throw new FormatException("The number of vertices in the mesh does not match the number of normals!"); } if (base.m_Decals.CurrentTangentsMode == TangentsMode.Target) { tangents = a_Mesh.tangents; if (tangents == null) { throw new NullReferenceException("The tangents in the mesh are null!"); } if (vertices.Length != tangents.Length) { throw new FormatException("The number of vertices in the mesh does not match the number of tangents!"); } } if (base.m_Decals.UseVertexColors) { colors = a_Mesh.colors; if ((colors != null) && ((colors.Length != 0) && (vertices.Length != colors.Length))) { throw new FormatException("The number of vertices in the mesh does not match the number of colors!"); } } if (base.m_Decals.CurrentUVMode == UVMode.TargetUV) { uv = a_Mesh.uv; if (uv == null) { throw new NullReferenceException("The uv's in the mesh are null!"); } if (vertices.Length != uv.Length) { throw new FormatException("The number of vertices in the mesh does not match the number of uv's!"); } } else if (base.m_Decals.CurrentUVMode == UVMode.TargetUV2) { uv = a_Mesh.uv2; if (uv == null) { throw new NullReferenceException("The uv2's in the mesh are null!"); } if (vertices.Length != uv.Length) { throw new FormatException("The number of vertices in the mesh does not match the number of uv2's!"); } } if (base.m_Decals.CurrentUV2Mode == UV2Mode.TargetUV) { uv = a_Mesh.uv; if (uv == null) { throw new NullReferenceException("The uv's in the mesh are null!"); } if (vertices.Length != uv.Length) { throw new FormatException("The number of vertices in the mesh does not match the number of uv's!"); } } else if (base.m_Decals.CurrentUV2Mode == UV2Mode.TargetUV2) { uv = a_Mesh.uv2; if (uv == null) { throw new NullReferenceException("The uv2's in the mesh are null!"); } if (vertices.Length != uv.Length) { throw new FormatException("The number of vertices in the mesh does not match the number of uv2's!"); } } this.Add(vertices, normals, tangents, uv, uv, boneWeights, triangles, transformArray, bindposes, a_SkinQuality, a_WorldToMeshMatrix, a_MeshToWorldMatrix); if (flag) { a_Mesh.normals = null; } } }
public static Vector2[] ApplySkinBlend(Uni2DMesh2D a_rMesh2D, Transform[] a_rJointCurrentTransforms, Transform a_rOriginTransform, SkinQuality a_eSkinQuality = SkinQuality.Auto) { Vector2[] rVertices = a_rMesh2D.vertices; int iVertexCount = rVertices.Length; Vector3[] oVertices3D = new Vector3[iVertexCount]; for (int i = 0; i < iVertexCount; ++i) { oVertices3D[i] = (Vector3)rVertices[i]; } Vector3[] oBlendedVertices3D = new Vector3[iVertexCount]; ApplySkinBlend(ref oBlendedVertices3D, oVertices3D, a_rMesh2D.bindposes, a_rMesh2D.GetBoneWeightStructs(), a_rJointCurrentTransforms, a_rOriginTransform, a_eSkinQuality); Vector2[] oBlendedVertices = new Vector2[iVertexCount]; for (int i = 0; i < iVertexCount; ++i) { oBlendedVertices[i] = (Vector2)oBlendedVertices3D[i]; } return(oBlendedVertices); }
// Deep copy constructor public Uni2DEditorSpriteSettings( Uni2DEditorSpriteSettings a_rSpriteSettings ) { this.textureContainer = new Texture2DContainer( a_rSpriteSettings.textureContainer ); // Deep copy this.atlas = a_rSpriteSettings.atlas; this.sharedMaterial = a_rSpriteSettings.sharedMaterial; this.renderMesh = a_rSpriteSettings.renderMesh; this.usePhysicBuildSettings = a_rSpriteSettings.usePhysicBuildSettings; this.spriteScaleMode = a_rSpriteSettings.spriteScaleMode; this.spriteScale = a_rSpriteSettings.spriteScale; this.spriteScaleNotUniform = a_rSpriteSettings.spriteScaleNotUniform; this.pivotType = a_rSpriteSettings.pivotType; this.pivotCustomCoords = a_rSpriteSettings.pivotCustomCoords; this.vertexColor = a_rSpriteSettings.vertexColor; this.dimensionMode = a_rSpriteSettings.dimensionMode; this.physicsMode = a_rSpriteSettings.physicsMode; this.collisionType = a_rSpriteSettings.collisionType; this.isKinematic = a_rSpriteSettings.isKinematic; this.isTrigger = a_rSpriteSettings.isTrigger; this.renderMeshAlphaCutOff = a_rSpriteSettings.renderMeshAlphaCutOff; this.renderMeshPolygonizationAccuracy = a_rSpriteSettings.renderMeshPolygonizationAccuracy; this.renderMeshPolygonizeHoles = a_rSpriteSettings.renderMeshPolygonizeHoles; this.alphaCutOff = a_rSpriteSettings.alphaCutOff; this.extrusionDepth = a_rSpriteSettings.extrusionDepth; this.polygonizationAccuracy = a_rSpriteSettings.polygonizationAccuracy; this.polygonizeHoles = a_rSpriteSettings.polygonizeHoles; this.onlyBorder = a_rSpriteSettings.onlyBorder; this.subdivide = a_rSpriteSettings.subdivide; this.subdivisionCount = a_rSpriteSettings.subdivisionCount; this.renderMeshGridHorizontalSubDivs = a_rSpriteSettings.renderMeshGridHorizontalSubDivs; this.renderMeshGridVerticalSubDivs = a_rSpriteSettings.renderMeshGridVerticalSubDivs; this.skinQuality = a_rSpriteSettings.skinQuality; this.boneInfluenceFalloff = a_rSpriteSettings.boneInfluenceFalloff; }
public static List <Vector2[]> ApplySkinBlend(Uni2DMesh2D a_rMesh2D, Transform[] a_rJointCurrentTransforms, Transform a_rOriginTransform, SkinQuality a_eSkinQuality = SkinQuality.Auto) { List <Vector2[]> oBlendedShapeVertices = new List <Vector2[]>(); int iShapeIndex = 0; foreach (Uni2DMeshShape2D rShape in a_rMesh2D.shapes) { Vector2[] rVertices = rShape.vertices; int iVertexCount = rVertices.Length; Vector3[] oVertices3D = new Vector3[iVertexCount]; for (int i = 0; i < iVertexCount; ++i) { oVertices3D[i] = (Vector3)rVertices[i]; } Vector3[] oBlendedVertices3D = new Vector3[iVertexCount]; ApplySkinBlend(ref oBlendedVertices3D, oVertices3D, a_rMesh2D.bindposes, rShape.GetBoneWeightStructs(), a_rJointCurrentTransforms, a_rOriginTransform, a_eSkinQuality); Vector2[] oBlendedVertices = new Vector2[iVertexCount]; for (int i = 0; i < iVertexCount; ++i) { oBlendedVertices[i] = (Vector2)oBlendedVertices3D[i]; } oBlendedShapeVertices.Add(oBlendedVertices); ++iShapeIndex; } return(oBlendedShapeVertices); }
/// <summary> /// Sets the default values /// </summary> protected override void DefaultValues() { base.DefaultValues(); this.Quality = SkinQuality._4Joints; this.rootJointChanged = true; }
void Update() { { if (_Ps != _TargetPs) { EnableParticleSystems(_TargetPs); _Ps = _TargetPs; } } { if (_Sr != _TargetSR) { EnableSkinnedMeshRenderers(_TargetSR); _Sr = _TargetSR; } } }
public void Add(Vector3[] a_Vertices, Vector3[] a_Normals, Vector4[] a_Tangents, Vector2[] a_UVs, Vector2[] a_UV2s, BoneWeight[] a_BoneWeights, int[] a_Triangles, Transform[] a_Bones, Matrix4x4[] a_BindPoses, SkinQuality a_SkinQuality, Matrix4x4 a_WorldToMeshMatrix, Matrix4x4 a_MeshToWorldMatrix) { try { this.Add(a_Vertices, a_Normals, a_Tangents, null, a_UVs, a_UV2s, a_BoneWeights, a_Triangles, a_Bones, a_BindPoses, a_SkinQuality, a_WorldToMeshMatrix, a_MeshToWorldMatrix); } catch { throw; } }