freetoplay Posted November 11, 2017 Share Posted November 11, 2017 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. Quote Link to comment Share on other sites More sharing options...
Dad72 Posted November 11, 2017 Share Posted November 11, 2017 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); Quote Link to comment Share on other sites More sharing options...
freetoplay Posted November 11, 2017 Author Share Posted November 11, 2017 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? Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted November 13, 2017 Share Posted November 13, 2017 Hello, basically every mesh has a material and this material can be shared. So you have multiple options: updating textures or swapping materials. Perhaps you can start a small repro in the playground to explain your goal? This way we can comment on real code Quote Link to comment Share on other sites More sharing options...
JCPalmer Posted November 13, 2017 Share Posted November 13, 2017 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. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.