Jump to content

Swapping clothings on a character model


freetoplay
 Share

Recommended Posts

Hi everyone,

I am new to Babylon.js and 3D programming in general. I was wondering what would be the best way of swapping out clothings and other items on a character model in Babylon.js? Should I swap using textures (though this probably wouldn't work very well for items that a character holds)? Or is there a better way of doing it? Thanks for any advices.

Link to comment
Share on other sites

Yes you can change the texture simply.

Something like that :

this.modele.material.subMaterials[1].diffuseTexture = new BABYLON.Texture(newTexture, this.scene);

or

this.modele.material.diffuseTexture = new BABYLON.Texture(newTexture, this.scene);

Link to comment
Share on other sites

14 minutes ago, Dad72 said:

Yes you can change the texture simply.

Something like that :

this.modele.material.subMaterials[1].diffuseTexture = new BABYLON.Texture(newTexture, this.scene);

or

this.modele.material.diffuseTexture = new BABYLON.Texture(newTexture, this.scene);

Thanks for the advice. What would I do in the case that I have different meshes for different items and clothings, what would be the best approach in that case?

Link to comment
Share on other sites

This method just adjusting the material has it's limitations, of course.  Changing vertices are what is going to actually change into different clothing.

Assuming you have different meshes for different items, then you should un-parent the mesh to leave and hide, & parent the new article to the body mesh.  To switch from pants to a skirt you obviously cannot cheat on the body mesh, removing the hidden vertices of the legs.  Programs like MakeHuman offer such optimizations.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...