Tails, You Win – 3D Trails In Papervision


2009-02-16_2218

I’m not really sure where the inspiration came from, but I decided to take a stab at doing Motion Trails with Pv3D.  Instead, I ended up with something more like a tail – but left the class name MotionTrail… Anyways – there isn’t a whole lot to say on the technique I used here – but I will give a general overview just to save you looking at code.  See the Demo.

The tail is defined by Number3D objects which “chase” each other, with the head node being pinned to the target you are chasing.  Each Number3D, which I’ve extended into a Trail3D class (its internal – just look in the MotionTrail.as file) – springs after the node ahead of it.  You can control this “springyness” by adjusting the minEase property of the MotionTrail.  The minEase refers to the ease amount of the very last node on the tail – which increases each node up to the head, which has an ease of 1.  So, the lower you set minEase, the slinkier the tail will end up looking.  You can control how many nodes are in the tail by adjusting the “iterations” parameter of the MotionTail class.  You need at least 2.

The tail is actually a triangle strip, which progressively gets smaller the closer to the end it gets.  This 1) lets you use any material you want, and 2)easily adjust the look and feel of the tail all you want. Feel free to override it to affect the width with speed, distance, or any other cool variables you want.  It looked good just tapering so I left it that way.   The triangle strips vertices are adjusted to their corresponding TrailNode, so they always face the camera.  This keeps the tail visible from any direction.  Again, you could change this if you wanted it to be a more obvious flat tail.  My initial idea was to use the delta properties of the adjacent nodes to determine the nodes up vector (find the cross product between the dx/dy/dz values of the nodes on either side of the current node) – but again – I liked how this looks so I left it.

The demo itself just makes use of some bezier curves to keep things moving smoothly.  You will notice the nodes are flocking – but really it is just setting the control point and end point of each node within a certain range – which changes positions when the first object arrives.  You can press “F” to toggle it so that each node has its own unique path.

Anyways – here is the code,

and another look at the demo

enjoy.


23 Comments, Comment or Ping

  1. ]a[

    Andy, You rock!!

    February 18th, 2009

  2. Nícolas

    Very cool man!

    February 18th, 2009

  3. This looks awesome. And also the dust particles around add an extra touch. Your demo comes at very good timing for me: I just started to work on a project which involves a 3D particle system! Thanks! :)

    February 18th, 2009

  4. Jessica PaperVater

    Excellent ,

    February 18th, 2009

  5. Love your work.

    February 18th, 2009

  6. this is a sweet demo andy! and some great code! the only thing i wanted was to be able to zoom in w/ the wheel mouse.

    February 18th, 2009

  7. oh! that’s amazing!

    February 18th, 2009

  8. So nice. Thanks for sharing this.

    February 18th, 2009

  9. Komplex is back!!

    http://pouet.net/prod.php?which=17

    ;D

    February 18th, 2009

  10. Great Work. Thanks for sharing.

    February 19th, 2009

  11. Great stuff! Maybe you could use a modified version of your shadowcaster to have a glow from the lights on the grass too.

    February 19th, 2009

  12. like everytime; it s so great !
    good job andy

    February 20th, 2009

  13. nothing happens when I press F. or P. couldn’t really tell which one.

    February 20th, 2009

  14. Great stuff Andy! Thnx for code & inspiration.

    regards from Norway

    February 21st, 2009

  15. Great stuff, Andy.

    Name suggestion: MotionTail.as? :)

    February 21st, 2009

  16. dude

    I guess the reason why you trail becomes tail is because the trail isn’t shaded so you won’t be able to make out the transformation of the tail as ie. in the wing trails of the fighterplanes in HAWKS

    March 2nd, 2009

  17. Nice Effects?~good work?

    March 4th, 2009

  18. hawaiiantime

    soooooo cool!!

    March 23rd, 2009

  19. This is nice. You may be interested in seeing a like-minded 2D version of the same concept I did in .NET –

    http://portfolio.felarca.org/experimental/dotnet/particle_system/

    Best,
    Lee

    April 8th, 2009

  20. kPod

    In the updateTrails function I changed chase function parameters to this:

    chase(new Number3D(target.sceneX, target.sceneY, target.sceneZ), nodes[0]);

    using the scene position so that I could have the trail follow children of a display object. This would allow for multiple trails following different points in a model. I don’t know if this is hack will work for everything but it seems to work for me.

    Thanks for your awesome examples!

    April 17th, 2009

  21. Hi this is great , any chance of some basic documents or tutorials finding it some what hard to implement.

    April 27th, 2009

  22. Awesome, Love your work………..

    June 25th, 2010

Reply to “Tails, You Win – 3D Trails In Papervision”