Archive for September, 2008

Ahhh….better

author Posted by: whaledawg on date Sep 29th, 2008 | filed Filed under: general

So last friday I was once again trying to psych myself up for a day of pouring over obscure file processing code when I realized something. This game engine could be broken down into the following parts:

  • Core services(message routing, drawing, error handling)
  • Utilities(3D math, actors)
  • Networking
  • Physics(collision detection, friction)
  • Tools(for making an actual game)
  • File IO
  • User Interface(keyboard input, minimaps and the like)

Why am I killing myself doing the least fun all in one chunk? File IO is important but it doesn’t have to be finished before everthing else.

So I am taking a break from .OBJ files and I’m cracking the UI. And it’s the best decision ever, I’m actually having fun again. Imagine that.

The only problem with the UI is designing it showed me how weak my message routing scheme was. Basically I had a class that processed the windows messages with a giant switch statement(another obscenely over complex code leviathan I’m forced to deal with) and it called a series of pure virtual functions(OnCreate, OnDraw, OnMouseClick and the like).

The user was expected to extend this class and over ride those functions to do what he wanted. Which is great, if all of your game will fit in one class. If you want to have different classes handle different events though you were out of luck.

So I changed it to be more of a “message router” that various “message handlers” register with. Everyone who can handle a mouse event and tells the router that he wants to get them will recieve the proper notices.  Yes, I copied Java. But if it ain’t broke…

Fucking C Programmers

author Posted by: whaledawg on date Sep 25th, 2008 | filed Filed under: general

So I’ve been working on my project for about a month now. Maybe 5 weeks. That’s 5 weeks at 40 hours a week, a pretty hard core time investment. And I’ve spent the last week, 20% of it, trying to parse a god damned .OBJ file. Fuck me.

And you might think that after investing this much time in understanding one file format I’d stick with it. I could get my engine to use the same files and just add a few new lines to represent my stuff(physical properties and the like). But writing something to parse this crap once tells me how poorly designed a file format it is.

A good system, game engine, file format, database or whatever, keeps you thinking as high up as possible for as long as possible. That’s why XML is so popular, you define everything by the rules of the shcema. I don’t have to think about the rules, they’re allready defined. That lets me concentrate on my data, the ‘high minded’ part.

With these old file formats I’m constantly thinking about the rules. When can you use a negative index? Is there a default material? Do I have to look at the material before I look at the .OBJ file, and how do I do that if the material file is listed inside the .OBJ. There’s too many valid ways to do the same thing and they involve too many unrelated sections of the file.

And why would they make a file format like that you ask? C programmers. Those mesozoic mother fuckers. See, to guys who wrote programs that parsed FAT12 any ASCII file seems simple.  And if the format updated or added new features they just spent days wading through code to find out where/what needed to be changed. As long as they had a human readable file they were happy to do it.

So now I have to deal with their poor design choices. Fuck me.

Blurg

author Posted by: whaledawg on date Sep 17th, 2008 | filed Filed under: general

Well I figured out the problem with determining a colision with an arbitrary plane.  The formula for a plane on one of my sources was given as:

Ax + By + Cz = D

Which means:

Ax + By + Cz - D = 0

But the other one of my sources was using the formula:

Ax + By +Cz + D = 0

Blurg. Almost the same, but just different enough to cost me half a damn day. That’s what happens when you mix and match definitions on the internet. :/

My Hate Has Made Me Strong

author Posted by: whaledawg on date Sep 17th, 2008 | filed Filed under: general

So I was supposed to get to work on the file handling stuff yesterday, but first I wanted to do a quick and easy physics simulation with a bunch of bouncing balls in a box. But I didn’t want to use the XZ plane or the XY plane as bound, I wanted to determine a collision between an arbitrary plane and a point.

Which apparently no one has ever had to do ever because there’s no simple procedure on the web describing it :(

By combining this method of getting a plane equation from three points with this formula for point-plane distance I should be able to do it. But it’s currently not correct and really hard to check a formula that you don’t understand :/

On another note, picked up The Force Unleashed last night. All the criticism, totally true. The targeting is wonky and your toughest opponent is the camera. But in spite of that I do love this game. It’s fast, it’s fun and it’s the fulfillment of every nerd fantasy that doesn’t involve a vagina(interestingly, not that many do).

Mainstream Stars Wars fans who pick this game up will love it. Those of us who played Jedi Outcast know that a better version of the same premis was made 8 years ago, but this game still has it’s place.

Where to begin

author Posted by: whaledawg on date Sep 16th, 2008 | filed Filed under: general

No posting for a while because the project is going well. I’m at the point where it’s time to start dealing with(ugg) files.

There’s a relatively simple solution for 3D file formats, the .OBJ. It’s text based so it’s almost human readable and other 3D tools readily export in it’s format. It’s just a series of verts, normals, texture coordinates then faces. Basically like this:


# this is a comment
# Here is the first vertex, with (x,y,z) coordinates.
v 0.123 0.234 0.345
v ...
...

#Texture coordinates
vt ...
...

#Normals in (x,y,z) form; normals might not be unit.
vn …
..

#Each face is given by a set of indices to the vertex/texture/normal
#coordinate array that precedes this.
#Hence f 1/1/1 2/2/2 3/3/3 is a triangle having texture coordinates and
#normals for those 3 vertices,
#and having the vertex 1 from the “v” list, texture coordinate 2 from
#the “vt” list, and the normal 3 from the “vn” list

f v0/vt0/vn0 v1/vt1/vn1 …

Easy to understand and process. But obviously my game library will need to have more information than just the polygons for most objects. Does it move? Does it have mass? Do other objects bounce off it or clip right through it? If they can’t move throught it what are it’s dimensions? So the questions becomes, how do I represent that?

The way I see it I have 3 options:

  1. Simply tack my information onto the end of the .OBJ with a new pattern.
  2. Place my information into .OBJ comments so it’s still a valid .OBJ file.
  3. Make my own file format from scratch.

I think I’ve talked about design principles before, that your pillars are simple, efficient, and elegant.  Effieicent isn’t that big a concern with file formats(getting it off the disk is never going to be the run) so lets concentrate on the others. Option 1 is simpler than 2, but 2 is more elegant. It’s nice that my files are compatible with a general standard. Or are they?

By burrying my propietary information in the comments they fake compatability, but is there a requirement that comments be treated a certain way by programs that use .OBJ? Not really, other than to ignore them if they find them. That means I could open up my faux-OBJ file with 3DS Max and change it’s color, then save it only to find it erased or moved my comments.

It’s actually very complicated and inelegant to try and hide new data in a standard not designed to hold it. Bad idea.

So that leaves making my own file format from scratch. I’ll be doing something XML based(simple and elegant). Sure this means I’ll have to make some tools for editing/combineing my files with .OBJ files but it’s not a huge amount of extra work and it’s worth it to have files that actually fit a standard instead of almost fit a standard. That never ends well.

Chrome

author Posted by: whaledawg on date Sep 10th, 2008 | filed Filed under: general

 

 

 

So I’m writing this post in Google Chrome and while it’s mostly an excuse to procrastinate from my very important project, there are a couple of things I can say are awesome right off the bat:

  1. It’s such a minimalist design. There are so many options for skinning and configuring Firefox I forgot how little interface a true web browser actually needs. Beautiful.
  2. It’s a very smart install. You download a tiny file that downloads the rest of it and imports all your settings autmatically. And then it’s installed into your application data! That means you can install Chrome on machines you don’t have administrative privileges on!
I’m not going to be switching anytime soon, Firefox has too many useful plugins ready to go for it(especially diigo, I couldn’t live without that). But Chrome is nice, and as soon as they have some kind of plugin emulation system I’ll probably make the move.
Note: As I was writing this Chrome had a crash with shockwave(trying to upload a picture with the wordpress tool). Which sucks because it shouldn’t have crashed but it’s awesome that it stopped it internally and didn’t bring down the whole application. 

My tears for PC gaming could fill an ocean of sorrow on a world of grief and sadness

author Posted by: whaledawg on date Sep 7th, 2008 | filed Filed under: general

Smashed ComputerWhy, you might ask, am I posting now instead of shredding Bright Wizards like Mexican pork in WAR? Because I woke up at 6 a.m. this morning to fire WAR up and have yet to play for 60 minutes total.  Some of the problems are on Mythic, too many people and not enough servers. I can only get onto European servers and my ping’s bigger than an average mortgage payment. Disappearing/reappearing everyone is less than immersive.

But on the other end of it, I had to upgrade my graphics card to play. I got a decent deal from NewEgg(I love them) on a GeForce 9600 GT made by BFG. It’s not top of the line, but it’s $85 and gets the job done. Like a thai hooker.

Except that it only gets the job done when I can boot up, which is 1 out of 4 times. And that’s if I unplug all my USB devices. And after I figured out to connect the cards power to a 6 pin molex instead of 2 4 pinners with their adapter. That was about 4 hours last night.  Oh, and about every hour or so my screen goes blank and my comp goes all Awakenings anyways.

So in summary, I’ll spend about 10 minutes trying to boot up(cycling the power helps, which means crawling under the desk for the process). Then I’ll spend 15 minutes getting into the game, then within a half hour I’ll either get a connection drop or my screen goes to black with a graphics card failure. So I’m actually spending more time trying to play then actually playing.

And I think that sums up PC gaming in a nutshell.
While I don’t blame Mythic I think this does not bode well for them. I’m probably in the top 10% of gamers in terms of PC knowledge[1] and I don’t even want to play their game anymore. Yesterday I was practically masturbating at the thought of getting into WAR and now I’m wondering if Too Human is better than it’s reviews.

Now as Raph has pointed out, PC gaming isn’t going anywhere. But if you look at what’s selling it’s not the MMOs, RTS, or FPS games. It’s the casual games. Not because people don’t want to play hardcore games on the computer but because they want to play on the computer, not with the computer.  Until either the game makers get wise to this and tone down/standardize system requirements or PC manufactures make hardware stable and compatible enough that everything is truly plug and play[2] I see console games gaining more and more territory.

[1]while admittedly toward the bottom 10% in terms of PC spendage
[2]why on earth do I still have to open up my PC and put components into a standardized slot and hook up extraneous power cables. if I can slide a blade into a server rack I should be able to slide a PCI-E component in from the back of my machine.

Programmers vs System Engineers

author Posted by: whaledawg on date Sep 5th, 2008 | filed Filed under: general

Code MonkeyAn important part of my project(any project) is documentation. Toward this I looked at quite a few documentation systems and decided to go with Doxys. It’s an extension of the open source Doxegen, but they fixed the HTML output. Doxegen tended to make massive, hard to read pages.

The problem is the guy who wrote Doxys is a programmer. Programmers see a problem and work from the ground up to fix it. Since Doxegen is open source the author was able to get right into the code and make the output exactly what he wanted. Which is good, right?

Except that Doxegen can also output in XML. A system engineer would have looked at that and seen how much easier it would have been to write a program that parses the XML and outputs the HTML from that. Let Doxegen do the heavy lifting and your program can work on the actual problem, hard to read HTML pages.

I admire programmers(I obviously consider myself one) but this mini-asperger thing is probably the biggest problem in software engineering today. Guys with incredible knowledge build programs to do a job and then when the job shifts slightly or there’s a problem with it the team has an impossible time fixing it.  A little forethought would have made Doxys a force to be reckoned with. Put a web interface on an XML parser and you have the greatest documentation tool out there.

Instead you have a slightly less annoying auto documentation system. Which would you rather have your name on?

Note: I’m not mentioning the author by name because I really do appreciate his tool and am thankful for his work, but it just could have been so much more

OO vs Functional

author Posted by: whaledawg on date Sep 4th, 2008 | filed Filed under: general

As I’m designing my project  I’m running into a main flaw of Object Oriented Programming. We think functionaly.

Or at least we do when we build something in incriments. We don’t think “I need an object to do this, one to do that, etc.” We think “I have to do this, then I have to do that.” That leads to classes that are little more than collections of functions. We’ve essentially ignored all the elegance of OOP and written functional code with a funny naming convention.

Now if I was building the whole thing at once, thinking in terms of classes and inheritance is much more natural. But I can’t think that way unless I know exactly what I want to build, and since I’ve never done this before I can’t.

So essentially you can’t build a good OO system until you’ve built a bad OO system for the same task.

Fuck me.

What does War mean to you?

author Posted by: whaledawg on date Sep 4th, 2008 | filed Filed under: general

I know this is getting a little heavy on the WAR side of things, but this is pretty good:


What does WAR mean to you? from Stone Falcon Productions on Vimeo.