Friday, June 24, 2011

Send report to Microsoft?


You might expected another "water tutorial". Excuses. Already wrote the text (a month ago actually), but I'd like to have some water pictures with it. I'd like to finish some maps first. You don't show photo's of your grandma when talking about your new girl either.

I got some other pics though. Sergi started producing various models. So while I was stinking in bed, he made an old computer, a lamp, comfortable bed, and a barrel. What kind of game doesn't use barrels?! Doom, Double Dragon, Halflife, Crysis, Final Fight, Donkey Kong. Except for Tetris, every game should have barrels. Especially the red explosive ones. A game without barrels (and crates) is like beef without beef.

To help the modeling guys, they finally got a working editor. This tool can import meshes, and render them in a test environment with the same graphics we use in the real game. As a little bonus, you can toss around objects to test their physics, and test the impact. Impact effects are collision, scrape, roll and spin sounds, particles, splat decals, bullet shots, et cetera.


Deployment my ass
Getting it to work on another computer wasn't so easy. I never had ATI videocards or a 64-bit machine, so the Editor went to unknown, possibly dangerous, territory. The very first issue was a mysterious "Runtime error 217". It seems to happen before the creation of any form, and the application just stops. Grumble!! Checked the DLL's dozen's of time with Dependancy Walker, but finally it turned out we had a "Millennium bug". Sort of. Sascha mentioned something about date function problems. The Delphi(7) function "strToDate('01-01-1900')", called at one of the unit initialisations, was making havoc indeed. What, not a valid date @#$%@#... my great grandmother was born in 1896 or something (married Julius Caesar, lived in a dolmen, and fought in the Eighty Years'War).

Now it works, and surprisingly it didn't produce tons of shader-compiler-errors... at least not on the computers with modern nVidia cards. One of the many programming horrors is to make your app "multi-platform". Yeah sure Java, OpenGL and the likes claim to be multi-platform, but in practice every PC is different. Even when using the same operating system. Conflicting security rights, hardware, Windows service pack version, screen resolution, component XYZ installed or not... It's a mess.

Any programmer should know that your program isn't finished as soon as you say "it's finished!". On your dev-station maybe, but you'll be amazed what kind of (stupid) errors will appear as soon as you deploy your hard-work on a customer computer for the first time. "Array index out of bounds... cannot open file... Hey... that's strange... Normally that doesn't happen.". Yes admit it, you said that more than once!


Congratulations, you have been selected to become a Beta tester!
That's why I try to delay my releases usually. Keep testing, add logbooks, and make use of those "try - catch" statements. If something goes wrong -and it will-, you can locate the cause somewhat better. At least try to give the client the impression you got it all under control hmm?

But yet, if you don't have extensive testing capabilities (thus 30 different computers including one with coffee spilled on it, and another one completely screwed up by porn websites), you got to move on at some point, and hand it over. For one thing, you are not a proper beta-tester, as you know how to use your own system unaware. You won't be hitting buttons 10 times in a row like a monkey, you don't click the cross while you should click "save". But don't underestimate the "stupidity" of your clients when it comes to using your software! They will produce fault-reports like Beethoven can write symphonies. Professional program-crashers as they are!

In other words, you'll need customer feedback to create stable software. Therefore it's wise to hand over your "Beta" version first to a few trusted persons (with a lot of patience!), before throwing it in the public. The problem is, the average user will stick to his/her first impression. If this first impression is "Access violation at address FF01234", they won't trust your software anymore. Even when build 4.0g12 is rock solid. First make sure it works as desired for a few test-persons (make them feel good about theirselves by telling they are specially selected to test your Beta!), then take the next step.

fuel barrels, empty barrels, rusty barrels, stinky barrels, bumped barrels, broken barrels, shiny barrels, important barrels, holy barrels, shitty barrels...

This card doesn't support multi-texturing
The advantage of a fixed hardware setup (like a PLC in a range of machines, or gaming console) is that the platform is equal everywhere. You know what to expect, now deal with it. Once it works perfectly on your development-machine, it should work on any other machine as well. But obviously, Tower22 is aimed for the PC. Maybe it will be ported to the XBox 720 Roundhouse kick, PS Forty-core, or Nintendo W00t some day :) But let's focus on my own dev-station first.

At some older ATI card, the Editor already didn't work. At least not with all the shaders enabled (you can still render with textures only). Well, I could do two things. Make a profile with simplified graphics and shaders that make it run on older machines. Or B:, ignore them. When releasing a game, more audience means more money. So obviously engine-makers try to get CryEngine2 run on an Atari as well (although one has to draw a line somewhere of course). Yet, I chose option B. For now. Why?

Adding support for older platforms takes time, of course. You can't just disable a few tricks and get a result that is "good enough". At the same time, T22 is far from finished. The graphics I produce today, are likely to be (out)dated two years later. So instead of spending energy on the past, I'd better try to focus on the future. Waste too much time on making your engine "backward compatible", and you will stick in the past. The average gaming computer might not be able to run T22 smoothly right now, but don't forget the "average gaming computer" evolves too. I'm pretty sure these systems can run (the current) T22 nicely in two years.

Other than that, I'm just too lazy to work through all those shaders again :) Hey, programming a game all alone in your free time isn't easy!

Playing around with some concrete textures. We'll need a lot of those for the upcoming Radar Station map.

Saturday, June 11, 2011

Poland, Auschwitz

Visited Poland, once again. That means trying to spot some Soviet stuff here and there, having a stroll in the forest hills. And mainly eating and drinking. Feeling like a sugar donut getting stuffed with even more jelly. Sausages are not just sausages here, you can feed a damn Tyrannosaurus Rex with it. Maybe Poland is not the richest country around on this planet, but you won't starve here. And neither run out of alcohol. I'll spare you the alcoholic drama stories this time, but yet I just like to mention I saw an older friendly looking grandpa-man with a baby-buggy... So sweet... wait, that isn't a baby. That’s a pile of beer and wodka bottles.

Since Tower22 uses the communistic atmosphere and architecture as a background (though the story has nothing to do with Stalin or other comrades) I always keep my eyes open for the typical details here. We love old worn buildings, rusty bus-stops, cheap interiors and batteries of tall flats which make you wonder how a person could ever become happy there. Plenty of things are different from my (over)organized, clean, efficient, modern, somewhat obediently Holland. Certainly in combination with those alcohol stories. But honestly, it all isn't THAT dramatic. We didn't spot Pyongyang buildings, KGB agents or jumped 60 years back in time. Many youngsters do have a Samsung Galaxy telephone by now.


What would a Polish landscape without a red-white striped chimney somewhere in the background?

On a train
------------------------------------------------------------
The fantasy tries to see things that aren't there (anymore). And maybe I'm just getting a little bit used to the cracked pavement, concrete blackened by smoke, weird-color-painted walls, rusty metal commercial signs on buildings, cheap products, noisy old cars that bump over the hole-filled streets, funny narrow passages, the “air raid” that goes off almost every day after a thunderstorm to call the firemen out of their beds/bars, and the fact that you can never get what you really want. I needed some veal to cook a meal for my family. Nowhere. Tortillas: huh? One year ago, I searched two(!) CITIES for a photo-camera and GTA San Andreas for the PS2 (present for little brother in law). On 24 fucking December. Just before giving up we finally found a shop with decent camera's, but no GTA:SA in entire Poland. Sunglasses (not the cheap plastic ones): not in this town.

Maybe a ticket to Krakow, one of Poland’s major cities, not that far away from us then... According to the atlas, there is a railroad between Zywiec (the most nearby city from our town Milowka) and Krakow, so we should be there in a 90 minutes... Ok, ok 2.5 hours, as the trains don't go that fast here. Well… forget about it. That train doesn't exist or only drives at 20:00 ó clock or something. Any alternative (bus)routes then? Here in Holland every idiot can plan a journey after 4 clicks on one of the route-planning websites. But my parents in law never heard of internet of course, and the annoyed grumpy ladies at the station ticket-window apparently neither. She searches for an old book and starts telling it's basically impossible to get there unless we take a long detour. And we need some luck as she is not sure whether train X comes or not. Not sure?!

The bus-ladies weren't very helpful either. Krakow?! Of course there is no bus going there! Don't you know?! No, because if we knew, we wouldn't be asking bitch. Do your damn job. Exceptions there, nice customer service doesn’t seem to be a well known word in Eastern Europe. You would expect a shop-owner to be happy if you buy something, giving the fact that it's hard enough to sell enough wares to make a living here. But most of them don't seem to give a crap... Pfff, got to work again, another annoying (spoiled) customer. Bleh.

For Dutch readers, you will respect and love NS & Pro-Rail once you tried to travel here. We complain if the train is 5 minutes late. But at least it drives every (half) hour, and brings you everywhere pretty fast. Other than the Polish trains who creak and ramble as an 200 year old ladie in a rusty wheelchair getting raped. And don’t forget our railways are one of the most occupied ones in the world. In Poland the smaller train-stations still have houses and a lady to operate the switches (hopefully not in a drunk mood). All in all charming, but not very efficient of course.



Oswiecim
------------------------------------------------------------
Nevertheless, we finally managed to find a route to Oswiecim (nearby Krakow). Oswiecim... yes, that is what the Germans would call Auschwitz. With a car it would take less than two hours. With our logical combination of trains and buses, it only took four or five hours. From which most of the time was spend waiting because the train stood still, or waiting for a bus. But hey! We did it. For Auschwitz I was willing to make an exception, as the 1,3 million people who once were deported to this place, didn't have a comfortable ride either.

Oswiecim is a little city, just like any other Polish city here. But behind the station and trees, it hides one of the most gruesome historical happenings; the extermination of 1,1 million men, women and children. Mainly Jews, but also arrested Poles, Russians, and minorities such as disabled people or gypsies, who didn't fit in Hitler’s picture of a perfect world either. The grandfather of my girlfriend had to leave his house and help building the camp. Others ended up dead there.


What kind of architects does it require to design a place to kill...?

Not far from the train station, just behind the city, lies Birkenau with camp Auschwitz. Camp number II out of III actually. 3 kilometers away lies camp 1, with the well known “Arbeit macht frei” sign (“Work makes freedom”, sure). Auschwitz III, Monowitz, was more of a work camp where factories like Krupp Stahl and IG Farben were installed. But we didn’t visit those camps. No internet, no car, or map. We went by foot and just asked directions to “Auschwitz” and ended up at camp 2, the destruction camp. Following a pretty busy asphalt road with plenty of trees, bush and typical Polish houses on both sides. As said, we weren’t prepared (which is a shame hindsight), so I really had no idea what to expect... Except that it might "disappoint" a little. I'll explain.

We all know Auschwitz from the books, scary black-white pictures and maybe movies such as Schindlers List where trains loaded like cattle wagons drive through the gatehouse, with the horrific smoking chimneys of the incinerators in the background. It's dark, cold, noisy, full of angry SS soldiers, and even more terrified people that have no clue what will come... And that scenario is not spiced with Hollywood movie ingredients. The reality might have been even worse.

And here we are. After passing a little hill and curve in the road, we suddenly see the gatehouse, and the long, long fences with the wooden watchtowers. But what we also see are touring busses going on and off, and singing birds, grass and flowers as it's a beautiful sunny day in June. I can't help it, but the normal houses here that have a view on Auschwitz while barbequing in the backyard make an absurd contrast. The remains of Auschwitz are still there, but life obviously continued.

Could you tell world most famous deathcamp is only half a mile behind these houses?

Compare this picture to this, and you understand why it's difficult to get a good image of what really happened. About the railroad; although it seems unseparatable from the gatehouse, this rail wasn’t there until 1944. Prisoners had to walk in. As a “welcome”, an orchest was playing cheery music, while dead bodies were stapled on the other side as a warning sign.


Once through the gate, we tried to separate from the groups of tourists. Although the guides do a good job giving a background story with all of its (gruesome) details, I didn't want to stand between giggling girls, photographing dad's, annoyed kids and people acting being shocked, then yapping on two seconds later. Not here. Luckily it wasn't that crowded, and Auschwitz is a really large place. So finding some rest wasn't difficult. We started on the East side of the entrance, walking through the few wooden barracks that remained. This is where mainly Jewish men had to 'live'. With up to 500 men in wooden stables that were originally stables to house about 52 horses. Hunger and execution weren't the only concerns here. The barely isolated barracks are ovens in the summer, and freezing cold in the harsh Polish winters. And due the bad hygiene all over the camp, insects and diseases were ever present. And I don’t have to tell you where a visit at the doctor would bring you when feeling ill…

It's quite strange to see the first line of barracks are only 50 meters away from freedom. A patch of grass (mined?), a not too deep ditch, a 4 or 5 meter tall fence, and watchtowers every 100 or 200 meters. You may wonder why there weren't massive break-outs, at the "top" days when Auschwitz kept 90.000 prisoners. Well, some people did escape. Especially at the beginning when the fences weren't electrified yet. Prisoners also managed to blew up one of the gas chambers by the way. But probably most the prisoners were too unsure, too afraid, and too weakened for escaping. In total, about 700 prisoners escaped. Only 300 actually survived.


Some tried to escape here, others used the (eletrified) wires to commit suicide.
"Er ging zu den Drähten" (he went to the wires).


It has to be said that the Nazi's tried to hide evidence of the Holocaust at the end of the war. Yes, the bastards themselves must have realized they were doing something terribly wrong, something not to be proud of... The four gas-chambers are completely burned (camp 1 has an intact one, open for public), and most of the barracks are gone as well. Only the stone fundaments and small chimneys (used as central heating systems in each barrack) are still standing. This makes Auschwitz a large, but also an empty place. So we stand here, trying to depict all the misery, chaos and inhumanity. But honestly, the silence, the emptiness, the shiny weather, the green grass, groups of tourists and cars that drive by the fence now and then in the background make it very hard to get the slightest idea of how bad it really was.

Auschwitz is not an attraction, or horror-museum, trying to shock you. It's just what it is. And the people who work here try to preserve this with the donations they get (entrance is free, but you can make a deposit). Of course. It shouldn't be anything else, we're not in Disney World for a day of fun. But yet, this may feel as some sort of disappointment; I just couldn’t really imagine what happened here. Then again, this is a personal feeling, and I guess each person will experience this place differently.


Gas chambers
We went back to the central path with the rail-roads. When the trains stopped here, people would get divided in groups. Jews, non Jews, women and children, men. Imagine this was probably the last time you would see your family... Groups of new-arrived people would be transported to the so called "Sauna" on the East-North side of the camp. But some were less “lucky”. The weaker ones (elder, pregnant, disabled…) were transported for immediate destruction right away. Not being able to work would death here.



Days of traveling without food or water, packed like cattle, would take its toll on quite a lot prisoners already. But if the prisoners would knew their true end-destination, maybe dying here wasn’t so bad after all…

Krema III entrance... Unbelievable that hundred thousands did their last steps here.

The terror-core of the camp, the four gas chambers plus crematoria. Compared to other deathcamps from that time, the chambers in Auschwitz Birkenau were "superior" with a capacity of gassing up to 2.000 people in one time. Prisoners usually didn't know they would get gassed though, as they were told they get a delousing procedure instead. People would undress first, and then get moved into the chambers where Zyklon-B gas was pumped into the rooms. The dead-bodies would then be incinerated, including their documents. Erased from history.

A dirty detail; valuables like golden teeth were removed from the bodies in room H.
From Wikipedia:


Unterscharführer Hackenholt was making great efforts to get the engine running. But it doesn't go. Captain Wirth comes up. I can see he is afraid, because I am present at a disaster. Yes, I see it all and I wait. My stopwatch showed it all, 50 minutes, 70 minutes, and the diesel [engine] did not start. The people wait inside the gas chambers. In vain. They can be heard weeping, "like in the synagogue", says Professor Pfannenstiel, his eyes glued to a window in the wooden door. Furious, Captain Wirth lashes the Ukrainian [prisoner] assisting Hackenholt twelve, thirteen times, in the face. After 2 hours and 49 minutes — the stopwatch recorded it all — the diesel started. Up to that moment, the people shut up in those four crowded chambers were still alive, four times 750 persons, in four times 45 cubic meters. Another 25 minutes elapsed. Many were already dead, that could be seen through the small window, because an electric lamp inside lit up the chamber for a few moments. After 28 minutes, only a few were still alive. Finally, after 32 minutes, all were dead . . . Dentists [then] hammered out gold teeth, bridges, and crowns. In the midst of them stood Captain Wirth. He was in his element, and, showing me a large can full of teeth, he said: "See, for yourself, the weight of that gold! It's only from yesterday, and the day before. You can't imagine what we find every day — dollars, diamonds, gold. You'll see for yourself!"



Sauna

No matter how hard I tried, it's almost impossible to realise that you are looking at the ruins and soil that caught the ashes of hundred thousands of people. The only real witnesses are the tall green trees that still stand there. Maybe the large memorial monument between the two chambers distracts too much. Personally, I think this monument was a good idea, but shouldn't be placed inside the camp. But who am I to judge? A path behind the monument leads to some sewage systems, a forest path where even more dead bodies would be burned in the open air, and the Sauna. If one place managed to give me the shivers, it was here.

The Sauna was used to "receive" new arrived prisoners, turning them into numbers. Again, this building is mostly empty and sober. Auschwitz was made to be cheap, quick and efficient. So don't expect any detail in the buildings. But I could imagine the horrible procedures new prisoners would undergo here. First they had to give up all their personal belongings. Unusable stuff was burned in ovens (operated by other prisoners), other belongings were cleaned in some sort of steam kettles. In the meanwhile, the prisoners would get disinfected in shower rooms. And it wouldn’t be Auschwitz if the shower water was either freezing cold or boiling hot on purpose.

Prisoners would then get their infamous striped costumes, and their names were replaced by a number-tattoo. Both men and women were shaved with blunt tools at great speeds, so injuries and screaming were all part of the introduction. Now imagine you are a mother. Humiliated in every possible way. Being naked, shaved and hurt, in front of the eyes of your own children. Not being able to help them, and being worried sick of the fates or other relatives. It all happens between a bunch of Nazi soldiers (men, but also women), who would treat you as a ragdoll, or cattle. After doing it endless times before, you couldn't count on any compassion or any dignity from their sides anymore.




Why?
We completed our tour by walking through the west side of the camp, where mainly women and children were kept later on. These (stone) barracks were also close to the infamous infirmaries where "doctors" like Josef Mengele would do experiments. "Clean" baby blood for example was used to cure sick SS soldiers. Because the poor hygiene everywhere, insects and diseases didn't discriminate on Jews and prisoners only. Other experiments included removing limbs from twins (usually without anaesthesia), injecting bacteria to see how long it would take before a patient died, and electrocution.

The stone women barracks were slightly “better” than the wooden barracks for men. But could you sleep here, on these three story-bunks, together with hundreds of other faces that come and go?

I didn't really caught “the horror” in Auschwitz itself. But once I was lying in bed that night, this whole experience started rambling. You start figuring how people can do this. Killing is one thing, but why like this? A beast that murdered ten people who ends up in Death-row, still has a somewhat clean cell, and a shower. He can choose his last-meal, and eventually let a Priest visit before he gets executed in a, relative, painless way. His remains will be returned to his relatives, so the family can finish the story.

Not saying the death-penalty is good or wrong, but compared to the Auschwitz methods, at least it still has some respect to a human being. The train-ride to Auschwitz, the separation process, the induction, showering, shaving, tattooing, housing, beds, food and practically everything else here, was done in the most inhumane ways possible. A pig on his way to a slaughter house may suffer less. And we are not talking about criminals or cattle here... Auschwitz holds a room where they tried to reconstruct the background of some of the murdered families with the help of photo's, belongings and diaries. What you see here are smiling children, new born babies, men and women in love, people playing instruments and having fun, families trying to make a normal living.

How on earth can people do this to each other? I'm afraid the inconvenient truth is that any person can be turned into an emotionless machine, by the influence of group solidarity. Just look at Hooligans, or the "Prison Break" experiment. “Them versus us”. Would a single, random German (SS) soldier hurt women and children, without a good reason? Most probably not. Don't forget these men had families too. The "endlösung"(final solution) was the idea of a few very sick minds, not of the individual soldier. But the group dynamics, fear-for-punishment and discipline that rules especially in military structures make it possible that an average man will follow such instructions. Maybe with questioning himself, but without questioning the system. Let him murder once, and he may feel awful. Let him murder every day, and it becomes a routine, without regret and emotion. Let him make jokes and create bond with his fellow soldiers to find (false) reasons to justify his deeds, and he doesn't have to feel bad about himself anymore.

Like Stalin (not uncommon with deathcamps either) said:

The death of one man is a tragedy, the death of millions is a statistic.


If you are ever nearby Krakow, I can certainly recommend to take a visit. Don't expect to see a lot of spectacular things, but this visit is certainly a life lesson.
And if you go, prepare yourself better than we did, to get a better understanding of what the eye sees. There are only few places on this planet that show the contrast between good and evil in such a pure way. But also the thin line between it. Maybe I didn’t manage to get a good image of what really happened, just because it so inhumane. But it did happen. And it's up to us to prevent it from happening again. Asides from preserving these black pages in human history (which sadly starts to fade away already, as the last Auschwitz survivors will be dead within ten years, kids think Holocaust is a Thai herbal, and some people even start questioning if it really happened), Auschwitz should be considered as a warning to all of us. Respect life. Don't let hate form your decisions.

Tuesday, May 24, 2011

Ou est le swimming pool? #1


What a shame, the world didn't end yet. And of course that old fool from Family Radio didn't admit he was wrong either. "What can I say, I'm not a Genius." Yeah, God works in mysterious ways, so maybe you'd shut up next time? Making up stories to scare the hordes of sheep, tssk. For those who spend all of their money before 21 May: HAHAHA. Read Darwin next time.

Sorry, I got carried away. Still a little bit angry about this documentary from Louis Theroux I just on Belgian TV one week ago:
The most hated family in America
Very cute, but fundamental idiots like grandpa Harold or those intolerant assholes from the link above caused dozens of wars, crusades and other stupidity throughout history. Claiming to be God’s messengers, but doing nothing but threatening with Hell, Doom, Sinfloods… Let me say this:
- For the mouth speaks what the heart is full of (Matthew 12) -
And now go jerk off yourselves.



To the happy news then. First, we get some more help on the modeling part. Another bandito from Spain, Sergi.
http://nueveparadas.blogspot.com/
He’ll be making models, maps, and eventually some of the textures that are required for them. Let's hope he can boost the development speed! The other good news; I just started adding some water-effects.
=====================================================================
WATER
=====================================================================

Do you want to go to the plage with me?

H20, the magical substance that is believed to be the source of life. And the source of eye-candy when it comes to visual scenes. Where there is water, there is life. No wonder scientists are curious about what they might find on Europa, one of Jupiters moon's that is covered with a thick shell of ice.

And where there is water, there are decent graphics programmers (ahum). No doubt that water is one of the eye-catchers when it comes to showing your game(engine). Now I'm not a real expert on this matter, as the last time I implemented it was years ago. So I might missed a few new gadgets. But since one of the readers here asked for some water-rendering tips not too long ago, I thought why not writing a little tutorial? For young and old:

1.- Basic water techniques (non-shaders, beginners stuff)
2.- (Basic) shader tricks
3.- Adding reflections and refractions

Users who already did some water and shaders might skip part one (and two). Although some of the tricks are quite universal. I won't mangle too much with waves and fluid dynamics though, as I simply never did that before. Anyway, have fun!



BASICS
-----------------------------------------------------------------------
You could try to implement an aqua volume that reflects and refracts light exactly physically correct. Or you just fake it with some tricks, with a wink to mister Fresnel. As usual, games tend to pick the second approach. And although water in games like Crysis or Halflife2 looks pretty real by now, we can nicely see how the fake tricks evolved from a blue texture to sparkling clear water.

Doom and Duke Nukem simply painted an animated(2 or 3 frames!) texture on the floors. So much for water. But pretty soon things evolved to a transparent water surface quad, with a moving wave texture rolling on it. You can laugh about it, but we have to start somewhere. Plus some hardware can't do much better anyway (The Wii? Just joking). Well, how do we do this?

- Make a quad(or a grid of quads) -> the water surface
- Apply a seamless (mipmapped) texture that "rolls" over the surface.
You can do this by accumulating the UV coordinates (glTexcoord2f( x+time, y+time )
- Disable specular and diffuse lighting before rendering. Don’t apply light, or
an ambient color only.
- Make it half transparent (glColor4f( rgb, transparency)
- Let it blend. Don’t forget to disable these settings after rendering the water btw!
glEnable( GL_BLEND );
glEnable( GL_ALPHA_TEST );
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);

Done. You can't get it much simpler than that. But at least most players will understand they are dealing with water here. How about some more effects dude? Sure.


Multi Texturing & Caustics
-----------------------------------------------------------------------
Apply the wave texture twice, using multi-texturing. Let the second texture scale and move in a different direction. Eventually use a different (wave) texture.
http://www.opengl.org/resources/code/samples/sig99/advanced99/notes/node60.html

Hey… if you can draw a second(or third, or fourth) texture on that water-plane… Then it’s also possible to draw a “caustics” texture onto the walls/floors/ceilings nearby the water-surface right? Sure, you can use the very same wave texture, grayscale it, and render it on top with additive blending modus. Man, you can even render it on the objects / characters that wade through the water.

Underwater fog
-----------------------------------------------------------------------
You can cut your world in 2 halfs: everything below and above the water surface. Everything rendered below the surface can use a much thicker fog value. This effect will make deeper or distant underwater polygons fade out in a basic color.
Use dark blue for an ocean, or brown for a muddy canal. If you want to do it really good, you'll need to use "height-fog". This is not a standard OpenGL feature, and requires a shader though, but a very simple one :)

Or instead of using traditional fog, you can simply decide the fog value based on the height of a vertex(or pixel, if you can use shaders).

fog = min( 1.0f, (watersurface.y - pixel.y) * thicknessFactor );

This would be a crude pixel-shader formula. If you can't use pixel-shaders, you can still do it per vertex. For each vertex you render, use glColor3f( fogRGB );, where fogRGB is computed based on the vertex height. However, this won't work very well if you have relative large polygons though. If you wonder in which order you should render things now:
1.- Stuff underwater with fat fog.
2.- Stuff above water with normal fog
3.- (Transparent) waterplane


Here the Swimming Pool map anno 2011. I only had a few textures to decorate it, and no other contents. But here some first water effects nevertheless. The brownish look is simply (height) fog. The deeper the pixel, the darker. I didn't make caustics yet by the way...


Waves (& LOD)
-----------------------------------------------------------------------
A single flat quad can’t make 3D wave shapes of course. Split your quad up in multiple smaller quads ("subdivide"). When rendering the water surface, you'll calculate the height(Y) coordinate for each vertex based on a wave formula. Now this can be damn tricky! I have zero experience with wave formula's, but I suspect it's a mixture of lot's of sines & factors. So let's keep the code simple, you can go figure out that formula yourself :)

function wave(x,y:single) : single;
begin
// Very simple wave function...
// _elapsedTime just increases with the deltatime every cycle
result := cos(x + _elapsedTime) + sin(y + _elapsedTime*4) * 0.2;
end;
...
For y:=0 to 100 do begin
glBegin( GL_QUAD_STRIP ); // Render horizontal rows of 1x1 meter quads
// Render the first 2 vertices on the left side
vertex1 := vec3(0, wave(0,y+0) , y+0);
vertex2 := vec3(0, wave(0,y+1) , y+1);
glTexcoord2f( 0 * uvScale, (y+0)*uvScale ); glVertex3fv( @vertex1 );
glTexcoord2f( 0 * uvScale, (y+1)*uvScale ); glVertex3fv( @vertex2 );
for x:=0 to 5 do begin
vertex1 := AffineVectorMake(x, wave(x,y+0) ,y+0);
vertex2 := AffineVectorMake(x, wave(x,y+1) ,y+1);
glTexcoord2f( x*uvScale, (y+0)*uvScale ); glVertex3fv(@vertex1 );
glTexcoord2f( x*uvScale, (y+1)*uvScale ); glVertex3fv(@vertex2 );
// Eventually calculate the normals here as well,
end; // for x
glEnd;
end; // for y


LOD (Level of Detail)
Wait a minute. I end up with a few billion vertices if I want to make waves on a 10x10 km water surface! So, decrease the detail for distant quads. If you look over an ocean, do you see any waves at the horizon? Unless you have a monster tsunami, you won't. Simple, because it's way too far to see such details. So neither do we have to render them.

The trick is to make the grid less dense at distances. But how? Again, I never did LOD on heightfields or water-surfaces so I have to apologize. But I might have some ideas though. From the top of my head:

1- Make a 3x3 initial grid. Around the camera(player)
2- Evaluate all (9) quads you just made
3- If 1 or more points from a quad are inside X meters from the camera (just check the distance, simple enough), subdivide the quad:
* don't do any (wave/heightMap) height calculations yet!
* don't think about triangles or OpenGL yet, just manage cells and points

4- Repeat step 2 & 3, but with a smaller radius around the camera.
Do this until the radius comes nearby the camera. The more steps you take, the
more divisions (but also the more work of course).

You don't have a 3D mesh yet, just a bunch of quads/points. Now you have to do 3 or 4 things to make soup out of this:

- Triangulate the shape (=make triangles)
- Calculate uv coordinates (interpolate)
u = ((point.x - fieldOffset.x) / totalFieldWidth) * repeatUcount
or
u = (parentQuad.leftVertex.u + parentQuad.rightVertex.y) / 2
- Calculate height ( y = getHeight(xz) or getWave(xz) )
- Optional, calculate normals (based on your surrounding point coordinates)

Sounds not too difficult, except for the triangulating part. You can keep track in each cell(quad) while dividing. Normally, a cell has 4 points on the corners. When subdividing, a new point will occur in the center, and 4 new cells will be generated. More tricky are cells that have extra points from a divided neighbor cell. See the picture for possible triangulating options.

LOD is a useful technique for large surfaces such as water with waves or heightMaps (terrains). The implementation above is just my quick thought. You might find better ways on the web.



Specular light
-----------------------------------------------------------------------
So far we didn't use any lights except an overall ambient color. Which might be a little bit odd of course. If you shine a flashlight on the bathtub, you won't see a nice circle spot caused by diffuse light. But what you do see is reflected light (=specular light). Well, sort off. Don't shoot me if that is not exactly correct, I slept during physics lessons.

Anyway, as water often comes with a sun or moon in outdoor scenes, you can activate specular light from that specific source. Be careful, you'll need sufficient triangles to do this (or use per-pixel lighting(and thus shaders)). That means you have to sub-divide your water quad. See LOD above. If your triangles are too big, the specular light effect will be chunky as well.

If you are doing real 3D waves, you will need to calculate correct vertex-normals as well, or your specular light suck.

Here you can clearly see the effect of specular light. Per-pixel specular with simplified Fresnel that is though.


Miscellaneous
-----------------------------------------------------------------------
I’ll keep it short. Don’t forget water splashes, underwater bubble sprites or drawing (additive transparent) ripple sprites on top of the surface whenever something falls in the water. There are advanced tricks for this as well, but with some simple sprites and particles you can come quite far already. Don’t underestimate the impact of these effects! You can have a horny Lagune-shader, but the illusion of water will still break in thousand shards when a fat man bombs himself into the water without making a splash.



So, enough for this long post. To be continued. Take two or three weeks to read it, cause I’m going to Poland this Sunday for a little vacation… If that fucking Volcano in Iceland let us go, that is…

Friday, May 13, 2011

Pina Collada

-Sorry if you see this post twice... Blogger suddenly removed it, so let's post it again-

Programmers are stubborn. nerdy, pimply, annoying persons. Ok, that might be too much of a stereotype, but stubborn we certainly are. No miracle, because when working with computers there are 7 million different ways leading to Rome. There are no single, simple, comprehensive solutions in computer-land. If someone asks how to implement a small administrative database for the local kebab store, You can’t just point to a single book which has the universal explanation for such a task.

For a start, what hardware/platform to chose? A MacBook? Unix station, PLC, Microcontroller, Industrial PC, Gameboy Advance? Next step, which programming language do we use? .NET, Java or are we going to print good old IBM Punch cards? Those who read some technical forums, know these discussions are guaranteed for some hot nerd-fights. Hail Linux! Windows 4Eva! Pic16F microchip for real yo. The funny thing is, after choosing your hardware and development platform, you still have nothing; the program has yet to be made. So, unless you need some very specific hardware, stop arguing and just pick the tools you are comfortable with, because it gives the best chance of actually succeeding.

Then when it comes to programming itself, again we have an infinite amount of strategies. OOP programming? Functional programming? Design patterns, or something very different? Do you use existing frameworks, or do you make your own components? A* pathfinding or Dijkstra pathfinding? OpenGL versus DirectX. XML files or binary files. Sigh.

Off topic. The Radar Station test-map in progress. This map will be a playground for the Object Editor. Plenty of stairs to torture ragdolls. This is a not an Engine render by the way.

Honestly I never really readed books about programming (except some Delphi beginner books a LONG time ago), and developed my own "style" throughout the years. A mixture of Karate, Jujitsu, and Turkish oil wrestling. And I guess that's how most programmers do it, more or less. Following advises from the books or not, at some point we'll have to decide whether to go left or right. And after X years you have a portfolio filled with a couple of languages, hardware, platforms and techniques you'd prefer. Which hopefully gives you a nose for things.


And that's how we become stubborn. Because with so many other techniques out there, we have to defend our chosen methods continuously. If some Cobol fanboy touches Delphi, he touches me. C'mon, you and me, after schooltime! Nah, but if you can't convince yourself walking the right path, you'll be lost in no time. It's not there are just one or two other alternatives you can try.... There are one or two THOUSAND alternatives to try, and each takes days, weeks or even years to master. It's just too much. You can ask around on the forums for some guidance (C++ or Java, OpenGL or DirectX?), but in the end you'll have to throw up a coin, or follow your heart. And don't forget that these forum guys, also the experts, are biased just as well. John Carmack’s advise will probably be very different from Tim Sweeney.

And of course, you'll be making wrong decisions now and then. Linux sucks after all ( :) ), Windows can't run 24/7 without a crash, OpenGL may become obsolete, DX doesn't run on your target platform, C++ was too difficult, Java too slow, Delphi not 64 bit. Whatever. But don't worry, making faults is a crucial part of the learning process. You can’t become a boxer without ever getting punched on the nose. Nevertheless... it hurts to discard a technique you spend many, many hours or even months on. Which is why programmers are even more stubborn than the average Joe. Don't admit your faults and fight till the very last man. Americans in Bagdad? Where? Russians in Berlin? We'll show them. Now you know why programmers have entrenched habits, and are deaf to criticism sometimes :)



You may have read the title, "Collada", and now you think "What the hell has a tropical drink / file format to do with the personal problems of a programmer?". Well, as said, Collada is a file format. For 3D related stuff to be more precise. These files can contain geometry data, materials, physical properties of a mesh, scene setup and animations I believe. Right, so we have 3DS, OBJ, LWO, MS3D, X and a few billion other 3D file formats. What format to chose?! Arh, another decision to make. And yes, it does matter what you pick. Some formats are more mature than others. And more important, you'll be telling which tools to use. If you make an *.MS3D (Milkshape) file importer, your modelers will need Milkshape or at least a (good working) exporter plug-in in their software. Unfortunately, plug-ins often include errors (outdated), and tossing around converted models from package to
package requires extra (annoying) time and is prone to mistakes.

A (love) letter to Julio who made this model. The trick is to put as much as info as possible in a model. Engine22 objects aren't just meshes with a texture. It also contains physical info (collision shapes & hitzones), Level of Detail variants so we can use a lower-resolution mesh for distant rendering, attachments such as lamps or particle generators. And eventually sub-objects that are connected with physical joints such as a door hinge.

This is why Collada was made; an attempt to create an universal, simple, all-round file format that will be supported by all 3D packages. Now I'm not sure if they actually accomplished that goal, but at least Blender and 3DS Max support this format, and newer version of Lightwave as well I believe. Yet, I made a Lightwave (LWO) importer ~6 years ago. A logical decision, since I used Lightwave. But from all formats, the LWO is one tough son of a bitch. And at this point, I'm forcing my fellow helpers (who use Blender and Max) to either find a LWO exporter, or we mess around with the OBJ format. Max to OBJ, to LWO, to Tower22. Bleh.

Wouldn't it be smarter to write a Collada importer then? Maybe, but this is where my stubborn, defensive programmer instinct comes around the corner again:
..A: I spend many f#cking hours in thet LWO importer, it finally works now :(
..B: Collada, pfff, don't let me laugh.

For one thing, I just don't like the name "Collada". It sounds like a tropical alcohol free drink or a kids icecream you buy on vacation. But what struck me more was the XML format. Yes, Collada files are just XML files. Which mean you can actually open the file as a text, or view it as a tree structure in any internet browser. I’m more a binary-format man. Never followed the Extensible Markup Language(XML) hype. Text formats… pfff. 50% of those files is overhead you don't need. Instead of just loading array's of data, you'll be "parsing" a whole pile of shit before you finally found something useful. It takes time, extra storage space, extra code to “understand” the file… No sir, I'm no fan of XML. And therefore neither of that Icecream format.


Fair enough? Maybe not. Just because I don't like it, doesn't mean it's rubbish. But it's just the way how my programming career got raised, people are afraid for changes, forgive me. Fact is that XML is used in many applications. Fact is also that Pina Collada is used in several 3D packages, at least more than my beloved Lightwave LWO format. Live with it. So, after many years, I finally decided to take a look at it... And with the Delphi TLibXMLparser it took me 6 whole hours to make a (basic) Collada importer for the Object Editor. The LWO format took me 6 light(wave)years...

Ok, ok, I've done this so many times that I can write file importers while sitting on the toilet, reading a Chuck Norris article. But I'll confess: I was wrong. I can hardly get it out my hands on the keyboard, but here you go: Boys and girls, if you need to pick a fileformat for an environment with a variety of 3D software packages, Collada is a good choice, and programming your own importer isn't so hard, certainly not if you can find a nice XML reader. Happy now?

There will be water and ice here. Gives a nice chance to play with water shaders and low-friction. You know what... I might just make a tech-movie once this map is up and running...

Monday, May 2, 2011

Smoke them out

Bin Laden dead? C'mon, put your AK-47’s in the air, scream it out on the streets, and do a victory dance. Ok enough silliness, let's just return to work. Osama dead eeyh... Now what? Asides from Gadaffi, and Kim Yong Pangang Il Turbo, there are no charismatic badguys at the moment. And... is the dead of Osama a symbolic thing, or will it really change the world? Unlike Hitler who was the "end-boss" of the WOII game, Al-Qaeda and the likes are usually independent cells. Osama was/is more like an inspirator, a motivator, a pop idol. Dead or alive.

I guess panic for terrorism is still there, and the real hardcore terrorist probably knows how to hate & how to detonate a bomb, even without uncle Bins. Anyway, if this Osama person really did what we he did (I know, there a lot of theories about him), he deserves to be dead. Not just for 9/11 and putting the Western and Islamic world into a dirty cagefight. Also for terrorizing Afghan people by using religion as an excuse for the 8th century barbaric Taliban ideology. Downgrading women to R2D2 service robots and forbidding kiting for kids. So... have a nice time in heaven with 72 lovely virgin piglets.

Or... maybe he got his paycheck, shaved his beard, shaked hands with the Navy Seals, and drove off in his Ferrari with a smile after ~25 years of outstanding acting work. It would fit in the complot theories. Who shall say. The story that his body has been dumped in the sea right after he was killed is odd, the least to say. Out of respect for Islamic rules that state Muslims have to be buried within 24 hours. Could be me, but I never saw soldiers cleaning up body pieces of Taliban that have been hit with a .50 in the desert. The meanest of them all, the uber-bombastic terror maestro, would get a fancy sea burial (is that allowed for Muslims anyway?). Out of respect… yeah right. With all those complot theories about 9/11 being an inside job, you would expect the Americans to show Bin Laden’s last minutes in full HD to prove the contrary. Or even better, catch him alive and “bring him to justice” like they did with Saddam. I hate complot theories, but this story smells a bit... like an old wet beard.

Sorry, I just don't trust politicians that much. Well, hopefully things will get explained soon. I think the world owes that, after 10 years of war and getting my underpants frisked at the airport. But assuming they really got him, it has to be said that the Americans kept their word. You can say all kinds of things about them, but not that they don't have the balls to accomplish big things. Other than we Dutchmen(& European in general) who prefer to criticize from the sidelines (like I just did now). Hey, guys like Osama don’t get smoked out just by talking you know. Talking about mysterious deaths, where the hell is Hitlers body?



-------------------------------------------------------------------------

Here, an old pic rendered by the great grandpa of our current engine, at times Saddam Hussain was still alive! This engine used Lightmaps btw, and a very special "pee shader" for that orange tube. Hey, got to show something.

Ok, how's Tower22 going? No new pics lately huh? True. But cheer up, plenty of things are being done. It's just that I'm not busy with any graphical programming tasks at the moment. In fact, the game doesn't even start at the moment as I'm doing all kinds of upgrades. And one update on X initiates two other updates on YZ. And before you know it, the whole source-code is turned inside out for the 600th time. I know, leaving your game “un-executable” for too long can be a critical point in the design traject. It's like stop cooling the Fukushima core for too long. But the planning is to have it back online within a month. With:

- FMOD Sound DLL
- Input DLL
- Newton2 Physics DLL
- A new Entity system (the stuff I wrote about in the "Puppeteer" posts)
- Several new features in the engine like trigger volumes or moveable platforms like elevators.
- A new Object Editor

Initially I was only implementing those custom DLL's to control the behavior of objects. But while doing so, you walk into all kinds of outdated stuff that had to be upgraded sooner or later anyway. Physics too old. Object Editor messy. Animation system sucks. Blablabla. So before you know it, you have a whole dozen of tasks.


One of the more “catchy” upgrades at the moment might be the Object Editor. To clarify, an object in T22 is a 3D mesh that can be duplicated and placed everywhere. Like furniture, decorations, barrels or other junk. Objects usually make use of physics, can be destroyed sometimes, or can be picked up for usage. More advanced types of objects are the animated ones, or the "thinking" one (which simply make use of a more advanced DLL/script to control them).

These objects have to be made somehow, starting with a 3D mesh. All those raw Lightwave, Max, Blender or whatever program meshes & animations have to be imported into the game somehow. So far the Engine22 Editor already had tools for that, but a little bit outdated. So, since we are driving the touristic route already, a few more or less miles don't matter anyway. It would be a nice chance to update some of the object aspects, like synchronizing it's collision volumes with a ragdoll (or vice-versa), adding Inverse Kinematics, using those AI / behavior DLL's, ...uh … pretty much everything.

Another good reason to make some work of it, is because my fellow modelers still need a tool to see/test their own work. I can promise all kind of things, but seeing is believing. So far I could only send them screenshots of their productions after being imported into the game. Nice vacation pictures, but a real modeler wants to play around and tweak his work inside a real game environment of course. I could send them the Map Editor which has been used for everything so far, but it's too huge and buggy to share yet. Programming experience tells not to release your products to the public until a monkey can use it. Giving half-baked crap to your clients/users will give them a wrong impression and distrust of the product.

Then again, I can't let them wait forever. So, I'll focus my Super Sayan level 2 energy on releasing a stand-alone object editor first. But it makes use of the same engine modules, so it should come with two extremely nice features:
- Physics testing (throw around your object through a room)
- Full-shaded graphics. What you see is what you get

So it's not just an editor which allows to import some meshes, and tweak a script. It should also be able to play with your object in a test-map that actually uses the same graphics as the real game. Sure, it takes some energy to produce such a thing. But if I get happy modelers as a return, it will be worth it. Really, don't underestimate the effect of feedback. A modeler, mapper, sound engineer or whatever kind of member should be able to see, hear, play, read or experience his work back into "the product", otherwise the motivation to keep producing may drop to zero at some point. So before inviting all kinds of people on your project, make sure they can get the right tools to work with, and give them some options to see their work in action. All work and no play makes Jack a dull boy.

For the same reason I’m a little bit quite last months. I guess most people who visit here just want to see pictures. But sorry, all the programming hours went into upgrading lot's of boring code modules and editors. And playing "Tower Defense" plus staring at the screen :). Well hopefully I can place some nice pictures of a test-map being used for that object editor soon! Since it should have a pool to test buoyancy graphics, I might just as well program some water-shaders as well...

Here, another prehistoric render. That was one of my last water-shaders, time for a boost! Oh, people who live in Oudenbosch, you may recognize that pool :)

Monday, April 18, 2011

A long time ago #2

Excuses for the somewhat lacking amount of posts last weeks… months. The reason is not that we’re doing nothing anymore. But there is simply no visual eye-candy at the moment! Busy with upgrading physics and that entity system at the moment. So I could show you some dull movies of tumbling boxes, buoyancy physics with still some errors, or Micheal Jackson ragdolls that get an epileptic attack (don’t worry, doctor Sascha Willems is on it). But then I could better refer to some REAL physics for now:
http://www.youtube.com/watch?v=qMAaza_rrxQ
1:33 is even more badass than Charlie Sheen. If I ever make a RTS game, that’s how the physics should look. 2:32 reminds me of squeezing pimples BTW.

Anyway, instead of pictures, I might interest you with some more story bits… Morgan Freeman, up to you.


============================================================================
Story fragment #2
============================================================================
"
For some reason, I can't recall how this flat -number '22'- looks from the outside. It feels as I've been working here all my life really... But judging from the interior, my guess is that the building looks pretty much the same as the other gray concrete monsters around here, except that it's a lot taller. Don't know the exact height, neither when this block was built. Probably somewhere in the late fifties. Although some parts here look a lot older already. But that just might be deferred maintenance as well.

Just like other buildings, it has a few elevators, a stairhouse, and endless corridors. Dark, old, corridors with countless doors. Closed, unnumbered anonymous doors, telling nothing about who might live there. The wallpaper and paintwork can be peeled off just by looking at it. Bugs found their way in the little holes and gaps. Some ceilings were left unfinished, revealing the rusty beating pipes and electric wires above them. Not uncommon either, the building has a couple of shared facilities here and there. Such as a laundry, or showers and toilets for the apartments that aren't connected to the water.

The same goes for the apartment interiors. We all share the same collections of furniture, thin mattress beds and kitchen sets. Some bright plastic utilities, flower curtains and small cheap decorations to add a little bit happiness to the otherwise depressing, pre-fabricated rooms. The apartments just do what they have to do: provide shelter and warmth for the cold winters.



Though I must say there are some impressive halls and wall paintings scattered around the building. Ones you would find in a church, or stately building. Who would have made them? I can't imagine they were part of the original design for a building like this.

When thinking about it, I noticed more and more uncommon details. For one thing, many of the windows are barricaded or just not there. It's hard to get a glimpse on the world outside here. Another thing that strikes me is the unusual floor lay-out. You would expect the elevators, central stairs and main corridors to connect all the apartments in a logical manner. But from what I have seen so far, not a single floor looked the same. Elevators aren't working or only bring you at a few locations. Stairs just stop at some point, and the hallways are mangled like a maze. Clearly the architect didn't follow his study here, where simplicity and efficiency are basic construction fundaments.



My work brings me at places where a normal person wouldn't or shouldn't come. Such as maintenance area's or ducts. With such 'privileges', one would think I could dream this building by now. But I feel there is a whole other world behind the locked doors, service ladders and twisted hidden shafts. In fact, in combination with the absence of anything alive except the crawling bugs so far, I'm feeling... claustrophobic. Scared actually.

I asked for a map, a layout of the building. But apparently, there is none. Again the Boss didn't really answer my request. Just a vague reply. Words like "The doors will lead your way, or block your way where you are not supposed to come.". Guess I'll have to make a map and notes myself on a piece of paper. Before I get lost some day.
"

Monday, April 4, 2011

Puppeteer Part #2

Nice. Our cry for someone who can solve E=MC^2 formula's has been answered by Sascha Willems. If you think, "Hey, I heard of that name", then you are right. He is a moderator on the Newton forums, made Delphi headers to use the DLL’s, and part of the Newton development team. So... guess I can't get much closer to the source! Well, I just wrote a document with 100 and one Physics questions he can hopefully answer. I guess some of the questions + answers can help other Newton users as well, so I was thinking about publishing that document once it got answered.Either how, this subject will surely return a couple of times on this Blog.
www.saschawillems.de

Another little detail I forgot to mention is the (prototype) logo on top of this Blog. Just a little present from a good friend who has his own business in logo & design since a while:
www.pixelridder.nl

Last but not least, in case you missed, we gave our engine a name…. Engine22. Not as brilliant as “Source”, but yet I like its simplicity. It doesn’t change the quality of the game, or how Earth orbits around the Sun, but it’s nice to call the beast with a name.

Off topic. Quick drawing by Jesse. Nitpickers as we are, sketches should help the modelers with details like these, rather than just go ahead and poop some polygons. Atmosphere is key baby, so every stupid wooden panel is handmade craftwork. The expected release date for Tower22 is May 2086 BFSM (Before Flying Spaghetti Monster) by the way
-----------------------------------------------------------

Back to the “input & output” story then. Previous time in The Bold & The Beautiful, we made an Input module. To register keypresses, mouse motion, sweat sensors and lightsaber velocity. Yeah, with some hardware knowledge you can do whatever you want there. Measure the player heartbeat, use the room temperature, make your own exotic joysticks, Duckhunt Zappers, dumbbell sensors for your own Dolph Lundgren fitness game, install a Boeing cockpit in your room and so on. The Input module abstracts the physical input to a listing of common controls that can be used in most types of games. And otherwise it's easy to extend.

But the real question is, what to do with it? Unlike earlier (messier) engine attempts, I made a strict difference between Input and Output this time. The Input module isn't aware at all of the game status. It doesn't know if you are controlling a HUD menu, Haiku Robot, or Lara Croft. Neither does it know which buttons are allowed or not. It just registers input, that's it. What to do with it completely depends on "the others"... whatever that is.

Sounds pretty simple, but there is a catch. Where exactly do we code the output? Didn't I say to keep game/entity specific actions apart from the core-engine? You don't have to follow my advice, but personally I don't want to litter Engine22(yeah) entity system with stuff like
- "player spawns 20 blood decals on bullet hit"
- "tanks accelerates forward when FORWARD is pressed"
- "Goku charges up powerlevel to a maximum of 45.000 while bashing the ACTION2 button"


You could try to make a super-entity that can do everything in the world, but that is asking for failure. Abstracting everything makes hard-to-understand and/or lacking code that just doesn’t do what you really want. Instead, like you do in small specific industrial applications, focus on the specific task. More effective, faster, less error-prone, and especially more fun. Finally you feel like you are programming an actual game!

To break up this large piece of text, just some relaxing carpet. A dull screenshot indeed, but carpetting the building has to be done as well. It should be somewhat more spectacular as soon as the carpet layer makes some holes and throws around carpet-tiles...

Right, that means we have to move the specific "game-logic" elsewhere. I'm not 100% done with the design, but I have some ideas... Half a year ago I mentioned Python scripts already. In short, when the engine detects a certain event such as onBulletHit(), onUse() or onSectorLeave(), it can call a Python script for the specific execution. Each entity (a barrel, player, monster, shotgun, …) can have its own script. Since Python scripts are external files, you can do whatever you want here. And also adjust whenever you want without needing Delphi, MS Visual Studio or other tools. Python scripts compile at run time, so you don't have to rebuild the Game project when you just added a "player health = 9999" cheat in the player script. That also means you can screw up the game any time you want :D

This is effective, but it still has some downsides. So far I used Python scripts for rather simple tasks that are only executed when X happens, not every cycle. Updating complex tasks like physics, controls, animations, AI and pathfinding each cycle (more than 30 times per second) might be too much. I have no idea how slow or fast Python really is, but it IS slower than normal compiled code. That's for sure. Maybe updating one entity isn't much of a problem, but how about 10. Or 100? I'm not taking the risk, neither do I buy "That few milliseconds don't matter as long as it works". That's a lazy approach sir.

Asides from speed, Python isn't as flexible than your trusted uncle Delphi. For real complex stuff I still prefer a traditional language (or at least I don't know Python that well). So... what to do now? How about making entity DLL's?

• Each entity can(doesn’t have to) be assigned to a DLL
• DLL does the cyclic update, physics, events, queries from other objects, handling the input, etcetera, etcetera
• DLL gets access to the Engine API so it can call all kinds of things (render something, apply force, get another entity, play sound, and so on).
• Most “simple” objects like a stupid box or chair can all do with the same DLL. So don’t worry, you won’t end-up with thousands of little programs.

Instead of letting the engine fool around with lots of specific actions, let the DLL do it. Yeah, even maintaining a simple "health" value can be different for each entity. Some are immortal, some are sensitive for headshots, others bounce back bullets, others explode when they got hit, etcetera. So, remove "health" and all the possible effects from the core-engine, and let the DLL (or script) do the job call.

The Engine is doing less and less… specific action is moved to the surrounding units, making the Engine more like a “manager”. All rendering functionality is (still) inside though. Even though we could move that to an external unit as well of course.

Engine22 only does what all entities should do when getting updated, hit, spawned, or whatever event there is. The DLL and/or Script tell the specific output by using the API delivered by the engine. API? Yeah, Application Programming Interface. Engine22 has a large list of varying functions that can be called by Python scripts. And also by DLL's now.

In Delphi terms, we just pass an "Interface" type towards the DLL when it asks for it. This interface is just one big listing of method pointers, towards the engine. You don't have to do it that way of course, but it looks nice. Either how, we can call those functions whenever we like. The beauty is that you can drop the choking "keep it universal" way of thinking once you are in your DLL. Sure, using some frameworks helps, but basically you can code whatever you want here. Ah.... it almost feels as good as when I began with programming games 10 years ago. No worries.

Some of the DLL & API functions...

Next time, in the last part, I’ll give some example code to illustrate some common game mechanics. In the meanwhile, eat your vegetables!

Thursday, March 31, 2011

Could the real Isaac Newton please stand up?

HEY! Do you happen to be a programmer with good experience in:

- Newton(2) Physics library (you made some advanced projects with it)
- Inverse Kinematics & Skeleton Animations

Ifso, I need some good advice. Sooner or later this year I need to update the physics part. Although I know how to use Newton 1 a little bit, I won't call myself Isaac. So before doing stupid things...

It's not really a programming job offer (but who knows), more like a request to have 1 or 2 experienced people on my side to mail with to dry my tears when the computer said mean words again. To give an idea of what needs to be done:

- Player movement (including @#$ stair climbing)
- Inverse kinematics (feet, hands, snakelike monsters)
- Combine Physics & Animation & IK
- Physics: proper behavior of all objects (now they react "unnatural" on collisions)
- Joints (swinging lamps, chains, doors, ...)
- Advanced raycasting for sensoring the environment
- Trigger volumes (player inside a water mesh?)
- Buoyancy
- Material feedback (on what kind of floor am I walking,
what type of material did I just shot?)
- Hitzones (headshot, hit his balls)
- Collision sounds (hit, scrape, roll, bang, snap, crack)
- Destroy stuff
- Ragdolls
- Multithreading optimizations advise?
- Pour in the engine or a wrapper DLL to simplify

I tried to ask on the Newton forums several times, but let's say my answers often don't get answered there. So, I prefer a personal coach;) On top, Newton 2 has quite some nice new functions, but I'm totally new to them. And last but not least, I’m stupid so please only react if you are patient enough to explain things to a 3-year old. Oh, and it is on voluntary basis of course.

Sounds like fun to have an advisor role? Then feel free to contact me (see "contact" link on the right). Ciao.