Monday, September 22, 2014

I'm Not Dead

Hi!

It's been a while since I've posted, so here's my way of letting you know two things:
  1. I'm not dead.
  2. Neither is this project.
Right now I'm working on another project which is taking up a large portion of my time, as well as a few others... So many projects, ah! So, yeah, I haven't had a lot of time to focus on this project up until now.

Instead of doing more with layering, since layers are just a huge pain in the ass, I'll be making a post on my thoughts about how one would use my system to interpolate between all the many complicated facial expressions that the characters of the show express. To start off with, I'd like to go back to the mouth and muzzle - instead of having pre-made shapes, I'd like to come up with an algorithmic way to create the mouth which would involve sliders.

I'll be posting more about it soon!

Tuesday, August 12, 2014

Eyes Test 3

Alright, I've been struggling with figuring out how I'm going to do layers... I decided I'd take a break from that and focus on 3D stuff. By applying transformations to a 4x4 Matrix (and then casting it to a 3x3 Matrix), I can use it to give the impression that a shape exists in a 3D space.


Oh yeah, I also added in some code for doing gradients. Anyways, I've at least got those things out of the way, so I'll be focusing again on doing layers....ugh.

Friday, August 8, 2014

Layering - a Work In Progress

Hi!

Today I decided I needed to focus on doing proper, optimized layering, but unfortunately it's complicated enough that I feel I need to make sure I have everything written in stone before actually trying to do layering myself. For that reason, I've started a document describing my thoughts and ideas for how I might (and will) go through getting layering to work. It is a WIP, so you might actually catch me working on it in real-time.

Click here to view the document.

I also suspect this will take several days to get in order, which is why I'm posting now as apposed to later when I've finished everything. That way, you can keep an eye on my progress.

Thursday, August 7, 2014

Putting it all together - Eye Test 2

This is the result of everything I've done today. Hot dog, I got a LOT of stuff done today.


I still have a lot of work to do in order for this to be efficient and working properly. It might be necessary for me to do 3D vectors and 4x4 Matrices as well to get things like this eye test to work right, but THAT'LL BE FOR ANOTHER DAY, MKAY?

Parenting

Wow, I never thought I'd post this much stuff in one day.

I've whipped up a class called Entity that serves to contain shapes and other entities. It manages it's own attributes, such as rotation, shear, scale, etc... and can "recursively" draw to the screen in a layered manner similar to how Flash might.

I did a simple test where there's only two entities.
  1. The first entity only contains a red shape
  2. The second entity contains a hollow box, the first entity, and a green shape
I then performed the same test I did the other day with the matrices, but instead I did it on the second entity. The first entity does it's own thing, but is always affected by any changes done to it's parent - the second entity.


Masking - Take 2

Ok, I found a solution. My solution is to type-cast the masked layer's alpha array to contain values of type <type 'numpy.uint16'> instead of <type 'numpy.uint8'>, which allows me to multiply the values of the two alpha arrays without worrying about modulation since 255*255 (the largest value this could possibly produce) isn't bigger than nor equal to 2^16. I then divide the resulting product-array by the value 255, and then finally assign it to the alpha values in the masked layer.

        masked_alpha = pygame.surfarray.pixels_alpha(self.output_layer)
        mask_alpha = pygame.surfarray.pixels_alpha(self.mask_layer)

        new_masked_alpha = numpy.uint16(masked_alpha)
        new_masked_alpha *= mask_alpha
        new_masked_alpha /= 255
        masked_alpha *= 0
        masked_alpha += new_masked_alpha

        del new_masked_alpha
        del masked_alpha
        del mask_alpha


The result is beautiful.


The only complaint that I have about using this method is that since I have to type-cast the one array, the values have to be copied over instead of referenced, which can be SLOW. Even so, I'm very happy with this result since it performs perfectly and is relatively fast.

Masking - Take 1 Analysis

Alright, so I figured out the issue with the first solution. The problem is the values are of type <type 'numpy.uint8'>. What's special about these values is that they're modulated by 2^8, meaning the values wrap around whenever they get larger than 255 or less than 0.

I'll have to figure out a way to get around this issue.