Categories
Uncategorized

PhysX review

Last week I started integrating physics into my game. The two first two days I spent trying to learn Newton. Although straightforward, I dumped it because of a combination of outdated documentation, insufficient header file documentation, quirks, performance problems, poor forum support, and closed source. Every minor feature was a major time consuming issue and it just wasn’t worth hours of grinding to figure out why stuff as simple as acceleration = velocity * time doesn’t work. At the rate I was going, for my simple needs, I could have just written the physics from scratch faster.

Next up was a choice between ODE and PhysX. ODE was open-source which is a tremendous advantage over PhysX because if there are problems or something is unclear I can figure it out myself, rather than being at someone else’s mercy or just grinding my gears. However, PhysX used to be a commercial library which is now free for PC games. In my experience commercial libraries are usually an order of magnitude better than the free stuff. What ultimately decided me was the promise of a plugin for my 3D modelling program, and more confidence in PhysX meeting my performance needs.

Initially, I was overwhelmed by the amount of documentation and code provided in the SDK. However, after only a few hours I understood the structure of the system and found that it wasn’t that bad. There’s dozens of samples and tutorials, each of which is documented in a windows help file, which itself contains professionally written documentation covering the whole system.

At about the same time I investigated using NxOgre, a library to integrate the Ogre 3D graphics engine with PhysX. I found that PhysX was well enough documented and easy enough to use directly, while NxOgre was missing huge chunks of documentation and it was very confusing and unclear in those cases. I pretty much decided NxOgre was a solution in search of a problem, so dropped it and went with straight PhysX.

I first investigated the 3D modelling plugins. Unfortunately, they turned out to be buggy incomplete messes that were not up to production quality for a serious game. A programmer can use them perhaps, but they would never suit artists. So I was left to my own devices to come up with a physics entities exporting scheme. I wasn’t that upset about it, since nobody else has working plugins either, except Havok, which is half a million dollars + royalties. Compared to free, I’ll just write my own system. For my simple needs it’s only a day or two of work. This may be a problem for others though, especially if you plan to model physics based animation, ragdolls, or joints. If I were going with ODE instead, I could have potentially used the Sythe Physics Editor

As for the library itself, I made a lot of progress. In only two days I went from knowing nothing at all to being able to fly my ship around in the game. You can code straight from the documentation and to get started you don’t miss not having the source. Things generally work the way the documentation says they will, and I didn’t encounter too many problems where things just didn’t work and I had no idea what to do. Overall, PhysX is easy to use and well-documented.

Their architecture is based around multithreading, or offloading processing to a Physics card. This is a really nice performance feature because you take advantage of multi-core processors essentially for free. You simply lock the physics scene, send your inputs, and then unlock the physics scene. This is mostly transparent to the user, and I have to qualify that as mostly, because quirks do come up.

One quirk is that it’s very slow to do conditional evaluation of collision. For example, in my game I have force fields that only your own team can fly through. Other teams just bounce off as if they were a wall. It took me hours to figure out deal with their collision filter system to hack up a scheme to do this. Multithreaded callbacks are supported, but discouraged. The collision filter system uses logical operations with bitfields (that you set) to figure out what is collidable or not. I was able to get it to work with my scenario, but with more complicated games I don’t think it’s sufficient.

Another quirk is your updates are not immediately reflected. If I add rotational thrust to an object, and immediately check the orientation, the orientation will be the original, and not updated orientation.

The multithreaded quirks are understandable and as long as you know what kind of issues to expect they won’t be a problem.

I’ve used 3 major features of PhysX so far: joints, triggers, and the material system. These aren’t all the features, just the ones I’ve used.

Their joint system is good and easy to use for basic stuff. There is over a dozen joints available, including limit planes, springs, motors, breakable joints, spherical joints, pully joints, and 6 degree of freedom joints. As long as you stick to their samples you can get joints in your game very quickly. However, for more complex scenarios, especially with 6 degree of freedom joints, I was so confused at times I was about to have a nervous breakdown. This is one of those cases were the code would have been less confusing than the documentation because their explanations are very round-about, lack detail and precision, in some cases wrong, and the samples do things that just make no sense. It took me 3 14 hour days of grinding and head pounding just to figure out how to get an object to freely translate and at the same time be able to roll on one local axis.

Their trigger system is good. You can attach massless shapes to actors and then get callbacks through an interface. You can attach your own userdata to both the shapes, and the actors (which are made of ships). Because triggers are based on shapes, you can get triggers for not just spheres but all the kinds of physics primitives they support. I’m using their trigger system to maintain nearby object lists for network culling.

Their material system is very good. Unlike Newton, which only supports an explicit table, you can define basic parameters of a property (bounciness, friction) and then specify how that material interacts with other materials (add, multiply, smallest, largest, and others). You can also define a specific table if you want. You can also define what kind of materials collide with other materials, up to 32 types. So for example I have it so bullets do not collide with powerups, but spaceships do (so they pick them up). You can get callbacks for collisions as well.

If I have one major complaint with PhysX, it’s support. It’s free, so it’s not fair for me to complain too much, but at the same time I need to get my game done and busting my head spending 3 14 hour days just to get something to roll isn’t something I can afford to do too often. The forums have very little activity, and while I’ll give the admins there credit for trying to help, so far all their answers have been unhelpful or wrong and made me lose even more time. This is another case where I would have been better off going with ODE, since it has more forum activity and I would have been able to just look at the source. I’m not sure if paid support or paying for source code access is an option.

In conclusion, I think PhysX is worth investigating for the $75,000 to $1 million niche. At this level there’s enough money and time to make it worthwhile to figure things out, and performance, feature set, and quality are important enough lesser solutions can’t be counted on. Over 1 million, I would require real support and source-code (such as with Havok). Under $75,000, time is too important and I’d go open source (ODE) instead.

*** Edit ***

I was told that full-source and support are available to large projects. In this case, I think PhysX can be a good, much more affordable, solution to Havok and it is worth looking at both of them.

Categories
Uncategorized

PhysX Tip

I lost an hour because of inadequate documentation regarding how to update the simulation in PhysX. Here is a tip:

If your objects just won’t move, it’s probably because you are only calling physicsScene->simulate. For reasons which are not explained, you have to call:


physicsScene->fetchResults

then update your inputs

then call


physicsScene->simulate((float)(elapsedTimeMS)*0.001f);
physicsScene->flushStream();

Categories
Game Development

PhysX pretty good so far

I spent several hours looking over PhysX and NxOgre, a wrapper for PhysX to bridge the gap between the two systems. I also experimented with the modelling program plugin for PhysX.

Conclusions so far:

PhysX: Powerful, pretty easy to use, professional quality level. Documentation is wrong in some places but nothing to really kill my productivity. Code documentation is generally sufficient – again while there are holes, it’s not enough to kill my productivity. Overall it’s pretty much pleasant to work with and I’m making good progress. The only thing I don’t like is that it requires its own installer.

NxOgre: Very easy to use if you already know what you’re doing. Otherwise about 70% of the documentation is missing and it’s definitely not clear what to do in these cases. Coding quality is above average relative to other freeware stuff, but still not up to the level I like to work with. In the end, I decided not to go with it. This is for three reasons:
1. Unclear memory management. While it’s clear that NxOgre handles most memory management for you, I don’t feel very comfortable putting new calls all over the place and trusting they were handled correctly. The architecture pretty much requires you do this.
2. Unique name convention for objects. This is similar to what Ogre does, and is one of the biggest annoyances about Ogre. I don’t want to name every damn class I want with a text string, especially not if I have to constantly work to make sure it’s unique.
3. Overhead. The documentation and samples for PhysX are just much more clear and straightforward, with better documentation, and it seems relatively easy to use. I don’t see the point of using NxOgre except to save me time, and without clear documentation it won’t save me much of anything. Plus, if I’m going to use a library it needs to be written at a higher quality level than what I saw or I’m not going to trust that it won’t crash or leak memory somewhere.

Modelling plugin: A buggy terrible mess, with outdated and wrong documentation. It looks like it was written halfway, then abandoned. I’m going to just integrate with the exporter I already have and parse out objects.

Right now I have PhysX integrated with my engine and creating a physics scene. I look forward to seeing how fast I can get the ship flying around.

Categories
Game Development

Changing to PhysX

In the end, after another few hours, I got Newton sort of working. Sometimes thrust would stop working for no reason, until I died and respawned, usually. Sometimes it would stay not working. And I wanted to fix the location of the fighter’s shield to the fighter’s body, and that never worked. Also, doing the same simulation on the client and the server was less accurate than with my own code.

It took me 2 days to get Newton sort-of-working. It took me 15 minutes to rewrite my old code back in, as all I wanted was a rotating ship in space with thrust.

My biggest problem with Newton is that if something doesn’t work, you’re basically fucked. The forum is unhelpful, the manual is incomplete, the tutorials don’t help much, and there’s no feedback from Newton as to why. So even if I were to attempt to fix the problem of “Why does my thrust suddenly stop working, but rotation still works?” I have absolutely no idea where to even look, with no source code to rely upon. These kind of things take hours, where just writing my own system velocity = thrust / mass * time takes about 10 seconds and consistently works.

It also lacks in easy-to-use features. For example, people have asked for efficient trigger bounds in the forum over a year ago, and it’s not there. I tried using my own system with AABB collision boxes and Newton was so slow I gave up on that and wrote my own system, again in not much time, which worked perfectly and was O(1). I have no way to update a single entity given a past time and state, which I need for networking. I don’t have access to the physics octtree which I also needed for network culling. There’s no easy way to do explosions or springs, and it goes on and on. I could spend another day guessing and probably get everything working, until I run into the next problem, and then lose another day, and so on.

So PhysX is free for PC games now and I got a developer account with them. I’m going to read over what they have and see if I can make the switch in a day or less. The nice thing about them is
1. A lot more people use that than use Newton, so I can get better support
2. There is a plugin for 3D modelling programs
3. It’s from a professional company so I have a feeling the quality and speed will be much better.

Categories
Uncategorized

Integrated Newton Game Dynamics

I spent the last two days integrating the basics of Newton Game Dynamics physics with my game. It took about 2 days – in some ways easier than I thought, but due to lack of forum responses and incorrect documentation I also wasted a lot of time. Note to others: setting an angular velocity on an object that isn’t moving is ignored unless you unfreeze it, even though it doesn’t say this in the manual yet does for other similar function calls.

I got Newton integrated enough to have the fighter fly around and shoot bullets. My FPS went from 30 to 2 with as few as 10 bullets on the screen. I actually set all those objects to use non-collidable ‘materials’ with respect to each other, (or I think I did, it’s hard to tell with the poor documentation and closed source) so I don’t know what the problem is.

I’m going to debug and profile where the slowdown is coming from. I really hope the fault isn’t with Newton, because I’ve finally learned how to use it and don’t want to waste another 2 days learning something else.

As an aside, I’ve found that in general I have a far easier time with open source libraries than closed ones. For example, I just spent 2 hours trying to track down why my objects weren’t moving, while they were immediately before I checked in. It turned out a bad merge set my world size to have the same value for z on both the min and max axis – so all objects were outside the physics world. Rather than asserting, or returning false, Newton just silently doesn’t work. If I had the code, I could have figured out why in about 10 minutes, as opposed to nearly giving up and changing to PhysX.

Categories
Uncategorized

Destroyer concept

This is a concept for the smallest carrier in my game. It will be about 1 screen in size, about 20 ship lengths.
Destroyer

Categories
Uncategorized

Intangible business costs

When I first set out to start my company, I basically did the time calculation as follows:

w = Number of hours of work
m = Number of months I want to finish in
h = Number of people I have to hire.

The calculation is then simply
h = w / (m*hoursPerMonth)

Before doing that calculation, I actually doubled w, to account for time in beta. I also increased h a bit, to account for lost time to to communication, since programmers do not scale linearly, but inverse exponentially.

The final total was about 4 months for 3 people. This was about 50% on me, and 25% for each of the other two programmers. I didn’t account at all for things I considered to be trivial / intangible – billing, hosting, finding artists, setting up a server, finding tools for communication and development, time off (just assumed a 4 month crunch), delays due to sickness or hardware failure. It wasn’t that I didn’t know about these things, but that I considered them to be too trivial to schedule. My concept was “How long could it possibly take to find, do, or manage [x]? Just post an ad (or do a web search), interview a few guys (or read a few websites), and go with it.”

In the optimal scenario this is actually true. The problem is that the world is filled with people who have nothing better to do than waste your time. This ranges from hosting services that take your server down without warning, to Linux programmers that don’t even know how to open files in windows, to people that spend weeks discussing a project only to ask for 4X more money than is reasonable.

So each of these steps of running a business become very time consuming, and there isn’t always an easy way to tell the difference between the guys who are wasting your time, and those who are not. For example, if I want a quote on my art assets, I really need to spend a lot of time explaining the contract every time, because no matter how detailed my asset list is, people will not understand or appreciate certain aspects. This is especially true if you are trying to save money (as I am), because at the low end of the totem pole there’s a lot higher noise to signal ratio.

As a result, I’ve learned to appreciate the value of businesses beyond the amount of intellectual property they own. Each programmer represents not just any dude off the street, but a long, careful, and expensive search both to find and retain a worker. Making a new programmer productive costs about that much again, when you account for the months of initial downtime required to train someone to really be productive. Getting a working setup and source control reflects many hours of work, from setting up the server, to finding a reasonable host, to purchasing the license, to training everyone how to use it. Having a team handle your art outsourcing takes many hours to find a qualified team, one that can do the job cheaply, setting up communication channels, explaining the requirements (including documentation), and sweat and worry that you might get ripped off anyway.

My initial schedule of 4 months with 3 programmers is now 6 months with 4 programmers (double the man hours) and even with that I don’t think beta will be long enough, and time is of the essence. Half my time currently goes towards intangibles. Tasks originally assumed to be trivial (a few hours) sometimes end up taking weeks. And other problems come up, such as sick time, people quitting, and bad hires. For example, nearly a month of productivity was lost in the first two months just from dealing with bad hires.

My advice to would-be game companies is to add 3-4 man months on to the total schedule to account for these kinds of things.

Categories
Uncategorized

Aria Billing Service

Yesterday a friend and I spent some time talking to Aria Systems, a company which specializes in billing systems for games. Basically, they provide the webpage by which users can pay, they handle the payments, and they pass the result of the transactions back to the customer (me). The good thing about this is I then do not have to get a secure webpage and handle these things myself. Although admittedly it is not that hard – I’ve set up this billing system before and it only took me a few days, even with recurring billing. I just like the security of knowing that a 3rd party is handling this, so I am protected from credit card fraud, webpage issues, etc.

The bad thing about this is how much they charge – the setup fee is $1500, even for the most trivial case (such as mine – just a flat monthly fee). They also take 2%, in addition to what the credit card providers themselves take. This will amount to over $1,000 a month and would only get larger as the game gets more successful. This 2% does not go down until you take in a million dollars a month, at which point it goes to 1.8%. That seems pretty outrageous to me. 2% of a million a month is $20K a month, just to have your billing processed by a 3rd party. For 20K a month I could hire a team of 3 guys full-time and host my own servers, and I doubt it will take that once the initial systems are written.

Anyway, I’m willing to go with that, except for one part in the contract I’m seeing if I can negotiate out. They want a 3 year exclusive deal to provide this service. What I said to this was:

I’d like to add “This agreement may be terminated by either party at any time, with or without cause, with 3 months written notice.”

With this change I can agree to the exclusivity agreement. Without this change, if Aria were not able to compete on merits in the marketplace, I would be locked in to providing my customers with less than the best possible service. If you’re confident that Aria is and will remain the best provider of billing services, then there shouldn’t be any problems and I will have no reason to switch.

It seems ridiculous to me that they even ask for this. The way to keep my business for 3 years is to provide the best service at the best price for 3 years, not to force me into the service without my prior knowledge of how good the quality is. I have a feeling the reason for this is what I was saying above – at my initial levels of sales, it’s cheaper to pay them than it is to hire my own guy and do it myself. At higher levels of sales, only someone with no other choice would pay their prices, which is what I think they are counting on.

Their responses to my initial emails only took minutes to get returned and its half a day now with no response to my last one. While I could be wrong, there’s a good chance I’ll never hear from them again. And that’s fine with me. If a company themselves do not feel they can compete on the merits of price and service, then I shouldn’t feel that way either.

*** EDIT ***

They got back to me a day later with an OK.

Categories
Uncategorized

Going with Slovakia

In a surprise twist, the company in Brazil turns out not to have any people with game art experience. I asked a friend who has his own company how important this is, and he told me “Very” so I dropped them out of the running. Between the company in the US, headed by the former WoW guy, and the one in Slovakia, I just decided to go with the latter. This is because I just am not confident that the game can get done with what is basically 1 1/2 guys working at half salaries for 4 months as a favor to a friend. I’m guessing it’s a 50/50 chance in that scenario the guy would just drop out or not put enough effort in, and the game either wouldn’t get done or wouldn’t get done right.

The more I think about this, the more confident I am it is the right decision.

First, with the 1 1/2 man company working on the cheap, if there’s a problem and something takes longer than expected, there’s only two possible outcomes – it’s late or features are dropped. There’s no profit margin to cut into to hire extra guys, and with so few people they are already working at 110%. With an established company, guys can be moved from other projects and the art can still get done on time.

Second, with the 1 1/2 man company, the people who will be working are unknowns – sure there’s a certain level of reliability when hiring people you know and trust, but at the same time it’s not like they are established in the job. There are growing pains, and they may only be taking the project conditionally, until they get an offer they can’t refuse. People are much more likely to leave on a new, low paid, temp project than from a company they have already been working at and living off of.

Third, 1 1/2 people is so few people that if one guy goes down, so does the whole team. With a company, there are extra workers, computers, backup power generators, etc. – basically factors to deal with one person or computer going down.

Lastly, it’s the choice between two bad alternatives – having the game done at a worse quality, or not at all. The worse art quality will at most cost me some percentage of subscribers, which I doubt will be significant. All I need is the art to be good enough to get people to notice the gameplay. The other alternative, not having the art done at all, is guaranteed to cost me 100% of subscribers. So in that context the choice is obvious.

Categories
Uncategorized

Art bidding down to 3 companies

My art bidding process has narrowed down to 3 companies. I’m really not sure who to go with.

The first one is in the Slovak Republic. They want $30,000 for 4 artists for 4 months. This sounds like a great deal and I was going to move forward with it. But they sent me some sketches that show they totally ignored what my asset list specified, which is that I’m going for a believable military look. The reason this is such a major problem is that if they are making such fundamental mistakes that even I can see it, what kind of mistakes will they make for things I can’t see, and will just get a bad looking game? For example, maybe a poor choice of a color scheme, or bad contrast between the background and the ships. If I was already an artist it would be OK but I have to really entrust that the company I go with knows what they are doing and I didn’t see that here.

The second is the guy who was on World of Warcraft. This is $30,000 for 1 1/2 artists for 4 months, plus himself directing. From talking to him I can tell he understands the requirements and isn’t going to screw up direction, the way the first company might. Plus he wants to work for me after my game ships, and it would be great to have the same guy doing both pre and post release art direction. My major concern is that I only get 1 1/2 artists to do the work that other art companies have been estimating between 2 to 4 artists. This kind of estimate cuts no slack at all – if it turned out halfway through he thought it was an undoable amount of work, I’d be stuck high and dry, where with a bigger company, where I had slack to begin with, they could assign more people. Even if he refunded my money, which I doubt would happen, I’d be behind schedule and it would kill me in other ways.

The third is a company in Brazil. They’ve quoted $30,000 for 8 man months of work, done over a period of 4 months. That’s actually not a very good deal. Even a top-notch artists in Brazil makes about $2000 US a month, and I’m being charged double that. On the other hand, they are very professional and they’ve clearly done high quality work for major companies. If their estimate is accurate (2 guys for 4 months) then I could just as well go with the company in the US and avoid the time zone and communication problems. I’m also concerned that they are taking a literal interpretation of my asset list. While it covers most of what my game needs, it’s obviously impossible to think in advance of every possible effect my game might have, especially since I don’t plan to do the art direction myself.

I wrote back to the third company clarifying what I need. If they are taking a literal interpretation of my asset list, or they misunderstood the amount of content I wanted, I will go with the second company. If everything was clear I’ll probably just go with them.