SpiderPig Posted January 12, 2019 Share Posted January 12, 2019 Can each instance have it's own material? I know we can edit vertex data with out it showing across all instances. Quote Link to comment Share on other sites More sharing options...
gamecreator Posted January 12, 2019 Share Posted January 12, 2019 I got help with that here: https://www.leadwerks.com/community/topic/12249-model-copy/ Quote Link to comment Share on other sites More sharing options...
SpiderPig Posted January 12, 2019 Author Share Posted January 12, 2019 Thanks. It seems that an instance can't have a separate material from the original. I guess it's kinda like not being able to alter the surface of an instance since technically the material is applied to the surface. Quote Link to comment Share on other sites More sharing options...
gamecreator Posted January 13, 2019 Share Posted January 13, 2019 Can I ask what you're doing that you can't load the model as a copy? Quote Link to comment Share on other sites More sharing options...
SpiderPig Posted January 13, 2019 Author Share Posted January 13, 2019 I'm creating instances of a lot of vegetation. When the player harvests a plant I wanted the material / texture to change to show it had been harvested. Model* plant = Model::Load("plant.mdl"); Material* harvested = Material::Load("Harvested.mat"); Entity* instances[100]; //Load for(int id=0;id<100;id++) { Instances[id] = plant->Instance(); } //InGame int closestIndex = 25; if(window->keyHit(Key::E) == true){ instance[closestIndex]->SetMaterial(harvested); } This is essentially what I'm doing except setting the material of one changes all the instances. I can't use a copy because it can't be used in real-time. As the player moves I create the foliage around them as required. Quote Link to comment Share on other sites More sharing options...
SpiderPig Posted January 13, 2019 Author Share Posted January 13, 2019 I think what I'll end up doing is releasing the instance and creating a new instance of a harvested plant. int closestIndex = 25; if(window->keyHit(Key::E) == true){ instance[closestIndex]->Release(); instance[closestIndex] = harvestedPlant->Instance(); } This means I could add different geometry in as well, like broken branches or something. 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.