Monday, June 4, 2012

Apex

Well,

Today we showed off capstone.  After 20 weeks, it's over.*  We set up the game to show in an old quasi-gutted church, plugged in the ol' laptop and let 'er rip.

Barring a few hiccups, it went flawlessly and people liked the game quite a bit.  We figured out that Kinect and direct sunlight do not mix.  At all.  Bodies/body parts exposed to direct and/or intense sunlight won't be picked up by the Kinect.  I know the Kinect works off of infrared light, beaming "lasers" out into space and measuring the diameters of said light sources, using that to determine depth.  Something in the sunlight washes out those lights, perhaps the sun's own infrared emissions, but that's an just a partially-educated guess.

Long story short, the place we demoed the game in was not short of a whole lot of nice big windows that let the sun come streaming in, so after the first few playtesters we had to be moved to a different spaces simply so the game could run.  I was somewhat crushed because the new room was set apart from the main testing area, but we managed to keep a good crowd despite that fact.

I managed to set up a high-score system about 30 minutes before the game was set to be tested that did the simple task of listing/retrieving and writing a list of high scores.  It tracks all highscores, ever, which needs to be changed because that could get insane, but for the purposes of the day it preformed swimmingly, tracking the scores of every one of our 30 players today.

So, what went right, and what went wrong?

Today I'll be depressing and start with what went wrong: The game wasn't universally playable.  The Kinect we brought with us refused to adjust it's elevation, which rendered it unplayable for one young boy and an excited mother who both wanted to try the game.  To me, that was a bit of a soul-crusher.  To our great professor, Brian Shrank, he simply adjusted the Kinect manually.  A task which you are not supposed to do because it kills the motors and that's probably why our Kinect wouldn't adjust automatically in the first place.
The buttons that I spend Friday creating weren't super intuitive, we kept having to tell players how to pick them up and what to do with them, they need to be both smash-able and crush-able, without having to pick them up and then smash them back down.  That, luckily, can be fixed.
Full screen mode has issues with computers other than my own, that was news to me.
Also, we are making one too many new calls in the game, somewhere.  Despite the fact that C# is a managed language and therefore memory leaks are technically impossible, after an hour and half of straight running the sound began to cut in and out and sound terrible.  The proposed problem of this would be that we ran out of virtual memory for our program.  Or were constantly on the verge of running out before the garbage collector came by and ate up some sounds.

The problem with that is, I have no idea where to start trying to solve that issue aside from hunting down and eliminated as many new calls as possible, and even then I'm only guessing.  The other possibility is that we went through too many levels, and David's great level-saving system hadn't let any of these assets go over the course of an hour+ cumulative game time, which includes the thousands of particles of blood and other effects that were generated throughout the course of the game.  But this puppy also has about 6 gigs of Ram, if I remember correctly, which would be an insane amount of memory to take up.  When we stopped the game, though, the physical memory capacity was around 43%, though. So there's that.

Okay, so now for what went good:

Aside from our two stranded players ( :( ) we had a lot of people play, and for me it was fun just to see people smile or laugh or even glare intensely at all of the little cavemen attacking their cave on the screen.  People had fun, people said the game turned out well.  If you know me well you know that, subconsciously at least, I yearn for validation for my work.  I work hard, but I'm never sure of it's quality.  That's not necessarily a good thing, but today really put me at ease, at least, because we achieved what we set out to do: Build an interesting, somewhat innovated and fun game that people would enjoy playing any way the played it.

The best was seeing friends play the game and how they reacted and played.  My friend Majdi was my hands-down favorite, he played the entire game as if he was trying to sooth the cavemen instead of kill them.  He was the gentle giant of the night, but watching him play made my day and hearing the banter between him and the crowd made my day, easily.

We did it, by golly we did it.  I've done a lot of attempting in my life, and if there's anything that's difficult for me it's following through.  Be it my swing in baseball, my techniques in Judo or the games I strive and love to create, I always start strong but end in a far worse position than I hoped for.  Capstone was not easy, but I had a great team and great people to support me and finishing this game was one of the more difficult tasks I've ever tackled.  And this is a game that I made with my friends from the ground up. There's not one brick or piece of duct-tape or staples that holds this game together that wasn't made by us, Team We're Okay, and the next wave of the gaming industry.

Sorry, I meant to say I HAVE a great team and great people supporting me.

Now... Back to programming! More games! Go, go, go!

-Kev

Friday, May 25, 2012

Running Scared

For the first time in my academic career I'm genuinely frightened of the upcoming weeks.

That's heard a lot, I understand, and my friends and family are quick to point out that I have spoken such "nonsense" before.  I stipulate, however, that this time is genuinely different at set apart from the previous set of experiences.  I have only one final to study for.  On the flip side, I have three monumental projects to complete... In a little under two weeks.  Less, actually.

Capstone needs menus. Badly.  I hate UI programming, but essentially that's one of the only things left on the list.  It's time consuming and arduous, but absolutely, positively, painfully necessary

In multiplayer I still have zero idea if my theoretical networked code will run.  I haven't been able to  test it, I don't have access to another computer that can run the friggin' windows live that the project requires.  The school computers are all out of date and I can't install or update them with Windows Live because I don't have administrative access, of course.

And I just barely got started with Graphics, which involves building an entire particle system utilizing the graphics card.  This assignment is what has me sweating bullets, I got such a late start because of other factors in school and I have no idea what I'm doing and despite the academic papers I've read there is no authority on the subject that I can find with any sort of examples or "baby steps" to follow.

Ordinarily, I would relish the opportunity to learn something from complete scratch, however, given my time constraints and the fact that these final projects are huge portions of my grade I really can't afford to get stuck on ANY of my projects.

And I'm stuck on ALL of them.  Capstone is bogged in UI, I have no clue what's happening in RenderGL, the "lovely" open-GL framework DePaul has (with shoddy documentation) and I can't even see where I stand in Multiplayer until I somehow get access to another computer.

And that doesn't even factor in my Calculus work, of which I have 5 outstanding assignments all given within the past week and a take-home quiz to complete.

...Check, please.

-Kev

Friday, May 11, 2012

The Little Things

Dr. Livingstone, I presume?

Yeah, it's been some time.  Partially for good reasons, partially not.  Tonight won't be a super long update, as I have a long day ahead of me tomorrow and It's currently 2:05 in the morning.  Dang it, that was not supposed to happen.

And I haven't been up to anything productive, per se.  I have a mountain of programming homework to tackle this weekend, and not enough time to do it.  That being said, I spent 4+ hours this evening (maybe? I guess that's right, maybe more like 3 or 2) doing little tweaks to capstone.  I fixed dumb things like a lag error in our particle effects.  I knew what the problem was, or at least I had suspected, for some time but I had not acted on it.  I finally got that out of the way today, which felt really satisfying.  It was a simple problem, I had all of my object stored in a linked list (I have my justifications, I'm using C# which is a memory-managed language, it automatically reduces memory fragmentation and I get O(1) insertion/removal time with my method, don't anyone start telling me that Linked Lists can't have a O(1) removal or I'll keyboard-smack you harder than that one guy did in Wanted) but I did my removals in a rather stupid manner, e.g. yoinking any object calling for removal immediately, which didn't break, stop, or even halt the game.  It would, however, halt the update of some of the other objects in that class group for just a fraction of a second.  I don't know the exact specifics, but yanking from the linked list caused the rest of the linked list's update to be skipped or short-changed.

Long story short I threw in a small vector list that stored the positions of all of the to-be-removed nodes, and then AFTER all those happy-go-lucky nodes updated, I swept through the list and plucked out anything that needed to be removed.  Problem solved in < 5 minutes.

And sometimes, as a programmer, you need that.  I've been wrestling with bugs and problems for months, in some cases, I needed a small, polish task that I could get done and move onto the next one on the list.  That just feels good.  And I could use some moral boost.

I also took down a number of other small issues.

Apparently our background clouds were supposed to animate, I don't remember ever being told this, so perhaps I wasn't paying attention, but I threw the scrolling clouds in in a few minutes.  I did some art-related exchanges, Justin got me the newly saturated sprites, which amped up the color and the overall aesthetic of our game immediately.

And... I completely forgot the other changes I've made.  There were a number of them, again, only small, quick little tweaks, but stuff that felt good to put in and have just WORK and not complain at me.

Oh yeah, I threw in limbs, that was one thing.  When a creep is hit so hard or has had so much damage dealt to him he simply explodes and a few limbs pop off and skitter across the screen, spraying blood as they go.

I love doing this, when it isn't slowly killing me!

I don't have any doodles for you, unfortunately, not at the moment.

Hold on, I recently uploaded a whole batch! It's (possibly?) your lucky day.

(Apologies for any obscenities, I have a class that I really hate this quarter, and sometimes feelings are manifested into written words)













-Kev

Friday, April 13, 2012

Crunch Mode

So it beings.

The beginning of the end.  The last push, the final battle, down to the wire and everything is on the line.

Well, not yet, but it's getting close to being that time of the year, and my college career.  That wasn't really supposed to rhyme, but for that you can blame David.  For some unbeknownst reason he has the uncanny and awesomely hilarious ability to rhyme in the character of the Lorax.  Yes, the one from the Dr. Suess book.  Some of his friends are a little annoyed by it, but I am under the impression that it's downright hilarious.  I wish I had that kind of quick mind to think of rhymes on the spot.

But there is a very good reason I'm in game design and development and not rapping, or singing, or majoring in math, or science, or business or medicine.  Because I'm not good at all of those other things.

The current stance of the game is interesting.  We are posed to submit to IndieCade to try and garner some attention for this little gem, but there are a bunch of hoops we have to jump through in order to get it submitted.  Same goes for Zombie yoga, we are both pushing for the 15th deadline.  Which is Sunday.

Yikes.

Better get crackin'

That, and on the rest of my homework.   Multiplayer Game Development, which should not be left to the last day, math (yuck) and Graphics, which was taught rather poorly to me and has resulted in a confusing mess.  I think I know what everything should be doing, but that doesn't mean it actually works according to plan.

This is no bueno.

Anyway, the game went through a small playtest on Thursday, and I think it went very well.  We have a lot of good data from the test, but we also have a lot of work to do.  I feel as if no game I ever work on will ever be finished, which is a very scary and discouraging thought.  I've only ever finished one game.  I've started many, but school and technical limitations have stopped the growth of many.  When I taught myself programming, I hit a wall of knowledge and understanding.  Now I'm hitting walls of time, priorities and some technical limitations.  If I just had capstone, this game would be sailing along, but I have to balance this with many other competing factors, I think the end result will just be little to no sleep (it is darn well near two right now) because we want and we need this game to succeed.  It won't bring in cash, and it was never supposed to.  This game is out there to show that we can be innovative, that we can find the fun in anything and extract that and give it back to players in a great package, and that we can make games, and that we are good at it.

I added some things in recently, mostly a lot of playtest tweaks, but some new features such as earthquakes and combo systems.  Brian is working on reducing and restricting the incoming enemy waves.  Justin is working on a new batch of art for the change in story direction that fits our scaled-down version of the game.

Just talking about this makes me nervous now, I feel like I should always be working and never be relaxing anymore, I just can't afford to do something like that.

Man, I can't wait to get back to judo, I really need that back in my life...

SOS.




-Kev

Tuesday, April 10, 2012

Humbug.

Normally I get hyper-focused at around midnight.

I don't know what it is about this week but it has been a mixed bag of really awesome and really crappy events, all in all I feel very drained and unfocused right now.  Spending almost my entire Easter Sunday trying to do math definitely did not help the matter at all.

And usually I eat quite a hefty amount.  In the past week I don't think I've had more than two meals in a day.

Now, I understand that's plenty of food for a person to survive off of, but considering my usual amounts of consumption this is very low and perhaps not a bad sign of... something?

On top of that I got chewed out by one of my favorite professors today.  The thing is I wasn't yelled at or reprimanded or given a stern warning or a bad grade or a bad critique.  Instead he expressed his extreme concern about the progress of our game.  That's a lot like your father sitting you down on the couch and explaining that he's not upset, he's just deeply disappointed in you.  Then he leaves the room and all you can do is hang your head and feel utterly devastated.

It was pretty much like that.  He was very concerned about my involvement in Zombie Yoga and if that will take over the Capstone project.  I know he's right, I know I have to be careful about how I split and spend my time.  But I'm giving all of my projects all that I have, I'm coding almost from sun up to sun down, especially now that my other shoulder is bum and I can't get out any of my code aggression in Judo.

I've been getting the small things wrong, bad variable names, bad values, not checking value ranges or forgetting basic features of IDE's and engines.

In my math class I'm flying through the examples the teacher gives with ease, but the homework has been thrashing my behind by being long and complicated.

Zombie Yoga had me smashing my head against the wall until just today where just barely in time for a playtest I got the new code in the game.  Only to have it not work for our lead designer/professor, Doris.  It worked for everyone else, but I couldn't even give Doris the ability to play her own game.

I had a small bug in the combo system that I've been developing for our Capstone Project that by all means should not have existed.

But I got Zombie Yoga working, I fixed the bug and within an hour or hour and half I had gotten the combo system visualized nicely and even added in features to the system in just 15 minutes.  I just wish I could be intelligent and responsive all the time, instead of only every once in a while, and that I could put in enough quality work for Zombie Yoga and Capstone to co-exist peacefully on my plate of ever diminishing time.

In general, I feel like absolute garbage, and for even more reasons than just being sometimes-bad at what I love to do and then for disappointing one of my favorite professors, but that's all I'm going to get into here.

Bah Humbug.



-Kev

Saturday, April 7, 2012

On Screwing Things Up

Mix of code-related and life-related postings today!  Mostly because I'm at similar junctures in both, or at least that's the way it feels.

First the code stuff, since that is the purpose of there 'ere blog in the first place.

If you asked me what my favorite part of programming was, I'd say it would be creating new and fascinating worlds, and learning how to do so in a faster, better, and more intelligent way.  If you took a look at what I do mostly when coding, it would appear that my favorite coding pastime would be screwing things up.  Most of the time, it's intentionally too.  I have a system in place, it works, it preforms as I need to, and I won't be happy with it.  I'll tell myself it could be more flexible, it could be faster, it could be more abstract, so I intentionally break it and try to rebuild it.

First lesson of the day, if it ain't broke, don't fix it.

Second lesson of the day, if you really want to fix something, start fresh and don't try and mold what you have into what you want to be (at least coding-wise, I'm not saying find a new girlfriend or wife, relationships don't work like programming stuffs... I don't think, it's been a while)

Molding the old to fit the new is a bigger pain in the rear than starting over.  That stands true for most anything, unless, perhaps, if its and entire huge project.  Even then, though, starting fresh is beginning to grow on me.

All I wanted to do was make the combo system I have more flexible, account for more options and situations.  So I had to make a bunch of changes that killed the system, so I couldn't test iteratively (misspelling? Not sure) and I had already propagated said system throughout the rest of my code, so I had to hunt down those spaces and make changes as well.

Then, when I had it working...

Perforce overwrote it all.  There were conflicts in the files that needed to be changed, so I went to press resolve and instead hit revert.  I spent all afternoon on this instead of my homework, and now I have nothing to show for the day.  Wonderful feeling, enough to make me sick to my stomach!

The thing about coding is, however, I'm rarely afraid of screwing things up.  The lessons I have learned in coding don't always seem to apply to my life lessons.  It's the same reality, though.  If you really screw things up in your code, or in your life, it's going to suck.  There's no getting around that fact, it is going to be terrible.  But it's not going to be the death of you.  Unless your mistake was crossing a mod boss or pressing the "do not press" button at a secret government facility.  In which case you probably killed us all.  Thanks.

My issue IRL is that I'm usually too cautious and concerned about making a mistake and suffering the consequences that I move in order to stalemate decisions instead of actually making them.  The problem is life moves forward, and if you keep side stepping you never actually get anywhere.  Even falling on your face is getting you headed in the right direction.  Take your pick, martial arts, relationships, other life choices, etc.  I don't want to fail, so I rarely take the risk to succeed.

This must stop. Just treat life like a program, plug your nose and dive in.  You're going to come out on the other side with experience, at the very least, and that's what makes up your life, a collection of experiences and stories to relive, relate, and pass on.

As they say, go hard or go home.

Though I wouldn't mind being home for Easter.

-Kev

Thursday, April 5, 2012

Rehash, Reuse, Recycle... Recreate.

Whoa nelly are there some awesome things to post about today.  Kinda/sorta.  Actually I'm not allowed to talk about most of them... Which means I'm potentially on the right track for game development if I am being included in hush-hush things.  Suffice to say, I really want to spill the beans about awesome stuff, but it's mind over matter, sorry everybody, I can't do that.

In vague terms, though, I can say that Kinect is making leaps and bounds within Zombie Yoga, and as of a few minutes ago I got the new pose system that David and I have dreamed up working full throttle in our C# version of the code, and now we finally have a way to get this code ported over into the game engine so Kinect plays nice with the rest of the game.

And, as I mentioned in my other shorter post, David and I received affirmation that we are not, how you say, doin' it wrong when it comes to the Kinect.  Lots of people are hacking away at this thing just to get it to work, and currently the best and easiest way to do this is... however you see fit, however you can fit it, however you can get it.  Anyway you want it, that's the way you need it... fill in the rest!  And our new system, though not thoroughly tested yet (It's just been me our little (yet huge... it's a funny room) studio apt. trying some whacky poses.  So far it's more forgiving (which, when it comes to the Kinect can be a good thing) and easier, which is all that we ever really wanted.

How does our new system work as opposed to our old?  Well, for starters our old system was based off of joint proximity, how close one joint was to the other.  That's all that's needed, right?  Well several problems arise from this, stop me if you've heard this before.  Or... I guess skip to the next section unless you can communicate telepathically with me RIGHT NOW. Oops, you are reading this, I posted it, too late.

But seriously, it wasn't a bad system... if you didn't have a lot of poses to check and everyone in the whole wide world was the same size.

We solved a lot of our problems pretty ingeniously, we had a complex yet effective means of eliminating "bad" poses when checking a player's pose, using outlying points to quickly scan through a list of poses and almost recursively loop through down these outlying points into the center positions (hip location and shoulder location, etc), each pass eliminating more and more poses until just one pose remained.

We also had a trick in terms of scaling the poses to be adjusted to the player's individual size.  We got a calibration before the player began the game, and compared these limb lengths with that stored in our pose data.  Every posed we had queued up then had it's limbs scaled appropriately, according to the calibration we just took and the calibration of the original yogi.

This system, however, only worked in practice. Kinect kept stepping in and kicking our butts, either by having a bad value during calibration (Left Hip was once (-infinity, 5, 5)...) or by it's lovely method of "inferring" joints.  Kinect doesn't always know exactly where your joint's are, it gets a rough guesstimate (Better than nothing!) but at times this could result in limb shortening or lengthening in the 3D skeleton data.. which is fine, if everyone's body types got this limb shortening at the same time for the same poses, but they don't.  So when the scaling was introduced with certain poses it would screw the rest of the data up by this limb shortening/lengthening putting the Yogi's original joints in strange, wild places.

There's ALSO the issue of player offset.  The Kinect returns joint locations as position in 3D Cartesian space (X,Y,Z, think graphing, remember High School math? Yeah, you DO end up using it for something) in terms of meters from the Kinect.  Which means if I'm in pose A and I'm a foot to the left of where our Yogi originally had the pose captured, then you would not be in the correct position.
This was a relatively easy fix, if you know vector math or understand 3D coordinate space all we did was make each of the joints relative to the center hip, or took each joint position and subtracted the center hip to make everything in "local space" as opposed to Kinect space.

Add, on top of this, the fact that Kinect loses your joints.  This is not a matter of if, but when.  The Kinect does great considering the fact that it's pretty much still just reading one dimension.  The problem is the minute things (read: limbs) start obscuring body parts, the Kinect beings to give it's best guesses as to where things are, which end up being really awful guesses.  So half (more than half, at this point, actually) of our poses involved a very three-dimensional stance.  Warrior One, and Warrior Two.  Google them.  Have safe search on, too.  You shouldn't need to, but I found out the hard way the other day that even something as innocuous and/or nerdy as C-strings (an oldschool format for printing lines of text in C) can give you very, very, very uncomfortable results.  Here's a hint, don't ever google c-strings.

Holy smokes that's a lot of workarounds Batman!  Why in the world did you do that?

Well considering Kinect only gives joint position and not rotation, it appeared to be the most straightforward and logical solution.  And in certain circumstances this would be the ideal solution.  For a small number of poses, if we had all of the tech we wanted down (appropriate body scaling, effective elimination system and not Kinect giving us random bad data) it actually could have been a good and flexible system.  It's highly accurate, pose definitions could be kept as tight;y or as loosely defined as we wanted to specify.  It's static, but that's all we needed for poses.  Before we got into the muck and mire of Kinect work, it seemed like a flawless plan.

Given what I know now, I'd go back in time and throw my past self out of a very tall building to save him pain, agony, and sleepless nights.

So what's the new system?  The new system is a combination of several different things that we thought were "hacks" but tend to actually be industry standard.  That is to say fake everything.

We combine a pose flag system, which is just a fancy programmer way of saying we store a lot of true/false (or binary) values in a single integer (4 bytes = 32 bits, each bit can be a 0 or 1, giving us 32 compact and easily comparable true/false values) that tell us information such as
"Are the player's hands above his head?"
"Are the player's hands togther?"
"Is the Right hand forward?"
and etc. to ad infinitum.
(Actually only to 32!)

These are our first test.  The really sweet thing about bit flags is that comparison between multiple true/false values is really simple and really fast.  So we use the pose flags as our first order of elimination.  A pose has  a specific set of these very general flags that must be true in order for the player to be in the given pose.  Just because the player's left foot and hand are forward doesn't mean that they are in Warrior Two, but it certainly means they aren't in Tree Pose or Warrior One.

This is fast elimination and means we don't have to use that really complicated (and expensive) distance-check for each joint location (lota joints x lota poses = big slow down)   To be fair, David had begun implementing the pose flags system in our old game too, but problems plagued that implementation, starting fresh really helped us out.

Then after that we ditch position.  Position data means nothing to us, now, we use the positions of joints to get the angular distance between them, and nothing more.

This is achieved by getting the dot product between two normalized vectors.  The result is the cosine of the angle between the vectors.  We take these dot products at the main joints, the elbows and knees.  The second phase is checking the these joint angles (anywhere between 0 degrees, the limb is straight, and 180 degrees, which technically is impossible for the human body, but that's the limb bent all the way back so that, say, your wrist is pointing in the exact opposite direction of your elbow) so that means Warrior Two is defined by the fact that, say, your right hand and leg are forward, your right elbow's angle is 0 degrees (or a dot product of 1) and your right knee is around 90 degrees or so (dot product of 0)

This is a terrible approximation, don't attempt those exact angles or you might suffer some joint strain, but you get the idea.

Now that's getting closer, but as you can imagine that still leaves a fair amount of wiggle room.  Or far too much forgiveness.  I could turn my torso so that my hands are pointing off at angles, but the angle between my bicep and forearm is still the same amount, and my right hand is still in front of my body, I'm just all twisted up.  The last layer on the triple chocolate cake is another dot product, but this time it's in terms of the proximal extremities.  Basically where your biceps and quads point.  We take these and change them into normalized vectors, and then also store these in our pose file.  When you the player are trying to get into a pose, we check the direction of your biceps/quads and see if they match, or are close enough too, the original pose file's directions.  This ensures that players are keeping, generally, the correct form and are facing all the correct directions, etc.

There's still wiggle room, but at this point we've eliminated the major stuff.  And the nice part about working with pose flags and angles is that they are all relative.  Pose flags get set by comparing positions in the skeleton itself.  Is the Z value of this greater than the Z value of that?  It's relative, it scales with the person playing.  Same can be said of the angles.  Barring the few possible exceptions, people have the same degrees of motion, and, if you remember trigonometry, angles are independent of size.  A 60-30-90 triangle can be infinitesimally small, or colossally large.  Same applies to the person on the other end of the Kinect.  As long as they fit in the Kinect's FOV (Field Of View) then the angles between their limbs and the directions of their limbs are independent of size and it makes no difference to the Kinect.

We eliminated our scaling and our too-hardcore accuracy problems by a base shift in how we work with the Kinect.  Our new system still needs to be thoroughly tested, but it's already been easier to set up and work with than our previous iteration.

Professor Ed Keenan is right, don't be afraid to throw away code, and throw it away often.  You build something, it kind of works, delete the code and start over with a better understanding and I guarantee that you will have a better and easier time dealing with the code than if you try and forge through with your old base code.  Again, their are exceptions to every rule, but I used to never do that, thinking it was a cardinal sin.  Well, I've only just started, but it's helped tremendously.

Delete old code.  Re-work it.  You get better, faster, and the end result makes more sense.

TL;DR, I know, sorry, no doodles for now, it's 0230, I need to sleep before class tomorrow.

And finish that math homework.

Fiddlesticks.

-Kev

Tuesday, April 3, 2012

Late Night Lovin'

Okay, I'll be the first to admit that's a terrible name for a blog post.

Regardless, let's take a look at what I've done in the past week or so:

Watched all of the Game Of Thrones.

Watched Girl With The Dragon Tattoo.

Hung out with friends a lot.

Celebrated Ricky's birthday.

Uh, wait... I programmed in there somewhere, right?

Yes, a little bit.  I fixed a massive processor-sink known as the "pit of constant memory allocation"
Our game has these really awesome scores that pop up when you hit guys and deal damage, and I worked my butt off creating a really dynamic (if a little costly) means of adding in our own sprite fonts, since I find XNA's defaults to be... messy.  Limiting. Primitive. Primordial. Neanderthal.  Really not cool.

The default sprite-fonts in XNA are not nearly as bad as I've made them out to be, but there were a number of limitations that caused me to balk at using them.  
-They required the computer to have the fonts pre-installed or packaged with the game (not that bad.)  
-They require you to use and allocate and entirely different font if you wanted to change the font size! (Kinda but bad, again, a good programmer can create systems to allow them to easily make up for these, creating an array of sprite fonts at different font sizes to allow for rapid font-switching)  
-Creating your own font meant learning how to create fonts according to standards (The equivalent of asking for directions, which guys never do. ...Right? Wait, why don't we do that?)
-To my knowledge, you couldn't do cool things like rotation and flexible scaling.

Looking back, it would have been far, far easier to just implement a system that simply didn't try and deal with dynamic rotation and scaling.  But I will not be dissuaded from my goal.  I crafted a system that lets a person use an image to specify a new font (adding it in is rather tedious, though) and after it's been added any string can be created and scaled, rotated, color changed, it can check for collisions and evra'thang!  The way it does this isn't necessarily great, it creates a new texture2d for every unique string generated, but stores all previously generated strings in a lovely hash-table for quick look up and grabbing the next time the same string  wishes to be generated.  This resets every time the game runs, so in theory a dedicated programmer could pre-populate his list of textures with his desired strings and lookup would run just that much faster!  Hooray!

Anyway, the long point of my story was that I was generating a bunch of new calls to create these little effects that called my sprite font, created themselves and then deleted themselves within a hot second (literally) and then sat around, presumably on some duvet somewhere in the lobby of lost memory allocations, smoking a cigar illegally or drinking heavily, waiting for the Garbage collector to come along, and when he did, boy would he have a lot of work to do.  Which causes the game to lag hardcore for a few miliseconds, and then return to normal.

Can't have that, that's just bad practice.  If games like Borderlands can run at 60fps (or near to it) on my computer then there is absolutely no excuse for my 2D game to lag.

Aside from that, I've just done some work on the score system, creating examples for Brian and making sure that it's at least visualized partially for upcoming playtests.

W00t w00t.

-Kev.

Oh yeah, you came for pictures, didn't you?



Cousin Collaboration

Guaranteed to solve most problems. 

Friday, March 30, 2012

New Post, new strategy

Hello everyone,

I'm going to be trying a new strategy to the blog, it will mean my posts are more frequent, but possibly that makes them less interesting.  Aside from my "usual content" I will be posting "engine maintenance" content, just a log, essentially, detailing the changes made to Princess throughout the course of a day.  This is mostly to help me (how selfish of me) keep track of everything that I've done, to what file and why, because future Kevin is going to want to know what in the world past Kevin was thinking, guaranteed.

So what have I done today?  I've tightened up Kinect a little bit.

"But Kevin," you ask, "You've been saying that for months! How much tightening can possibly be left?!"

Let's just say I'm the personal trainer of a morbidly overweight technology.  There's a whole lot more tightening that can be going on here!

But I did do work, so to speak.  I've kind-of-sort-of-maybe finally adopted a new method of looking at my hand "point cloud" that seems to work well enough for my needs.  Taking (slight) inspiration from calculus, I changed my method of storing my cloud points as elements of the X-axis (each x-axis spot has a small list of Y-axis positions)

From there its quite simple, I split the cloud into bottom-max values and top-max values (Y-axis) I check for valleys and peaks (derivatives, anyone?) and If I get a certain amount of peaks and valleys in my point cloud I assume this is "fingers" and then  my problem is solved.

What if the person has the hand to the side?  And their fingers didn't point up or down?  I also check the number of points on the given Y axis, any more than four (at least one gap) then I, again, declare the hand to be "open"

Again, are there are ways to do this better, but I want it done FAST, so if I can hit all of this in just one or two passes, I am a happy man, and I can devote my time elsewhere to gameplay programming.  Had a friend of mine, Ozzy, test the game rather unplanned, which confirmed to me that: The hand opening/closing is "good enough"

It needs more work, but it's good where it is at.  Will I work on it more? You bet, I'm a perfectionist when it comes to, well, random things, but this Kinect is one of the areas I always feel I need to improve at.  And so I shall, but it's now officially on the back burner of the project.

Ozzy also showed me a degenerate strategy I'll have to talk with Brian about.  One of the coolest parts of our game is the "smashing" feature, it's simple, but fun, if you have guys in your hand and then bring your hands together, they get crushed and blood spews everywhere, it's an insta-kill.  However, it's also entirely possible to pick guys up and clap your hands together rapidly, just hovering guys above the ground and as such simply kill attackers left and right without rhyme or reason.

So that must be remedied, but overall we need to reign in the number of our attackers.  Too many guys on the screen doesn't make for what feels like good gameplay, just really hectic arm-waving.  Brian and I talked it over, we're going to try to lower the enemy count but raise the health and see if that helps maintain the difficulty but makes the game more about having fun smacking guys around a lot.

I'm also thinking about bringing back the "close hand to grab" functionality, at least temporarily to see if, now that Kinect is a little bit nicer, it brought anything to the gameplay.

I also implemented a quick pausing system that pauses the game if you are "interrupted" or step out of frame it pauses the game and allows you to step back in, quit or resume the game.  It's not perfect, for some reason the draw order for the pause is out of whack, but it works and it's something that I had been meaning to do for a while.

The next few things I want to nail down is a more efficient system for the numbers popping up every time you hit enemies, it really can slow the game down for a bit if there are a lot of enemies on screen, and.. dang it, I just forgot.  Well, I'm sure it will come to me in time.

I actually have a lot left to do.

- Background displays village and enemies leaving village (think the "what's coming next" indicator in Tetris)

- Kinect Wide-gestures (earthquakes, etc)

- Finish up scoring sytstem/hit tracking/combo recognition (base system is in place, I want the visualization to be there)

- Tweak Kinect every so slightly if time permits.

- Add catapult men.  (Sssh! it's a secret!)

- Add more sounds and some music

- Many more things I am forgetting right now.

That doesn't seem like a lot, even to me, but I know things will be much harder than they seem, and I am missing a number of different tasks.

We also need some awesome intro cutscenes or something similar.  We are re-working elements of the story to be a little more cohesive with what we've got.  We shall see how that goes, we have to be very careful now, the difference between an okay game, a good game, and a great game is how it all comes together.  We've got the art, we've got the design, I'm holding the program together with staples and superglue, it's good.  We need it to be great.

Okay, that was my Coach-Carter moment.

Elsewhere in the world I finished my Delaunay Triangulator by complete accident.  Well, not entirely, I scrapped all of my old code that I had because it was just not working and I couldn't figure out why.  I re-did the code in a much cleaner and simpler fashion... and it still didn't work.

Then I changed the order of the vertex creation in new triangles and... lo and behold it worked.  A seemingly random and insignificant matter as the specified order of vertices in a new triangle makes or breaks the algorithm... yet I followed it to the T, and there was no mention of vertex-dependent order?  Did I still do something wrong?  I have no idea, but boy am I glad there are only 3 verts in a triangle or I would have never figured it out by moving random stuff around.  Which is how I come to a find many a solution in my code.  It means I'm always 98% right and 2% wrong... but being 2% wrong still means you are wrong in programming and logic... and math.  Most especially math.

Can't be wrong, must improve.

Must maths, must programs, must logics, must succeeds.

Wednesday, March 28, 2012

Slowly but Surely.

Had a talk with Brian Schrank today, our adviser/professor for the capstone project.  He thinks the game is coming along nicely and is shaping up well, which is a huge relief, but it's more than clear we aren't out of the woods yet, a lot of work, and I mean a whole lot of work remains on this project.

Also, zombie yoga needs the Kinect working at 100% levels by... April 15th.  Oh snap.

So what did I get done today? Practically nothing, I'm still working on my triangulator that I mentioned last (or the one before last) post, and after having a day off of it it's ridiculous to go back and have such a clear head of where everything was going wrong... which hopefully will happen with Zombie Yoga's pose recognition system too, but that's aside from the point.  I simply got too far into the system and made some dumb mistakes with inter-class relations.  Now it is very, very, very close to working.  The only issue now is I have too many triangles on the inside of my objects, as opposed to having only 2 triangles in a box I have 4, they simply create too many triangles and let the others overlap.  This is cause for minor concern, as I don't really know why this is happening (duh) but also minor celebration (yay!) in that I got the Delaunay triangulation technique to mostly work.

The other thing I did was go ahead and build a system for combos in our game.  This leads into one of the points Brian (Schrank) mentioned today, that while our game is coming along great, some of the cohesiveness is missing.  We have a game where you play as an angel, defending Eden, but with an arcade-y feel with points and numbers popping up everywhere and cartoony graphics.  Each element is great on its own, the arcade feel is fantastic and was met by players with good responses, the carnoony art that Justin has been working on is simply amazing, and the story is one that has a lot of potential.  But we have to cut back and reign it all back in, possibly major changes are coming in the future of this project, not necessarily in gameplay, but perhaps in presentation, we shall see.

Anyway, the combo system is a fairly flexible system, C# for some unholy reason decided it didn't really "like" binary search trees and doesn't include them as a base systems class which strikes me as rather odd.  Regardless, I had to set up what would be a "quick search" system (ended up being a dictionary of lists...!) that could take the first "hit type" that a creep has received, find the appropriate list of possible combos, and iterate through that list until a match is found and a combo is registered.  The combo is found, the appropriate message is displayed, point's added, and a counter keeps track of the times each combo is used/found/registered, etc.  It's pretty standard stuff, however we can get a lot of creeps on screen, and searching through a list  which has a list of conditions each combo must fulfill can eat up more time than I'd like, so the combo system has a cap.  Think of it like your computer trying to send packets.  There's a queued buffer of packets waiting to go out, if your packet encounters a full buffer of packets then, well, it get's dropped. (Yay multiplayer game development explaining the different joys of packet loss!)

My system is not quite so elegant (if you can call fumbling a packet elegant) it simply has a set number of times per second that the CheckForMatchingCombo() call can actually be utilized.  If it has already reached it's max for that second, no more "expensive" calls iterating through the dictionary and lists will be made.

That kind of stuff is busy work.  My system works, I have no doubt there are more elegant and efficient solutions, but mine is robust, it allows for lots of experimentation with different combos and more importantly it works, which is all that I need for it right now.

Tomorrow beings the long process of beginning to wrestle with the kinect again.

We who are about to die, salute you.

-Kev

Monday, March 26, 2012

Spring

It has Sprung.  Too quickly, if you ask me.

Well what have I done?  Not much, admittedly, for my spring break my dear cousin came out to visit me in Chicago, and we had a great time doing all the things tourists do.

Up to and including getting really tired the last day and spending it watching movies and TV, haha.

In all seriousness, it was great to have her here, and as much as I enjoyed the break, it's time to get back to business.  Or "srs bsns" as it has come to be known in our capstone group.  I have to get back to working out, and to all of the things I have to do this quarter, which includes...

Calculus II (After a year off...!)
Multiplayer Game Development (Looking forward to this one!)
Capstone II (Duh)
Real Time Graphics (Please be good, please be good...)

And..
Working as a lab mod
Training for the next Judo tournament
Grading for Charley (My awesome faculty adviser at DePaul)
Zombie Yoga (...so much to do... so little time)

Not to mention the things I want to do, like learning how to do some sweet aerial kicks and tricks to impress at the dojo at home (as well as get me in better shape doing something fun as opposed to lifting which I find very hard to do without someone to do it with)

But, what have I done in terms of PROGRAMMING over the break?

I've been fiddling with creating a generic volume class for princess to be used in mo' advanced versions of our current collision system (which needs to be re-hauled... when I have the time)

It's a relatively simple system, it just takes a series of 2d vertices specified in a counter-clockwise order that is closed by connected the last vertex to the first vertex.  There are edges between each of these vertices that check against other edges for collisions and etc.

That, my friends, is the drop-dead easy part.
A vertex class? Piece of cake.  Edge class? I could do that in my sleep.  Connecting them together? Pah! No problem.

So... then WHY am I still stuck on this?  Well that's something I've been asking myself.  You see, I'm trying to make the whole process as simple and efficient as possible, but at the same time I want this as robust as possible.

If I just want to check edge to edge collision, my system can stop where it's at, however, if I want to check if, say, certain points are contained in my newly created volume that beings to give me problems.  If this volume that you've specified is convex, meaning that there are no interior angles in yo' shapes, then all I have to do is check to see if a point is to the left of each edge in the lot, and TA-DA! If it is, then the point resides inside the volume.
Pictures always help me

...however, if my shape is non-convex, then this to-the-left-of-each-vertex thing kindof falls apart.  (also, the more complex these shapes get, the more processing has to be done for each interior check, which is also a general case, but if there was a simpler way....)

So what to do?  Well, its elementary really.

In theory.  In practice, not so much.  The solution is to divide up the interior of the bounding volume into triangles, then loop through each triangle when looking for a point lying on the interior of a shape, and do some quick and cheap eliminations of unlikely triangles (point not within min/max bounds of a given triangle) before doing the messy stuff (checking the relative space to an edge).

Again, that's not my problem, my problem is HOW to break up the interior into triangles?  Well, I kicked around a lot of my own idea for a while.  That should be read: I do what I always do when I get stumped, snack profusely while staring blankly at my computer letting my mind alternate between creative thinking and flavor comprehension.

Regardless, I was getting nowhere, this is not a simple as I first thought, so I decided to see if the internet knew anything, and lo and behold I found this, or a good explanation about Delaunay Triangulation, which does more or less what I want to do, it takes a list of vertices, and creates a convex hull out of all of them.  The article I linked is the only article I think is worth reading.  I found a dozen more before (with source code) and they made no sense to me until I saw the picture-illustration of the algorithm at work in that article.  That's when it all made sense to me.

That being said, I'm still having problems.  One is conceptual, and one is my implementation.  The implementation problem arises when I try to remove triangles as denoted in the algorithm.  For some reason my algorithm is very trigger happy and removes too many triangles, leaving me with a sadly half-complete volume-mesh, which makes a very unhappy Kev.

The conceptual problem is that Delaunay's method creates a convex hull, even when  I don't necessarily want a convex hull.  So I have to go back through once good ol' Delaunay has done his thing and then remove any edges that connect vertices that shouldn't be connected.  Imagine two vertices as Romeo and Juliette, which would make me Poison.  Or Death.  Though I think them both dying was supposed to be, as well as tragic, somewhat reassuring because "they died together" or "died for each other" or whatnot.

It's been a while since I read that play for English in high school, don't judge me.  Getting back on track, this is achieved relatively simply if messily by comparing the angle between the two "true" outside edges of each vertex, if the angle from the first to the second (thinking clockwise here) is greater than or equal to 180 degrees or Pi/2 then it's a lovely convex point and we don't have anything to worry about, however, if the point is less than 180 degrees and we have a third edge between the two vertices at either end of the vertex in question, that edge must be removed to maintain our desired non-convex result.

But I haven't even gotten to that part yet because of my trigger happy triangle-removal portion of my code.
This is depressing, this algorithm shouldn't have taken more than a day to implement.

This quarter is going to kill me.
It's 0200. I can't maths, I can't draws, I can't programs. Therefore, I blogs. I should probably sleeps, though.
-Kev

Saturday, March 17, 2012

Dreams, Aspriations, and the Sweat of my Brow

Looking down from my precarious perch on my chair, it's evident I could probably use some more sweat of my brow and lose a couple extra pounds.

Regardless, I haven't updated this thing in a very long time.  That's in my coming "new quarter" resolutions. I'm doing a lot, and I want some place where I can, at least personally, see the progress that I am making.  Speaking of progress, an update on Capstone!
Screenshot of our current build
It's looking really good, especially considering where we came from.

Kinect is at almost 100% functionality, a few tweaks remain to be implemented before I'm completely happy with the result, but for now all of our base functionality is in. (Throwing, smashing, swiping and hitting)

The next steps would be to implement a combo system, and special moves such as the earthquake and tornado, the team also discussed some interesting ideas as to changing our background to be more interesting/interactive, I will keep you all posted on that.

Unfortunately (for some...?) I won't be nearly as content-heavy with my descriptions of what has been done, honestly the game has come a long, long way from where it started, and since my last update there is simply too much to cover.  I will say, however, that my current method of determining Kinect hands open/closed is about as straight up as a hack as it is going to get.  I'm currently using what I assume to be a "point cloud" system, which simply generates the points around a given model, image, or in this case "body part"

I have no problem in isolating the hands from the rest of the body, that's the easy part.  The tough part is quickly and cheaply reading all of this constantly updating data and determining: Hey, this is an open hand, this is a closed hand.  I also have to do all of this processing alongside whatever my game is trying to run.  Simply put, this isn't a very fun problem.

The Kinect, as I have previously mentioned, is event-based, or rather that is how we choose to use the Kinect.  As many headaches as this can create, it eventually saves on processing because we are only doing these operations when the Kinect is good and ready, and we don't have to keep asking it "Hey, are you ready yet?" Over and over.

Anyway, every time the Kinect shoots me a depth image I go into the quasi-lengthy process of running through segments of the depth map, checking for the relative depth locations from the hands.  This is opposed to my original system, where I built and entire group of "depth objects" based on the Kinect's depth image and then manually determine which segments are hands, feet, etc... Every. Single. Frame.

Good lord, what was I thinking?  While the Kinect's skeleton may not be entirely accurate, it has it's own processor and using the data it gives me is certainly much more efficient than trying to build my own skeleton, and while I may have been proud of my skeleton for being "mo' accurate" it didn't have any efficient means of determining joints and the like, and in the end it just wasn't practical.

Luckily I'm still using a little bit of that logic to get the hand point cloud I'm working with.  I don't know if it's really a point cloud or not, because at this point I'm simply tracking the max hand width/height and the number of points per line.

Points per line?  Yes, well, this is a cheap way of checking and seeing if "Hey, this line has 4 points" which registers as having a "gap"  If enough of these gaps are registered then the hands are considered to be "open"

Of course, that's not the extent of it, especially because the Kinect won't see fingers as being spread apart unless you really make an effort to spread 'em good and wide.  I do some checking with the depth values and if a depth drops a certain per-defined amount, then another point is added, this time classified as an "inside point"  These factor into the points-per-line which means if fingers are curled inwards, even though the outline may look like a closed fist, the inner finger-outlines are still (somewhat) registered.  However this only works on a horizontal axis, the lines read from left to right like a line of text, going vertically through the depth pixels add more passes and can be bad for the cache, not that what I'm doing is terribly cache-efficient in the first place, though.

The issue here is that the Kinect's depth values degrade over distance from the Kinect.
What?
Well, the distance from the tip of my index finger to my palm if I'm pointing at the Kinect is read differently if I'm standing right in front of the Kinect compared to me being 10 feet away from the machine.  My finger is not physically shrinking or growing with the depth (duh) but the Kinect's perspective is saying so, at least on the depth map.  I haven't found a precise and simple way to convert from depth-map values to physical values such as meters.  Granted, there are equations that MSDN provides to do the conversion, but I have not had good results from using those functions.  In other words, the problem persists after the conversions, possibly because I'm looking for very small distances and the equation is a distance approximation.
(The Kinect works in meters for skeleton frames)

Well, it's 2:30 and I have Judo tomorrow, so I should get some rest so I can get my butt whupped (...into shape?!)

But yes, the original meaning of the post?  I'm applying for internships and jobs, which is a nerve-racking and anxious project for someone who is not entirely confident in themselves.  It's the same story as asking a girl out for a date, or coffee or whatever you kids do these days.  It requires confidence and assertiveness.  Insecure and unassertive people know this, but there are severe mental blocks when it comes to changing their personalities, even if temporarily, to just drop the insecure and unassertive parts of themselves off at daycare and go have fun with the adults.  So I feel as if I am lying when trying to make myself appear hire-able material.  I'm not unintelligent, I'm not a sloth, when I work, I work hard, I give it my best efforts and I always strive to improve, but I know I'm not the best at anything, and that knowledge in itself has hindered me far more times than I care to count.  Just because I'm not the best doesn't mean I'm not good, but try telling that to my psyche.  I am, everyday, but it's an uphill battle.  I'll get there someday.  In the meantime I feel very awkward crafting a Resume and cover letter to make me stand out as "The best"

I feel as if job-hunting is a competition, and I don't enjoy competition, I am much more comfortable being friends with all, not trying to beat somebody out for something.

Okay, but for srs now, bedtime.

Have a good night (morning?) everybody,

-Kev

Stress test.  Yes, we have elephants.
Oh yeah, doodles.  Early morning roommate ambush!

Wednesday, March 7, 2012

Close Enough

Hey everyone (or rather, hey whichever single person decided to read this)

Despite my silence, I've been up to a lot.  Finals are in full swing after this week, I've got a few final projects to finish up, Zombie Yoga is unofficially at GDC and Capstone is... kind-of-sort-of coming along.  I just have one last Kinect tweak before I have it where I want it to be.  It's been like that all quarter, though, it's very discouraging.

One of those days...
I'm not in the mood necessarily for a full update, but a low-down wouldn't hurt.

In the past quarter, I have:

Modified Princess to be based on matrix-transformations for rotation, scale, translation, etc, the usual stuff, it was a long time coming since I first learned about the matrix representations of position and related information, but it made it into the engine.  We've re-worked the system slightly to better deal with destruction/creation (hint: in a managed language, try not to leave too much stuff for the garbage collector, be smart or the collector could cause your program to chug.  We weren't being smart before)

Finite state machines have been implemented, up next would be goal-oriented behavior and fuzzy logic, this is all straight-out-of-the-book stuff from the Game AI class I am taking.  Which, by the way, is a complete flop of a class.  I have never been so uninspired and frustrated by a class.  This is what happens when you take a curious mind and shove it in a class with a time limit, all of the interesting parts of the class are not covered because we "lack the time" and the only assignments we give are maddeningly frustrating because ALL of the base code has already been given, no fundamental understanding of the underlying processes are truly necessary or even gained because half the time I'm wrestling with finicky compiler errors from not having the correct includes, or perhaps because I'm busy trying to re-write all of classes I'm supposed to be deriving from because I want just a tiny bit of the base changed, and the hierarchy of classes is all too reliant on each other down the line to permit simply inheriting into a different class.
End rant about that, however.

Game Jam took place.. wow, almost two months ago!  Going in with friends made all the difference, and while I'm still not completely happy with the product of our game jam, we actually got a small game finished, and had we not had late night version control issues I'm confident our game would have been as polished as any of our competitors.  Regardless, it was a lot of fun making a game with guys that I respect and who's skills continue to impress me and make me strive to better myself.
GO TEAM JAM!

By now I've totally lost my train of thought, so goodnight, and goodluck with whatever challenges may be facing you, as I turn back to face the challenges of uncooperative code, lethargy, and the infamous Microsoft Kinect.  Away!




-Kev

Wednesday, January 11, 2012

Kinect Connect

So I haven't posted for a while, but that doesn't mean I haven't been doing anything.  Quite to the contrary, David and I have been pushing ahead full-throttle with the Microsoft Kinect.  For this coming quarter I am beginning my gaming capstone development project, which will take 20 weeks with two other team members, I am working hard on Zombie Yoga with David to get pose detection working, and we are going to jump into Game Jam at the end of this month to develop something awesome.

So yeah, a lot of games, a lot of work, and not much time to do it all and my homework.  Oh dear.
F*#k
Anyway, where shall I begin?  Where did I last leave off, anyway? Dang.

Well let's start with the Kinect, then.  Kinect in it's current state, or rather using the current SDK that Microsoft has released (The Kinect SDK beta) returns raw, unfiltered, and mostly really, really, really, really wonky data.






Like having a conversation with the Kinect
Now, to be fair, the Kinect is an awesome and amazing tool, and given what they have to work with, Microsoft has done a spectacular job.  I could sit here and grumble about the Kinect having issues, which is what a lot of people might prefer to do (the let's-rag-on-what's-popular-to-rag-on mentality) but the truth is what they have done with the input the sensor gets is phenomenal.
It's just not perfect like many developers would prefer, because that takes all of the serious effort out of our hands.  No, we have to do some of the tweaking and fiddling ourselves.


So what David and I have decided to do is kind-of-sort-of what the Kinect already does, brings together an infrared depth image and pair it with some bone data.  The Kinect software does the hard part and using the information it gets puts together a "skeleton" structure that represents a player's body.  The only problem is if my limbs go off-screen, or begin to cross, the Kinect just loses it's marbles and spends the duration of the limb-crossing by comically running around and bumping into tables while trying to collect the said stray marbles.

Now, for Zombie Yoga we want the Kinect to register poses, and the thing about Yoga is it's not all nice and planar, some of the yoga positions people can get themselves into are downright nuts.
Like cramming a monster into my homework assignment
Solution?  Take what the Kinect gives us depth-wise, split that into individual chunks of depth-based objects that know where they are in relative 3D space, and then check those against the bones that are whacky.  If where we think a bone should be there is an object of appropriate size at about the right depth we can tell the program "hey, this crazy bone-joint that is freaking out, it should go here)



That's the gist of it, anyway.  The actual implementation is going a little bit slower.  We are just about done with the code that checks out the depth image and comes up with a bunch of depth objects from said image.

Again, the Kinect and the SDK most of the heavy lifting, it scans the environment, picks out up to 7 players and sends back pretty darn accurate depth data pertaining to how far each player is from the camera (and not just the player, but every single part of the player, it can tell the difference between your nose and your forehead, which if you have a bigger nose like me isn't too impressive, but trust me)

Snakes in a Notebook.
Anyway, this part might be boring, but just how you go about extracting depth information from the depth image isn't as simple as just looking and saying "oh, look, there's my hand!"
It's easy for us, because we have eyes, but computers, like justice and awkward dates, are blind.



The trouble was being able to break apart one large image into a bunch of smaller pieces of data, without spending a whole lot of time on the image.  Basically, when a computer displays or processes an image it starts from the top left and goes through the entire image row by row.  Pixel by pixel.  That's how it has to draw.  While there are lots of "fancy" computer concepts such as multi-threading and other sweet processor behaviors, essentially a computer operates linearly.  Line by line, instruction by instruction.  One at a time.  It just does it awesomely fast.

Anyway, the problem is when you only get one pixel of information at a time, how do you, quickly and efficiently, begin to group pixels that share the same properties together when you only have information pertaining to the current pixel?

Through the power of dragons?

Well I'll skip all the ways my logic failed and give you the good version: As I run across "depth pixels" of a similar depth I keep track of the first pixel I saw that matched my depth description, and as we go across horizontally (how pixels are read, one by one, row by row) I keep track of the latest pixel that met my requirements.  Then, when I find a pixel that doesn't match what I was looking at, I kick that last line to an object that maintains a grouping of what I called "depth objects" and the line glues itself onto a depth object that the line is directly underneath, or it creates a new depth object that will be looked at during later passes.

So why is this good?  It sounds stupid, right, adding things on line by line?  And keep in mind, these can be short lines too.  When I go through a row of pixels I will probably find several different lines of different layer depths in the depth image.  Why just not look to the depth pixels immediately surrounding the one I'm currently looking at, and letting it create a depth object by expanding outwards and checking outlying pixels?

Several reasons: It doesn't maintain any sort of order, my depth-checking of an individual pixel just beings expanding out to the surrounding pixels, and how do I know if I've found enough? That problem is likely to also be recursive, which if you are checking nodes for pathfinding maybe isn't so bad, but in my case I'm checking a 320x240 depth image, which if you do the math is 76800 pixels.  That's a lot of ground to cover, and even when I do find the edges of this certain depth I want to check, how do I find the next place to start checking?  I may very well just be jumping around to random places on the image checking all the pixels in no particular order with recursion, running up how much stack space I have left.  And this is happening at about 24 frames per second, on average.  Sure, computers could handle it, but on top of running a game?  A 3D game at that? You might as well set your computer on fire as is.

So by just collecting information of lines and then sending the lines to sorting into their appropriate depth object we manage to build up an entire grouping of depth objects whose size and location match the different depth's seen on your computer screen when you boot up the Kinect Skeletal veiwer.

Wait, you can see it already? So why did we go to all that trouble?  Because the computer is going to have to look at that image every time the Kinect sends out an DepthReady read event (whenever a new depth image is ready) and it keeps track of only which depth pixels are how deep, not their mass or the average location of the mass, that's what the Kinect bone tracker is doing.. to an extent.  It's still gives crazy and weird data sometimes, which is why we went to all the trouble to do this thing.  And plus, it has given us some pretty crazy game ideas that you will see up here for game jam and my capstone project, so stay tuned!
Indeed.


-Kevin