Game Development Community

Trigger numbers problem.

by Flashback · in Artist Corner · 04/24/2007 (11:30 am) · 3 replies

I tried to search first. Honest. But it didn't help, so here is my problem.

When I we used only two triggers (#1 and #2) in our sequences, the problem wasn't obvius, but after I added keys with 3, 4 and 5 values, I've noticed a weird thing. After the sequences are exported, the value of those triggers is modified, and I'm not exactly sure where does it happen (while exporting or while TGE is loading the sequences?). So, triggers #1 and #2 are OK, but #4 suddenly has a value of 8, #5 is 16. Looks like a power of two.

I'm using Max7 + DTS exporter and Torque ShowTool Pro. Well, watching the trigger values in debug mode shows the same thing as TSTPro - trigger values are 1, 2, 4, 8, 16 instead of 1, 2, 3, 4, 5. I wouldn't like to recompile the exporter, putting the "debug output" lines everywhere - a terrible waste of time :) So if someone knows what's wrong with it, please tell me.

#1
04/24/2007 (12:44 pm)
Well, I looked through the exporter's code and saw the next:
trigger.state = 1 << (U32)val;
So it's a bitfield, not a number. When you deal with it as a parameter, you should use TSShapeInstance::setTriggerStateBit function instead of TSShapeInstance::setTriggerState in your code. Oh well...

But the surprising thing is that TST Pro "features" the same bug as my code did, that was the most confusing part. That's the hell of a concurrence.
#2
04/24/2007 (1:51 pm)
@Flashback - What are you trying to say? Are you trying to say that the exporter does not work as you think it should?

TGE and all it's derivatives support multiple triggers at the same time. So if you wanted to fire trigger 1 and trigger 3 your would call setTriggerState twice, once passing the 1, and the second passing the 3.

Now if you knew the bit positions, hence the power of two, then you would call setTriggerStateBit passing 1 first time an 4 the second.

Basicaly the difference, is how you want to look at it:
If you want to deal with the trigger number as 1,2,3,4,5, etc then call setTriggerState.
If you want to deal with the trigger as a bit position as 1,2,4,8,16,32, etc then call setTriggerStateBit.
#3
04/24/2007 (2:39 pm)
I had a good reason to think that it was exporter's fault, because TST Pro has the same bug as my code. I.e. Torque ShowTool Pro, in "sequence info" window shows invalid trigger numbers: 1, 2, 4, 8... So I thought that it's sooner a bug in exporter's code then in BOTH my code and TSTPro's.

No need to explain triggers and bitfield mechanics, I know what they do and how they work. But thanks for your reply anyway.