Archive for the ‘Development’ Category

Feb
4

Trip Back to Math Class

A recent project had me trying to find the distance between a point and a line segment, and a coworker reminded me that the distance from a point to the line can be found from the line perpendicular to the line, which passes through the point. That means figuring out the linear equation that defines the line segment. That’s y=mx+b, if you remember your Algebra days. I was stumped for a little while – stuck on the concept of solving for two variables with Actionscript. Actually, I was stuck on the concept of solving for a single variable in Actionscript, because I was being dumb.

Then, last weekend, laying in bed, I cracked it. Didn’t get around to writing the code until Monday. I wrote a LinearEquation class – capable of being given two points, a point and a slope (m), a point and a y-intercept (b), or a slope and a y-intercept – and builds a linear equation from it, in a manner of speaking – you can give it an x value, and it will return the y value. You can give it a y value, and it will give you the x. You can get the y-intercept, the slope, or the inverse of the slope – which will be the slope of a line perpendicular to that one.

Most importantly, the LinearEquation class has a static function – following the model of Point.distance() – LinearEquation.intersection(). It takes two LinearEquations as params, and returns the point where they intersect.

So we create a line and a point – then we get the inverse slope of the line, and pass that along with the point in to get another line. Then we get the intersection of the two, and voila, we’ve the line segment that is the distance from the point and the line.

Unless of course, that intersection is outside of the first line segment – that’s why LinearEquation gets extended by another class, LineSegment. But I’m not going to tell you all my secrets all at once.

So check out the demo I’ve set up. [ Line Segment / Linear Equation AS3 demo ]

And the practical applications for this? Not really sure yet, but there have to be quite a few. Just to name one or two, perhaps making line-segment checkpoints in a racing game, or part of an AI system where an enemy is shooting at you.

Maybe I’ll share the source sometime soon – if so, you can look for it here.

Feb
13

Quality Check

So… been working on a dev project at Struck, but ran into an a bit of a bug. Loading in images and then trying to apply smoothing to them:

var _bmp: Bitmap;
_bmp = _loader.content as Bitmap;
_bmp.smoothing = true;

However, when scaling the images down, it was clear that they simply weren’t smoothing. I asked around, and tried lots of things – cacheAsBitmap, everything everyone else could think of. Don’t know if it was because I’m building it as a ActionScript project in Flex Builder, don’t know if there was some setting somewhere that I messed up – really no clue.

Well, I have to say, still don’t fully understand what is wrong. Something strange is definitely going on. What I did discover, though, is this: while when I right clicked on the flash player, it told me that the quality was set at ‘High.’ However, if I manually reselected a ‘High’ quality level, poof, everything started smoothing!

So, while I’m still completely baffled by the bizarre quality bug, but if I set it using Actionscript, it works correctly! So in my base swf, I just include

stage.quality = StageQuality.BEST;

And, well, it works. And I think I’ll be using that all the time from now on – according to the Adobe AS3 docs, setting the quality to StageQuality.BEST will smooth everything automatically, and how many times have I heard the question “Why don’t images just smooth by default?”

Feb
27

GRAVmarbler

It’s my second VE project, my first foray into the wild and woolly world of Flash Media Server.

Big learning curve, learned a ton. I think it has potential to be a good portfolio piece, but it’s gonna need some serious retooling.

So, for the time being, to finish up my last winter quarter at RIT:
GRAVmarbler || case study

Feb
22

gravMarbler test

Well, we’re in rapid development mode here… finally have turn handling working here. It’s very blackbox right now, skinning and prettying up will be coming in the next few days.

gravMarbler communication prototype

Jan
9

Pollockesque

Prints due today for VE… big changes to my processing stuff since last time.

Set the code up so that it groups the audio input into 4 groups, from lowest tones to highest. It then creates a bunch of “agents,” each assigned one of the four groups, and it has different behaviors based upon which group it belongs to.



They really don’t work in realtime yet, so my plan is to build an interim step, crunching the sound data and outputting it to an XML file, and then I can read it back frame by frame to render it out, and then I’ll be able to produce a movie of it… so look for that in the next week or so!

Dec
16

Snowflake

What I was working on in lab this week… seasonal as well: Snowflake

processing snowflake

Right now it’s random… the feathery bits were inspired by Jared Tarbell’s Substrate. The intent was to tie it into audio analysis. It was also suggested to try to tie it into Processing’s 3D engine, but from research it looks like that won’t be doable in real-time – it will require storing every bit of drawing and redrawing it every frame, which will get ridiculous.

Dec
9

Neon Grubs

Neon Grubs

More playing with Processing, leapfrogging off what I did earlier – it’s a bit geometric and straight yet, not as organic as I want to go, but it’s a start – next I’m going to introduce angles, rotation, trig, that sort of business
Neon Grubs

Dec
5

Processing, Day 1

Today I started experimenting with Processing…

Did a quick test, creating a number of “agents” and making them move around and interact with each other.

Check it out!

Nov
14

Velos, round 1…

Well, it’s been a mighty push… and it’s not nearly there yet. Many roadblocks overcome but many more found… all the same, here’s your first look at Velos. Enjoy.

Velos