More physics
Today, I added some key features for improving the physics in Flint. Primary among these is the addition of mass and radius properties to the particle class.
The mass property represents the mass of the particle. By default, particles have a mass of 1, meaning all behaviours remain unchanged unless you modify the particle's mass. The mass is used in the collide, friction, drag, bounding box and gravity actions.
The radius property represents the size of the particle when calculating collisions. In collisions, all particles are treated as circles (in 2D) or spheres (in 3D). The radius is used in the collide and bounding box actions.
In addition, the mass and radius are used to calculate the moment of inertia of the particle, which affects rotational friction and rotational drag.
To integrate the scaling into this, the Scale action and ScaleInit behaviours have been split into ScaleImage and ScaleAll actions and ScaleImageInit and ScaleAllInit initializers. The ScaleImage actions and initializers just alter the scale property of the particle (and hence the image size), while the ScaleAll actions and initializers alter the radius and mass as well.
I also added initializers and actions for modifying the mass and collision radius of the particle.
Finally, I updated the examples to work with these changes, and added an example that simulates brownian motion in both 2D and 3D.
Posted on 2 September 2008
Developer diary
I've decided to make this blog more like a developer diary than an announcements page - the blog had become a double to the announcements category in the forum. Also, by making this a developer diary I can keep you all updated on progress with new features and what has been checked into the code repository. Expect the first diary entry very soon.
Posted on 2 September 2008
Version 2.0 alpha released
In brief gaps between work I'm making steady progress on 2.0. It's pretty stable and working well. 2D is probably nearly as stable as 1.0.4, and has some new features that improve on the 1.0.4 version. 3D is working well with Flint's own renderers. I hope to get initial versions of the Papervision3d and Away3d renderers out soon. The source includes a number of examples to show how it works, along with the usual Asdoc documentation.
I've added the source code, documentation and examples to the downloads.
If you're wondering whether to use this version in a project, much of it is already very stable, and I'm aiming for a final release in a month's time.
SVN changes
This morning I moved the 2.0 code from the branch into trunk. Version 1.0.4 has been tagged, so is still available via SVN from the tags directory. I don't expect to release any new 1.0.x versions.
How you can help
If you have time, please try this version out. I need feedback on any bugs you find so I can fix them now rather than later. Also, I need more examples showing what this version can do, so if you make an interesting example and want to share it, please let me know so I can include it in the distribution (with credit to you of course).
Posted on 1 September 2008
Version 1.0.4 released
This will be the final version on the 1.0.x branch. It incorporates a few minor changes that were already in the code repository. The next version released will be the first 3D version. New features and changes in this version are
- Added a Collide action that manages collisions between particles.
- Added bounce parameter to the Bounding Box action, to control the amount of bounce in the collisions.
- Fixed TurnTowardsMouse and TurnTowardsPoint actions to stop the particles oscillating when travelling approximately towards the target.
- Added maximumFrameTime property to Emitter to prevent the system jumping when outside influences pause the system (e.g. when resizing the browser window).
- Added conditional tests to Emitter to prevent errors when a renderer hasn't been assigned to the Emitter.
- Altered Emitter and BitmapRenderer so that the particles array is in creation order, rather than reverse creation order, because this is more logical.
- Added run-time error to DiscZone and DiscSectorZone to check that the outerRadius is not smaller than the innerRadius.
Posted on 21 August 2008
3D plans
Because I had a lot of client work on, I haven't done much work on Flint since April. That's now changing since the large job I was working on is complete and I have some time to myself again. I thought I'd outline the plans for the next major version of Flint.
The next major version will do 3D particle systems as well as the 2D systems it currently does. There will be some architecture changes that will benefit the 2D version as well as the 3D version and then there's a lot of work on implementing the 3D version. Much of this work is now done, and can be checked out from the three_d branch of the code repository.
2D changes
The main architectural change involves completely separating the renderer from the rest of the system. Making the emitter independent of its renderer allows a single renderer to display multiple emitters, and multiple renderers to display the same emitter.
I have also separated the update tick from the emitter so that developers can supply their own update tick if they want to (from systems like the GoEngine) and also can update the particle system at a different rate from the frame-rate. The current system, where Flint provides an update tick that matches the frame-rate, is still the default.
Both these changes are already checked in to the branch.
3D implementation
The 3D implementation involves converting the core system and the various behaviours to 3D. This is now almost complete - a few behaviours remain but these relate to the mouse position and I haven't decided how, or if, to implement these (specifically how to relate the mouse's 2D position to the 3D space). The code is checked in to the branch but still needs to be optimized for speed.
The 3D implementation also requires renderers. My goal is to have a set of stand-alone renderers, plus a set of renderers for each of the major 3D systems. The stand-alone renderers are part done - the current versions work but lack many desirable features. I'm working with the Away3D team on developing renderers for Away3D and hope to work with the Papervision and Sandy teams also. If I can't get collaboration from them it will take a little longer to create renderers for these platforms since I'm not yet as familiar with them as I need to be to complete the work.
There are a couple of 3D examples checked in to the branch if you want to see it in action and have some code to start playing from.
And
Also, the documentation needs a lot of work.
So, that's the plan. I hope to have this complete sometime in August, and may move it over to trunk before then if it's stable and the 2D stuff in particular is thoroughly tested.
Finally, I'll be talking about Flint at Flash on the Beach in September. If you're available, come along. It's the best Flash conference I've been to and I'm very pleased to be speaking there for the first time this year.
Posted on 15 July 2008
Reorganised SVN
I reorganised the SVN repository today. You may need to check-out the code all over again - sorry about that. It's a minor change but the repository's structure is more logical this way. I don't anticipate altering it again so it seemed sensible to get this change out the way as soon as possible.
Posted on 23 June 2008
Alpha of the 3D version is available
I've added the alpha of the next version of Flint to the SVN code repository. You can check it out anonymously from
http://flint-particle-system.googlecode.com/svn/branches/three_d/
This version will support 3D particle systems in addition to 2D particle systems as supported by the current version.
The 2D content in this alpha should be stable and has some features not present in the current version 1.0.3 - specifically, it supports the display of multiple emitters within a single renderer and the display of a single emitter within multiple renderers.
The 3D content still needs a lot of work. It has a simple renderer, which I will be doing a lot more work on in the next few days, but needs renderers for the various 3D libraries that are out there. It doesn't yet support rotation of the particles but I have converted most of the non-rotational effects in the 2D system to 3D. I hope to do frequent updates to this alpha in the coming weeks - it all depends on time. Feedback on the architecture and suggested features (including code) are very welcome.
Posted on 23 June 2008
Version 1.0.3 released
This version adds some minor enhancements
- KeyDownCounter - this new meta-counter causes an associated counter to only emit particles if a particular key is down.
- KeyDownAction - this new meta-action causes an associated action to only occur if a particular key is down.
- ZonedAction - this new meta-action causes an associated action to only affect particles that are within a particular zone.
- LinearReactangleZone - this new Zone is like the RectangleZone but the getLocation method returns a sequential set of locations within the zone rather than a random point.
- Palette maps - the Bitmap Emitter can now use a palette map to alter the color of the particles.
- removedFromEmitter() - this new method has been added to the Action, Initializer and Activity classes and is called when the behaviour is removed from the emitter.
- Protected methods - a number of methods and properties have been changed from private to protected, while others have been exposed via getter/setters.
- Optimizations - some general speed optimizations have been added to the library. These don't affect the API.
Posted on 5 June 2008
Version 1.0.2 released
This version fixes a couple of minor bugs.
- When setting the dimensions of the canvas on a BitmapRenderer, it didn't correctly remove the previous canvas, causing the dimensions of the renderer to appear wrong. This has been fixed.
- The Velocity and Position initializers didn't always correctly reflect the rotation of the emitter. This has been fixed.
Also added, PositionAbsolute and RotationAbsolute initializers that are independent of the emitter's location - they operate relative to the coordinate system of the particles.
Posted on 23 April 2008
Version 1.0.1 released
I uploaded version 1.0.1 this morning. The main change is to fix a limitation in the BitmapRenderer and PixelRenderer classes.
The BitmapRenderer and PixelRenderer create a canvas for drawing the particles in. In previous versions this canvas covered the stage. This has caused problems for some developers who want more flexibility over the size and placement of this canvas.
It makes sense for the generic BitmapRenderer to allow the developer to specify the size and position of this canvas, so that is what it now does. This requires a single parameter in the constructor for the BitmapRenderer. This parameter is a rectangle and specifies what region within the renderer (i.e. within the coordinate space of the particle system) where the canvas should be drawn. The same change has been made to the PixelRenderer.
The old behaviour, a canvas that covers the stage, now exists within two more specific classes - the FullStageBitmapRenderer and the FullStagePixelRenderer. Changing all references to BitmapRenderer and PixelRenderer to these new classes will enable any previous scripts to work as before.
Other minor changes - all renderers now have mouseEnabled and mouseChildren set to false by default, so that they don't respond to mouse events and it is possible to click through renderers to buttons and other objects below. To enable mouse events, set one or both of these properties to true as required.
Posted on 14 April 2008