Facing the right direction while walking...
by Joel Schilling · in Verve · 10/22/2009 (2:06 am) · 16 replies
I have an NPC villager as a StaticShape, with a motion track on a VPath, and a walking animation. As long as she is headed to the first point, everything looks good. After the first point, she heads in the right direction, but keeps facing the original direction while moving the other way.
If I try to change the Orientation from FREE to TOPOINT, or TOPATH, or INTERPOLATE, etc, the model gets all funky looking. It's as if the model gets rotated to face the correct direction, but the material still faces the original direction, making the UV wrap around the model incorrectly.
If I try to change the Orientation from FREE to TOPOINT, or TOPATH, or INTERPOLATE, etc, the model gets all funky looking. It's as if the model gets rotated to face the correct direction, but the material still faces the original direction, making the UV wrap around the model incorrectly.
#2
The TOPATH does face the model in the correct direction, but the material faces the old direction. It's really weird seeing a face textured onto the hair mesh on the back of the head!
I had a thought this morning that maybe this is caused because I am using setSkinName on the ShapeBase to change her dress. I probably won't be able to get to it till tomorrow, but I will comment out the call to setSkinName, and see if that solves the problem.
Oh, one other thing--in your tutorials you mention a cs file (the name slips my mind right now) in the scripts/server directory with the function Verve::PlayCinematic() but neither the script nor the function are included with the version I downloaded.
10/22/2009 (9:52 am)
I bought it Tuesday, and tried it out yesterday... I downloaded it from the link in My Products, so I assume it's the latest.The TOPATH does face the model in the correct direction, but the material faces the old direction. It's really weird seeing a face textured onto the hair mesh on the back of the head!
I had a thought this morning that maybe this is caused because I am using setSkinName on the ShapeBase to change her dress. I probably won't be able to get to it till tomorrow, but I will comment out the call to setSkinName, and see if that solves the problem.
Oh, one other thing--in your tutorials you mention a cs file (the name slips my mind right now) in the scripts/server directory with the function Verve::PlayCinematic() but neither the script nor the function are included with the version I downloaded.
#3
Thanks Joel!
10/22/2009 (6:11 pm)
Quote:Oh, one other thing--in your tutorials you mention a cs file (the name slips my mind right now) in the scripts/server directory with the function Verve::PlayCinematic() but neither the script nor the function are included with the version I downloaded.Nuts. I'll post a link for the missing files in this forum. Thanks for letting me know!
Quote:The TOPATH does face the model in the correct direction, but the material faces the old direction. It's really weird seeing a face textured onto the hair mesh on the back of the head!This sounds very odd. I personally haven't had any problems with using any of the path orientations - so it could be due to the changed skin. Give that a whirl and get back to me. I'll also try to look at it over here.
I had a thought this morning that maybe this is caused because I am using setSkinName on the ShapeBase to change her dress. I probably won't be able to get to it till tomorrow, but I will comment out the call to setSkinName, and see if that solves the problem.
Thanks Joel!
#4
One with TOPATH:
www.imagedump.com/index.cgi?pick=get&tp=554701
The one using FREE (this is what she should look like from behind):
www.imagedump.com/index.cgi?pick=get&tp=554702
10/22/2009 (11:14 pm)
Nope, still the same thing without the skin change. Here are two pictures, both taken from behind, using the same track and same shape:One with TOPATH:
www.imagedump.com/index.cgi?pick=get&tp=554701
The one using FREE (this is what she should look like from behind):
www.imagedump.com/index.cgi?pick=get&tp=554702
#5
This mangling takes place, not when you run the sequence, but when you load the sequence. Or if the sequence has a motion track using FREE, it occurs when you change the orientation to TOPATH.
I am using a linear path, and she is facing the correct direction. If you run the sequence on FREE, she will walk very nicely to the next node, and then start moving the right direction, but still facing the original direction. If I change the sequence to TOPATH, the mesh immediately mangles. The funny thing is, when you load it, there is no reason to do any sort of transform on her at all! (At least that I know of)
At any time in the sequence, I can grab her and do a rotate in the World Editor, and she rotates correctly. I can even pause her at the node where she is supposed to turn and get her position, and do a call to setTransform() and face her in the right direction, and she walks facing the correct direction till the next node.
I noticed each node has a rotation property... but it appears to be ignored for this particular group type. It should be fairly easy to make an orientation type that is the same as FREE, except it rotates the shape using the rotation on the node by calling setTransform(), when it reaches it.
However, you should still look into why the sequence with a motion track other than FREE mangles meshes when it is loaded.
Thanks!
10/23/2009 (10:45 am)
So, it looks like the texture is being misapplied, but when looking into it more, I don't think that is the case. When I put a plain white texture on the model, I can still see the feet facing forward, and the face facing back. So it looks like the actual mesh is getting mangled.This mangling takes place, not when you run the sequence, but when you load the sequence. Or if the sequence has a motion track using FREE, it occurs when you change the orientation to TOPATH.
I am using a linear path, and she is facing the correct direction. If you run the sequence on FREE, she will walk very nicely to the next node, and then start moving the right direction, but still facing the original direction. If I change the sequence to TOPATH, the mesh immediately mangles. The funny thing is, when you load it, there is no reason to do any sort of transform on her at all! (At least that I know of)
At any time in the sequence, I can grab her and do a rotate in the World Editor, and she rotates correctly. I can even pause her at the node where she is supposed to turn and get her position, and do a call to setTransform() and face her in the right direction, and she walks facing the correct direction till the next node.
I noticed each node has a rotation property... but it appears to be ignored for this particular group type. It should be fairly easy to make an orientation type that is the same as FREE, except it rotates the shape using the rotation on the node by calling setTransform(), when it reaches it.
However, you should still look into why the sequence with a motion track other than FREE mangles meshes when it is loaded.
Thanks!
#6
The orientation for TOPATH is calculated for a linear path is just to take the position of the destination node from the position of the source node, normalize it and use that as the forward vector in a matrix. The code is really simple, so I don't see how that math is failing. I'll take another look at it now though.
Can you do me a favour and download the latest files? I gave a new set to GG last week and I don't think they uploaded them until Wednesday.
Maybe you could send me your project to have a quick look at?
10/23/2009 (5:44 pm)
This is really bazaar. Can you try using another model on the same path with the same settings? I just cannot see any kind of deformation happening on any of the models (animated or static) that I am using.The orientation for TOPATH is calculated for a linear path is just to take the position of the destination node from the position of the source node, normalize it and use that as the forward vector in a matrix. The code is really simple, so I don't see how that math is failing. I'll take another look at it now though.
Can you do me a favour and download the latest files? I gave a new set to GG last week and I don't think they uploaded them until Wednesday.
Maybe you could send me your project to have a quick look at?
#7
Like I said, the mesh is getting deformed when I open the sequence file in the Verve editor. For all I know, the actual transforms while on the path may be working correctly, and it's just a bug on loading the sequence. I don't see why a transform would be happening at that point.
I'm not sure if I'm allowed to send you the Female Villager NPC model I bought from Dexsoft-games or not. My project is pretty big ~500 M, so if I send you anything, I will make a smaller project with just the problem area in it.
10/23/2009 (6:20 pm)
I'll download the latest and try that out. Like I said, the mesh is getting deformed when I open the sequence file in the Verve editor. For all I know, the actual transforms while on the path may be working correctly, and it's just a bug on loading the sequence. I don't see why a transform would be happening at that point.
I'm not sure if I'm allowed to send you the Female Villager NPC model I bought from Dexsoft-games or not. My project is pretty big ~500 M, so if I send you anything, I will make a smaller project with just the problem area in it.
#8
I'm not 100% sure what it is, its rather odd though. It looks like it only happens for linear paths, though the calculations for an objects orientation is far simpler for a linear path than they are for bezier. Really odd stuff.
I'm looking into a fix now.
Thanks Joel!
Update: Scratch that, the whole thing is messed up! Damnit!
10/23/2009 (7:11 pm)
Joel, I can verify that something is wrong, no need to send me your project.I'm not 100% sure what it is, its rather odd though. It looks like it only happens for linear paths, though the calculations for an objects orientation is far simpler for a linear path than they are for bezier. Really odd stuff.
I'm looking into a fix now.
Thanks Joel!
Update: Scratch that, the whole thing is messed up! Damnit!
#9
In VPathObject.cpp, look for the method ::getTransform and ::getRenderTransform and replace them with these:
In VPath.cpp, look for the ConsoleMethod getPathTransform (line 1798) and replace it with this:
10/23/2009 (7:37 pm)
Alrighty, it looks as if I have a fix for this issue. It was much more serious than I thought.In VPathObject.cpp, look for the method ::getTransform and ::getRenderTransform and replace them with these:
MatrixF VPathObject::getTransform( void )
{
MatrixF mat( true );
switch ( mOrientationMode.Type )
{
case k_OrientationInterpolate :
case k_OrientationToObject :
case k_OrientationToPoint :
case k_OrientationToPath :
{
// Y-Axis.
VectorF yVec = mOrientation;
yVec.normalize();
// X-Axis.
VectorF xVec = mCross( yVec, VPath::gBezierUp );
xVec.normalize();
// Z-Axis.
VectorF zVec = mCross( xVec, yVec );
zVec.normalize();
// Setup Object Transform.
mat.setColumn( 0, xVec );
mat.setColumn( 1, yVec );
mat.setColumn( 2, zVec );
mat.setColumn( 3, ( mPosition + mOffset ) );
} break;
case k_OrientationFree :
{
// Fetch Current Transform.
mat = mObject->getTransform();
mat.setPosition( mPosition + mOffset );
} break;
}
// Return.
return mat;
}
MatrixF VPathObject::getRenderTransform( const F32 &pDelta )
{
MatrixF mat( true );
switch ( mOrientationMode.Type )
{
case k_OrientationInterpolate :
case k_OrientationToObject :
case k_OrientationToPoint :
case k_OrientationToPath :
{
// Y-Axis.
VectorF yVec = getOrientationDelta( pDelta );
yVec.normalize();
// X-Axis.
VectorF xVec = mCross( yVec, VPath::gBezierUp );
xVec.normalize();
// Z-Axis.
VectorF zVec = mCross( xVec, yVec );
zVec.normalize();
// Setup Object Transform.
mat.setColumn( 0, xVec );
mat.setColumn( 1, yVec );
mat.setColumn( 2, zVec );
mat.setColumn( 3, getPositionDelta( pDelta ) );
} break;
case k_OrientationFree :
{
// Fetch Current Transform.
mat = mObject->getRenderTransform();
mat.setPosition( getPositionDelta( pDelta ) );
} break;
}
// Return.
return mat;
}In VPath.cpp, look for the ConsoleMethod getPathTransform (line 1798) and replace it with this:
ConsoleMethod( VPath, getPathTransform, const char *, 5, 5, "( int pSrcNodeIndex, int pDstNodeIndex, int pInterp ) - Get the transform of the path at the interp point between two nodes.\n"
"@param pSrcNodeIndex The first node.\n"
"@param pDstNodeIndex The second node.\n"
"@param pInterp The time to interp between the two nodes. Value is between 0.0 and 1.0.\n"
"@return Returns the transform of the interp time between the two given nodes." )
{
// Fetch Nodes.
VPathNode *srcNode = object->getNode( dAtoi( argv[2] ) );
VPathNode *dstNode = object->getNode( dAtoi( argv[3] ) );
// Interp Time.
const F32 &interp = dAtof( argv[4] );
// Fetch Position & Orientation.
const Point3F position = object->getPathPosition( srcNode, dstNode, interp, true );
const VectorF orientation = object->getPathOrientation( srcNode, dstNode, interp, true );
// Y-Axis.
VectorF yVec = orientation;
yVec.normalize();
// X-Axis.
VectorF xVec = mCross( yVec, VPath::gBezierUp );
xVec.normalize();
// Z-Axis.
VectorF zVec = mCross( xVec, yVec );
zVec.normalize();
// Setup Object Transform.
MatrixF mat( true );
mat.setColumn( 0, xVec );
mat.setColumn( 1, yVec );
mat.setColumn( 2, zVec );
// AngAxis.
AngAxisF aa( mat );
// Return Buffer;
char *buffer = Con::getReturnBuffer( 256 );
dSprintf( buffer, 256, "%g %g %g %g %g %g %g", position.x, position.y, position.z,
aa.axis.x, aa.axis.y, aa.axis.z, aa.angle );
// Return.
return buffer;
}Thanks for your patience Joel, much appreciated!
#10
Here are steps that you should be able to recreate using only those models:
1. Create a new Verve project, either blank terrain or empty room.
2. Highlight Gideon and drag a copy of him, and name him.
3. Create a path, in this case I actually used Bezier.
4. Create a scene sequence targeting your copied player and the path.
5. Add animation and select Run.
6. Create a motion track and import the nodes from the path.
7. Hit play, and the copy of Gideon exhibits the same phenomenon.
(I also reproduced this using the NPC Villager pack sold on GG, too.)
Thanks for looking into this! Have I earned my $20 discount yet? :)
BTW, I really am liking Verve, and am sure this is going to be a big help in my game!
10/23/2009 (7:39 pm)
I used this as an opportunity to download the 1.0.1 release of T3D, and got the latest version of Verve, and started from scratch.Here are steps that you should be able to recreate using only those models:
1. Create a new Verve project, either blank terrain or empty room.
2. Highlight Gideon and drag a copy of him, and name him.
3. Create a path, in this case I actually used Bezier.
4. Create a scene sequence targeting your copied player and the path.
5. Add animation and select Run.
6. Create a motion track and import the nodes from the path.
7. Hit play, and the copy of Gideon exhibits the same phenomenon.
(I also reproduced this using the NPC Villager pack sold on GG, too.)
Thanks for looking into this! Have I earned my $20 discount yet? :)
BTW, I really am liking Verve, and am sure this is going to be a big help in my game!
#11
Under all of the header includes, add this:
10/23/2009 (7:41 pm)
One more thing, if you find that a StaticShape moves like crap while on a path, open T3D/staticShape.cpp and make these changes:Under all of the header includes, add this:
#ifdef VT_VERVE #include "Verve/VPath/VPath.h" #endifLook for the method ::interpolateTick (line 151) and replace it with this:
void StaticShape::interpolateTick(F32 delta)
{
#ifndef VT_VERVE
if (isMounted()) {
MatrixF mat;
mMount.object->getRenderMountTransform(mMount.node,&mat);
Parent::setRenderTransform(mat);
}
#else
if ( isMounted() )
{
VPath *path = dynamic_cast<VPath*>( mMount.object );
if ( path )
{
MatrixF mat;
path->getRenderMountTransform( delta, mMount.node, &mat );
Parent::setRenderTransform( mat );
}
else
{
MatrixF mat;
mMount.object->getRenderMountTransform( mMount.node, &mat );
Parent::setRenderTransform( mat );
}
}
#endif
}That will ensure that the object interpolates correctly on the path.
#12
I'm a bit new to Torque... When I change the code in your source directory, will the new project pick up the changes, or do I need to merge the code changes to the T3D code base and make a compile?
Thanks!
10/23/2009 (7:43 pm)
Ooh, you beat me to it! I'm a bit new to Torque... When I change the code in your source directory, will the new project pick up the changes, or do I need to merge the code changes to the T3D code base and make a compile?
Thanks!
#13
The changes to StaticShape will affect all of your projects, which is why I had to include the preprocessor stuff (to ensure that it compiles in a project not using Verve).
Once you make the above changes to the files you need to recompile the engine.
10/23/2009 (7:48 pm)
The changes to VPath and VPathObject need to be made to the source files in your project. The path is something like "<T3D_Install_Dir>/My Projects/NameOfProject/source/Verve/Torque3D/VPath".The changes to StaticShape will affect all of your projects, which is why I had to include the preprocessor stuff (to ensure that it compiles in a project not using Verve).
Once you make the above changes to the files you need to recompile the engine.
#14
If I add the Verve classes to the T3D source, it should make it available to all my projects, right. I plan on trying to use Verve, Yack Pack, and AFX 2.0, and I have to get my head wrapped around how everything fits together.
Thanks for looking into this and getting a fix. I'll let you know how it turns out!
10/23/2009 (7:58 pm)
If I change the Verve source code under the Verve Kit, it will recompile when I create a new project of Verve type?If I add the Verve classes to the T3D source, it should make it available to all my projects, right. I plan on trying to use Verve, Yack Pack, and AFX 2.0, and I have to get my head wrapped around how everything fits together.
Thanks for looking into this and getting a fix. I'll let you know how it turns out!
#15
10/23/2009 (8:00 pm)
Quote:If I change the Verve source code under the Verve Kit, it will recompile when I create a new project of Verve type?If you change the source files in the template, yes.
Quote:If I add the Verve classes to the T3D source, it should make it available to all my projects, right. I plan on trying to use Verve, Yack Pack, and AFX 2.0, and I have to get my head wrapped around how everything fits together.Yes, but you will either need to update the project generator or add the source files to your project manually.
#16
I suppose getting Yack Pack to work in T3D won't be anywhere this easy. Time to break out Konrad Kiss' guide.
Thanks, Philip! I appreciate you getting this to work for me.
10/23/2009 (11:06 pm)
Awesome! I got it to work. That really made my weekend, and it just started. I suppose getting Yack Pack to work in T3D won't be anywhere this easy. Time to break out Konrad Kiss' guide.
Thanks, Philip! I appreciate you getting this to work for me.
Associate Phillip O'Shea
Violent Tulip
If you want the object to always face the way that it is traveling, you need to use "TOPATH". I'm not sure what would cause the model to go all funky.
Let me know if this is with the latest update or not.