SQUARISM addicted to pixels

Elevator Sim update

Posted on June 21, 2009

elevator_sim_2
Quick update about the elevator sim post. Currently the cars are animating fine. IE: you press 3 and car #1 goes to floor three, stops, opens the door and waits. If you press 1, the car closes the door, moves to floor 1 and opens the door. The building controller is aware of the care state as evidenced by the little labels you see.

The person sprite (on that line there) is currently a placeholder. He paths over to wait for the elevator but I don't have the "AI" done for him to wait.

This has lost a bit of traction since I've been cranking on the iPhone class.

Filed under: Blog No Comments

Parallax Clouds

Posted on May 6, 2009

paraclouds

Updated this a bit. Added sound, scanlines, mouse following, bird sprite thing. Made a few performance tweaks. It still runs a bit slow, it's better under OpenGL but you can't embed it in a web page. The code is from a while back and I just polished it a bit so the source is fugly, fugly, fugly. I like the tune though. The ableton live demo has turned into a musical idea notebook and a short idea is all I seem to grind on.

The music is original (no samples).

View it here.

Download here - Mac, if you want to run it fullscreen.

Filed under: Blog No Comments

Elevator Sim [wip]

Posted on April 26, 2009

Car idle:
elevator_sim_wip_1

Car called, doors open.
elevator_sim_wip_2

Some shots from a work in progress. Elevator simulator. People are going to get on and off and ride the cars down. It's an exercise in 3d, queuing, event detection (without using events) and a boat load of other stuff. It's coming along nicely. The car motion is really convincing.

Filed under: Blog No Comments

OpenCV in Eclipse

Posted on April 5, 2009

I was getting a weird runtime error about native library something in Eclipse while messing around with OpenCV (using Processing.org).
!!! library OpenCV not found
Exception in thread "Animation Thread" java.lang.UnsatisfiedLinkError: capture

I found the answer was to configure native libraries in my project. This is something I've never done in Eclipse so I thought I'd post it in case someone googles this error message. First, I set up my project like the following. Notice that I created a folder named "native". I moved the shared library files (.dll, .so, .jndilib) into this folder. I am on a mac but I moved the DLL files anyway.
opencv_eclipse_1

Then I went into my project properties and set the Native Library Location as this folder. Viola. The processing applet launches.
opencv_eclipse_2

Filed under: Blog No Comments

Triangle Building

Posted on April 3, 2009

triangle_building_1
I got distracted while working on an actual game and started messing around with image recognition. I was greatly inspired by the LevelHead tech demo and thoroughly depressed by Julian Oliver's talent. I started messing around with OpenCV and wanted to track rotation of objects. I figured out that a triangle would be the best way to track rotation because a right-triangle is unique when rotated 90º four times.

So the magic triangle again. It seems it has endless uses. I started trying to draw one programmatically. But my trig skills are lacking and I needed to create a test program. My math didn't work out that great so I asked yahoo answers. Someone named Mathmom28 answered my question perfectly and the above sheet of paper shows the end result of her answer. It's a bit disheartening to be relying on a homework forum for answers from "Mathmom28" but I don't think I'm going to pass judgement on my superiors. Suddenly I feel like I'm in high school again.

The magic to this madness was a formula she posted which is something I've since long-forgotten: the point-slope form of a line. A line 90º perpendicular to another one is it's negative reciprocal. In other words, y = 3x/5y at 90º is y=-5y/3x. Once I got that, it was cake to finish something that's pretty polished.

Try out Triangle Building. The instructions are at the bottom of the screen.

triangle_building

Filed under: Blog No Comments

Boom Threads

Posted on March 10, 2009

boomthreads_sshot
I was messing around with threaded drawing. I really don't know how much of an advantage this gives. I needed to figure out a way to animate something on the side for performance gains. I think this is how I'd do it (not with 78 threads running).

I did see a ton of threads created though. You can see below out of Activity Monitor. Each of the boxes displayed is a thread that draws itself. They all maintain elapsed which might be a design flaw. I couldn't figure out a way to sync the drawing to all the threads running by themselves.
boomthreads_threads

Animation is done with timeElapsed in mind. That's so it runs about the same on fast and slow computers.

Hit the link here to check it out: BoomThreads

UPDATE: I was thinking about this and this is not actually accomplishing any threaded performance gains. It sequentially calls draw which doesn't thread the drawing itself. I need to take out the random waits and have it look like this. Right now, there is artifical randomness (which is why all the boxes move at different speeds). I'll update this soon if drawing can be threaded.

Filed under: Blog No Comments

Linked

Posted on March 25, 2008

I just finished a book called Linked. It's a book about network theory and covers a wide variety of topics very quickly. It's not incredibly long but I found it very interesting just because of speculation I've done over the years.

Sometimes, I've wondered if the patterns I see in some subject translate (either by divine will or mathematics) into other subjects. For example, if the 80/20 rule applies in software, does it apply to business or biology or anything else? The author covers these kinds of things in a much more journalistic approach than my everyday speculation and casual daydreaming could. It was reinforcing in a way.

Towards the end of the book, the author has a diagram of a three-point triangle. He relates the node map to society and members of society as connectors and hubs. The chapter covered topics like infection and how certain hub-people will transmit disease faster than others. It's a bit more complicated than how I'm summarizing but the diagram caught my attention none-the-less. The author started with a node and then added nodes recursively (whether he knew it or not). So I fired up the processing.org program and tried to draw what he had made but make it configurable with depth. Here's the result, was fun.

The depth goes 1,2,4,8. After that it becomes a white mess.

linkedRecursion1
linkedRecursion2
linkedRecursion3
linkedRecursion4

int scale = 100;  // size of initial triangle
int w = 500;
int h = 500;

void setup()
{

  background(40);
  size(w,h);
  noStroke();
  smooth();
  noLoop();
}

void draw()
{
  drawHorseshit(w/2, h/2, 9, scale);
}

class tri {
  int ax;
  int ay;
  int bx;
  int by;
  int cx;
  int cy;
}

void drawHorseshit(int x, int y, int depth, int s)
{
  fill(140);
  stroke(255);

  stroke(255,5);
  line(0,y,w,y);  //horizontal line
  line(x,0,x,h);  //vertical line
  stroke(255);

  // interior lines
  tri outline = new tri();

  //center
  ellipse(x, y, s/4, s/4);

  //top
  ellipse(x, y-s, s/8, s/8);
  outline.ax = x;
  outline.ay = y-s;

  //right
  float ra = s * sin(60);
  float rb = s * cos(60);
  ellipse( (x-rb), (y-ra), s/8, s/8);
  outline.bx = (int)(x-rb);
  outline.by = (int)(y-ra);

  //left
  float la = s * sin(60);
  float lb = s * cos(60);
  ellipse( (x+lb), (y-la), s/8, s/8);
  outline.cx = (int)(x+lb);
  outline.cy = (int)(y-la);

  stroke(255,50);
  line(outline.ax, outline.ay, x,y);
  line(outline.bx, outline.by, x,y);
  line(outline.cx, outline.cy, x,y);
  stroke(255);

  if(depth > 1) {
    depth--;
    s = s/2;
    drawHorseshit(outline.ax, outline.ay, depth, s);
    drawHorseshit(outline.bx, outline.by, depth, s);
    drawHorseshit(outline.cx, outline.cy, depth, s);
  }

}
Filed under: Blog No Comments

Macbill Intel

Posted on April 12, 2007

macbill intel
No credit go to me, everything goes to Macbill. I couldn't get it to build a ubin for the Macbill source and I couldn't find one anywhere.

So here's Macbill for Intel.

Filed under: Blog No Comments

Upgrade fest.

Posted on April 10, 2007

Following an upgrade guide on gentoo's lovely doc site. GCC was majorly out of date (3.3 to 4.1.1) and hopefully you can still read this after all is said and done.

Right now, apache is in a weird state and I need to emerge a ton of crap:

# /etc/init.d/apache2 restart
* Apache2 has detected a syntax error in your configuration files:
Syntax error on line 6 of /etc/apache2/modules.d/70_mod_php.conf:
Cannot load /usr/lib/apache2-extramodules/libphp4.so into server: libXrender.so.1: cannot open shared object file: No such file or directory

Need X11 and a million other things put back on. Cobwebs from leaving it alone for so long.

Filed under: Blog, Unix No Comments