Saturday, August 30, 2008

Convex Decomposition

hi, this time i fixed my physics objects support so i could add more complicated objects to the scene not just box, sphere etc, but also concave models.
physx does not support dynamic concave objects but it support multiple collision shape per obj so in order to support concave objects we must do something called: convex decomposition which break down or split the mesh into few convex meshes.
the data is stored in xml file which include all the info to create the convex mesh shapes that describe to render model.
i created new function in the physics manager that creates physics obj directly from this xml file, also i add the ability to specify collision script file (this xml) to every render model exist in the scene.
to work with xml files i use tinyXml which is very small and easy to use.
here is few screenshots that shows perfect collision with concave objects:

tables lies on the inner part of other tables
note the left table edge placed on the right table

tables placed on the inner parts of other tables

Saturday, August 23, 2008

Sound Manager

hi, this time i worked on the sound system, there is a lot of sound libs such as openal, bass, fmod, miles.
i chosed to use fmod ex because it is very advanced system and very easy to use.
i created sound manager to manage all sound creation in the game, i also add something called sound shader which is very similar to my material script.
sound shader is a script that let you to define specific parameters to one or few sounds and when you want to play the sound/s in that shader you just call CreateSoundFromShader(shaderNameInScript) which is a function inside sound manager and it will be played with all the attributes you specified in the script.
for example:
sound weapon_blaster_fire
{
minDistance 393
maxDistance 1181
volumeDb -2
frequentlyused

sound/weapons/blaster/fire01
shakeData 0 zzzztsolggeedccbbbaaaaaaaa
sound/weapons/blaster/fire02
shakeData 1 zzzztsolggeedccbbbaaaaaaaa
}
1) weapon_blaster_fire is sound shader name which we called from the code
min/max distance is the distance which the sound is audible
2) volumeDb is volume in decibels
3) frequentlyused is one of few flags that allow me to control few sound attributes such as occlusion, looping etc. this is used to cache the sound so it will be played from memory and wont be decompressed every time we want to play it
4) sound/weapons/blaster/fire01 and sound/weapons/blaster/fire02 is 2 sound files we wish to play while activating this sound shader. by default we chose randomly one of them.
5) shakeData is intensity of the sound in ascii form (z is loud, a is complete silence), i use it to change camera view based on the sound volume.
few of the sounds in the game must be played in relation to model animations, so to make it possible i created something called frame based event system, which allows you to specify events that will be triggered on specific animation frame/s.
for example, this is how i created shotgun reload sound events:
VIEW_RELOAD_CMD =
{
"RELOAD", "9", "sound", "weapon_shotgun_clipout",
"RELOAD", "22", "sound", "weapon_shotgun_clipin",
"RELOAD", "35", "sound", "weapon_shotgun_pump1",
"RELOAD", "38", "sound", "weapon_shotgun_pump2"
}
"RELOAD" is animation name
"9", "22", "35", "38" is frames to trigger the event
"sound" event type - all of them is sound
the last parameter is based on event type, in sound events its sound shader name

Saturday, August 16, 2008

Material Hit Effect

hi, this week i fix my projectiles hit effects so they support per surface material effect,
until now, i had only one impact effect per projectile for all surface types, this was very unnatural when you hit water surface because it was applied the same effect on it, so you saw decal rendered on the water, yes - very strange so now if you hit glass surface the effect will be different when you hit stone or liquid surfaces, depending on what you defined in the weapon script.
here is a screenshot that shows the effect on stone, glass surfaces:

left: stone hits, right: glass hits

Saturday, August 2, 2008

Weapons Sniper Scope

hi, i'm still working on weapons features, this time i added sniper scope with nice radial blur effect.
to create this radial effect i needed to add few features to material system so i could define which shader to use in which stage and which shader parameters and samplers i need to bind when binding this shader.
i also add the option to use current back buffer image as one of the samplers i'm binding to the shader, so i could create post process effects.
the effect i chosed is radial blur so everything outside our zoom area will be blurred and stretched.
i also change aim accuracy based on zoom, the more we zoom in the more we get accurate.
here is screenshots of the effect.