View Full Version : Solved: Recolorable with "Change Material"
29th Jun 2009, 08:48 PM
I have an object that uses the "Change Material" primitive and I want to be able to provide a number of colors of it (all in my package). Any advice on how to detect which Material is currently being used so that the appropriate "Change Material" entry can be used.
I hope this is possible because otherwise I'm stuck with making the same object with different textures mutliple times which will cause complaints about space in folks download folders.
30th Jun 2009, 01:10 AM
Basically it's a bit of a pain in the backside. ;) The one and only time I had an object which required it, I cheated and got Numenor to do it for me. It involves setting up the material change as a "state change", like the way lamps have an on/off material change or counters have a clean/dirty change. They still use "Change Material", but they do it with states so that it switches to the necessary state for the currently active recolour.
30th Jun 2009, 04:25 PM
The one and only time I had an object which required it, I cheated and got Numenor to do it for me.What was the object (if you don't mind me taking a peek?)
1st Jul 2009, 10:44 PM
I feel like I'm almost there but am missing some very crucial point that actually makes it work. So I investigated with a lamp that had both lit and unlit states and had several different colour options. I noted the following things in that object and made the same changes to mine:-
There was an MMAT for each colour and each state, e.g. blue_lit, blue_unlit, green_lit, green_unlit
Each matching colour MMAT had the same family string (presumably to tie them together)
In each pair, the _lit said materialStateFlags = 0x00000001 and objectStateIndex = 0x00000000, and the _unlit said said materialStateFlags = 0x00000000 and objectStateIndex = 0x00000001.
The Material Names STR# (0x0088) only contained the default colour references, with _lit in position 0, and _unlit in position 1
The BHAV that called "Change Material" just refered to that string that was the default colour.
I successfully have a recolorable object but when the BHAV that calls "Change Material" runs it changes the texture back to the default one - which is kinda what the instruction said. So the question is, what little trick is it that ties the "Change Material" using the default colour to actually the appropriate colour set - I assume something to do with the objectStateIndex set in the MMAT maybe, but I don't see anything that jumps out at me.
Any help most appreciated.
2nd Jul 2009, 01:41 AM
T'was the pinata. ;)
2nd Jul 2009, 09:11 PM
I have taken a look at the pinata, also started looking at a counter since they have the same deal going on with multiple colours and a clean and dirty state and I still haven't been able to work out what it is that makes "Change Material" use the correct colour. Now I'm stuck. Can you tell me what the trick is?
5th Jul 2009, 12:13 PM
I found my issue when I saw this comment by SnowStorm on something vaguely related. My naming didn't include the subset name in the TXMT name, and once I added it, it all worked. Phew!
vBulletin v3.0.14, Copyright ©2000-2013, Jelsoft Enterprises Ltd.