Monday, December 3, 2007

Sad Blue Faces

Haxxed it away for now: The tiled floor is always 'behind' the faces now. Made the tiled floor random (based on sine waves). Gave the tiles multiple textures now per tile. Create characters only on blue ones. Drag to rotate camera.








[fullscreen]

Familiar Faces

Ok, added some planes with textures on them that always point at the camera. Now the culling issue is quite obvious: whole objects (based on their centers) are being sorted first instead of dumping all the triangles into the same sorter.

I can see the reasoning for this but it ultimately fails at what I'm trying to do here. I may have to write my own split-triangle culler or even test out writing a z-buffer system (though think that will probably kill speed entirely).

Notes: Click and drag to move camera. Be patient for images to load.








[fullscreen]

Wednesday, November 14, 2007

Constructive Geometry

Made a TileTerrain class that uses constructive geometry to build it instead of cubes. Solves a lot of the problem - not perfect though but the final tweak to this method is much harder so that will come later.








Tuesday, November 13, 2007

Papervision vs Sandy

After reading Sandy 3D's code and tutorials I found that I liked the organization of the code leagues better than Papervision 3D (which I have more experience in at this point). So I decided to do a little test.

In the past hour I wrote the same basic thing in both engines. Other than some features that one had and the other didn't (neither seemed to have a useful concept of 'lighting' - but in the Papervision case I'd already written my own primitive Lambertian reflectance shader so I just reused that), one thing I noticed was that both of them had problems with z-index culling - putting one triangle on top of another that shouldn't be.

I did a lot of reading on Sandy and tried all combinations of their culling and didn't manage to solve it. Only thing I could find in Papervision is an arbitrary z-depth sort for objects for the camera.

P.S. If this example looks familiar to you it's no mistake - I'm actively dreaming these days of making a Final Fantasy Tactics style game in full 3D (not just iso) in flash.

Sandy Example
Papervision Example

Also, the Papervision performs notably better. So as much as I like the structure of Sandy better I may not be using it as soon as I'd like.

Sunday, October 28, 2007

Polar Color Test

More complicated Entity Test

Still entirely nondeterministic, but now I've added some more color controls. Some of these particles are positive poled and will naturally attract, some will repel. Hold down the mouse to invert the magnetic pole of the mouse (and increase the power of the magnet).

Tuesday, October 23, 2007

Companion Sphere

Abject return value chain abuse here:

em.addAffector(new MouseAttractor(5)).assign( em.addEntity(newe(0,0xEE0000)) );
em.addAffector(new MouseAttractor(-5)).assign( [em.addEntity(newe(90)), em.addEntity(newe(180)), em.addEntity(newe(270))] );

Creates this version, with 3 of them hating the Mouse and 1 loving it

(newe() in this case just makes an entity with a circle drawn and a start angle with a velocity of 10 and a color)

Uno Mas

Added a 4th Affector that will attract to the mouse cursor if you get close enough

Entity First Tests

First Entity Test

I'm rebuilding my particle system around a couple base objects: Entity, EntityManager, EntityEmitter(optional).

Entities are Sprites with the ability to be updated via a delta 'time' slice. They support nondeterministic animation through this system natively, but they also can each have their own timeline objects to have properties of themselves deterministic.

EntityManager objects manage groups of entities and serve as a single point of contact to update or evaluate an entire group. They also manage removal, and Affector chains.

The whole entity thing is basically a way to get things like Affectors without having emitters - so I can write an Artificial Intelligence Affector for an enemy that needs updating/main loop service.

This example has 4 entities and 3 affectors (WobbleAffector, VelocityClampAffector, RadialSoftBoundsAffector).

Flash? in my YouTube?

http://www.lostinactionscript.com/blog/index.php/2007/10/13/flash-you-tube-api/
Saved here for future usage.

Entity is coming

rewriting particle framework, brb

Saturday, September 22, 2007

Flash 9 Dance Dance Revolution

Very simple rhythm game written with help of my existing gemini lib for AS3. Game itself is 270 lines of code, including MXML. This doesn't include the libraries, but the two new classes RhythmTimeline and RhythmKeyframe are only a couple lines each on top of the existing timeline stuff.

Each keyframe has a 'radius', the distance at which a hit is viable. When a key is pressed, I dig through the behind and ahead heaps up to a given max distance (the maximum radius that you use is a good value), to build a list of possibly 'current' ones, and then I go over this list testing absolute distance versus radius to get a final list.

Most of the speed problems are due to the movement of the sprites (and the fact that I'm creating all the sprites ahead of time and not as needed - easy to fix). I really need to steal/write a good parallax scroller to do this for reals. I found when I added a clipping mask to the keyframes I lost like 20x more speed, so I left it out for now.

There are some small issues regarding visual position not syncing perfectly with the audio (it actually IS synced, but the write and flush delays are hurting it), so sometimes it may feel like you're being gypped. Also this song is probably not the best choice is it actually seems to drift in parts (the latter half of the song is almost perfectly mapped).

You can drag to scroll around the music, and hit the "a" and "q" keys on your keyboard to dance with intensity. You may need to click in the browser (anywhere) to get the keys to recognize (I know how to fix this).

Be patient if you have a slow connection, song is just under 3mb and I didn't make a loader.

Enjoy!

Silver Screen Dance

Wednesday, September 19, 2007

Introduction

Hello, welcome to my new experiments blog. Any and all posts before this were made in my livejournal before I had set this blog up. I figured I should have something specifically for code experiments so that it's separate from my personal journal.

Most all of these experiments are Actionscript 3.0+ and built in Flex 2.0+ and as such to view any of the examples, you must have the Flash 9 plugin installed. Some of the examples require additional things (web cams, mics, wiimotes, etc).

I will be posting source code for any of the projects that become mature enough to warrant posting. Source code is available for other examples on request (use at own risk).

Herd of Boxen

FROM http://oizys.livejournal.com/228030.html

Obvious next step

My particle emitter + Papervision3D

PaperVision Test 2

FROM http://oizys.livejournal.com/227760.html

Balls are out

click and drag to move the camera

3D? In my actionscript?

FROM http://oizys.livejournal.com/227335.html

I downloaded Papervision 3D today and started learning it.

So far I've made my own material (ShadedColorMaterial), based on the Lambertian reflectance half of Phong shading, and my own object with its own custom renderer (BoundingCube - has no faces but only vertexes and custom drawn edges).

My first Papervision Tests

You may find the shape/proportions of the object familiar. This is by all means intentional.

Shapes

FROM http://oizys.livejournal.com/226330.html

Last night I wrote a standardized shape baseclass with the important draw() and clone() abstracts and some handling of size/color/line etc, and then moved all my shape scraps to this.
Here is a Gear class which is derives from Star.. and a ShapeParticleEmitter that emits shapes by using their clone(). The joy of this is that you can change the "prototype" object at will and the next particle emitted will be a clone of it in its current state.

I realize there are better Shape libraries out there already (hell there are better Timeline libs out there than mine), but I like the joy of making it and of making it how I invision (plus being able to optimize it).

While digging around looking at flash stuff I found two amazing sites:
Papercritters.com - (here's my first one)

Let Them Sing it for you

Typhoon Evolution

FROM http://oizys.livejournal.com/225735.html

The latest code is a bit of a jump

Things added:

  • LoopedSequence and PingPongSequence (modifying colors globally via ColorTransform)
  • Enemy plane moves, Particle Emitters can now 'house' their particles under another container so that they can move without moving their children
  • Enemy has 4 Emitters, Player has 1 Emitter
  • Collision is now a CollisionParticleAffector, allowing you to collide particles with object sets and particle sets, with event callbacks
  • Emitters now have "ParticleEmitterBehaviors", an example one here is the TargetingParticleEmitterBehavior, making the two side turrents target the player on fire but then not do anything special
  • The mini bomber ships are particles emitted slowly with a Targeting affector that tracks the player.
Click to fire

One minor bug... if you leave the ship NOT firing for a while (like the game is running in another browser/tab) and then you fire - it eats CPU for a long time (will appear frozen). Don't do that... fire a lot... it's okay to not fire for like 10-20 seconds or so at a time.

Exploring more particle fun

FROM http://oizys.livejournal.com/225043.html

I'd gotten a little bored with all the particles moving straight, and while waiting for the motivation for my true ParticleData slice structure rewrite that will allow me true velocity/accel control over parameters, I decided to pursue the other half of particles:

Affectors.

ParticleEmitters now have an Affector stack which can have an arbitrary amount of ParticleAffector objects that evaluate for each particle.

A simple example is wind/gravity/force. This looks and feels awesome even for a simple single affector.

But shmups often have over 50% of the bullets that go no where... why would you fire like this? Why does the fire have to be stupid also? What if the fire actually wanted to kill the player?
It might look something more like this Attractor. In this example, you can hold the mouse down to reverse the attractor (To make a repulsor) - a useful weapon in your arsenal.

Oh and since I programmed all the ParticleAffector objects with the ability to have a 'global' effect or a localized (BASED ON SPRITE SHAPE!!) effect - I can easily contain this. (note, repulsor mode here makes awesome bounce shield like effect).

I think my goal is to make a shmup that makes people invent new curse words and name them after me.

Fresher pls

FROM http://oizys.livejournal.com/224933.html

Ugh sick as hell today for some reason. Forecast for tomorrow: 80% chance of fail.

Comic con was a blast this weekend - special thanks to Matt, Nessa, and Maryssa for being awesome. Special thanks to Rog and 'Rie for containing lols (Mini!).

Over the last couple days here are my advancements:

AudioTimeline Test (click around - the timeline's 'time' is being driven by the sample offset of the song: "out of sync" is an impossibility)

Full particle and collision test (the red dots are what are actually colliding - in this case a full hitTestObject calc for each - not too shabby speed wise, but I have many optimizations in mind)
Try to sneak through the big sweep attack on the last one.

Squeeky Mirror

FROM http://oizys.livejournal.com/224517.html

Cheezy CamPaint app [Requires Connected WebCam]

You can draw on top of your webcam image. Press 'v' to have an opacity slider show up (top left), press 'b' for brush size slider and 'c' for color picker. Number keys 0-9 (top of the keyboard) are quick hotkeys to set brush sizes. Spacebar clears the screen.

The primary purpose of this application is to draw a mustache and then say "It's A ME!". All other usages are not covered by warranty.

circleOfLife()

FROM http://oizys.livejournal.com/224388.html

Simple Instanced Position Test
Basically, the other (not red) objects mark themselves as "instances" of the red on, so that all I'm doing it moving the red one and the rest follow suit (in their own respective coordinate systems). Going to make a couple variations of this class/system and a couple helper instance Arrays to make grids, rings, spirals, etc.

The primary purpose of this is to cut down on the amount of mathwork the system has to do to transform a lot of points that are identical along some form of symmetry.

Imogen

FROM http://oizys.livejournal.com/224033.html

This will probably only hold feigned interest from the Computer Scientists who might read this (including my future self) but I've completed/debugged my new BidirectionalTimeline class, which allows for an impressive number of sequences within a single dimension to be sorted and evaluated in minimal time. The objective is... you have a time position, and you want to know what sequences you've completely passed, which you've not reached yet and which you are on (and where you are along them). Now you want to know this whether you're going forward or backward through time. Now add on that if you skip any arbitrary amount of time that you know exactly how many you've passed over, in which direction and where things lie now.

All in the least amount of time possible.

Now there's probably a better solution than my simplistic one, but I believe there's an inherent value that simplicity adds that is probably worth whatever small speedup there is left to ponder.

The first basic test... 50 sequences and showing you how they are sorted

The real test... 5000 sequences - the lists aren't populated because the Flex list display alone drops the framerate to around 1/50th

The solution? Two Heaps (one sorted by highest end time, one by lowest start time) and a Linked List or Resizeable Array. If you have another idea, I'd love to hear about it.

Oh also, I just watched The Prestige. Crazy awesome film but kinda creepy to think about.

Now with more bitmap

FROM http://oizys.livejournal.com/223205.html

More tests using a bitmap emitter here and here.

This time you can attempt (though futile) to catch'em all. More fun I've found is just holding down the mouse and swatting them around.

making the new BitmapParticleEmitter was about as hard as this:


package
{
import gemini.display.particle.Particle;
import gemini.display.particle.ParticleEmitter;
import gemini.display.particle.ParticleEmitterData;
import flash.display.BitmapData;
import flash.display.Bitmap;

public class BitmapParticleEmitter extends ParticleEmitter
{
public var bitmapData:BitmapData;

public function BitmapParticleEmitter(base:ParticleEmitterData,v:ParticleEmitterData = null)
{
super(base,v);
bitmapData = null;
}

public override function createParticle():Particle
{
var p:Particle = new Particle();
var b:Bitmap = new Bitmap(bitmapData);
p.addChild(b);
return p;
}
}
}

Emmitt Field

From http://oizys.livejournal.com/222886.html

Some particle emitter tests in actionscript 3.

Look, I made a simple lever - this is a simple emitter you can play with

This one might hurt a bit - but it looks pretty ^_^ (the number on the top should tell you it's averaging at 760 particles in existence at once - more than most computers can dish out at 30fps but I'm working on that). It's the same as the first with different default settings.

More to come later.

Waitwhat

I just set up this blog to house my flash/actionscript/flex experiments.
Need to first post the backlog...
(RSS feed)