Game Development Community

Motion trail and sword trail

by PGames · in Torque 3D Professional · 09/15/2010 (9:41 am) · 14 replies

I'm trying to create a sword trail for my weapon, I found this old thread here (http://www.torquepowered.com/community/forums/viewthread/16884/) that mentions a motion.h and motion.cc, does anyone have a working copy of motion.h and motion.cc for T3D or know the concept behind getting a trail for a sword? Any help would be appreciated!

#1
09/15/2010 (10:44 am)
Ben McIntosh did an analogue resource for this: check out the Flaming Sword resource for TGEA.
He used to attach an emitter on nodes.
#2
09/15/2010 (4:37 pm)
The motion trails that were used in Realmwars simply drew a series of quads between a start and end node added to a weapon that moved on a spline if it (the weapon) was active. I'm not sure if you can still find the RW source on here anymore -- if you do it will be an old version of TGE and the gl methods would have to be ported to GFX.

EDIT: I have the files... somewhere - but never ported them. Will see if I can find them and reply back here.
#3
09/17/2010 (12:54 am)
Michael, did you find them by chance?
#4
09/17/2010 (8:53 pm)
Here you go:
motion.h
motion.cc

Keep in mind that this was written for the RealmWars community project circa TGE v1.3 so it will not work as is for Torque 3D -- some porting required.
#5
09/20/2010 (6:19 am)
Great thanks, I'll see if I can port it and will post the results here if I'm successful. Also, do you happen to have mCatmullRomPatch.h and mCatmullRomPatch.cc?
#6
09/20/2010 (7:38 am)
I am very interested in this port to T3D if anyone gets it working.

I will even pay to have it or another mountImage motion trail solution that is painless to integrate.
#7
09/20/2010 (8:26 am)
@Michael: can you send the two files on my email frank at indie - zone dot com, as I cannot access google docs... thanks
#8
09/20/2010 (11:39 pm)
Here are the catMullRomPatch files:
mCatmullRomPatch.h
//-----------------------------------------------------------------------------
// Torque Game Engine
// 
// Written by Markus Nuebel
//-----------------------------------------------------------------------------

#ifndef _CATMULROMPATCH_H_
#define _CATMULROMPATCH_H_

#ifndef _PLATFORM_H_
#include "platform/platform.h"
#endif
#ifndef _MPOINT_H_
#include "math/mPoint.h"
#endif
#ifndef _MSPLINEPATCH_H_
#include "math/mSplinePatch.h"
#endif


//------------------------------------------------------------------------------
// Catmull-Rom spline patch
//------------------------------------------------------------------------------
class CatmullRomPatch : public SplinePatch
{
   typedef SplinePatch Parent;

private:
	Point3F	tangent0;
	Point3F	tangent1;

	void calcTangentVectors();

public:

   CatmullRomPatch();

   virtual void   calc( F32 t, Point3F &result );
   virtual void   calc( Point3F *points, F32 t, Point3F &result );
   virtual void   setControlPoint( Point3F &point, int index );
   virtual void   submitControlPoints( SplCtrlPts &points );
   
};

#endif

mCatmullRomPatch.cc
//-----------------------------------------------------------------------------
// Torque Game Engine
//
// Written by Markus Nuebel
//-----------------------------------------------------------------------------

#include "math/mCatmullRomPatch.h"


//******************************************************************************
// Quadratic spline patch
//******************************************************************************
CatmullRomPatch::CatmullRomPatch()
{
   setNumReqControlPoints(4);
}

//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
void CatmullRomPatch::calcTangentVectors()
{
	SplCtrlPts* points = (SplCtrlPts*) getControlPoints();
	if(points->getNumPoints() > 3)
	{
		tangent0 = *points->getPoint(2) - *points->getPoint(0);
		tangent1 = *points->getPoint(3) - *points->getPoint(1);
	}
};


//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
void CatmullRomPatch::submitControlPoints( SplCtrlPts &points )
{
   Parent::submitControlPoints( points );
   calcTangentVectors();
};


//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
void CatmullRomPatch::setControlPoint( Point3F &point, int index )
{
   ( (SplCtrlPts*) getControlPoints() )->setPoint( point, index );
}

//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
void CatmullRomPatch::calc( F32 t, Point3F &result )
{
	SplCtrlPts* points = (SplCtrlPts*) getControlPoints();

	F32 t2 = t*t;
   F32 t3 = t*t*t;

   F32 h0 = 2*t3-3*t2+1;
   F32 h1 = -2*t3+3*t2;
   F32 h2 = t3-2*t2+t;
   F32 h3 = t3-t2;

   result = h0*(*points->getPoint(1)) + h1*(*points->getPoint(2)) + h2*tangent0 + h3*tangent1;
}


//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
void CatmullRomPatch::calc( Point3F *points, F32 t, Point3F &result )
{
}
#9
09/20/2010 (11:40 pm)
@Frank: email sent - enjoy.
#10
01/10/2011 (10:15 pm)
.
#11
01/11/2011 (6:10 am)
EDIT:

Didn't mean to steal the thread:
Moved here.
#12
01/18/2011 (8:54 pm)
oops
#13
07/24/2011 (11:56 pm)
PGames, would you care to share the files for T3D ?
#14
12/11/2012 (2:41 pm)
Anyone have a port for T3D?