Object rotation

Introduction
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
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.''

Euler to Quaterion Calculator Quaterion to Euler Calculator

Example
... to come ...

Matrix
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

Identity matrix stored in effects.bin

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:

Sample output:

NOTE: Script works in GMAX too.

Example
... to come ...