Archive for the ‘CODE’ Category
Sample Silverlight textured 3d in a pretty slick Vista Silverlight theme. It is a pretty impressive demo that is full screen app and a slight performance test with the 3d in it.
I would love for some kits like papervision3d, Sandy etc to be ported to Silverlight. There are some other early 3d works from bubblemark, a 3D engine recently released in early stages called Balder (source at codeplex), pageturns, and more but it is still pretty young.
Sample Textured Silverlight 3d Vista demo
3D Engine for Silverlight Alpha 1.1
But until Silverlight is available in the market it will hard to justify projects in it unless they are demos or technology show pieces. When it hits around 85% market availability and is finalized (it is currently 1.1 Alpha) it could be dangerous.
Who’s got the textures and cool chrome shiny 3d objects in Flash? There have been lots of materials work recently from papervision list developers and away3d developers (away3d is a branch of Papervision3D) and recently it is heating up a bit.
Early on on the papervision3D excitement, flash possibilities in 3d with AS3 specifically, much of that was due to 3d in flash but also the ability to texture and have bump mapping, toon rendering/cell shading and other neat effects like baked lighting, faked real-time lighting, video and movieclips on flash 3d objects and animated textures.
But when it comes to environmental mapping and true 3d reflection that might be simply stretching Flash to a limit that might require hardware acceleration but that isn’t stopping some.
I am not sure if environmental mapping will every be possible on a large scale without hardware acceleration. Pushing the limits could help influence Adobe to the market direction. But then again I never thought I would see the level of 3d in flash that we have and maybe in 2-3 years with multi-core processors it will be possible.
Here’s a snapshot of the current materials and environmental mapping (fake and real attempts).
UnitZeroOne first environment mapping /bump mapping:

Some toon renderings from UnitZeroOne 
Recent work by mr doob
Wood

Recent work by actionscript architect
Perlin noise algorithm to animate texture real-time into water effect
More environmental mapping effects by the away3d materials developer Fabrice. Fabrice and the away3d developers are really taking off with the papervision3d core. I am seeing lots of engine limits tested and some great work at away3d.
Flat Lighting on bitmapMaterial

Chrome Ball (dont’ zoom in too far
)

Did your processor melt yet?
I think that for games and flash effects faking it or real environmental mapping will have to be judged by what is needed for your purpose. I think that Flash player on software rendering can only go so far. So if you have real-time environmental reflections and surroundings it doesn’t always make your gameplay better and it won’t make your demo better if it means removing assets in other areas to make up for the performance drain of software rendering and the pressures it puts on the processor or browser plug-in.
You can still make really killer effects with baked animations, fake environmental mapping, faked dynamic real-time lighting and other effects. Flash, nor silverlight, will not be able to match hardware rendered shaders, per pixel lighting and physics anytime soon. But people are making good progress on this. I think it would be great if hardware acceleration were added to both Silverlight and Flash, with that, a brand new massive game market online, and it will be game on!
The actionscript architect Paul Spitzer has posted two killer demos of pathfinding using A* in AS3/Flash 9 using the Away3D engine (derivative of Papervision3D that is taking off) and you can download the source for both. These demos not only highlight the pathfinding but also provide editing of the graph to be traversed which could easily be made into a game world editor.
Paul adds to some path finding work with the likes of Zeh using Tweener (the best animation kit for AS3 yet) with the bezier papervision pathfinding and the good work going on at polygonal labs in data structures for games and their usage in pathfinding for gaming in flash.
At the actionscript architect’s blog check out the true 3d path finding in all three dimensions, and a 2d based pathfind using A* algorithm in 3d.
Here’s the 3d pathfinding with true 3d (x,y,z) points used in the path.
Here’s the 2d pathfinding with 3d interface.
Paul has been doing very cool vector work from video on 3d in flash using papervision3D, to being one of the first people making demos for WPF and Silverlight such as the Northface Demo.
If you are working on path finding or gaming in AS3 be sure to check out Paul’s work, Zeh’s bezier pathing in papervision and polygonal labs often.
Open Source Flash Conference – June 15th UPDATE(Change In Time)
The second Open Source Flash Conference will be held on June 15th. The conference will start by 11:00 am Eastern Time. This conference is completely free and to attend you only need a computer , the internet and flash installed on your computer.
http://osflash.org/blog/2007_06_12_open_source_flash_conference_-_june_15th
Aral Balkan – Keynote Speech
https://breeze.itap.purdue.edu/p53406718/
Ralph Hauwert – Papervision 3D
https://breeze.itap.purdue.edu/p83105421/
Aral Balkan – SWX
https://breeze.itap.purdue.edu/p62103321/
Nicolas Cannasse – Haxe Programming Language
https://breeze.itap.purdue.edu/p22188329/
Firdosh Tangri – ASWing Component Framework
https://breeze.itap.purdue.edu/p20838194/
John Grden – The Red5 Project
https://breeze.itap.purdue.edu/p20388149/
Igor Costa – Flex Applications using Flex 2 SDK and Granite Data Services and Conclusion
https://breeze.itap.purdue.edu/p19208031/
Special Drum Solo – John Grden
https://breeze.itap.purdue.edu/p38865264/
Session Details
Session : 22
Start Time : 06/15/2007 10:00 AM
End Time : 06/15/2007 4:26 PM
Number of Attendees : 838
Peak : 256
Polls
How do you rate this conference
https://breeze.itap.purdue.edu/admin/meeting/sco/reports/sco/polls/poll-answer-distribution?interaction-id=6712579&sco-id=6438511
How good was John’s Drum Solo
https://breeze.itap.purdue.edu/admin/meeting/sco/reports/sco/polls/poll-answer-distribution?interaction-id=6713919&sco-id=6438511
Are you more design or development oriented?
https://breeze.itap.purdue.edu/admin/meeting/sco/reports/sco/polls/poll-answer-distribution?interaction-id=6713995&sco-id=6438511
You are using recently mostly…
https://breeze.itap.purdue.edu/admin/meeting/sco/reports/sco/polls/poll-answer-distribution?interaction-id=6714276&sco-id=6438511
ASWing
https://breeze.itap.purdue.edu/admin/meeting/sco/reports/sco/polls/poll-answer-distribution?interaction-id=6715098&sco-id=6438511
Right clicking and other mouse support in flash is not really a shining star but in AS2/AS3 you *can* stuff the context menu with items. You can clear out all but Settings and About from the menu and stuff in other items that may pertain to a selected movieclip or the entire app you are building. This can be good when adding multiple functions into applications and for extra functions that you want to make available from a quick location such as full screen, selecting an item etc.
To enable a context menu for full screen capabilities take this example:
1) Make your document class of your AS3 Flash CS3 file to the class below.
package { import flash.display.*; import flash.errors.*; import flash.events.*; import flash.filters.*; import flash.geom.*; import flash.net.*; import flash.media.*; import flash.ui.*; import flash.utils.*; import flash.xml.*; public class FullScreenTest extends MovieClip { public function FullScreenTest() { // create the context menu, remove the built-in items, // and add our custom items var fullscreenCM:ContextMenu = new ContextMenu(); fullscreenCM.addEventListener(ContextMenuEvent.MENU_SELECT, onContextMenuHandler); fullscreenCM.hideBuiltInItems(); var fs:ContextMenuItem = new ContextMenuItem("Show Full Screen" ); fs.addEventListener(ContextMenuEvent.MENU_ITEM_SELECT, onShowFullScreen); fullscreenCM.customItems.push( fs ); var xfs:ContextMenuItem = new ContextMenuItem("Exit Full Screen"); xfs.addEventListener(ContextMenuEvent.MENU_ITEM_SELECT, onShowNormalScreen); fullscreenCM.customItems.push( xfs ); // THIS ASSUMES YOU HAVE A MOVIECLIP IN THE LIBRARY // THAT IS SET TO A CLASS NAMED 'mc' that inherits from MovieClip var m:MovieClip = new mc(); m.contextMenu = fullscreenCM; addChild(m); } // functions to enter and leave full screen mode function onShowFullScreen(event:ContextMenuEvent):void { stage.displayState = StageDisplayState.FULL_SCREEN; } function onShowNormalScreen(event:ContextMenuEvent):void { stage.displayState = StageDisplayState.NORMAL; } // function to enable and disable the context menu items, // based on what mode we are in. function onContextMenuHandler(event:ContextMenuEvent):void { if (stage.displayState == StageDisplayState.NORMAL) { event.target.customItems[0].enabled = true; // show full screen button event.target.customItems[1].enabled = false; // hide normal screen button } else { event.target.customItems[0].enabled = false; // hide full screen button event.target.customItems[1].enabled = true; // shoe normal screen button } } } }
2) Now Export to HTML and be sure to change the exported parameters in the HTML file to allowFullScreen = true (for the fullscreen effect) and menu = true (for the ability to add in context menu items) to whatever library you use for embedding flash:
'menu', 'true', 'allowFullScreen', 'true'
OR if using HTML parameters
<param name="allowFullScreen" value="true" /> <param name="menu" value="true" />
You can view a sample here. (right click on the movie clip and ‘show full screen’, then ‘hide full screen’)
You can download a sample FlashCS3/AS3 version here.
If you want more information on fullscreen check here and here (downloadable sample and component).
When storing numbers in AS3 VM Andre Michelle and his collegue Bram de Jong at splicemusic found an interesting behavior of the internal uint storage. When the numbers are stored they change from int to Number depending on range. Why does this matter? Because ints are faster than Numbers and during larger simulations with lots of math it could slow things down quite a bit at these types change.
The disadvantage of this is that Numbers are slower in computation as well as reading, writing in an Array.
The internal findings when storing a uint
From 0 to 27 it is int
From 28 to 31 it is Number
From 32 to 59 it is int (again)
From 60 to 63 it is Number (again) …
Found when reading another excellent polygonal labs post on benchmarks and performance (this one is great as well concerning faster operations using bitwise shifts or alternate ways to eek out more performance) where he wisely advises to use signed int for loops or iterations rather than uint where needed because the iterations with numbers will be slower.
Andre Michelle posted an Adobe response on the issue and it is a known and by design characteristic due to the metadata that is stored with the datatype in the AS3 virtual machine.
The AS3 VM uses 32-bit Atom formats to store various types. 3-bits of the Atom describe the type data, leaving 29-bits for actual data. In some cases, like null/undefined/void/etc, we use 3-bits plus a few more bits to define the type.
For signed integers, we have 28-bits to work with plus a sign bit. For unsigned integers we have 29-bits (or maybe 28 with the upper bit always zero?). Once your number gets larger than 28/29 bits, we dynamically switch it to a Number Atom type, which contains a 3-bit type value with a 29-bit ptr. All ptrs are 8-BYTE aligned so we get away with using 29-bits there.
All three formats are basically interchangeable. When storing a number in an Atom, we see if it’s an integer and fits within the 28/29 bits. If so, we store it as a int/uint value – otherwise we store it as a Number value.
It essentially is an optimization for uint to make it faster at times but its good to know for large iterative loops or large storage where uints might be needed. This goes back to sometimes where optimizations are a mixed bag. The switching/converting types adds delay to the iteration.
var num: uint;
for (var i: int = 0; i < 64; i++)
{
num = 1 << i;
trace( i, getQualifiedClassName( num ) ); }
0 int 1 int 2 int 3 int 4 int 5 int 6 int 7 int 8 int 9 int 10 int 11 int 12 int 13 int 14 int 15 int 16 int 17 int 18 int 19 int 20 int 21 int 22 int 23 int 24 int 25 int 26 int 27 int 28 Number 29 Number 30 Number 31 Number 32 int 33 int 34 int 35 int 36 int 37 int 38 int 39 int 40 int 41 int 42 int 43 int 44 int 45 int 46 int 47 int 48 int 49 int 50 int 51 int 52 int 53 int 54 int 55 int 56 int 57 int 58 int 59 int 60 Number 61 Number 62 Number 63 Number
Be sure to check out the APE physics engine for flash.
The library contains particles to assign to movieclips that appy the physics. These base objects can be extended in many ways to create complexity from simplicity.
APE (Actionscript Physics Engine) is an AS3 open source 2D physics engine for use in Flash and Flex. APE is written and maintained by Alec Cove.
CircleParticles
-fixed or non-fixed
-variable mass, elasticity, and surface frictionRectangleParticles
-rotatable
-fixed or non-fixed
-variable mass, elasticity, and surface friction
-corner particles that can be attached to other particles with SpringConstraintsWheelParticles
-traction and angular velocity
-fixed or non-fixed
-variable mass, elasticity, and surface friction
-edge particles that can be attached to other particles with SpringConstraintsSpringConstraints
-stiffness
-collidable or non-collidible
-collidable constraints have variable width and scaleLicensing
-non restrictive LGPL
Hopefully we will have a tutorial soon here using APE and some other excellent libraries released recently with the onslaught of AS3 code and kits that will be fluid in their frequency. Another coming physics library is from polygonal labs called the Motor Engine.
The Algorithmist posted an AS3 character rigging class library. The kit includes some really specific classes for building characters and is quite well done.
The library includes all you need to rig up characters in flash and includes the source, samples for flex and what the hell more could you ask for?
The Algorithmist calls it the Singularity Package and it contains:
Singularity Package Contents (character rigging classes)
All rigging classes are in the Singularity package, which must be added to your path when building a new Flex project. The current package organization for the rigging classes is as follows,
Singularity.Rigs
Arm – 2-link bone chain representing right or left arm in a humanoid biped.BaseBone – Base class encapsulating functionality common to Bones and Connectors.
Biped – Used to create and animate humaniod biped characters.
Bone – Represents a single bone with support for fast propagation of FK transformations in bone chains. The Bone class is optimized for linking bones together in chains.
Chain – Manager class for a single chain of bones.
Clavicle – 1-link connector representing right or left clavicle in a humanoid biped.
Connector – Optimized container for multiple single-bone chains with a single input and multiple terminators. Chains or additional connectors linked forward at each terminator.
Foot – 1-link connector representing right or left foot in a humanoid biped.
Hand – Multi-link connector representing right or left hand in a humanoid biped.
Head – 1-link connector representing a humanoid biped head.
IBone – Bone interface – represents all functionality a bone must implement.
IChain – Chain interface – represents all functionality a bone chain must implement. Chains and Connectors implement IChain and are considered interchangeable when propagating FK.
Leg – 2-link bone chain representing right or left leg in a humanoid biped.
Neck – 1-link connector representing the neck of a humanoid biped.
Pelvis – Multi-link connector representing the pelvis of a humanoid biped.
SimpleSpine – 1-link connector providing the simplest representation of a humanoid biped spine. Used for very simple (but fast) game characters.
Template – Templates are used to skin (or draw bones) for segmented characters. Refer to SimpleSkinTest for examples.
When developing physics and character based animation rigging can help to really speed things along in 3d and here in this case in 2d flash. This allows the developer/animator more freedom to work on the animation and not about redrawing. It also helps to create characters that can be animated from the beginning rather than an afterthought which usually leads to less troublesome issues.
The AS3 rigging classes are used for skelton rigging and skinning of 2D characters. The rigging class library is organized around the development of highly specific articulated rigs. The current focus is on humaniod bipedal characters. In a 3D animation package or game engine, a bone hierarchy would normally be represented as a tree structure. In this class library, bones and chains are organized in a structure that is easier to deconstruct and understand by OOP programmers. This structure has some performance advantages, particularly when propagating FK in a 2D rig.
The only drawback to this kit is it is not fully open source and commercial use must be approved.
The Singularity AS3 parametric curve library requires the Flash 9 player and a development environment supporting Actionscript 3. All demonstration programs were created with FlexBuilder 2. The AS 3 character rigging classes are copyrighted and licensed for personal, experimental usage. Please contact me to obtain authorization for commercial use. The download includes the entire Singularity package (which includes the parametric curve library).
Download library (.zip) here. Before running any example programs, place the Singularity package in your build path.
Didier Brun of ByteArray just keeps throwing down. Here is another great showcase of the power of AS3 and the tools that can be built with it, strongly based on alogorithms proven in other hardcore languages. This project is a Mouse Gesture Recognition lib for AS3 (demo)
Mouse gesturing can be used for recognition of letters, numbers or even just programmable actions by gesture. Imagine an application that allows you to just make a gesture (even if its not a drawing program or letter recognition) that would open when you make an open gesture, or close a file with a slash gesture. I have many uses for this planned. Very inspiring stuff.
A bit on the algorithm from Didier at ByteArray, I just don’t think it can be made any more simple:
- Each letter is defined by a n ‘ 8-directions gesture sequence
- The mouse moves are saved with the same 8-directions sensibility
- A Levenshtein distance is calculated from each letter to the user moves
- The algorithm return the best candidate (lowest levenshtein cost)
Usage
Example for the B :
gesture=new MouseGesture(stage); gesture.addGesture("B","260123401234"); gesture.addEventListener(GestureEvent.MATCH,matchHandler); function matchHandler(e:GestureEvent):void{ trace (e.datas+" matched !") }This project is OPEN SOURCE under RPL License.
2007-05-17 v1.0 mouse_gesture_v1_0.zip
I have been waiting for this. Polygonal labs released a pretty sweet package of core game development AS3 data structures (and other rich application development) tools that are common on other languages but not so in ActionScript. The library is extremely well written and polygonal labs focuses on speed of the stuctures.
The methodology for these libraries is right along the lines I like. Focused on speed and performance but also readbility and speed over patterns if needed.
I have tried to provide just the bare algorithm, coupled with a minimum set of methods I think are most useful to work with. Simplicity and performance were the key guidelines for the whole package.
I am especially intruiged because I am building our core gaming libraries for blipgames and have been doing a bit of this myself but the depth of this kit is many hours ahead and very well written.
Some of the classes include very common programming structures that are missing from flash/flex libraries. These will be pretty standard to most Java/C#/C etc developers but adding this to flash is just excellent. Here’s a list of the goodies in the kit.
Multi-Dimensional Arrays
The library contains a two-dimensional and three-dimensional array. They are both implemented by a single linear array rather than nested arrays…
Queue
This is also called a FIFO structure (First In – First Out).
Stack
Also commonly know as a FILO structure (First In – Last Out)…
Tree
A node-based structure. Every tree starts from a single node, called the root node…
Binary Tree
This is just a specialized kind of tree where each node is only allowed to have up to two children, called the left and right node…
Binary Search Tree (BST) and Hash Table
Both structures store data that can be retrieved quickly by using a key….
Linked Lists
A linked list is similar to an array. The main difference is that in an array, each cell contains just the data and is accessed by an index. A linked list consists of several node objects, which in addition to storing the data, manage a reference to the next node (singly linked) or to the next and previous node (doubly linked) in the list. Think of it as a more natural approach to work with sequential data…
Heap and Priority Queue
A Heap is a special kind of binary tree in which every node is bigger than its child nodes…
Graph
A graph is a loose node-based structure…
Bit Vector
A bit vector is some kind of array in which you can store boolean values (true/false – 1/0) as close as possible without wasting memory.
Polygonal Labs has a tree sample up that has many possible usages from visualization of game states to building node based editors to anything really in game development. I could easily see a mix of this and scene creation in papervision via a flash application/IDE.
I have to say I am excited to base my libraries on these kits and work to improve them as I can. Get on over there right now and check it out. Also, its under the MIT license so this instantly makes polygonal labs famous. Thanks Michael!
















