Box2D is responsible for inspiring many 2d physics engines including Motor2, Box2DFlashAS3 and others. Box2D the original toolkit is a solid c++ physics engine that has many great examples and features including real collision.
Now it has inspired a pure Javascript version of Box2D called Box2Djs to (using prototype dependency) to implement many of the same demos using the same functionality. So it appears Box2D if you want to find a baseline standard physics kit for 2D, it now has versions in many languages that might allow you to have 2d physics capabilities across many platforms.
Box2DJS is a JavaScript port of Box2D Physics Engine. To tell the truth, this is converted from Box2DFlashAS3_1.4.3.1 in an automatic manner. (The reason why not Box2DFlashAS3_2.0.0 based is simply because I overlooked the renewal.)
Copy js/ and lib/ directories from the extracted directory to your app directory.
Copy script tags in the header part of index.html in the extacted directory to your html file where you want to simulate physics.
Because this library does not have a lazy-loading system now, you should load all classes before starting your simulation. To make things worse, each library has a bit complicated dependency each other so that loading libraries in wrong order may cause a fatal error. To avoid such a trouble, it is strongly recommended to copy the header part of this file or `index.html’ including the downloaded zip file.
Utilizing Box2D APIs, simulate the newton world as you like.
The Box2DJS APIs are completely same as those of Box2DFlashAS3. Please refer information about it.
Also the speed of your javascript engine makes a big difference just like the AS2 AVM1 to the AS3 AVM2 virtual machines. Chrome is much faster than FF3.
Nicolas Cannasse is at it again. This time with a PBJ (Pixel Bender File) binary file reader and writer in haXe and Pixel Bender Assembler tools. What this can do is create and decompile PBJ files with haXe, the possibilities are limitless to how this is used including dynamic pbj file creation.
The latest haXefile format library contains complete support to read and write PBJ file, enabling you to write Pixel Bender assembler directly in haXe, then compile it on-the-fly into PBJ bytes, which can then be saved on disk or loaded directly in Flash.
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…
Be sure to check out the shadow demo that this is based on:
After posting my shadow experiment, Patrick Matte posed a question wondering if I would be able to do real-time reflections in a similar manner. The next day I had it done, along with some nice iterations along the way: orthographic and perspective projection (I can release those later if anyone really wants them). I’ve been sitting on it every since and finally decided I would take the time to write a little description into how its done and give the code to those who are interested (and I fixed up some code for backface culling in the reflection this morning).
UPDATE: See comments and papervision list for revert of this change. You can now use localRotationX, localrotationY and localRotation Z instead. yaw(), pitch() and roll() are back by popular demand.
Hi List,
Sorry for this confusion, but we decided to revert back to pitch(
angle ), yaw( angle ) and roll( angle ) methods.
pitch( 30 ) would be the same as doing localRotationX = 30;
Note that localRotationX / Y /Z are rotations relative to the
rotation as set by rotationX / Y / Z.
Also note that after do3d.lookAt() localRotationX/Y/Z will be resetted to 0
Tim
ORIGINAL POST:
Papervision 3D 2.0 Alpha has been undergoing lots of changes and one you might want to know about is the object yaw, pitch and roll change. Thisis changing on how you access them but only slightly. This is good because you an read and write the values on the object not just set them. Per the papervision list from the man Tim Knip:
On many users request:
DisplayObject3D’s methods pitch(), yaw() and roll() arenowgetters / setters.
This means these values arenow ‘absolute’ values instead of previous ‘relative’ values as in deprecated do3d.yaw( 1 );
Let me know any issues (as I’m sure there are…)
Tim
This only affects the latest and greatest revisions of papervision but is definitely a good change. It is good to make changes that make more sense without worrying about breaking changes.
The engine is highly optimized and smooth, heavy on the processor, but using the ‘t’ key you can see some nice revealing triangle rendering. Also, playing with the field of view adds for some nice game effects. (try jumping on the fans in the half-life like room in the first demo)
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
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.
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.
It is heavily based on Glaze (demos) and Box2D which the Motor2, Glaze and Box2DFlashAS3 physics kits are all based on. Box2D is a great C++ 2D physics engine, it is simple which lended itself to being ported to AS3 quite easily. It is also a testament to AS3 that C++ kits are being ported into the language, not once, but many times. Also C ports like Chipmunk and other signs point to == AS3 is of fun.
Physaxe is quite amazing you must see the demos (very similar to Glade demos), it will get the inspirational wheels turning in your idea machines.
2D Physics in Flash and AS3 are extremely hot and can be used for many, many things from game development to promotions to simulations to user interface or visualizations and even modeling natural systems. It is nice to have a port of Box2D and similar to glade capabilities with Chipmunk like Glade has.
A game and physics engine for Flash including:
Rigid Body Dynamics
Scene management
Line of sight
User Input
Scrolling
AI
Core parts of the physics solver and collision system are based on the C physics engine Chipmunk
Notes about Physaxe:
Physaxe is a 2D Rigid Body Library written in haXe. It’s been highly optimized for the Flash 9 Player, with the best optimizations available.
Physaxe is based on several existing physics engines, mainly :
Alice in Wonderland was pretty good, great visuals, pretty decent dose of Burton. 1 day ago
OpenGL 4.0 released, in a couple years we will have opengl 4 enabled cards w tessellation... http://bit.ly/cggF3f - puts it on par with DX11 2 days ago
Finally got an openssl network lib running pc, mac, iphone + nix..biggest problem was iphone os compared to iphone sim (arm vs i386 targets) 3 days ago
Triangle was pretty decent for a netflix movie, totally ripped the premise from Timecrimes (which was really good) but still interesting. 4 days ago