Sunday, September 26, 2010

Break down the doors

This week I had to deal with kicking in doors and “swapping sectors”. Ever played Resident Evil 4 or 5? Then you know there are two ways to open a door; doing it gently or by force. Pressing the “open” button twice will let you kick or slam a door open. I was in the need of something similar. Normally you would open the doors as a gentlemen. Not just because the game isn’t that rushed, the noise will also attract enemies. But since the movie contains a chase scene, it would look quite stupid when the hero carefully opens a door after running for his life for 60 meters.

Doors in the engine are objects like any other, but with a couple of special features. The model itself could be a door of course, but also any other model. Having Anne Frank's closet as a door is perfectly possible. But on top of that, you define how the door is opened/closed with properties such as “angle closed”, “angle opened”, “position closed”, “position opened”, the squeak and slam sounds, and the speed of operation. Oh yes, and the kind of required access(keys, itemX in inventory) of course.

This allows to make simple rotation / slide animations by interpolating with an “elapsed time” between the opened and closed status. Kicking in a door simply boosts the deltaTime speed, and causes another sound effect plus animation for the player (kick, push, pull, …). Hi-tec Star Trek doors that curl up or something can use animated objects.

Last but not least, when placing a door it figures out at which portal and A* path connection it is. When closing a door, the path and portal will eventually get blocked, preventing enemies trying to take that route or rendering the sectors behind that door.

Police! Please wipe your bottom and get off the toilet with your pants up before we kick in the door!

Second issue, swapping sectors. Say what? Although a few (modern) games have total destruction and chaos abilities, it is still a common technique to replace a piece of map when something happened. Example. You wonder what happens when pushing that button labeled with “Detonator”. Bang. When going back, you notice uncle Buck’s chicken barn is completely gone.

In real life stuff like this only requires some TNT. In games you’ll need to adjust the visual mesh, reevaluate the collision mesh, alter path-finding routes, and eventually regenerate static lighting or reflection information. Which is why replacing a piece of map with a second pre-modeled variant is a common way to fix this little problem.

In my case I didn’t need to blow up barns. Nah, but nightmares tend to spawn complete new locations in all of a sudden. One second you were walking in your house, the next second you are suddenly in a metro station or cornfield. With this technique you could make dynamic “mazes” for example.

You have seen this chamber in a few hundred ways already. But now it's also possible to replace it with a complete different map (also the dimensions can be different).

Replacing a sector had a few difficulties though. As you may have read previous week, the world is one huge map. All sectors connect with each other, which means their absolute positions in 3D are important. Throwing one out can cause some problems. First of all, the world has 1 big global octree that helps you sorting out where you are
(function whereTheHellAmI( vector position ) : sector ).
Second, pathfinding may require a rerouting. Third, lights from neighbour sectors have to rebuild their “visible sectors” listing. Fourth, old info such as collisionMesh and local objects need to get removed / replaced. And last, if there were any global objects / characters inside that sector, they need to get transferred somewhere. There is a realistic chance this happens, since the enemies are free to walk everywhere.

I did it as follow. Both (or even more) sectors are placed at the same position, meaning they can overlap each other. But only one should be activated. By default all sectors are active, but sleeping sectors that pop-up later can be disabled by hand. When replacing:

- “Active flags” from both sectors are switched. Disabled sectors cannot be rendered, loaded or picked when requesting the sector at position XYZ.
- Unload previous sector completely. Just like the background roaming thread would remove sectors that were left behind / too far away. This also removes its physical mesh. Don’t want to stick behind invisible walls.
- For each global object inside the old sector, call a script callback that decides what to do with it. Enemies could get moved to a default location. Stuff like weapons or puzzle objects can get moved to a temporary “vault” sector somewhere outside the world. When loading back the previous sector, a custom script can ask these objects back from the vault.
- Load the new replacement sector
- For each neighbor sector of the old one (trace via its portals); adjust portals and force to reevaluate the lights to make sure the shadow depthMaps are correct. Each portal has a property that tells which sector can be seen behind it. In case this was the old sector, replace it with a reference to the new one.
- Path-finding… The game basically has one huge navigation mesh, also for unloaded sectors. When two sectors overlap, then just also model 2 pieces of nav-mesh at that point. But block all the connections that belong to a disabled sector so that the player cannot use that route.

You can guess the scripting was extended with a few new functions for swapping sectors.

Crikey, that was the detonator button

Sunday, September 19, 2010

Multi-Headaches

As you may have seen, there are a few links added to the top-right corner on this blog page. Somebody suggested to add some project summaries and well, I think he was right. I was struggling what to tell and what not to tell about the story and gameplay elements, so I tried to outline the game, without spoiling too much. Nevertheless, you can find some details about the game itself that you may not have found between all the weekly yapyap.

There is also a "Movies !" section, without any movies. However, there is a list with remaining points that need to be done. If you ever get impatient, you could check the list to follow the progress. As you can see, I needed to model a fuse box, the end-section of the hallways I made earlier, storing animated sprites, and improving some camera work. When running, the player would actually pass the camera. Since there is this so called "body awareness", I would see my own eyeballs in front of the camera. That may happen when Chewbacca flies with the speed of light in its reversal, but here it occur. Turns out the camera matrix was always 1 cycle behind. Doh.


Then there is also that “Uncle Sam needs you” section in the top right corner. First I planned to finish that movie before asking any help, but since I was writing anyway, I added that too. I’m not in a hurry to assemble a huge team of programmers and artists to make a big commercial game, but one or two artists to help with a second demo movie are surely welcome.

When the first movie is finished, probably somewhere at the end of this year, I’ll have to plot the next targets. Improving ambient lighting, and real enemies with AI are two main goals. But also creating a second demo movie is one of those things to do. See, you are looking mostly at programmer art right now. It isn’t that bad, but it doesn’t really represent my actual ideas for this game either. It can be done a lot better, so the magic wand of an artist is what this project really needs sooner or later. So if you know somebody with talent and too much free time, you could send him or her that link. Who knows.

Anything else to report? Not really. Spend most of the time modeling and fixing(finding) the camera bug. The apartment and spooky corridor sectors are all connected now, so you can walk from A to B without needing teleporters. For the info, the map is divided into small pieces; “sectors”. A hallway or chamber would be a typical example of a sector. Each sector contains portals, the openings(doors, windows, …) that show connected neighbor sectors.

While walking around, the surrounding sectors will be loaded at a certain level of detail. Distant sectors will have a simple mesh and possibly simplified materials without all the fancy shader effects. Close sectors on the other hand are fully loaded with all the details. All the loading and dumping of sectors that were left behind, happens in a background process to prevent the game getting halted by the loading times. In short, pretty much how free roaming games like GTA work.

It did take me a few billion frustrating hours to remove the bugs caused by multithreading madness though. If you have no idea what I’m talking about… If you have a Dual- or Quadcore processor, you basically have 2 or 4 CPU's that can process tasks at the same time. But you'll have to tell your program how. Multi-Threading means you make another separate "thread" that runs a part of the program. For example, thread A does rendering, thread B physics, thread C sound and game logic, and thread D loads the sectors. The OS and CPU internals will cleverly throw tasks towards the processor(s) to make things run parallel. Sounds easy, but it isn't.

Ever worked as a team, or better said, NOT as a team? You bought a can of red paint. Bob didn't know that, so he bought the same can as well. You started to paint that wall, but crippled Joe walks in the way all the time. When you have a break, Jimmy decides to continue your work, but forgets to lacquer the wall first. The boss promised the client that his house will be finished yesterday, but the work isn’t even half done… If you want to work as a team, you'll need to communicate, make appointments and eventually clearly divide the work into separate tasks.

The problem with MT(Multithreading) is that you can't simply read/write variables. If process A reads while B writes on the same value, you'll read something terrible. If both A and B write at the same time, the value is messed up. Bob and Jim can't paint at the same place either, you'll have to pause either A or B. But having lots of pauses is not exactly the idea of MT. Your boss didn't hire 10 men to work in turns either.


In this case, the background thread loads data that is heavily used by the other thread for rendering, collisions, AI stuff, and so on. To prevent the main thread from using half-loaded bullshit, the sector will be loaded in “quarantine” first, then transferred to a "ready list". The other main thread will check this list every time to see if anything new became available. If so, it will be grabbed from the list and placed in another "active list".
- Thread A >>> load item apart from the rest
- Thread A >>> once finished loading, put it in a “ready list” (lock / unlock while inserting)
- Thread B >>> check if there is something in the “ready list” (again, lock / unlock while reading)
- Thread B >>> Ifso, move item to the active list. Delete from the ready list.
Here's where both threads can touch each other. Since the loading thread can insert items into that "ready list" while the other process reads from them. Again, do not do this at the same time. Lock the list with a “mutex’ or “critical section” while one of them either reads or writes. A common mechanism to share values between 2 (or more) threads.

After a long struggle, frustration and many bugs, it worked (for more than a year already). It introduces some extra difficulties like having an changing/unpredictable set of data for AI or special rendering routines. Or being careful about all the garbage(unused textures/models) will get removed 100%, otherwise the memory will flow over sooner or later. All in all, not the easiest way, but having the environment getting loaded without annoying loading times is worth it.

Monday, September 13, 2010

Controlfreak


Super Mario's 25th anniversary! He's looking kinda old for 25 though... and dirty

Excuses for a later post. I had this little birthday last Saturday (no, not from Mario). With as a result that I couldn’t come any further than the sofa all Sunday, watching cartoons. Talking about sofas, I made one last week, see the screenshots. Other than that, I was busy with light flickering schemes and controls this week.

Light flicker schemes? Sounds more difficult than it is. Maybe Wolfenstein not yet, but Doom 1 already had the option to let a light flicker on a certain interval. You know, buzzing TL bulbs. Lights are a little bit more complicated these days though, but the idea remains the same. Compose a record of "random" values that tell how often, how strong and at which frequency the lighting changes. Continuously buzzing? Slow & steady on/off maybe? Light up with peeks sometimes? For each light, you can choose a schedule (normal, buzz, disco, rotating (sirens), etc) and fill in some random values. Scripts can also change this schedule setting. For example, when shooting a light you can select a schedule where the light flicker/sparks sometimes.

Ok next issue. Controls. I never understood all the fuzz on controls in game reviews. "Superb controls!"... Except with platform games maybe, I always took that for granted. But making your character move smoothly and gently taking the stairs is harder than it seems. Not only the physics, also handling the input on a smooth matter can get tricky when running at lower/fluctuating framerates. Losing control over your character is one of the most frustrating things that can happen in a game. Don’t want H@x0r or FunkySn!per1987 getting fragged in a Deathmatch game because of the sucking controls.

I had to smooth the mouse-look to start with. Certainly because recording that movie requires a smooth camera look as well of course. But it would move a little bit jerky, probably due the lower framerate. So I moved the mouse handling code to another background thread to get updates on a high, fixed interval. Easy right? Well, not really. I tried billion different filters, averaging, acceleration and damping before it would run a little bit. Now it looks like this:
------------- how the hell do you insert code blocks in Blogspot? ------------------
< thread makes about 200 samples per second.
getMousePos( point ); // Windows API call
deltaX += previousMouseX – point.x;
deltaY += previousMouseY – point.y;
if ( ++sampleCount == 2 )
{
rotationX = deltaX * _mouseSensitivty.X + rotationX * _dampingFactor ;
rotationY = deltaY * _mouseSensitivty.Y + rotationY * _dampingFactor ;

playerCamera.applyRotation( rotationX, rotationY );
deltaX = deltaY = 0; // Reset delta
sampleCount = 0;
// Centrate cursor
setMousePos( screenW/2, screenH/2 );
}
// And if you saw errors, yes that could be true as I'm writing Turbo Pascal actually
------------- EndOfCrap ------------------
Still not nice, but at least it improved. Have to make a shooting range for testing the mouse some day.

All right, furthermore a couple of basic moves were still missing. Sprinting and strafing. In most FPS games the player runs a 20 hour marathon at lightspeed. My game is somewhat slow-paced though, so I swapped it for fatguy controls that make you sweat after 20 meters. By default, the player just walks. When holding the shift button, the player starts "jogging". And when quickly tapping the shift, that lazy bastard finally starts to sprint… if the stamina bar didn’t reach zero. Pretty much the same way walking works in Grand Theft Auto games.

I bet your family will throw you and your computer out after banging the shift button for 10 minutes, but don't worry. You only sprint when shit hits the fan. Which shouldn't be too often. While sprinting you can't aim guns or make very sharp turns for example. Plus all the noise will attract enemies. On top, as you get more tired, aiming, vision, hearing and everything else will get distorted. One of the tactics in this game is to keep your heartbeat down. Stay cool dude.


We're still far from done with the controls. Lot's to improve when it comes to physics and stair walking(falling) for example. But that's for another time.

Got my chamber filled with the IKEA Hökebünker set

Sunday, September 5, 2010

Junk needed

Not much spectacular to report this week. Most of the time was used for completing invisible pieces of code. And I still needed to model a few things, including a piece of hallway that connects 2 chambers. Not even sure if I'll have a walk here in the movie, but having open portals that show a skybox behind isn't exactly nice either.

Another boring corridor. Yep, that's the downside of having a flat in mind. Corridors, stairways and apartments. That's pretty much it. Well that would suck of course, I have somewhat more ambitious plans with this flat. I'm hoping to give you a slight impression what that could be with the movie. Though I'm pretty much limited by my architectonic & modeling skills.

Nevertheless, dusty corridors are part of the job whether you like them or not. As simple as they seem, they are pretty hard to make them look nice. The shape doesn't really please the eye, and this particular hall doesn't even have windows. So you'll have to impress with other things. But what? Doorbells? Textures also repeat a lot here, and even doing lighting is difficult. Narrow spaces like hallways should have lot's of indirect bounces to spread the (ambient) light throughout the space, but as you may know, indirect lighting is damn difficult. The engine actually updates a lightmap for indirect light realtime, but its resolution is too low to have good results.

Corridor... boring. Need some lightshafts, better smoothing, more decals, junk on the floor. And probably a very different texture setup as well.

The answer is probably to add lot's of details, at the right places. Randomly throwing boxes won’t work either, the mess needs to make sense. Install switches, cables, pipes, fans, stuff like that. Paper and bubblegum on the floors, maybe a vacuum cleaner somewhere in the hall. If you need examples, iD Software are masters in making (eerie) corridor games like Doom3 or Quake4.

Another trick are decals. To break the repeating wall textures, paste dust, rust, blood, puke, poop, goop or cracks on top. Too bad my library doesn’t have much junk-objects and decals yet, so the hall looks awfully empty. But I played around with “torn-off plaster”, inspired by the picture below:

That's how every hallway should look like

Beautiful, isn't it? I mean the peeled wall. Ow, by the way, this screenshot is made by an artist that shows how Halflife2 *could* have looked with modern techniques. Well dammit, hurry on with that third expansion then. And start building Halflife3 already, I've seen enough Combine, Alyx and City17.

So that wall... There are 2 common tricks to achieve such an effect. A: Draw a flat texture/decal on top. B: Make an actual model of it. Option B is too difficult for me, and probably not worth all the polygons. Option A would work 5 years ago, but players are not stupid either. They'll notice it's flat. I'm not sure how the wall is made in this screenshot, but it doesn't look really flat, does it? Yet, if you check the wireframe from the same scene, you won't find curvy wallpaper polygons. Some sort of advanced decal with depth illusion then?

Whatever it is, my game will have quite many boring hallways, so I'd better think of something to make them somewhat more appealing. Regular decals look too flat, especially if they are relative big. So I came up with a somewhat more advanced decal shader, but still as flat as Will Smith's high-top-fade haircut in Prince of Bell Air. I think it's a little bit similar how F.E.A.R made it's bullet holes:

- 1 texture contains the "wall behind" part. Bricks or something. It includes an alpha channel to mask it. Transparent parts just pick the original background. Same like regular decals.
- 1 texture contains a normalMap. Not only for the brick part, also to override the surrounding wallpaper or plasterwork pixels to make it bumpy. That means different masking for the normalMap part of the decal. I'm using a deferred renderer, so overwriting pixel characteristics before the lighting happens goes pretty easy.
- For some additional depth, the normalMap contains height in it's channel for some slight parallax mapping.
- Shadows caused by the foreground are still drawn onto the brick layer. Not computed realtime. Keep them slim so you won't notice. You could however do self-shadowing with a more advanced parallax technique (marching through pixels).

It still sucks compared to the Halflife next-gen screenshot, but that’s probably due my drawing skills. Especially making that crumbled-paper normalMap. Stuff like this really requires an artist. As for the shader, maybe it can be done better with a more advanced parallax technique. I was thinking about making a displacement in the vertex-shader for a moment (like doing a terrain with a heightMap), but couldn’t figure out how to correctly pick the background pixels then. Next time Gadget, maybe.

Sunday, August 29, 2010

Press the Red button

Working on another computer is like cooking in a strange kitchen. All tool are missing or placed in a different drawer. After installing six million tools, I was finally able to work on the project again. Let’s see how many brain cells were lost during the last two weeks.

Noticed that more and more console games are using scripted "hit-the-right-button" sequences last years? God of War and Resident Evil are good examples of this. At some points, you'll have to hit the right (gamepad) button within a short time to dodge, climb-up, respond or uppercut your opponents through a window. Or more annoying, to dance with CJ in GTA San Andreas.

Button bashing is nothing new. Remember this? Sixteen billion pulses per second where needed to break through ruby. Poor SNES pads.

Personally I'm not a big fan of this. As you get older, your reaction time starts to get worse again. Really, I didn't finish God of War simply because I couldn't kill one of the boss characters that required a whole combo of pushing the proper buttons. Since I'm not playing that much with Playstation gamepads either, I just couldn't figure which button to hit. Square?? Where the hell, shit too late. Game over.

Then again, there are some exceptions. Resident Evil 4 for example contains a superb cinematic fight between Leon (you) and Strauser (Dolph Lundgren). It's good because it's just a cool piece of CGI. But instead of watching only, you also take part a little bit by dodging knifes occasionally. Like an interactive movie.


I had a new idea for this guy when falling half asleep... This won't be his final shape!

I'm more into the Halflife approach where the player never-ever loses control over our bearded friend. But having cinematic button-bush sequences can actually help you visualizing the scene precisely the way you want. Especially in horror scenario's where camera-work is crucial for the Boo! effect. You can't expect the player to be watching at the right places all the time, and the first-person view makes it even more difficult to focus on specific parts or to show player motions like climbing back from a abyss or making a counter-attack. Imagine a movie car-chase would be filmed from the lead driver perspective only… you’ll miss about half of the scene.

So I decided to look at some related options
- Taking over control of the player
- Using button(bash) as input for a motion
- Making an alternative temporary camera setup (shoulder cam, watch the player from the front, peek around a corner, etc.)

All possible, but again, you need to insert such features smoothly into an engine so it becomes available for the mapper/scripters in an user friendly way.

One of the better pictures if you ask me. The dusty sprites may need some softening though. This can be achieved by using the depthMap from the camera point of view. For each particle pixel, check if it's nearby geometry. Ifso, fade it out so that the intersections won't be visible.

It's already possible to let the player follow a fixed path (“railing”). But I needed to show a "PUSH! PUSH!!" button that gives impulses to how fast the player runs, instead of a predefined speed. With script functions I can adjust the rail following speed, or give a temporary speed boost (for button bash mechanisms). The boost pulse is also used as a shader parameter to temporarily highlight the indicator image. Although it can be fuzzy sometimes, quite a lot is possible with the scripting, triggers, railing and GUI definition files by now.

Run Dummy, Run! That Shift button looks a little bit odd though... Not the same as those candy Nintendo/Xbox buttons, or the symbolic Playstation ones. Anyway, it's now possible to put the camera somewhere else. Let it follow another entity, or give a fixed location. Ideal if you want the good old fixed Resident Evil1 camera.

Monday, August 23, 2010

Lonely planet


Hey, we're back, alive. Good to see a couple of new visitors came along here as well. So I'd better start writing something useful again. Though except from some vacation stories, I’m still out of ammo. I was hoping to do some work on the laptop, but the bastard gave up on me. A few hours before leaving, one of the cooling fans started to make an ugly loud noise.

So, yesterday I booted my old desktop system again after a long, long time. And guess what, I like it. Good old Windows XP, a wide screen, big mouse, and it actually runs my game slightly faster on a bigger resolution as well. Almost forgot why I used to prefer desktops in the first place. Laptops are expensive, you can't simply upgrade a video-card, and they never live longer than 1 or 2 years. The only advantage is their mobility of course, although my Toshiba weighs 25 tons (the adapter alone is a nuclear power plant on itself). Probably my girl won't appreciate it if I install the desktop in our bed, so guess I'll have to sneak out the next few weeks. Don’t know about you, but most of the productive programming hours are during night for me.

Let's hope Toshiba fixes the damn thing quicker than Hewlert Packerd. Still angry if I think about that. The screen didn't work anymore, so I wrote a letter on top of the laptop. "Screen not ok, videocard kaput maybe?". "DO NOT REMOVE HARD-DRIVE WITHOUT NOTIFYING ME, HERE MY EMAIL/MOBILE NUMBER:" blabla. Really, I pointed out everything. Thus, they replaced the hard-drive, gave me back a laptop with still a broken screen, and threw away my drive full of data. Without notifying me of course. Had to send it back another 2 times before the problem was fixed. Half year later the screen was toasted again, so I gave up on that HP laptop. I'd better call the plumber rather than sending it to HP again.

Hippies
Well, I managed to finish the monster model + animations though, noisy fan or not. @Peter Welzien, thanks for the Sculptris tip! The only thing that remains is drawing a proper skin, and importing the skeleton animations properly. So far my monster would end up in "The Thing", with twisted necks & arms broken Steven Seagal style. Probably some bone matrices are inverted or something. I didn't had the brainpower to trace the bug though, as I was alcoholized most of the time last 2 weeks. Better not mess with your code when being drugged.


Part of the monster model, untextured. A clayish material is used for now.

Talking about drugged... I probably had the weirdest experience of my life in the Ardennes. I'm really not into "drugz", but my friends bought these "truffles". Sort of mushrooms, a mother nature product, and 100% legal in Holland, so I thought what the hell... Sweet mother Maria on a stick.

I always found Fear and Loathing in Las Vegas just a weird movie, but it actually depicts pretty well what happens. Complete chaos. Everything is strange, funny, maybe scary. Your body malfunctions and all you can do is shit your pants if you don't watch out. And although everyone is on the same frequency and "understands" each other with just a few mimics, conversations never go further than 2 or 3 words. Because talking is too damn difficult. Blrrp, dudu blup.

So for the next 4 hours, I saw trees plumbing into the ground, the horizon getting stretched, flattened and bulging. And my friends in that wooden house made me think of an Al Bundy soap series with cardboard decors & a laughing band. So much noise and things going on, can’t relax for a second.

Strange enough the effect smoothly leaves without leaving headaches or any other bad feelings. As if nothing happened. Except there is this aftermath you start to notice... Garbage everywhere, chairs placed inside flower bushes, mattresses below the car, a parasol penetrating the airbed of one, bottles of beers that only miss 1 sip all over the place. The funniest thought is that the neighbors might have seen a bunch of idiots nervously walking/sitting/moving around all the time, talking gibberish, observing little bugs or stones from the gravel driveway. Difficult to explain the whole effect, and therefore probably just as difficult to understand what’s going on from a neighbor point of view. Seeing a couple of guys acting… rather strange.

Uhm, nothing to do with the story, but here's another shot of the monster model. Yes I made it unclear on purpose. Don't want to spoil everything already

Not sure if I'll ever do that again, but it was quite a funny experience. Most of it. I'd like to have control over my body, but with this stuff you'll be downgraded to retarded levels. The only thing you can do is go with the flow, otherwise you might end up in big panic. But since I have a little daughter, I'm quite a careful person. I was continuously stressed and being afraid one of my friends would do something stupid such as starting the car, lighting the campfire, fall down the balcony, burn the kitchen, etcetera. But wonderfully, we only had some wet pants because aiming while peeing became damn difficult. Anyhow, if you ever feel like trying such stuff, I would advise to do it together with persons you trust, and preferably someone sober to keep an eye. You could ask your mom for example.

Poland
Second week I spend in Poland. Didn’t see much from the recent flooding there. Just the typical Polish landscapes; forest, forest, farm, a few houses in forest, and more forest. More towards the cities Wroclaw and Katowice it makes place for deserted buildings, old train stations, and lots of graffiti. Or the famous grayish concrete flats of course. Preferably right next to a stinky factory pipe. To make the view somewhat more happy, much of the houses and flats are painted in bright pink, yellow, aqua blue or ochre green colors though. “Happy concrete”, as I like to call it.

Not a foto of me, but this is a typical train station. However, with a shining sun even places like these can look quite charming. It makes a HUGE difference if you visit Poland in the winter or summer.

Greetings from Bielsko-Biała!

The sober communistic flats and architecture are part of the inspiration for the Tower 22 design though. So I was quite enjoying my view from the train (although… after sitting 16 hour in that wagon…). Don’t know why but the threatening, maybe even somewhat inhumane buildings are fascinating. How the heck can a person live there? Well, acclimatizing works pretty fast, and for the people who live there, this is common business. Still, the contrast between the rather beautiful nature and the cold soulless buildings is sort of unique for a spoiled Western boy like me.

That said, just like many other Eastern Europe countries, Poland evolves quickly. Although my parents in law still use a steam-driven telephone, they also have a huge flat LCD TV. Things are just a little bit simpler here. You’ll walk on your slippers to the bar, instead with your shiny shoes. You’ll drink cheap big cans of beer instead of expensive wine. Instead of separating garbage you’ll just burn everything in the house central oven (which gives a chemical odor all over the place during the winter). Ladas drive in front of Mercedes cars, and pretty girls walk next to old grandma’s who are escorting their cows back home.

I like just walking around here. Whereas villages in Holland are typically well ordered like a Sim City map with straight boring blocks of houses and occasionally a piece of grass, the environment here is much more varying. Curly roads, strange secret paths, and beautiful houses right next to wooden cottages where a witch could live. It’s like those Zelda villages, asking to get explored.

This photo from Milowka was taken during Christmas by the way. I didn’t had a photo camera with me! Stupid.



Well, let's try to make something again for the next weekend. Ow, while being in Poland I red about Crytek's way to do realtime ambient lighting; Light Propagation Volumes. First I'll finish that movie, but this is definitely something I'd like to try out soon. Hopefully I can turn this rather difficult technique into something readable. Although Spherical Harmonics are not exactly my piece of bread either...

Thursday, August 5, 2010

We ain't going to Ibiza

Mailman brought post on thursday already? Yep, I'm going on vacation tomorrow. So just to let you boys(and girls?) know. When nothing appears the next 2 weeks, I'm not dead. Unless my plane or train crashes, I get toxinated by alcohol, kidnapped by terrorists, or eaten by Russian bears.

I'm going to Poland, nearby Zywiec(from the beer) to be precise. Not exactly the place-to-be for spectacular vacations, but I'll have to show my face to the parents in law of course. I can't complain, only have one or two family visits per year. By the way, I decided to take the train this time. Why?
A: Because it gives me that adventurus feeling, being on a looong trip (instead of flying less than 2 hours)
B: The ICE in Germany can drive 400 kmh (in theory), and the second train has a bar-wagon. Maybe I can enjoy a drink with a charming Eastern-Europe James Bond girl!
C: Because I don't like flying, period.


But first, while girl and kid are already in Poland... a week Ardennes with the guys. Woman have to understand that we men have to "ventilate" sometimes as well. Making garbage, doing nothing, drinking, eating raw meat, swearing, etcetera. Look, dogs need to play and run, pigs like to roll in shit, and so do we men have our needs. Because of you we're already behaving ourselves the whole year. Cleaning up, shaving, being polite, wearing clothes and such... So please, just once a year, let us be men again. And Hey, we're not complaining either when you go shopping (on our costs) or having silly girl icecream-on-the-bench nights.


Any programming news maybe? Well... no. I made a bug somehow that took me 3 nights to trace back. Just a stupid adjustment in one of the miliion codelines made a chain reaction of crap. Joy.

The laptop is going with me, so there is plenty of time for modelling and finishing stuff for the movie. If I'm capable that is. No internet though. The most advanced technology at my parents-in-law house is probably the steam driven radio. So... I'll be back.

Sunday, August 1, 2010

Pull my finger

Again a busy week. Long days at work, and our little daughter got two years old yesterday. Just like any Muslim has to visit Mecca at least once, every Dutch family has to visit the "Efteling", our variant on Disney World. So that’s what we did with family and friends. Including our long lost Indiana Jones friend that finally came home this week. After travelling around the world for a year. From Ecuador to Argentina, from India to Bali, from Neptune to the Andromeda solar system, and who knows where else he has been. Looking forward to hear all the stories next week, when he joins us at another “well deserved” vacation in the Ardennes (a stunning 250 kilometer from here). Yeah I know, besides the neighbor countries, Poland and Prague, I haven’t seen much from the world yet.

Anyway, not much programming, but a fun weekend nevertheless. Lovely how that little girl is still completely fascinated by chunky moving robot dragons and plastic pirates on strings. Beautiful to see how pure children still are. Untouched, unprejudiced, still clean from all the bad things in this world. Then to think I never really was a childrens man. Not that I don’t like them, I do, but I just didn’t know how to behave when they are around. I’m too serious for doodoo-daada conversations, scared to break them / make them cry, or scared to get a slap by a concerned mother that thinks I’m a pedophile or something. But there you go, things can radically change in a few years :)

Thank God this train only moves about 3 miles per hour, without loopings. One of the fears that comes with being a daddy is, besides chasing away 16 year old boyfriends on scooters, having to ride the rollercoaster with your daughther one day.

Okidoki. Game programming then. I spend the scarce free hours this week on making a trigger system. I wrote about scripting several times before, but in case you don’t really know what they are… Scripts are adjustable pieces of text/code that can tell what to do. Usually written in a higher (somewhat “easier”) level programming language. Just like with any other programming language, you can apply all kinds of logic. However, in this case the actual work is still done by the underlying engine. Script tells “play sound” or “walk to point B”. Then the engine does the actual (difficult) work. Compare it to cartoons where you have the Muscle and the Brain. The engine is the dumb guy that does all the dirty jobs, the script is the evil genius that makes the plans.

One of the biggest pro’s about using scripts is that they are A: relative easy to write. And B: you can change them afterwards without having to change/recompile the engine code. This makes it perfectly possible to separate specific game stuff (rules, events, behavior) from the engine. But there is also a downside; script runs slower. Although computers are fast these days, it’s still not recommended to perform complex routines inside a script, and certainly not every cycle. Which is why scripts are usually just small pieces of code that instruct the engine. Engine asks what to do, script briefly instructs.

The ping-pong communication between the two can be a little bit chaotic sometimes. And although scripts are great, I still try to avoid them as much as possible in order to keep things simpler and faster. Since I’m quite familiar with PLC’s, AND/OR/NOT’s, pulses and delays, I thought “why not making a trigger system?”. Here a trigger is a set of conditions and events.

After doing it 54259 times, I'm starting to hate designing forms with lots of checkboxes and such. I looked for an "Object Inspector" component for Delphi7, but couldn't find a free one... Maybe I should make one myself... or maybe not.

The picture above shows an example. A set of engine built-in conditions and events can be used to compose a trigger. For example, check if the player is inside a certain part of the map, is looking at object B for at least 2 seconds, and has a screwdriver in its inventory. IFSO, play a sound, spawn an object, change the weather, or whatever.  
Conditions:
- Test if entity is inside a region. Eventually filter on group, velocity, etc.
- Test if entity A can see entity or point B
- Compare entity property or global variable (health / battery less, equal or more than X)
- Do a date/time or weather check (handy for populating streets in GTA kind of games)
- Test if person has item X inside inventory
- …
Events:
- Play sound
- Hide/Show objects
- Give something
- Spawn object
- Start cinematic script
- Adjust entity property or global variable (health += 10, … )
- Change light / atmosphere, day/time or weather
- Open or close doors
- …
Now it’s possible to construct quite complex logic, without having to use scripts. All the items above are common checks and do not cover specific game code either. And otherwise scripts can still be used to define specific conditions or events.


Last but not least, the trick is to know which triggers to check and which not. In an open roaming world like this one, you could have thousands of triggers in total. Although the checks are fairly simple, you still don’t want to evaluate that whole shitload. Especially not if 99.9% of the conditions will turn out false anyway. Therefore I made an “active list”. Each sector (a room or corridor for example) carries its own set of triggers. As soon as you get nearby enough, it will put its triggers into that “active list”, from where they get evaluated every cycle. The few triggers that are not bound to a specific location can still be inserted/removed manually via a script as well.


Now this stuff didn’t bring me nice new pics for this week, so you’ll have to do with this dusty crap. Same old apartment room, but decorated with some of the newer objects I added last months. Nice to have a growing library of garbage to put in that world. If the horror idea fails, we can still turn it into The Sims go Soviet.