| |
| |
 |
|
| |
| |
30/5/2005
For the non-technical of you out there this may bore you! (Also, to clear up any confusion particle systems are often used represent explosions, sparks, smoke etc.. in games.)
I’m not sure if I mentioned that I completed the virtual machine for my particle system the other day. You can create and manage particles without using the VM if required but it is a nice addition to the functionality of the demo harness. Just to recap, the motivation behind creating a VM for handling the initial and ongoing creation of particles was speed. Lua is fast, but not that fast. Repeatedly calling lua script functions (as would be required by a custom particle effect generating new particles every 10th of a second say) is slow. I wanted to maintain the data-driven nature of the whole demo harness with the particle system, so using a VM was a good way to go. VM programs can be defined using lua script (using a scripting language to define a program in another scripting language…) and are interpreted by the native code VM as required.
The VM is register based, the initial stack based plan being overkill, and it’s instruction set resembles the Direct3D vertex shader set. For anyone who is interested the current instruction set is included below. I have not included any instructions requiring “forward jumps” for simplicity although I am considering adding instructions such as If and For and maybe simpler instructions such as Compare.
The set of registers available is as follows:
- 8 Input Registers (set before the VM is first executed)
- 8 Persistance Variable Registers (can also be given an initial value. Value persists between code executions)
- 16 Tempoary Registers (value does not persist between code executions)
- 7 Output Registers (no read access - for new particle pos, size, UVOffsetSize, velocity, userData, userDataVelocity, timeSpan, size)
The registers themselves are type-less. A value carries it’s own type with it, with supported types being a single float, a vector(dim: 4) or a matrix(dim: 4×4). Not all instructions can operate on every type of course (e.g. Cross only applies to vectors, as does Dot).
In addition to specifying constant values for the input registers you can also specify a generic property. A property is a concept used in the demo harness to allow objects to expose values as objects themselves with either read, write or read-write access. This allows you to (for example) create a particle generator for a missile smoke trail that generates new particles that are always behind the missile in the correct position and is quite a powerful tool and also helps to keep everything data-driven from the script side. Input registers set to a property have their values samples at the at the start of each execution of the VM code.
The VM code is stored in an array of bytes, 1 byte per instruction. Arguments following an instruction consist of one type byte and a variable number of bytes following. Arguments can specify a particular register or be a constant value (again float, vector or matrix).
The VM itself is a fairly simple affair using utility functions to acquire the value of the supplied input arguments, a generic value structure for performing basic artithmetic between arguments of differing types and another util function to store the result in the supplied destination.
I haven’t really optimised the VM yet but already it runs at a very suitable speed. The initial optimisation I may make is to align constant matrices and vectors to 8 or 16 byte boundaries in memory for faster handling (when using SSE\SSE2 etc…).
In addition the the functionality provided by the VM, the general particle manager also supports groups of particles having their own individual velocity and being affected by gravity. The particle manager also handles things like sorting the particles based on distance from the viewer if required and sorting groups of particles by material type for reduced state changes.
Some screenshots will hopefully follow soon, maybe even a small video, after I’ve finished moving appartment.
(Hmmm. I’m having issues getting the below to come out correctly. Bear with me.)
The (Current) Particle VM Instruction Set:
// Basic Commands
Move // [ins] [dest] [src]
SetComponent // [ins] [dest] [component] [src]
// [dest] is a vector, [src] is a float
// Sets component [component] (0-3) of [dest] to [src]
GetComponent // [ins] [dest] [src] [component]
// [dest] set to a float, [src] is a vector
// Sets [dest] to the component [component] (0-3) of [src]
SetFrequency // [ins] [arg]
// [arg] is a float, in seconds.
// Particle Commands
SubmitParticle
// Arithmetic
Mul // [ins] [dest] [src1] [src2]
Div
Add
Sub
Dot
Cross
Normalise // [ins] [dest] [src1]
Length
LengthSqd
Cos
Sin
Tan
// Looping
Do // [ins]
WhileLT // [ins] [arg1] [arg2]
WhileGT
WhileEQ
WhileNEQ
// Generation
RandomFloat // [ins] [dest] - Sets dest to a random float between 0 and 1
RandomVec // - Sets dest to a random vector with each component ranging from between 0 and 1
RandomVecCube // - Sets dest to a random vector with each component ranging from between -1 and 1
RandomVecSphere // - Sets dest to a random vector representing a point on a sphere centered at 0,0,0 with radius 1
// - (Correct random distribution)
RandomInt // [ins] [dest] [arg]
// - Sets dest to a random whole number float between 0 and arg.
// System Commands
Exit // [ins] - No need to use explicitly.
28/5/2005
I am a Defender-ship.
I am fiercely protective of my friends and loved ones, and unforgiving of any who would hurt them. Speed and foresight are my strengths, at the cost of a little clumsiness. I’m most comfortable with a few friends, but sometimes particularly enjoy spending time in larger groups. What Video Game Character Are You?
|
Good to know.
Suprisingly accurate as well!
27/5/2005
This is a bit of a hotch-potch of technical details on how I am currently going about working on my portfolio demos, written very early in the morning. Mistakes may be abound!
I am working increasingly more with content rather than code as I near the end of my main portfolio demo. This is something relatively new to me, having to spend proper amounts of time tweaking things so that other people, besides me, can understand what is going on. It is actually rather satisfying once you get used to the tools you are using. For scene composition I am finding it useful to first mock up a rough model of the scene I am working on, before starting to model the final scene and gather the final art assets. Wings3D is my application of choice for quickly blocking out a scene as it has a fairly “no-nonsense” interface and is quick to use. Once I have my mock-up I can check that my planned camera placement\movements will work etc…
The mock-up itself is usually based upon (fairly detailed) notes I have previously written (usually in a coffee shop somewhere in Uppsala) together with annotated plan-style sketches. In my notes and annotations I include details such as graphical effects used for each surface, any physical behaviour required, any game-logic related behaviour required etc… From this I can build up a set of three lists: Required Materials & Visual Effects, Required Physical Rigs, Required Entity Script.
The final model geometry, as I mentioned in a previous post, is modelled in a mixture of Wings3D and Truespace. I usually group the model surfaces in Wings3D based on their desired material so that I can easily apply the final materials in Truespace. For each required material I use a makeshift texture map, looking as near to the final material as possible, to texture map the model in Truespace. Each makeshift texture map shares its name with the material it represents. The model is then exported to the D3D X format and when loaded by the demo, the makeshift texture names are used to lookup the final material from the material library.
I then create the dynamic entities and their physical rigs in Truespace and export (to lua script) ready for use. Final entity behaviours are scripted in Lua and tested, and converted to native C++ code if speed becomes an issue.
Material creation breaks down into two steps: Choosing\creating a visual effect and Choosing the various image maps and options to be used by the effect. If the required visual effect already exists material creation just boils down to tweaking a few parameters and choosing a set of maps to use (base, normal, gloss, etc…), otherwise creating a new visual effect from scratch can be quite time consuming.
Currently the main surface shading styles being used are basic lambertian, phong-style metal, simplified oren-nayor and a transparent water-like effect. All support cube-map based ambient light lookup to prevent shadowed areas from appearing “flat” and shadow-mapping (casting and receiving). Support is also build into the “standard” shaders for transparent objects casting shadows (more or less) correctly.
Below is the current mockup I am working off to create the scene for the final iteration of my main portfolio demo. Hopefully, when the demo is released you can see how faithfull I have ended up being to this mockup.

26/5/2005
OK. Well Karin is much better now and came out of hospital today. She is so much better in fact that her doctors say that she can fly to America with her family on Friday which is good news for her (I will be worried however, and had kind of gotten used to the idea of Karin being home for the next two weeks - she should have a great time though).
While Karin is in the States I will be returning to England for a short spell, from the 2nd June to the 8th, so I am looking forward to that. I’m going to chill out mainly - thereby increasing the revenue of The Coopers Arms in Reading by approximately 100% -, the last week being stressfull and all, so I may not get around to see everyone I said I would, but this doesn’t mean I don’t love you. Oh No! I shall be back in the land of bowler hats and teenage pregnancy again on the 24th for a longer 2Wk period.
Sadly I will not be in England long enough to catch Mono Effecto’s next gig (9th June - Hoxton) but I encourage everyone else to go as they are excellent…(they also recently headlined the Bud Rising Festival so now is a good time to see them).
Work is going well again, although I have a pretty packed week with having to move rooms and clean up and all, but I should be making some serious movement towards a finished article in the coming couple of weeks…
22/5/2005
Karin had her appendix removed yesterday but it all went fine and she is resting in hospital now. I think that she will probably be kept in hospital for about a week on antibiotics just to make sure everything is back to normal inside her.
Karin had her operation before I arrived at the hospital yesterday so I waited in Uppsala for a while before going to the hospital at around 3pm. I then ended up waiting over 8 hours to see her! I know the reception and canteen area of the hospital very well now! It wasn’t as boring as you might think as I had my notebook (paper, not a PC!) with me and so could do some work, and it was definitely worth waiting to see Karin.
Well, I’m off to the hospital again now, after a much needed mammoth sleep last night.
Mike.
20/5/2005
Today wasn’t so great as Karin is currently in hospital. After being sick through-out most of the night and experiencing bad stomach pains Karin and I went to the hospital this morning and after a fair bit of waiting (we were next in line until a girl barely able to stand came in, followed by a pregnant lady!) Karin was taken up to a ward and given a drip (Karin was very dehydrated) while they awaited a slot at the x-ray department. The x-ray is due in about 20 minutes so we should know more then. Most likely nothing too serious but it is good that Karin is in hospital now. I have just got back to our room to sort a few things out and what-have-you but will be heading back early tomorrow morning if not later tonight, so I will probably be out of contact for most of this weekend as mobile phones have to be turned off in the hospital.
It’s quite odd being in a hospital over here as it makes me feel more “at home” than being in Uppsala town center as I am quite used to mooching around hospitals for one reason or the other. For Karin however this is her first time in a hospital so she is quite nervous, but she is being brave and has me to look after her(!! - I nearly lost my fingers in her spring-loaded hospital bed as I put the back up!).
Get Well Karin!
Mike.
19/5/2005
I haven’t posted an update on the current status of my work recently so here it is.
On a non-work related note Karin has been ill for the last few days, and even after a trip to the hospital she feels no better, still being sick often. And Karin has her end of year University exams this week. She is working away well though, bless her, so I think that she will do fine but hopefully she will also start to feel better soon.
Work is going at a reasonably satifactory rate at the moment. Taking a break from the more graphical elements of the demo harness system I spent a couple of days integrating the Novodex physics engine into it with very pleasing and rapid results. I enjoy working with physics simulations in general, having written a particle based physics engine a couple of years ago now (I think), and I evaluated the first version of MathEngine and a few others a few years back (Interestingly most of the ones I evaluated have now gone bust or been bought up). For a while now I have had my eye on Novodex as a suitable candidate for integration, often perusing the manual and checking out the latest version, and it seems I have made a good choice. The quality of the simulation seems solid, providing you deal within a reasonable number of constraints (keep gravity lowish, keep the ratio of masses between two jointed objects to within a factor of 10 etc…) and the API is nice to use with only a few bug-bears.
Created entities in the current scene can be assigned custom a behaviour object that handles responses to various events and messages, you can even use a lua script object to handle responses to one, some, all events if you wish. This allows for fast prototyping of entity behaviours in Lua script before commiting the behaviour to faster native C++ code seamlessly.
The current tool chain I use for 3D content is to model in Wings3D, touch up in Truespace, texture in Truespace (usually) and then export to a D3DX .x file for use by the demo harness. This fitted in nicely with the introduction of physical properties as I have used a Truespace plugin I wrote for my SmallWorld engine, slightly modified, to allow me to define physical bodies and their collision shapes in Truespace together with any joints acting between them and export them to a Lua script for use in a demo. This is working suprisingly well, with objects like “wobbly bridges” being easy to model. The plugin and script also supports creating “instance-able” entities which is quite cool.
I would point out the Truespace is not what I would recommend for this kind of work. It is, in my opinion, a rather second grade modelling program, but as I already have a license for it (and little - or no! - spare cash) it is what I am using.
I still have a few last joint types to add support for in my Truespace plugin but no major work.
I have also just finished the foundation for the particle effects system for the demo harness (just implemented as a custom controller object) and I am about to work on the next stage of a basic virtual machine to allow for flexible and scriptable (custom VM and not Lua for speed) particle generators (for things like explosions, missile trails, dust etc…).
So, I guess it is going well. Some pictures may appear sometime soonish, maybe.
Mike.
16/5/2005
Or: Never Let A Mathematician Make Breakfast.
I was pretty hungry this morning (about 6-7am) after working all night so I thought that I’d make some pancakes.
Simple enough.
I knew the basic recipe but I thought that I would check anyway, in case I remembered the quantities wrong and ended up with Yorkshire Pudding, so I found a recipe online (courtesy of Delia Smith of all people) and copied it out. So far so good. I went into the kitchen and assembled the required ingredients. And then I realised we don’t have a set of scales. And I needed 110g of flour. I wasn’t sure of the density of flour so I needed some way to measure weight. To do that I needed to have something I knew the weight of so I could create a balance. After looking around a while the most accurate known weight I could come up with was that 1ml water = 1g. So I needed to balance 110ml of water with the correct amount of flour. Except I couldn’t find anything suitable to make a set of balance scales with. All the useful materials like meter rules and dowling you have at school are strangely absent from your average kitchen.
OK, no problem I thought. I had found a 1/2 cup measuring spoon with the appropriate number of ml on it, so I decided to look online for the density of flour. Except I couldn’t find any suitable information. But I ended up finding this page with the information I required on it. All that remained now was to get the correct amount of water and milk. Which took a little while as I only had a 125ml spoon and a 15ml one.
But finally I had my batter! And shortly afterwards, my pancakes. It was a bit dissappointing as it took about 100 times longer to make the pancakes than eat them. And I literally deep fried the first one in butter by mistake.
Ah well.
As Karin told me later I could have just remembered the 2-4-8 rule (2 eggs, 4 dl flour, 8 dl milk)…
Never let an over-tired programmer with a mathematical mind make breakfast.
13/5/2005
While you and I are safe at home, a crack team of scientists are hunting the “Mongolian Death Worm“!
Please think of them, braving it in the Gobi desert, next time you complain about something trivial!
Seriously though, it would be cool if they found one…
3/5/2005
So, what did I do over the weeked?
Well. I spent Saturday fighting off the drunken student (and otherwise) hordes in Uppsala town center. Saturday was “Valborg” - a Swedish celebration of spring - that is taken very seriously in Uppsala. University tradition dictates (and I mean that strongly) that everyone should have a champagne breakfast, listen to the university president speak a bit and then run down into town to get slaughtered. By the time I woke up (about 4pm, to the sounds of “Ring Of Fire” by the late great Johnny Cash being played full blast by someone nearby) everyone was pretty messed up. Being in a bad mood I walked into town for some food. Town was a mess, with crap everywhere. Drunken students lined the roads, falling over, being picked up and - I’m sure - being sick. Lovely.
Saturday night (I haven’t been sleeping much lately) I spent in our closet, sitting on the floor with my laptop on a suitcase in front of me with clothes hanging down around me. No, Karin and I hadn’t had an argument, Karin had a friend staying over and I didn’t want to disturb anyone while I worked and the kitchen communal area was a mess. As my laptop acts as a space heater at the best of times it got rather hot so 4 hours in I was semi-naked trying not to faint. Still I got a load of good work done.
Normally any excuse to have a good time sounds good to me but a mixture of not sleeping and eating a less than wholesome chinese buffet on Friday did not put me in the mood to participate. I’m sure you needed to know that.
Anything else?
Oh, yeah. At 4am some English “gentlemen” on a balcony opposite our window decided to endear themsleves to the Swedish people by shouting and throwing things at the few people walking past and singing such traditional English songs as “You bald c…” and the like to a guy minding his own business on another balcony.
And then someone went to the toilet in our appartment block’s stairwell. God knows what he/she used for toilet paper…
God Bless Sweden and Valborg.
Anyway, work is going well, I’m very focused on it and I am currently just adding extra graphical effects and shine to the main demo. Maybe I’ll show you something soon. But then again, maybe not.
(I’m putting off writing about Resident Evil 4 for some reason but I will hopefully get around to it soon…)
|
|
|
| |
|
|
| |
|
|
|
|