Mounted Image States...
by Andrew Hall · in Torque Game Engine · 02/03/2005 (1:04 pm) · 10 replies
Hi.
I'm trying to use mounted images for things other than weapons, like gizmos and the character's faces. What I would like to do is to write a function that takes a sequence name or number and plays that sequence on a mounted image, as opposed to just marching through the states after a trigger. Much like the shapeBase::playThread function except for mounted images. Basically I would like the AI to control its own animation on its mounted images and jump, for example, from sequence 2 to 5 in some cases and 2 to 3 in others.
Something like : player.playMountedImageThread(slot#, sequence)
Or even : player.setMountedImageState(slot#, state#)
I'm not sure if I'm making this harder than it really is, or if it will require ripping through the engine code and rewritting the way it changes image states.
Perhaps I need to mount the dts files as objects instead of images, although I havent had any luck getting mounted objects to even show up.
thanks for any help.
I'm trying to use mounted images for things other than weapons, like gizmos and the character's faces. What I would like to do is to write a function that takes a sequence name or number and plays that sequence on a mounted image, as opposed to just marching through the states after a trigger. Much like the shapeBase::playThread function except for mounted images. Basically I would like the AI to control its own animation on its mounted images and jump, for example, from sequence 2 to 5 in some cases and 2 to 3 in others.
Something like : player.playMountedImageThread(slot#, sequence)
Or even : player.setMountedImageState(slot#, state#)
I'm not sure if I'm making this harder than it really is, or if it will require ripping through the engine code and rewritting the way it changes image states.
Perhaps I need to mount the dts files as objects instead of images, although I havent had any luck getting mounted objects to even show up.
thanks for any help.
About the author
Recent Threads
#2
It's up to you if you want to do this with images, or the objects themselves. Objects can be loaded and mounted directly, a bit of a search will show you how. If you wish to stick with images, you'll have to add another consolemethod or three to access the animation calls directly. I looked over the code for you, and it very much appears do-able, even somewhat easy.
02/03/2005 (1:43 pm)
Images are rendered, or else you would never see them :) They are however, bridges of a sort. They contain some of the objects info, but not all. This pretty much just ensures less network traffic.It's up to you if you want to do this with images, or the objects themselves. Objects can be loaded and mounted directly, a bit of a search will show you how. If you wish to stick with images, you'll have to add another consolemethod or three to access the animation calls directly. I looked over the code for you, and it very much appears do-able, even somewhat easy.
#3
02/03/2005 (1:48 pm)
And today we both learn something... thanks Erik! =)
#4
Let me elaborate a little. Characters faces are mounted in front of the characters heads in order to have several of the same models with different faces running around. Much like the crossbow, each face has several animations (such as blink), which are mapped into state arrays like the crossbow...
Currently, after mounting this face to an ai character, it shows up and renders just fine. In fact, if I define only the "blink" sequence the ai will continously blink. Changing the Timeout value effects the rate at which the ai character blinks.
Im not sure, but I think if you mount a crossbow to an AI player you can see the crossbow from your own first person view actually run through the animations (states) of fireing, reloading, etc - which are animation sequences in the weapon dts file. Somewhere in the engine the ai fires its crossbow, and the states of the crossbow are switched from "fire" to "ready" or whatever.
Is the crossbow the specific ai player has an "associated model" or an "image"?
Also, besides specifying Timeout values to controll the switch from one state to the other, isn't there some other way of controlling what state a mounted image or associated model is set to?
*edit: Thanks erik, images really seem to be the way to go, we eventually want alot of ai with lots of facial animation so the 'less network traffic' seems to make it worth it. I'll look into the console methods
02/03/2005 (2:20 pm)
Thanks for your reply, I think I see what your getting at. To my understanding images are just a copy of a single existing shape in the world, so you would want to animate the image and not the model. (Mabey I have my terminology crossed).Let me elaborate a little. Characters faces are mounted in front of the characters heads in order to have several of the same models with different faces running around. Much like the crossbow, each face has several animations (such as blink), which are mapped into state arrays like the crossbow...
datablock ShapeBaseImageData(chickface)
{
shapeFile = "~/data/shapes/hotchick/face/face.dts";
emap = true;
stateName[0] = "root";
stateTimeoutValue[0] = 0;
stateSequence[0] = "root";
stateWaitForTimeout[0] = 0;
stateName[1] = "blink";
stateTimeoutValue[1] = 5;
stateSequence[1] = "blink";
stateWaitForTimeout[1] = 0;Currently, after mounting this face to an ai character, it shows up and renders just fine. In fact, if I define only the "blink" sequence the ai will continously blink. Changing the Timeout value effects the rate at which the ai character blinks.
Im not sure, but I think if you mount a crossbow to an AI player you can see the crossbow from your own first person view actually run through the animations (states) of fireing, reloading, etc - which are animation sequences in the weapon dts file. Somewhere in the engine the ai fires its crossbow, and the states of the crossbow are switched from "fire" to "ready" or whatever.
Quote:
make sure you are animating the associated model and not the actual image!
Is the crossbow the specific ai player has an "associated model" or an "image"?
Also, besides specifying Timeout values to controll the switch from one state to the other, isn't there some other way of controlling what state a mounted image or associated model is set to?
*edit: Thanks erik, images really seem to be the way to go, we eventually want alot of ai with lots of facial animation so the 'less network traffic' seems to make it worth it. I'll look into the console methods
#5
If you'de like to keep at your current method, I think I'd make a new class, FaceImage or somesuch. Copy all the ShapeImage code, cut out all the bits you don't use, etc. See, images are pretty specific to weapons. Kind of dumb, but thats how it is. The animation it looks for are based on what a weapon needs. You probably could get it to work like you need, but it would be a real hack.
......
Thinking a bit more, I'm wondering if your method with a newly formaed image class might work extremely well. It's possible you could even use morph targets as your animation method, which not only would allow facial animations, but also facial tweaking. One face can be used for a fat guy and a skinny guy. Or a really big nose, or....
02/03/2005 (3:16 pm)
Hmm, your method is pretty interesting, but I'm not convinced images are the proper method. You're still adding traffic, just not as much as an actual object. Why not use mesh hiding? I never quite finished it, but its very very close, and it probably wouldn't take much to get what you need out of it. Its basically how the Ghoul2 system works, used in SOF and numerous other titles.If you'de like to keep at your current method, I think I'd make a new class, FaceImage or somesuch. Copy all the ShapeImage code, cut out all the bits you don't use, etc. See, images are pretty specific to weapons. Kind of dumb, but thats how it is. The animation it looks for are based on what a weapon needs. You probably could get it to work like you need, but it would be a real hack.
......
Thinking a bit more, I'm wondering if your method with a newly formaed image class might work extremely well. It's possible you could even use morph targets as your animation method, which not only would allow facial animations, but also facial tweaking. One face can be used for a fat guy and a skinny guy. Or a really big nose, or....
#6
Actually, the faces use texture animation (bit map arrays). So far it's been very successful - it gives the characters a very cartoony way of speaking and making expressions.
Also, in this case, images would be great because the characters are supposed to be able to do things that shoot projectiles out of the face. You know, like crying, sneazing, sweating, spitting, or shooting a snot rocket out of the nose. I'm going to get this image thing to work and report back. Thanks for the pointers.
02/03/2005 (7:25 pm)
Yes, thats exactly the idea. How sweet would it be if most of the parts of the players were mounted? (Hair, nose, eyes, clothes, etc.) You could get a lot of characters for every model. It's just a matter of being able to set image states.Actually, the faces use texture animation (bit map arrays). So far it's been very successful - it gives the characters a very cartoony way of speaking and making expressions.
Also, in this case, images would be great because the characters are supposed to be able to do things that shoot projectiles out of the face. You know, like crying, sneazing, sweating, spitting, or shooting a snot rocket out of the nose. I'm going to get this image thing to work and report back. Thanks for the pointers.
#7
02/03/2005 (7:40 pm)
Andrew, the only problem with using images for body parts is that they don't have collision. So if your game requires your heads to have collisions, it won't work out of the box.
#8
So you were right erik, it was just a simple matter of defining a console method in shapeBase.cc :
After I did that the code started flowing. Here is a good example...
Josh you are correct about the collisions, this would not be a good method of mounting a head on someone in a first person shooter. For things where the geometry is not important, such as a face, it works great.
Eventually I'll go back and rewrite the image class like you were saying, but for now this works and opens up a few doors. Thanks for the help dudes, see ya'll in another post.
02/04/2005 (2:00 pm)
Ahh, finally...So you were right erik, it was just a simple matter of defining a console method in shapeBase.cc :
ConsoleMethod( ShapeBase, setImageState, void, 4, 5,
"Usage: (int slot, int state, bool force)")
{
if(argc > 4)
object->setImageState(dAtoi(argv[2]), dAtoi(argv[3]), dAtob(argv[4]));
else
object->setImageState(dAtoi(argv[2]), dAtoi(argv[3]));
}Which only took a little while. Then I spent forever trying to figure out why it was changing to the correct state but not playing the animation. After a few hours of frustration i finally realized that the animation needs to play on the server side, not just the client side. The workaround for now is to just set 'stateFire[1] = 1' in the ShapeBaseImageData datablock for all of the facial sequences besides the root.After I did that the code started flowing. Here is a good example...
function AIPlayer::doRootBlink(%this)
{
// Our blink state is 1
%this.setImageState(0,1);
%tRandom = getRandom(15000, 500);
%this.schedule(%tRandom, "doRootBlink");
}This makes the ai blink every now and then randomly. The state system is perfect for this because in script you can set the blink state to transition back to the root state when it's finished. Yes, initiating the blink needs to be on the server somehow, but changing through several following states and then back to the root state is taken care of by the client.Josh you are correct about the collisions, this would not be a good method of mounting a head on someone in a first person shooter. For things where the geometry is not important, such as a face, it works great.
Eventually I'll go back and rewrite the image class like you were saying, but for now this works and opens up a few doors. Thanks for the help dudes, see ya'll in another post.
#9
02/07/2005 (1:18 pm)
@Andrew: damn, man, that's a really good idea! Never thought of mounting an image to represent the face before. Very smart. I like it!
#10
02/07/2005 (1:42 pm)
That is a damn nifty idea... would be interesting to see a resource on this when you get done.
Associate Dave Calabrese
Cerulean Games
What I _think_ you should be doing here, is the model that represents your weapon is what you should be changing the animation sequence on. With that it actually should be really easy. However, I personally have never tried this, but it seems like it should just be as easy as that.
Read up a bit on how images work, and make sure you are animating the associated model and not the actual image! =)