3D fading trails

Hi all,

This is a C++ extension that creates 3D trails from a moving point.
Each frame, just update the new position and the trail (actually a bended cylinder) will follow it.
As few data as possible is modified every frame, so it runs with very nice performances.

Warning : there is no type checking on the parameters !
Includes a compiled version for windows + a VS8 compiling project.

You just create the trail object as follows :

	self.gt = GeomTrail.GeomTrail(
	self.node = render.attachNewNode(self.gt.getGeomNode())

And then, each frame :

self.gt.update(self.ncenter, radius, color) # vec3, float, vec4

Wow, looks great, and thank you for sharing the code.

Hi enn0x, I think I’ve read somewhere that you’ve written some C++ extensions too. Do you know how to perform type checking on the parameters ?

Yes. I would have released my own extension a week ago, if I had been able to upload to my webspace, but they seem to have technical problems. Well, perhaps next week.

(1) Objects of a particular type, e.g. NodePath or Vec3 or my own extension types. This is what I do most of the time. Error messages get set automatically.

if ( ! PyArg_ParseTuple( args, "O!", &Dtool_LVector3f, &_velocity ) )
    return NULL;

(2) Python methods, e.g. for callbacks, or any kind of sequences (list, tuples, …). These checks are not for one particular type, but for groups of types, like all callable objects, or all objects that support the sequence protocol.

if ( ! PyCallable_Check( _callback ) )
    PyErr_SetString( PyExc_TypeError, "Callback must be a callable method" );
    return NULL;
if ( ! PySequence_Check( _cloud ) ) {
    PyErr_SetString( PyExc_TypeError, "Argument two must be a sequence!" );
    return NULL;

(3) Well, and then there is PyObject_TypeCheck(PyObject* obj, PyTypeObject* type) too. But I have no need to use this way of type-checking in my code.

Hope this helps.

That sure helps a lot, I wasn’t ware of the “O!” feature. Thanks !

Hmmm, am I missing something? The actual dll is nowhere to be found in the zip file, and I don’t have a Visual Studio environment to build it myself…

Anyone has the windows compiled version of this? I’d appreciate a copy.


Roo exellente one i love it :slight_smile:

An other technique share by Trreform :
discourse.panda3d.org/viewtopic.php … ion+trails

I have rewritten my old tutorial to use the new pyro system