CuteAlien wrote:Add a test to show it works (I sometimes write those myself when I find time, but thatoften takes weeks/months/years until I get to it)
A real test or an example?
CuteAlien wrote:Maybe describe first how you plan to implement that - then you can get feedback from others.
The Motion trail will be a linked chain of billboards, where each of them can only rotate around a certain axis. The segment count will have a maximum value (no dynamic array).
Wireframe example: Left image shows usual behavior, right image is with enabled shrinking towards the end.
The green dots are the user specified segments, the rest is calculated based on settings like width. Note that the mesh ends before the last segment, because it takes the maximum length in account.
So the IMotionTrailSceneNode
interface will look like this:
create: necessary parameters: time/length based, face direction (camera (+locked) / custom), relative/global coordinates, segment count
addSegment: segmentPosition, currentTime (if time based, will log warning if missing), custom facing direction (if enabled, will log warning if missing)
This method will be called every frame for a usual motion trail, for adding the current position of the object it belongs to. Either the newest or oldest segment will be removed (The oldest when it gets too long.)
setSegment: like addSegment, but it doesn't take care of the maximum length and doesn't alter the other segments. Useful for non-motion trail stuff like lightnings, where every segment changes position every frame.
animate: fades out segments, based on time (only for time based trails)
render: builds the mesh (if necessary, uses caching if possible, e.g. for custom normals or locked axis) and renders
getBoundingBox: builds the bounding box (if necessary, caching is used in every case, since it doesn't matter, in which direction the billboards face.
(getter and setter methods): for all the appearance settings like thickness, vertex color, fade options
Implementation detail
Uses 3 fixed size arrays (1 for segment center, 1 for segment time, 1 for custom segment direction). Only the arrays which are needed will be allocated.
In order to keeping them fast, they will be used as if they where cyclic.
Animators
The interface will provide some static methods which will set up a motion trail scene node for doing a certain task.
createTrail(ISceneNode attach, vector3df offset, ...): Allows the user to attach a trail directly to a scene node. Works by creating a special scene node animator and adding it.
createShortLightning(vector3df start, vector3df end, uint lifetime, ...): Creates a lightning which appears for a short time and fades out. Deletes itself after that using a delete animator
createLightning(vector3df start, vector3df end, ...): Creates a lightning which stays and 'flickers', so it changes every frame.
Other pre-made effects are possible and it will also be easy to code them for users of Irrlicht with just a few lines.