Animation of Nodes
by Demolishun · in Torque Game Engine · 06/24/2006 (12:05 pm) · 13 replies
I am interested in creating a tutorial of how to write code to animate shapebase objects. My previous foray into this was trying to duplicate the turret example. I had problems where it would look one direction, fire another, and had strange glitches when it went out of client scope. What I am hoping to do is create a very small and solid code base that explains how to do it right.
Here are my questions:
1. How do I create a TDN article that restricts who can view the content? I intend to put c++ code on the page. I have created TDN articles, but was not sure how to restrict who can go there or if I even need to since I have to login to see it anyway.
2. Would anyone be willing to provide assistance in explaining how the parts work? Last time it seemed like it was hit or miss on getting anyone with any real knowledge to comment on the subject.
3. Are there other resources besides the turret resource that would be helpful? I can include these on the page as well as use them to learn the details of the animation of nodes through code.
Thanks,
Frank
PS There is a rhymn and reason for me doing this. I want to eventually create a resource for doing IK in Torque. The problem is the more I search, and the more I look at other code in the engine, the more confused I get for what it the best/right way to approach it. The games I want to create will be best served with dynamic animations (IK).
Here are my questions:
1. How do I create a TDN article that restricts who can view the content? I intend to put c++ code on the page. I have created TDN articles, but was not sure how to restrict who can go there or if I even need to since I have to login to see it anyway.
2. Would anyone be willing to provide assistance in explaining how the parts work? Last time it seemed like it was hit or miss on getting anyone with any real knowledge to comment on the subject.
3. Are there other resources besides the turret resource that would be helpful? I can include these on the page as well as use them to learn the details of the animation of nodes through code.
Thanks,
Frank
PS There is a rhymn and reason for me doing this. I want to eventually create a resource for doing IK in Torque. The problem is the more I search, and the more I look at other code in the engine, the more confused I get for what it the best/right way to approach it. The games I want to create will be best served with dynamic animations (IK).
About the author
I love programming, I love programming things that go click, whirr, boom. For organized T3D Links visit: http://demolishun.com/?page_id=67
#2
1. Admins can edit permissions, but primarily it is done based on where you put it (ie, everything under Torque/ is locked to Torque owners). For now, don't worry too much about it, we'll be putting a more obvious system into place later on.
2. Sorry, too busy to commit to anything. :)
3. Reading TS thoroughly is what I'd recommend. There are probably some good discussions in the forums, and Chris Calef knows it fairly well, so you might get something from him if you ask very nicely (or better yet beg him to write a TDN article on it ;).
write/readPacketData are used to write every-packet updates for a connection's control object (ie, the current control object). They are only used in this scenario, and you can assume they are sent as frequently as possible, ie, every packet. (They are actually not sent if client and server are getting the same values from getPacketDataChecksum on their respective control objects.)
So client is "out of sync" if the checksums vary, and an update is sent in response in this scenario.
Hope that clears things up a bit.
06/24/2006 (11:21 pm)
Random answers:1. Admins can edit permissions, but primarily it is done based on where you put it (ie, everything under Torque/ is locked to Torque owners). For now, don't worry too much about it, we'll be putting a more obvious system into place later on.
2. Sorry, too busy to commit to anything. :)
3. Reading TS thoroughly is what I'd recommend. There are probably some good discussions in the forums, and Chris Calef knows it fairly well, so you might get something from him if you ask very nicely (or better yet beg him to write a TDN article on it ;).
write/readPacketData are used to write every-packet updates for a connection's control object (ie, the current control object). They are only used in this scenario, and you can assume they are sent as frequently as possible, ie, every packet. (They are actually not sent if client and server are getting the same values from getPacketDataChecksum on their respective control objects.)
So client is "out of sync" if the checksums vary, and an update is sent in response in this scenario.
Hope that clears things up a bit.
#3
Yes, this clears up the questions. I did not realize the section on Networking existed. I must have overlooked it a hundred times. TS? Three Space, Torque Script?
Thanks,
Frank
06/24/2006 (11:36 pm)
Ben,Yes, this clears up the questions. I did not realize the section on Networking existed. I must have overlooked it a hundred times. TS? Three Space, Torque Script?
Thanks,
Frank
#4
06/24/2006 (11:38 pm)
The only thing in the engine that has all its files prefixed with ts and is in a folder called ts - the 3space animation system.
#5
06/25/2006 (7:33 am)
Frank, your research interests me as well (I'll *have* to implement IK someday, it's fate). I've messed a lot with the player class animation stuff, but haven't toyed with manipulating bones via code yet, so you can drop me a line if you need help in understanding certain parts of the source code.
#6
I create this page
Not here anymore: http://tdn.garagegames.com/wiki/Code/Node_Control_Through_Code
tdn.garagegames.com/wiki/Torque/Node_Control_Through_Code
I tried logging out and accessing and it would not let me in unless I logged in. Is that the right spot?
Manoel,
Take a look at the page from time to time and if you can add do.
Also, if you have player class experience maybe you could scout out what the parts do and do quicky outline on the page. I am working on modifying the StaticShape object to control a few nodes. When I get that working I will place it in the page.
Thanks
06/25/2006 (9:07 am)
Ben,I create this page
Not here anymore: http://tdn.garagegames.com/wiki/Code/Node_Control_Through_Code
tdn.garagegames.com/wiki/Torque/Node_Control_Through_Code
I tried logging out and accessing and it would not let me in unless I logged in. Is that the right spot?
Manoel,
Take a look at the page from time to time and if you can add do.
Also, if you have player class experience maybe you could scout out what the parts do and do quicky outline on the page. I am working on modifying the StaticShape object to control a few nodes. When I get that working I will place it in the page.
Thanks
#7
Currently NO ONE can access anything on TDN if they do not own a product. So it's pretty safe. We will be doing a Great Reorg to get everything organized neatly at some point, as well as making a lot more stuff public. TDN is currently a bit lower on my task list (taking care of Atlas right now is top priority and of course I'm on vacation atm :) so I don't have a firm date to give out on that stuff - not right away.
The Code folder is probably not going to last because it does not indicate what product it's relevant for. Preferable is Torque/, TSE/, TGB/, etc.
Please see the Meta section for documentation on how to use TDN. tdn.garagegames.com/wiki/Meta is the place to read.
06/25/2006 (11:21 am)
Hey Frank,Currently NO ONE can access anything on TDN if they do not own a product. So it's pretty safe. We will be doing a Great Reorg to get everything organized neatly at some point, as well as making a lot more stuff public. TDN is currently a bit lower on my task list (taking care of Atlas right now is top priority and of course I'm on vacation atm :) so I don't have a firm date to give out on that stuff - not right away.
The Code folder is probably not going to last because it does not indicate what product it's relevant for. Preferable is Torque/, TSE/, TGB/, etc.
Please see the Meta section for documentation on how to use TDN. tdn.garagegames.com/wiki/Meta is the place to read.
#9
06/27/2006 (6:59 pm)
Added first attempt at adding networked animation to a shapebase object at the link above. Please comment, especially experienced Torque networking programmers. The code is very neatly layed out so it should not be hard to follow.
#10
Vehicle and Player both have this behavior; they send lower fidelity updates if you're not controlling them.
06/28/2006 (10:22 am)
You'll typically want to decimate the rotation values when sending them in packUpdate/unpackUpdate, ie, write them as maybe 10 bits of precision each instead of 32. The whole idea is that you want to use network bandwidth as needed to give a high fidelity end user experience in minimum network traffic.Vehicle and Player both have this behavior; they send lower fidelity updates if you're not controlling them.
#11
Like this?:
That is so way cool and good design. I was just talking to a guy at work about using a decent network protocol and this takes the cake. I think I will suggest he look into TNL stuff. I wonder if there are any industrial real-time networks that are conceptually at this level?
06/28/2006 (6:46 pm)
Wow, I did not even know you could do that. That is very cool!Like this?:
// FHC - animation
if(bstream->writeFlag(mask & AnimateMask)) {
stream->writeSignedFloat(mRot.x,10);
stream->writeSignedFloat(mRot.y,10);
stream->writeSignedFloat(mRot.z,10);
// bstream->write(mRot.x);
// bstream->write(mRot.y);
// bstream->write(mRot.z);
}
if(bstream->writeFlag(mask & OptionsMask)) {
stream->writeSignedFloat(dRot.x,10);
stream->writeSignedFloat(dRot.y,10);
stream->writeSignedFloat(dRot.z,10);
// bstream->write(dRot.x);
// bstream->write(dRot.y);
// bstream->write(dRot.z);
}
...
// FHC - animation
if (bstream->readFlag()) {
mRot.x = stream->readSignedFloat(10);
mRot.y = stream->readSignedFloat(10);
mRot.z = stream->readSignedFloat(10);
// bstream->read(&mRot.x);
// bstream->read(&mRot.y);
// bstream->read(&mRot.z);
}
if (bstream->readFlag()) {
dRot.x = stream->readSignedFloat(10);
dRot.y = stream->readSignedFloat(10);
dRot.z = stream->readSignedFloat(10);
// bstream->read(&dRot.x);
// bstream->read(&dRot.y);
// bstream->read(&dRot.z);
}That is so way cool and good design. I was just talking to a guy at work about using a decent network protocol and this takes the cake. I think I will suggest he look into TNL stuff. I wonder if there are any industrial real-time networks that are conceptually at this level?
#12
Yes - but be aware those things assume you have a normalized float (0..1 iirc), so you may have to do clever things to make sure your values aren't mangled. I believe there are better way than sending euler angles to transmit rotation, as well, i.e.:
Which is what Vehicle does in its packUpdate.
You'll also note it does some other filtering in that function.
06/28/2006 (6:50 pm)
That's the whole point of having the seperate paths. ;)Yes - but be aware those things assume you have a normalized float (0..1 iirc), so you may have to do clever things to make sure your values aren't mangled. I believe there are better way than sending euler angles to transmit rotation, as well, i.e.:
if (stream->writeFlag(mask & PositionMask))
{
stream->writeCompressedPoint(mRigid.linPosition);
mathWrite(*stream, mRigid.angPosition);
mathWrite(*stream, mRigid.linMomentum);
mathWrite(*stream, mRigid.angMomentum);
stream->writeFlag(mRigid.atRest);
}Which is what Vehicle does in its packUpdate.
You'll also note it does some other filtering in that function.
#13
To normalize in this instance I would just divide by 180 and remultiply by 180. That is not to bad. I don't like using euler angles, but I am just testing stuff out for now. Makes it a bit easier to understand. That explains this code for me:
Thanks for your insight.
06/28/2006 (10:03 pm)
Ben,To normalize in this instance I would just divide by 180 and remultiply by 180. That is not to bad. I don't like using euler angles, but I am just testing stuff out for now. Makes it a bit easier to understand. That explains this code for me:
stream->writeSignedFloat(mHead.x / mDataBlock->maxLookAngle, 6);
stream->writeSignedFloat(mHead.z / mDataBlock->maxLookAngle, 6);I am eventually planning on using quaternions for transferring rotation and those are generally normalized for animation. I will have to look at the different functions in the network code. Now that I know there is a lot more to learn about what is being sent I will look into it a bit more. Thanks for your insight.
Torque Owner Demolishun
DemolishunConsulting Rocks!
I thought writePacketData and readPacketData were for highly time critical data and I thought packUpdate and unpackUpdate were for less time critical stuff. How does the server determine if the client is out of sync? Also, what does it mean by 'current control object'?