Sword Trails
by John Eric Miller · in Torque Game Engine · 03/15/2004 (7:24 pm) · 40 replies
Does anyone have any ideas on how I could have sword trails when a sword is swung?
#2
I don't know if this was added to Torque CVS or the Resources section.
-Eric F
EDIT: A message in the above IOTD says it's in the RW CVS.
03/15/2004 (10:05 pm)
Check out the Realm Wars demo. It has the trails you are looking for. Thank Google for this: Sword Trails PicsI don't know if this was added to Torque CVS or the Resources section.
-Eric F
EDIT: A message in the above IOTD says it's in the RW CVS.
#3
03/16/2004 (12:27 am)
Markus fixed the sword trail code so that it doesnt have the gap when generated and a few other things recently.. that should be in the CVS now too eh markus?
#4
03/16/2004 (8:36 am)
Can anyone point me in the right direction in the code to where this is? Or better yet make it a resource for everyone :)
#5
I don't know where any of this code is.
03/16/2004 (11:12 am)
I don't think they're using particle effects, but I guess it's possible. I'm no genius, but you might be able to use some type of "billboard" and have it appear at the sword's location every millisecond or whatever, and then fade out.I don't know where any of this code is.
#7
Thanks!
03/17/2004 (6:05 am)
Are there any other dependency changes from version 1.2.1 ? Do I only need motion.cc/.h?Thanks!
#8
Of course there are other dependencies.
If you check the includes of motion.cc:
you see, that there are a couple of dependencies.
New is the reference to the CatmullRomPatch class in the /math folder. I implemented the used hermite spline interpolation for the trail in there.
-- Markus
03/17/2004 (6:14 am)
Not quite sure, what you mean?Of course there are other dependencies.
If you check the includes of motion.cc:
#include "game/fx/motion.h" #include "math/mMath.h" #include "math/mSplinePatch.h" #include "math/mCatmullRomPatch.h" #include "sim/netConnection.h" #include "dgl/dgl.h" #include "sceneGraph/sceneGraph.h" #include "sceneGraph/sceneState.h" #include "console/consoleTypes.h" #include "core/bitStream.h"
you see, that there are a couple of dependencies.
New is the reference to the CatmullRomPatch class in the /math folder. I implemented the used hermite spline interpolation for the trail in there.
-- Markus
#9
Also where in the script is the trails setup?
03/17/2004 (6:37 am)
I would like to implment the sword trails in the version 1.2.1 of Torque. Does alot of code need to be changed to implement this in 1.2.1 of Torque? I appreciate the information and any help you can provide. I am downloading the realmwars source code right now.Also where in the script is the trails setup?
#10
Just include game/fx/motion.cc/.c along with /math/mCatmullRomPatch.cc/.h
(That's for the trail itself.)
The trail is configured with two new datablocks, that you can check out in the RW corssbow.cs and axe.cs scripts.
To display the trail you must feed it with position data. This is implemented in ShapeImage and I think in ShapeBase.
You have to add these changes to your torque.
I tried to mark all changes with:
So this should be easy to find.
-- Markus
03/17/2004 (6:44 am)
Don't have the code at hand, so I may miss something, but here is what you have to do.Just include game/fx/motion.cc/.c along with /math/mCatmullRomPatch.cc/.h
(That's for the trail itself.)
The trail is configured with two new datablocks, that you can check out in the RW corssbow.cs and axe.cs scripts.
To display the trail you must feed it with position data. This is implemented in ShapeImage and I think in ShapeBase.
You have to add these changes to your torque.
I tried to mark all changes with:
// RW --------------------- // <authorname> --> ... // <authorname> <-- // RW ---------------------
So this should be easy to find.
-- Markus
#11
03/17/2004 (7:19 am)
Awesome, thanks so much for the help.
#12
// RW --------------------------
// MAN -->
// MAN <--
// RW --------------------------
for anyone else looking to implement this.
03/17/2004 (7:22 am)
Your changes were marked as // RW --------------------------
// MAN -->
// MAN <--
// RW --------------------------
for anyone else looking to implement this.
#13
03/17/2004 (7:30 am)
I found all the changes in the code. Do I need to add any nodes to the weapons to support this? How does it know how wide to make the trail?
#14
Check out: ShapeBase::UpdateImageMotionTrail().
You need the nodes: damageStart and damageStart.
The thickness of the trail is determined, by how near these two nodes are to each other.
Other trail parameters are determined by the new datablock: MotionTrailData.
Check out my code comments.
The length of the trail is generally determined by the lifetime setting.
Longer lifetime makes longer trails, since the quads are not fading so fast, but you have to keep an eye on the variable numberOfQuads.
Having a long lifetime results in a lost of quads stored in the trail. When numberOfQuads is reached, the older ones are discared. This may cut of the end of your trail.
03/17/2004 (11:19 am)
Yes, you do.Check out: ShapeBase::UpdateImageMotionTrail().
You need the nodes: damageStart and damageStart.
The thickness of the trail is determined, by how near these two nodes are to each other.
Other trail parameters are determined by the new datablock: MotionTrailData.
Check out my code comments.
The length of the trail is generally determined by the lifetime setting.
Longer lifetime makes longer trails, since the quads are not fading so fast, but you have to keep an eye on the variable numberOfQuads.
Having a long lifetime results in a lost of quads stored in the trail. When numberOfQuads is reached, the older ones are discared. This may cut of the end of your trail.
datablock MotionTrailData(AxeTrail)
{
// Destination blending
// 0 = GL_ZERO,
// 1 = GL_ONE,
// 2 = GL_SRC_COLOR
// 3 = GL_ONE_MINUS_SRC_COLO
// 4 = GL_SRC_ALPHA
// 5 = GL_ONE_MINUS_SRC_ALPHA
// 6 = GL_DST_ALPHA
// 7 = GL_ONE_MINUS_DST_ALPHA
// Source blending
// 0 = GL_ZERO,
// 1 = GL_ONE,
// 4 = GL_SRC_ALPHA
// 5 = GL_ONE_MINUS_SRC_ALPHA
// 6 = GL_DST_ALPHA
// 7 = GL_ONE_MINUS_DST_ALPHA
// 8 = GL_DST_COLOR
// 9 = GL_ONE_MINUS_DST_COLOR
// 10 = GL_SRC_ALPHA_SATURATE
srcBlend = 4;
dstBlend = 5;
lifetime = 0.4;
curveDetail = 0.05; // Small values produce a high curve tesselation
// High values produce a low curve tesselation
numberOfQuads = 100; // Number of quads, used to render the trail
showAlways = false; // Trail is only shown during attack move
// If showAlways is set to true the trail will be
// rendered all the time
color = "0.0 1.0 1.0 0.20"; // Color or the trail
trailTexture = "common/lighting/beamside" ; // Alpha texture of the trail
};
#15
Your comments in the code are extremely helpful!
03/17/2004 (11:43 am)
So I would placed the damageStart node at the tip of the blade and the damageEnd node at the base of the blade for a sword? Your comments in the code are extremely helpful!
#16
The positions of these two nodes are the input to the trail rendering code.
If you have other means of determining a start and end point for new trail quads, you could use them as well.
Just plug the points into:
-- Markus
03/17/2004 (10:34 pm)
Yes, that's how it is done in RW.The positions of these two nodes are the input to the trail rendering code.
If you have other means of determining a start and end point for new trail quads, you could use them as well.
Just plug the points into:
void MotionTrail::addQuad( const Point3F &start, const Point3F &end )
-- Markus
#17
11/01/2004 (8:23 pm)
I made all the changes in the code within the RW --- ... --- RW and compiled, but the trails aren't showing up. I also added the MotionTrailData. Is there something I missed?
#18
11/01/2004 (8:26 pm)
Errr scratch that, got it showing. Nice effect! thx guys. One thing, it only draws when I have the showAlways = true;
#19
I think I'm gonna try attaching these to projectiles rather that using the particle engine. Might save some frames.
11/01/2004 (9:04 pm)
Nice implementation.I think I'm gonna try attaching these to projectiles rather that using the particle engine. Might save some frames.
#20
or where the function body is? I'm tryin to figure out how to draw the sword trail only when swinging. Anybody have any pointers? Any help is greatly appreciated. :)
11/02/2004 (6:09 pm)
Anyone know where this function is being called, virtual void UpdateImageMotionTrail(F32 dt,U32 imageSlot);
or where the function body is? I'm tryin to figure out how to draw the sword trail only when swinging. Anybody have any pointers? Any help is greatly appreciated. :)
Torque Owner John Vanderbeck
VanderGames