Ejemplo n.º 1
0
        protected virtual void updateMatrixes()
        {
            if (!_areMatrixesDirty)
            {
                return;
            }

            Matrix2D tempMat;

            _transformMatrix = Matrix2D.createTranslation(-entity.transform.position.X, -entity.transform.position.Y);               // position

            if (_zoom != 1f)
            {
                Matrix2D.createScale(_zoom, _zoom, out tempMat);                   // scale ->
                Matrix2D.multiply(ref _transformMatrix, ref tempMat, out _transformMatrix);
            }

            if (entity.transform.rotation != 0f)
            {
                Matrix2D.createRotation(entity.transform.rotation, out tempMat);                   // rotation
                Matrix2D.multiply(ref _transformMatrix, ref tempMat, out _transformMatrix);
            }

            Matrix2D.createTranslation((int)_origin.X, (int)_origin.Y, out tempMat);               // translate -origin
            Matrix2D.multiply(ref _transformMatrix, ref tempMat, out _transformMatrix);

            // calculate our inverse as well
            Matrix2D.invert(ref _transformMatrix, out _inverseTransformMatrix);

            // whenever the matrix changes the bounds are then invalid
            _areBoundsDirty   = true;
            _areMatrixesDirty = false;
        }