c# - XNA - Copies of Same Source Model -


if this:

model test1 = content.load<model>(@"models/floortile"); model test2 = content.load<model>(@"models/floortile"); model test3 = content.load<model>(@"models/floortile");  foreach (modelmesh mesh in test1.meshes)     foreach (effect effect in mesh.effects)         ((basiceffect)effect).diffusecolor = color.red.tovector3(); 

all 3 models assigned color red, not test1.

this simplified version of problem, in real version, using actual hlsl effect, , while know how clone single effect work on multiple unique fbxs, not sure how create more 1 instance of 3dmodel , assign each it's own texture, instead of them referencing 1 texture/effect , therefore every "floortile" in scene same.

the workaround can think of create different floortile fbx model each model, have lot of tiles, far ideal.

the solution can think this:

foreach (var mesh in model.meshes) {    foreach (basiceffect effect in mesh.effects)    {        effect.enabledefaultlighting();        effect.textureenabled = true;        effect.texture = modeltexture;        effect.projection = camera.projection;        effect.view = camera.view;        effect.world = absolutebonetransforms[mesh.parentbone.index] * finalworldtransforms;     }     mesh.draw(); } 

you can have more 1 model (like model1, model2 , model3) , different modeltexture apply on them.
can see uses basiceffect, don't know if can useful if you're using hlsl.


Comments

Popular posts from this blog

java - How to Configure JAXRS and Spring With Annotations -

visual studio - TFS will not accept changes I've made to a Java project -

php - Create image in codeigniter on the fly -