Sce.PlayStation.Core provides features such as math functions that are the basics of game programs.
Contents
FMath is a static class that provides math function wrapper functions and convenience functions. Math functions for float and various other useful functions are defined.
Matrix4, Vector4, Vector3, Vector2, and Quaternion Rectangle are structures that indicate vector types that have float elements. 4D matrices, 4D or less vectors, quaternions, and rectangles are defined.
Rgb*, Half*, Short*, UShort*, Byte*, and UByte* are structures that indicate data types used in graphics. Integer expression color types, half precision floating-point types, and fixed-point types are defined.
The angle is shown in radians. The matrix is shown in a right-hand coordinate system. In addition, the matrix multiplication order is parent*child and matrix*vector. Note that the matrix multiplication order is backwards from the Cg shader language. For example, WorldViewProjection in the semantics of the Cg shader language is calculated as projection*view*world in Sce.PlayStation.Core.
The following code is an example of matrix creation, calculation, and element access.
Matrix4 m4 = m1.Inverse() ; // member function
Matrix4 m5 = m1.Multiply( m2 ) ; // member function
Matrix4 m6 = m1 * m2 ; // operator
float f1 = m4.M11 ; // attribute
Vector4 v1 = m4.ColumnX ; // property
If desired, a static function can be used in place of a member function.
To improve performance, an overload function which takes a reference argument can also be used.
Matrix4.Inverse( ref m1, out m4 ) ;
Matrix4.Multiply( ref m1, ref m2, out m5 ) ;
When using a function that takes a reference argument, correct results will not be calculated if a variable the same as the "this" argument or "ref" argument is specified to the "out" argument.
In particular, be careful with the following functions.