There are two possible ways to rotate objects in Hidden & Dangerous 2. In most files the roation is specified in quaterions. In some cases the roation is included in a 4x4 transformation matrix (TM) which handles also the position and size of an object.
Quaternions are used in files like actors.bin or scene2.bin to handle rotations of objects.
About quaterions on euclideanspace.com:
Quaternions have 4 dimensions (each quaternion consists of 4 scalar numbers), one real dimension and 3 imaginary dimensions. Each of these imaginary dimensions has a unit value of the square root of -1, but they are different square roots of -1 all mutually perpendicular to each other, known as i,j and k. So a quaternion can be represented as follows:
a + i b + j c + k d
It may seem strange that there are 3 square roots of -1, but we have to remember that we are working in 4 dimensions so there are at least 3 ways to get round from +1 to -1. It is not very practical to try to draw 4 dimensions in 2 dimensions, but here is an attempt:
We have to be very careful with this picture of quaternions, it gives an intuative feel for how quaternions can represent rotations in 3D but it is misleading, we might think from this (as Hamilton did) that since i² =-1 that therefore i² represents a rotation of 180° and so 'i' represents a rotation of 90°. This is wrong! As we shall see below, to make it work porperly, we need to halve the angle so 'i' represents a rotation of 180° and i² represents a rotation of 360°. So +1 and -1 both represent the same rotation, this will be explained more fully later.
... to come ...
FIgured out by hdmaster, used e.g in effects.bin
Matrices can be represented in different ways (left-handed or right-handed, Y-up or Z-up) thus we have to swap column 2 with column 3.
Identity matrix in DirectX
[1,0,0] [0,1,0] [0,0,1] [0,0,0]
Identity matrix stored in effects.bin
[1,0,0] [0,0,1] [0,1,0] [0,0,0]
Creating a TM is fairly easy using 3ds Max. Try to load the scene.4ds into Max, create a dummy and place the dummy where you want to have your particle effect. Now with your dummy still selected open the MAXScript-Editor, copy & paste the script below into the editor and run the script. Open the MAXScript-Listener window to see the TM of the dummy/particle and copy the values into your effects.bin file.
Here's the script:
function GetTM = ( print ( "TMatrix: "+$.Name ) a = $.Transform.Row1 b = $.Transform.Row2 c = $.Transform.Row3 d = $.Transform.Row4 format "[%, %, %, 0]\n" (a.X as String) (a.Z as String) (a.Y as String) format "[%, %, %, 0]\n" (b.X as String) (b.Z as String) (b.Y as String) format "[%, %, %, 0]\n" (c.X as String) (c.Z as String) (c.Y as String) format "[%, %, %, 1]\n" (d.X as String) (d.Z as String) (d.Y as String) OK ) GetTM()
TMatrix: Dummy001" [1.0, 0.0, 0.0, 0] [0.0, 0.0, 1.0, 0] [0.0, 1.0, 0.0, 0] [3.0, 0.0, 5.0, 1]
NOTE: Script works in GMAX too.
... to come ...