Core Overview

Sce.PlayStation.Core provides features such as math functions that are the basics of game programs.

Math Functions

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.

Vector Type

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.

Packed Type

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.

Unit and Coordinate System

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.

Usage Example

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

Usage Example 2

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 ) ;

About Argument Restrictions

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.

  • Matrix4.Transpose()
  • Matrix4.Inverse*()
  • Matrix4.Multiply*()
  • Matrix4.Transform*()
  • Vector3.Cross()
  • Vector3.Rotate*()
  • Vector3.Perpendicular()
  • Vector2.Rotate()
  • Vector2.Perpendicular()
  • Quaternion.Multiply()
  • Quaternion.Transform()