Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Dress Problem (Skinned Mesh Renderer)

Discussion in 'Editor & General Support' started by PartyNeverEnds, Aug 2, 2014.

  1. PartyNeverEnds

    PartyNeverEnds

    Joined:
    Apr 24, 2013
    Posts:
    172
    Hi guys,

    Clothes are intertwined. How can I solve this?
    I attract the video to better explain the problem.

    Video ;


    Picture ;
    http://upmatik.com/m/2014/08/02/1NSdRY.png
    http://upmatik.com/m/2014/08/02/2e3OIV.png

    Code ;
    Code (csharp):
    1. using UnityEngine;
    2. using System.Collections;
    3.  
    4. public class Kıyafet : MonoBehaviour
    5. {
    6.  
    7.     public GameObject orjCharacter;
    8.     public GameObject orjDress;
    9.  
    10.     void OnGUI()
    11.     {
    12.         if (GUI.Button(new Rect(0, 0, 70, 20), "Render"))
    13.         {
    14.             AddLimb(orjDress, orjCharacter);
    15.         }
    16.     }
    17.     void AddLimb(GameObject BonedObj, GameObject RootObj)
    18.     {
    19.         var BonedObjects = BonedObj.gameObject.GetComponentsInChildren<SkinnedMeshRenderer>();
    20.  
    21.         foreach (SkinnedMeshRenderer SkinnedRenderer in BonedObjects)
    22.  
    23.             ProcessBonedObject(SkinnedRenderer, RootObj);
    24.     }
    25.  
    26.     private void ProcessBonedObject(SkinnedMeshRenderer ThisRenderer, GameObject RootObj)
    27.     {
    28.         var NewObj = new GameObject(ThisRenderer.gameObject.name);
    29.  
    30.         NewObj.transform.parent = RootObj.transform;
    31.  
    32.         NewObj.AddComponent<SkinnedMeshRenderer>();
    33.  
    34.         var NewRenderer = NewObj.GetComponent<SkinnedMeshRenderer>();
    35.  
    36.         var MyBones = new Transform[ThisRenderer.bones.Length];
    37.  
    38.         for (var i = 0; i < ThisRenderer.bones.Length; i++)
    39.  
    40.             MyBones[i] = FindChildByName(ThisRenderer.bones[i].name, RootObj.transform);
    41.  
    42.         NewRenderer.bones = MyBones;
    43.  
    44.         NewRenderer.sharedMesh = ThisRenderer.sharedMesh;
    45.  
    46.         NewRenderer.materials = ThisRenderer.materials;
    47.     }
    48.  
    49.     private Transform FindChildByName(string ThisName, Transform ThisGObj)
    50.     {
    51.  
    52.         Transform ReturnObj;
    53.  
    54.         if (ThisGObj.name == ThisName)
    55.  
    56.             return ThisGObj.transform;
    57.  
    58.         foreach (Transform child in ThisGObj)
    59.         {
    60.  
    61.             ReturnObj = FindChildByName(ThisName, child);
    62.  
    63.             if (ReturnObj)
    64.  
    65.                 return ReturnObj;
    66.  
    67.         }
    68.         return null;
    69.     }
    70. }
     
    Last edited: Aug 2, 2014
  2. Dantus

    Dantus

    Joined:
    Oct 21, 2009
    Posts:
    5,667
    Maybe the weight painting of the cloths is wrong. And did you make sure the skinning quality is equal for all the meshes?
     
  3. PartyNeverEnds

    PartyNeverEnds

    Joined:
    Apr 24, 2013
    Posts:
    172
    Consider of different outfits. All the settings will be required for this. It's exhausting. I want to do with this code. (automatic)
     
  4. MakeCodeNow

    MakeCodeNow

    Joined:
    Feb 14, 2014
    Posts:
    1,246
    I've never seen a code solution that works well enough. It pretty much requires at least some hand fixup. Even if the code works most of the time, you should support a modifiers system so that you can apply custom corrections.
     
  5. PartyNeverEnds

    PartyNeverEnds

    Joined:
    Apr 24, 2013
    Posts:
    172
    Well, do you know the code logic? There is ready source or tutorial video?
     
  6. Dantus

    Dantus

    Joined:
    Oct 21, 2009
    Posts:
    5,667
    It doesn't matter how many outfits you have. If one of the doesn't have correct weights, this one will produce errors. If all of them aren't correctly weight painted, all of the will be wrong. Where is the weight painting being made? Does it take place in the code or are they already weight painted?
     
  7. PartyNeverEnds

    PartyNeverEnds

    Joined:
    Apr 24, 2013
    Posts:
    172
    weight painting? I don't understand. What do you ask? (Bone system, mock up 'model')
    There are various different models. To manually fix, exhausting. A coding should be. Auto-correcting.
     
  8. Dantus

    Dantus

    Joined:
    Oct 21, 2009
    Posts:
    5,667
    There are bones and each vertex knows how much it is influences by which bone. Where is this information set?

    Also, did you make sure that both the cloths and the character are based off the exact same rig?
     
  9. PartyNeverEnds

    PartyNeverEnds

    Joined:
    Apr 24, 2013
    Posts:
    172
    Clothing : Marvelous Designer 3
    Bone System : Daz Studio (Character combination with the outfit. / Bone transfer system.)
    Attire : With, code. (I got ready.)

    So, I did not write the code.
     
  10. Dantus

    Dantus

    Joined:
    Oct 21, 2009
    Posts:
    5,667
    The error could happen at any of those. If you don't understand the details, it is unfortunately not possible to help.
     
  11. PartyNeverEnds

    PartyNeverEnds

    Joined:
    Apr 24, 2013
    Posts:
    172
    Examine the video. The problem, to appear in the video. (Skinned Mesh Renderer) Is it possible to edit? Example : "Apply Push Modifier" Like the option. Or something like that. Because, a coding required. A system.
     
  12. Dantus

    Dantus

    Joined:
    Oct 21, 2009
    Posts:
    5,667
    I have seen what the problem is. Of course it is possible to edit that, but I don't know your applications and whether it can be done there, I don't know whether the base rig is completely identical, I simply don't have enough information to help you and I have absolutely no idea what "Apply Push Modifier" is.
    In other words, I can't help.
     
  13. PartyNeverEnds

    PartyNeverEnds

    Joined:
    Apr 24, 2013
    Posts:
    172
    Answers and thank you very much for your interest.
    About clothing attire do have the resources or video?
    I'm waiting for help.
     
  14. Dantus

    Dantus

    Joined:
    Oct 21, 2009
    Posts:
    5,667
    Learn to understand what you are doing and what you want to achieve. This will help a lot to resolve issues.

    There are various potential causes for the issue:
    • The rigs of the character and the cloths don't match (maybe the hip bone is slightly offset)
    • The weight painting of the character and cloths are not identical
    • The weight painting includes more bones per vertex than your current setup in Unity, but it may be even more than the maximum in Unity which is 4. That would mean you need to restrict it. At first you may try to increase it to 4 to see whether it helps.

    Possible solutions are:
    • Make the size of the cloths slightly bigger (should be made in the modeling application you are using)
    • Use correct weight painting, verify that they actually match
    • Make sure that the rigs are completely identical in the rest pose
    That's all I can do for you. I suggest you to learn how to rig a character and how to weight paint in order to understand how it works, such that you get a better understanding. Then you need to understand how it works in Unity, because Unity is a realtime application and as such is more limited than other applications.
     
  15. PartyNeverEnds

    PartyNeverEnds

    Joined:
    Apr 24, 2013
    Posts:
    172
    Still have not found the solution.
    New video (Detailed) ;

    Please look.
     
    Last edited: Aug 3, 2014
  16. Dantus

    Dantus

    Joined:
    Oct 21, 2009
    Posts:
    5,667
    Did you try any of the possible solutions I suggested in the previous post?
     
  17. PartyNeverEnds

    PartyNeverEnds

    Joined:
    Apr 24, 2013
    Posts:
    172
    Yeah, but is not the solution. I researched. A clothing system needs. But, I do not know how.
     
  18. PartyNeverEnds

    PartyNeverEnds

    Joined:
    Apr 24, 2013
    Posts:
    172
    Example ;
    Like this.
     
  19. Dantus

    Dantus

    Joined:
    Oct 21, 2009
    Posts:
    5,667
    Did you try to make the cloths considerably thicker, just to see whether it improves the intersection?
    It looks as if the weight painting of the trousers is not made for the hip bone. Did you check that?
     
  20. PartyNeverEnds

    PartyNeverEnds

    Joined:
    Apr 24, 2013
    Posts:
    172
    Yes, I checked. Not the problem.
    I need something like this. I added a video. (Mega Fiers)
     
  21. Dantus

    Dantus

    Joined:
    Oct 21, 2009
    Posts:
    5,667
    Then buy Mega Fiers.
     
  22. PartyNeverEnds

    PartyNeverEnds

    Joined:
    Apr 24, 2013
    Posts:
    172
    I think. But, In the information will not help. I prefer manual. And again, have no knowledge about this topic. Do you know what logic?
     
  23. Dantus

    Dantus

    Joined:
    Oct 21, 2009
    Posts:
    5,667
    How about getting in touch with the author of MegaFiers to get the information you need?
     
  24. Dantus

    Dantus

    Joined:
    Oct 21, 2009
    Posts:
    5,667
  25. PartyNeverEnds

    PartyNeverEnds

    Joined:
    Apr 24, 2013
    Posts:
    172
  26. Dantus

    Dantus

    Joined:
    Oct 21, 2009
    Posts:
    5,667
    To me it sounds exactly like UMA would solve your problem. Of course, it is required that the character is set up appropriately, but it doesn't seem as if you have an setup yet that works.
     
  27. PartyNeverEnds

    PartyNeverEnds

    Joined:
    Apr 24, 2013
    Posts:
    172
    I'll try. (UMA) Hopefully, would be a benefit.

    - Waiting for further assistance.
     
  28. Dantus

    Dantus

    Joined:
    Oct 21, 2009
    Posts:
    5,667
    No one is going to hold your hands, didn't you already get tons of hints?
     
  29. PartyNeverEnds

    PartyNeverEnds

    Joined:
    Apr 24, 2013
    Posts:
    172
    Lol. In the meantime, one did not work. (UMA)
     
  30. Dantus

    Dantus

    Joined:
    Oct 21, 2009
    Posts:
    5,667
    The amount of information you are sharing is brilliant. If you could share what is not working, it would give others the possibility to help. That's not just the case for UMA, but for everything else that was suggested.
     
  31. PartyNeverEnds

    PartyNeverEnds

    Joined:
    Apr 24, 2013
    Posts:
    172
    Whatever it is I do not know.

    Look. '3:50' MegaWrap uses. Such a coding is required.
     
  32. Dantus

    Dantus

    Joined:
    Oct 21, 2009
    Posts:
    5,667
    As you don't seem to be interested in investing time into finding a solution or to even try the tips out, but you are just looking for someone who does it, I am wishing you good luck to find a person who does all the work for you.

    I understand what you want to achieve, but I won't do the work for you. And I won't help you any further if you don't even share any kind of information about what does not work for you.
     
  33. PartyNeverEnds

    PartyNeverEnds

    Joined:
    Apr 24, 2013
    Posts:
    172
    What is the logic of coding? Can you help in this regard?

    I guess, need to invest.
     
  34. PartyNeverEnds

    PartyNeverEnds

    Joined:
    Apr 24, 2013
    Posts:
    172
    The problem continues.
     
  35. drewradley

    drewradley

    Joined:
    Sep 22, 2010
    Posts:
    3,063
    This looks like a job for blendshapes.

    You'll have to figure out how to do this from your modeling software as each one is different. Since you seem to be using some DAZ models, DAZ Studio can export morphs in FBX which Unity then converts to blendshapes. Then it's a matter of writing a script to adjust the blendshape based on what clothes options you have.