Archive for the ‘LIBRARIES’ Category

Tuesday, December 23rd, 2008

I have mentioned before that flash to unity3d communication is a key part of game development for the web now where you are using Unity3D as a higher end renderer and some of your other page elements might be flash. Now there is a new open source kit for this called u3dobject.

To get Flash and Unity3D to talk to one another in an HTML/XHTML page is pretty simple with javascript and with the internal Unity3D Application object and the ExternalInterface in Flash.  But there are lots of elements of that communication that can be consolidated and reused so you don’t have to recreate that over and over.  Various studios and programmers come up with their own kits but when it becomes a shared activity to get the best integration and make it more of a platform that is where things like swfobject, swfaddress and u3dobject come in.

So far swfobject is the standard for flash html embedding and unityObject is a similar take (but a bit dated) on that but now we have u3dObject that is open as well and a more official open source project for unity3D <–> flash integration and test harnesses for development when those two technologies are used together.

Unity3D <-> Flash Embedding Info:

Thursday, December 4th, 2008

When you do lots of any language you build up libraries over time that are time savers that are repetitive and tedious if you do not consoildate into a library.  Taking a look at the CASALib, an as3 library of common functions for flash that was released I have many of the same things in my libraries but CASALib just has lots of extras that go a bit deeper than some libraries, is very clean and is organized pretty well.

One cool thing about it is the IDestroyable interface and the CasaMovieClip, CasaSprite, CasaTextField , etcthat all have a destroy() method that cleans up all events, removed instances and even removes it from the parent display object. Gets me thinking why this isn’t just part of DisplayObject in the first place.

From the release:

Here are a few of our favorite things in CASA Lib AS3:

  • Standardized external load API
  • Easily remove listeners with IRemovableEventDispatcher
  • destroy methods make garbage collection easy
  • Large group of utility classes for common manipulations

We will be elaborating further the power of CASA Lib in future blog posts.

As with any new release there will be bugs that emerge, but with your help we promise to release updates often to keep CASA Lib as stable as possible.

1.0.0 Downloads & Documentation

ZIP: http://as3.casalib.org/releases/1.0.0/1.0.0.zip
SVN: http://svn.as3.casalib.org/releases/1.0.0/
Documentation: http://as3.casalib.org/releases/1.0.0/docs/

[source]

(more…)

Friday, November 28th, 2008

I am working with lots of content now that is flash and unity3d in game development for the web, and occasionally systems built in flash, javascript or other have to communicate with Unity3D and vice versa.  You can do this from the server side (WWW/WWWForm class or sockets) OR you can also communicate client side for many things such as sending name value pairs or variables into Unity3D, Flash or the javascript in page as needed. There are some great tools like UnityObject that is like swfobject (only you have to update it to work with latest browsers) that make this more simple to send in params and messages. The same can be applied to Silverlight. It is pretty simple all in all but having a sample to start with is good with all these technologies.

Paul Tondeur threw togetother a little sample that shows how you can integrate Unity3D, Flash and javascript in the page fairly simply with lots of great demos.  It really is just about passing parameters around into the objects from javascript, then within Flash calling ExternalInterface to call external javascript or within Unity3D calling Application.ExternalCall.

//Flash adding callback for javascript code
ExternalInterface.addCallback("functionNameInBrowser", functionNameInFlash );
//Unity3D calling javascript code
Application.ExternalCall("javascriptFunction", "Parameter1");

Nothing too tasking but if you want to see samples of this working together from flash, flex, javascript, unity3d then check it out. Zip on over to Paul’s site to grab the files and more demos and samples. All examples are bundled in one download, which includes all the Unity3D, Flash, Flex, Actionscript and Javascript files.

Here’s some demos

Saturday, October 11th, 2008


as3isolib is a great isometric library for actionscript 3
by Justin Opitz.  This is a lower level isometric library that could be used in building your own isometric gaming engine or learning more about the popular isometric view in games or other flash content.

From building basic blocks…

To constructing sprites and objects with individual iso objects with their own bounding boxes.


This sample shows a two piece tree, a common issue with sprites in isometric is where to slice them up.  This sample shows a tree with the leaves able to be in front of a character so that you could walk under the tree and be in front of the trunk but covered by the trees.  Essentially height is respected.

Sample code for the tree tutorial:

package
{
import as3isolib.display.IsoSprite;
import as3isolib.display.primitive.IsoBox;
import as3isolib.display.scene.IsoGrid;
import as3isolib.display.scene.IsoScene;

import flash.display.Loader;
import flash.display.Sprite;
import flash.events.Event;
import flash.net.URLRequest;

public class IsoApplication extends Sprite
{
 private var scene:IsoScene;
 private var assets:Object;

 private var loader:Loader

 private function loadAssets ():void
 {
  loader = new Loader();
  loader.contentLoaderInfo.addEventListener(Event.INIT, loader_initHandler);
  loader.load(new URLRequest("assets/swf/assets.swf"));
 }

 private function loader_initHandler (evt:Event):void
 {
  buildScene();
 }

 private function buildScene ():void
 {
  scene = new IsoScene();
  scene.hostContainer = this;
  scene.container.x = 200;
  scene.container.y = 200;

  var treeTrunkClass:Class = loader.contentLoaderInfo.applicationDomain.getDefinition("TreeTrunk") as Class;
  var treeLeavesClass:Class = loader.contentLoaderInfo.applicationDomain.getDefinition("TreeLeaves") as Class;

  var grid:IsoGrid = new IsoGrid();
  grid.showOrigin = false;
  scene.addChild(grid);

  var s0:IsoSprite = new IsoSprite();
  s0.setSize(25, 25, 65);
  s0.moveTo(50, 50, 0);
  s0.sprites = [treeTrunkClass];
  scene.addChild(s0);

  var s1:IsoSprite = new IsoSprite();
  s1.setSize(125, 125, 100);
  s1.moveTo(0, 0, 75);
  s1.sprites = [treeLeavesClass];
  scene.addChild(s1);

  scene.render();
 }

 public function IsoApplication ()
 {
  loadAssets();
 }
}
}

current features

  • simple scene creation
  • 3 primitive types
  • base class for displaying user-created content
  • plenty of styling option on vector based primitives
  • integrates well with a variety of tween engines
  • standard 3D isometric positional sorting

So get busy building the flash version of roller coaster tycoon…

Saturday, October 4th, 2008

This project is stacked with cool, but is also useful, an ogg/vorbis player in flash/as3.  Arek Korbik at barelyfocused implemented a port for a pure Ogg/Vorbis audio library called FVorbis.  Check out the demo (need flash player 10). Groovy.

The name is: FVorbis. Which stands for more or less “Ogg and Vorbis in Flash”. That’s right, pure ActionScript 3 implementation of the Ogg and Vorbis libraries that require no kind of native support from the Flash Player. A simple Vorbis player implemented using the new FVorbis lib compiles to about 46KB SWF file. And that’s it.

To top it off the code is actually written in haXe, a favorite of the flasherati. This version was iterated from the Cortado’s JOrbis code.

Ogg Vorbis is a great open source audio format which is widely popular in game engines such as recent tools like Unity3D (which will be launching their iPhone dev kit on Oct 22 btw but I digress), so it is great to see it starting to appear in flash. Thanks Arek.

Monday, May 26th, 2008

Tink posted a great library manager for using external assets in your flash projects. When you start getting deep in projects you end up either having to roll your own that might end up being project specific, or you can just grab this from Tink and it is nice and standardized now for you.

Here’s and example of our Library & LibraryManager classes that we use in some of our Flex and AS 3.0 projects to manage our external assets stored in SWF’s.

The classes enabled you to create multiple libraries of embedded (retaining and giving access to code) or loaded SWF’s.

You can create instance of Library wherever you want, but you can also create them through the LibraryManager giving you a single class to gain access to all your Library instances.

As you develop more and more flash/flex projects with AS3 these types of utilities come in handy. Another that comes to mind is Arthur Debert’s BulkLoader and polygonal labs Data Structures for Game Developers that are all great kits.

Add Tink’s Library and LibraryManager to your arsenal today! Thanks Tink.

Thursday, April 17th, 2008

Box2dFlashAS3 has been updated to version 2.0 complete with ragdolls and Theo Jansen walkers ala APE fame.

Friday, April 11th, 2008

Jono is giving SWFZ to science and the open source devices.

The SWFZ engine is one Flash 3D engine that took a different approach. It is a bit early in its technique used but the author at custom:media Jono has decided to float the source code out there in ghost mode (no active development but not dead). It is just ready to branch and others to run with it. He is floating the source but I think in 1-2 years this will be the preferred method if processors and multicore parallel usage is optimized. We shall see.

The implementation method and difference with SWFZ engine in Flash for 3d is that is is a pixel based renderer or scanline. It is based on a really fun game engine called Irrlicht which has been pretty active for the last few years but is a C++ DirectX and OpenGL engine. Since SWFZ has to run in Flash and it is a pixel renderer/scanline it has some limitations currently in Flash. Games and renders have to be fast to pull this off and Flash is limited by the software renderer but as computers get multiple processors and flash player gets better at this then this will be a viable option (it is the same thing that limits Canvas based renderers right now). One main problem with this is you can’t go too full screen the biggest sizes that perform well are smaller windows 320×240 etc. But if the processors can handle it it is actually more efficient when it removes overlap, extra triangle drawing and painters algorithm like problems dont’ pop up (triangle overlap when on same plane). This method draws pixel by pixel but fast enough flash engines like Papervision, Sandy3D and Away3D draw overlaps due to the drawing technique, back to front.

But SWFZ still manages to pull off some amazing feats such as these demos

Quake Demo

Terrain Demo

Yoshis Hip Hop Couzin

Jono has put some great classes into SWFZ engine such as bsp parsers, quake md2 parsers, animated mesh, and lots of great examples in porting C++ Irrlicht to AS3. This was a very early example of how AS3 was fun for programmers to port stuff from C or C++ into Flash. AS3 is just fun. Also be sure to check the site for more samples like an FPS game, some basic ai etc.

Jono has been working on 3d in Flash for a while and actually this message is what shows the difference betweeen this approach and other flash engines the way Papervision, Sandy and Away3D (pv3d derivative) make 3d in flash fast enough (Painter’s Algorithm and drawing skewed movieclips and textures.

Demos

More about the Engine Some Notes

The SWFZ engine.

Overview:

SWFZ engine is the result of four years of me messing with 3D in Flash.

I was a complete newbie to 3D, so a lot of learning has happened to get to here.

If you’re interested in 3D engines check out the resource links at the bottom of the page:

The Demo:

Model

  • .md2 format from ID’s Quake2.
  • Uses frame based animation
  • Textured with jpeg
  • No lighting, No Gouraud Shading, just plain texture

Skybox

  • Textures are just jpegs.

Boxes

  • Rendering – Textured Gouraud , Textured Gouraud with Alpha, Textured Gouraud with Quick Alpha, Gouraud Shaded, and the large box is just Textured.
  • Star Texture – Targa (.tga) file format.

AS3 classes

  • 171 classes and interfaces

Scene

  • No lighting
  • No collision detection

SWFZ engine technology:

The demo only shows a small part of the capabilities of the engine. In the coming weeks I will get www.custommedia.co.nz up and running and start to post more info then.

Currently implement stuff:

New file formats supported

  • .tga – Targa Image
  • .bmp – Bitmap Image
  • .3ds – 3D Studio Max
  • .bsp – Quake3 levels
  • .md2 – Quake2 models
  • .obj – Wavefront 3d object (static)
  • .zip – Read from a zip archive (all in Flash, no server side scripts)

3D Rendering

  • mipmaps
  • perspective correct texturing + affine texturing
  • Flat shading
  • Gouraud
  • Textured Gouraud
  • Textured Flat
  • Textured Two Layers
  • Gouraud Alpha
  • Textured Flat Alpha
  • Textured Gouraud Alpha

3D Scene

  • Billboards
  • Parent, Child scene nodes
  • OctTree
  • Skybox
  • Static Meshes
  • Animated Meshes
  • Basic collision detection
  • Scene node animators

If any code is useful to you maybe drop him a donation or what would be nice if this was all setup at google code and used to be integrated into other engines. Irrlicht ports are fun and there is a future in this method when processors catch up I think.

Sunday, March 16th, 2008

Rostislav added a sample for his excellent SWFAddress kit using the new YouTubeAPI and deep linking to parts of the video. Part of the YouTubeAPI is by Geoff Stearns (the creator of SWFObject who works at YouTube now) and allows much more script control and embedding of the youtube player (chromeless with just the video canvas).

The sample Rostislav at Asual has, shows how you can incorporate SWFAddress now that the youtube player can be embedded by script, and thus how it can have deep-linking to sections of the video from the url.

So, today I spent some time trying to integrate SWFAddress with the sample YouTube video and the result is now available online. There were some tricky parts and probably the code can be encapsulated better, but overall I’m satisfied with the result. Every pause action or significant jump in the playback produces a deep link which will definitely make sense for long videos or specific scenarios. If you want to automatically start the video from the second verve just try this deep link. For this case I decided that it will be better to disable the generation of browser history and the SWFAddress strict mode.

The sample is available in the SWFAddress repository and will become a part of the upcoming 2.1 release.

The cool part about all this is is makes it extremely easy to add commenting at moments in time throughout youtube videos, enables deep-linking, allows snapshots of not just the flash application but also the video that might be playing in that chapter. This is done on services like viddler and others but now you can do it for youtube videos and this will also possibly start a standard way to do this across media players so that a platform of video commenting emerges.

The integration of SWFAddress is simple, on the normal onSWFAddressChange you just pass in the value to the seekTo call:

function onSWFAddressChange(event) {
  time = seek = parseInt(event.value);
  ytplayer = document.getElementById('myytplayer');
  ytplayer.seekTo(time, true);
 }

Google video always had jump to time params like:http://video.google.com/videoplay?docid=-5830318882717959520#01m30s (this is a classic/hilarious Erlang video)

…but this is not very workable with the google video player, also you can always add this to other players but having this ability for youtube is a great leap in allowing a more integrated commenting, chapter and community like feel to video.

Since youtube is so big finally having some more control with the YouTubeAPI will allow much more great additions to the capabilities of using youtube video in many more ways and integration of more great javascript kits like SWFAddress.

The YouTube API is really quite useful. Here are some links of interest:

Saturday, February 23rd, 2008

havok_logo2.gif

This is a bit off the online games department (although Havok was part of Director previously) but they are offering Havok physics core engine, the one that runs many great games including Half-Life 2 family, free. This is truly amazing Havok was the best and probably still is the best 3d physics engine for so long but was so freaking expensive it made it unattainable to anyone without probably close to half a million for budget. I think they are either getting heat from competition or they realize the importance of allowing communities to see what they can do with something, then coming along for the ride rather than being a wall that they have to go around. (of course this leads to bigger license fees once someone is established and can afford it).

They say exactly this here:

Havok’s core platform, Havok Complete combines the industry-leading Havok Physics engine and Havok Animation, the company’s premier character animation solution. Havok Complete is already the most popular solution in the cross-platform AAA games market, featuring technology used in over 200 games. By making Havok Complete for the PC freely downloadable, Havok will further build on its leading position by completely removing the barriers to entry for the large number of independent developers, academic institutions and enthusiasts in the PC space.

I always encourage products and people making any sort of toolkit, engine, application or library to offer it free or a portion of it free to get people hooked, and then as skills are acquired, they are then completely sold in. It is a bit of a play on the old piracy market where applications become so rampant that everyone uses them for years, then they recommend them at work and the growth of this type of marketing is long-term. Windows and Photoshop both got their market shares this way, they will never admit this though but I digress.

I am so excited by this news. It is interesting that the next version of Director, Director 11 was recently announced and it NO LONGER uses the Havok 3d physics engine but the AGEIA PhysX due to it being free (although the source license is still 50k).

I currently use Irrlicht and AEGIS, or ODE (open source physics engine – open dynamics engine) for pc based game development and physics fun. I will have to read the Havok license carefully but just getting your hands on this will be beneficial to all aspiring game developers.

Now if only game companies like Epic, Artificial Studios, and others would do the same, hrm…

One item of note is that it won’t be available until May.  I can imagine that the developers are like “ok well give me a few months to clean up all the code and cuss words from the source” j/k.  Let’s hope this release is not on Valve Time.

Get your game on!