martyj Posted May 16, 2016 Share Posted May 16, 2016 I'm trying to programmatically change models skins depending on what type of NPC it is or a specific interaction. Such as woodcutting, when you chop down a tree, the tree will change its material to be an invisible material on its surface. Other cases this will be used is for Multiplayer, each player can have a unique skin. My problem can be seen in this video: I've tried using Entity::Copy and Entity::Instance to copy the entity, but to no avail. I've also tried copying each surface. Which causes the entity not to show up. As seen from this image: http://i.imgur.com/NKuyzuH.jpg Even with the cloned surfaces, if I set the material, the model doesn't show. Any idea how I can set a material on an instance without it changing any other instance of the same model? Quote Link to comment Share on other sites More sharing options...
Rick Posted May 16, 2016 Share Posted May 16, 2016 When you load a model you have options for asset flags and those values are: http://www.leadwerks.com/werkspace/page/api-reference/_/asset/ You can search this forum for these but I think unmanaged means unique materials per model? I could be wrong but we asked for this a long time ago. The issue is that this only works when loading the models in code. If you place them in the editor you don't have this option. That being said, why put the invisible mat on the tree in your first example? I would think just hiding the tree model would be a better option in that case. When you get into your characters and skins, I think you'd be better off searching the forums for the atlas shader that exists (shadmar made it). This allows you to make a really big texture that has subtextures on it. So you could have a 4096x4096 and it could have a 4x4 grid of subtextures (giving you 16 variations) that are 1024x1024. Only 16 you may say, but that was just an example and doing what you want (like most MMO's do) is a complicated thing and requires a lot of art setup really. Note that materials are per surface. So your characters could have a surface for the head, shoulders, chest, legs, hands, feet and you could programatically set which subtexture in the atlast each would get and each would be able to use a separate texture atlas. If you make the textures 512x512 and maybe use a bigger overall texture atlas you can get more variations. You could also swap entire models out for chest, head, etc and "stitch" them together at run-time to give even more variations. Don't ask me how to stitch them together but I hear this is a common thing in MMO's as well. Another option is to have all model variations in the model itself and then in code you just hide all the other surfaces that you don't want. One of the modelers that sell here have characters like this, but the model size because fairly large and any change is changing the base model vs the modular approach of separate models and stitching. Overall, this is a little more complicated than the tree stuff. Quote Link to comment Share on other sites More sharing options...
Josh Posted May 16, 2016 Share Posted May 16, 2016 In the case of different players, I would just duplicate the model file, or use the unique flag if every player texture really only occurs once. In the case of the falling tree, why would you not just hide the tree? Quote My job is to make tools you love, with the features you want, and performance you can't live without. Link to comment Share on other sites More sharing options...
Rick Posted May 16, 2016 Share Posted May 16, 2016 or use the unique flag if every player texture really only occurs once. I'm pretty sure his game is a multiplayer game, and I'm pretty sure loading a character model with the unique flag causes a pause in the game while it's happening in real-time. So as you're moving around and players are coming into your zone you'd have to load their characters which would cause an unwanted pause in the game all the time. Ideally the game would load 1 instance of each type of character (human, drawf, etc) and then just create instances (instant in game) and then swap textures that are also already loaded at startup. This is why things get tricky in LE. Without the ability to load assets on another thread and move them to the main thread we have to handle the pauses of loading in different ways. 1 Quote Link to comment Share on other sites More sharing options...
shadmar Posted May 16, 2016 Share Posted May 16, 2016 I just repeat it seems Quote HP Omen - 16GB - i7 - Nvidia GTX 1060 6GB Link to comment Share on other sites More sharing options...
martyj Posted May 16, 2016 Author Share Posted May 16, 2016 The reason not to hide the tree is that I want a stump still to show. I could swap the tree model with a stump model if needed. I defiantly want something there to be a place holder so players don't stand in a tree when I spawn one. @Rick. I agree completely with wanting multi-threaded asset loading support. Quote Link to comment Share on other sites More sharing options...
Josh Posted May 16, 2016 Share Posted May 16, 2016 You could call Entity::Copy() to duplicate the model without loading it from a file. 1 Quote My job is to make tools you love, with the features you want, and performance you can't live without. Link to comment Share on other sites More sharing options...
macklebee Posted May 16, 2016 Share Posted May 16, 2016 You could call Entity::Copy() to duplicate the model without loading it from a file. example code showing copied models with different materials: http://www.leadwerks.com/werkspace/topic/12249-model-copy/#entry88822 3 Quote Win7 64bit / Intel i7-2600 CPU @ 3.9 GHz / 16 GB DDR3 / NVIDIA GeForce GTX 590 LE / 3DWS / BMX / Hexagon macklebee's channel 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.