Game Engine Architecture 7

1、SRT Transformations

  When a quaternion is combined with a translation vector and a scale factor (either a scalar for uniform scaling or a vector for nonuniform scaling), then we have a viable alternative to the 4 x 4 matrix representation of affine transformations. We sometimes call this an SRT transform

    Game Engine Architecture 7

2、Dual Quaternions

  A rigid transformation is a transformation involving a rotation and a translation.

  A dual quaternion is like an ordinary quaternion, except that its four components are dual numbers instead of regular real-valued numbers. A dual number can be written as the sum of a non-dual part and a dual part as follows: ˆa = a + e^b. Here e is a magical number called the dual unit, defined in such a way that e^2 = 0 (yet without e itself being zero). This is analogous to the imaginary number.

3、Rotations and Degrees of Freedom(DOF)

  "six degrees of freedom"  This refers to the fact that a three-dimensional object (whose motion is not artificially constrained) has three degrees of freedom in its translation (along the x-, y- and z-axes) and three degrees of freedom in its rotation (about the x-, y- and z-axes), for a total of six degrees. 

4、Plances

  Game Engine Architecture 7

  plane normal. If the vector [A B C ] is normalized to unit length, then the normalized vector [a b c]= n, and the normalized parameter d = D/ sqrt(A2 + B2 + C2) is just the distance from the plane to the origin. The sign of d is positive if the plane’s normal vector n is pointing toward the origin (i.e., the origin is on the “front” side of the plane) and negative if the normal is pointing away from the origin.

  

  we need only the normal vector n = [ a b c ] and the distance from the origin d. The four-element vector L = [ n d ] = [ a b c d ] is a compact and convenient way to represent and store a plane in memory. Note that when P is written in homogeneous coordinates with w = 1, the equation (L P) = 0 is yet another way of writing (n P) = -d. These equations are satisfied for all points P that lie on the plane L. 

5、Axis-Aligned Bounding Boxes (AABB)

  Game Engine Architecture 7

6、Oriented Bounding Boxes (OBB)

  testing whether or not a point lies within an OBB, but one common approach is to transform the point into the OBB’s “aligned” coordinate system and then use an AABB intersection test as presented above.

7、Frusta

  Testing whether a point lies inside a frustum is a bit involved, but the basic idea is to use dot products to determine whether the point lies on the front or back side of each plane. If it lies inside all six planes, it is inside the frustum.

  A helpful trick is to transform the world-space point being tested by applying the camera’s perspective projection to it. This takes the point from world space into a space known as homogeneous clip space. In this space, the frustum is just an axis-aligned cuboid (AABB). This permits much simpler in/out tests to be performed.

8、Random Number Generation

  random number generators don’t actually generate random numbers— they merely produce a complex, but totally deterministic, predefined sequence of values. For this reason, we call the sequences they produce pseudorandom, and technically speaking we should really call them “pseudorandom number generators” (PRNG). What differentiates a good generator from a bad one is how long the sequence of numbers is before it repeats (its period), and how well the sequences hold up under various well-known randomness tests.

9、Linear Congruential Generators

  this algorithm is sometimes used in the C standard library’s rand() function. 

  The numbers produced do not meet many of the criteria widely accepted as desirable, such as a long period, low- and high-order bits that have similarly long periods

10、Mersenne Twister

  It was designed to have a colossal period of 2^19937-1 = 4.3 x 10^6001. It is fast.

  Various implementations of the Twister are available on the web, including a particularly cool one that uses SIMD vector instructions for an extra speed boost, called SFMT (SIMD-oriented fast Mersenne Twister).

11、C++ Static Initialization Order

  In C++, global and static objects are constructed before the program’s entry point. However, these constructors are called in a totally unpredictable order. The destructors of global and static class instances are called after main() and once again they are called in an unpredictable order.

  所以全局单例模式,在C++中不合适。如下:

    Game Engine Architecture 7

 

12、Construct On Demand

  A static variable that is declared within a function will not be constructed before main() is called, but rather on the first invocation of that function.  So if our global singleton is function-static, we can control the order of construction for our global

singletons.

class RenderManager
{
public:
    // Get the one and only instance.
    static RenderManager& get()
    {
        // This function-static will be constructed on the
        // first call to this function.
        static RenderManager sSingleton;
        return sSingleton;
    }
    RenderManager()
    {
        // Start up other managers we depend on, by
        // calling their get() functions first...
        VideoManager::get();
        TextureManager::get();
        
        // Now start up the render manager.
        // ...
    }
    ~RenderManager()
    {
        // Shut down the manager.
        // ...
    }
};
View Code

相关文章:

  • 2021-07-09
  • 2022-01-30
  • 2021-08-06
  • 2021-09-25
  • 2021-12-14
  • 2021-06-27
  • 2021-08-23
  • 2021-08-12
猜你喜欢
  • 2021-07-28
  • 2021-09-16
  • 2022-02-24
  • 2021-10-24
  • 2021-10-10
  • 2021-08-11
  • 2022-02-28
相关资源
相似解决方案