Forum

Material Switch

26 February 2016 15:19
Hi,
I'm doing something wrong with this material switch but can't figure it out.
I've taken the 'inherit_material.blend' and recreated it to better understand the process. Unfortunately, my attached example does not change the material like the example does… I have no idea what the issue is… Any thoughts?
Danny Austin,Technical Manager
PIX Set Visions
26 February 2016 15:46
Hello, Danny!

You just forgot to enable logic editor and choose active logic tree for your scene
Blend4Web Team - developer
Twitter
LinkedIn
26 February 2016 16:01
Ahhhhhhh SUPER noob!
Here's the file now working for reference.

Is there a way to load materials from an external library from inside the presentation?
Perhaps materials could be exported to a database and then called by an event in the interface?

Thank you for your help
Danny Austin,Technical Manager
PIX Set Visions
26 February 2016 16:46
Is there a way to load materials from an external library from inside the presentation?
For now there is such way:
You can use simple scenes with one object as library. Let's name it for example "SuperMegaMaterialCarrier".
Then you should dynamically load library scene from your main scene and use inherit material method:
https://www.blend4web.com/api_doc/module-material.html#.inherit_material

Perhaps materials could be exported to a database and then called by an event in the interface?
As we can see from the previous answer you only need to store info about your library scenes (json and bin files). There are plenty of opportunities to organize storage and interaction depending on your needs.
Blend4Web Team - developer
Twitter
LinkedIn
26 February 2016 17:06
Excellent! Thanks for that great info.
If you had thousands of materials (assigned to "SuperMegaMaterialCarrier") could you call only one single material and it's resources? This would be fantastic.

OR would the entire library be required at client side for this to work?

Thanks

Danny
Danny Austin,Technical Manager
PIX Set Visions
26 February 2016 17:22

If you had thousands of materials (assigned to "SuperMegaMaterialCarrier") could you call only one single material and it's resources? This would be fantastic.

OR would the entire library be required at client side for this to work?
If you want to load exactly one material per call you should create carrier scene for every material. As far as i can see the most optimal way is to batch objects thematically (somehow predict what material user will choose next, again everything is depending on your application) . For the best performance you should experiment in balancing carrier scene loading routine in engine and receiving carrier scene info from the server.
Blend4Web Team - developer
Twitter
LinkedIn
26 February 2016 17:23
Ahhh yes. Great. That's really helpful. Thank you very much
Danny Austin,Technical Manager
PIX Set Visions
26 February 2016 18:16

Here's the file now working for reference.
Just not to confuse this thread visitors:
one of the inherit material nodes outputs is not connected and the logic stops there
Blend4Web Team - developer
Twitter
LinkedIn
26 February 2016 18:27
Well spotted
Danny Austin,Technical Manager
PIX Set Visions
 
Please register or log in to leave a reply.