Photon Quantum 3.0.0

Public Member Functions | Static Public Member Functions | Public Attributes | Static Public Attributes | Properties | List of all members
Quantum.Transform3D Struct Reference

The Transform3D is an entity component providing position and rotation for a 3D object. More...

Inheritance diagram for Quantum.Transform3D:
Quantum.IComponent

Public Member Functions

override int GetHashCode ()
 Overrides the hash code generation of this type. More...
 
FPVector3 InverseTransformDirection (FPVector3 direction)
 Transforms a direction from world space to local space. Rotation is expected to be normalized. More...
 
FPVector3 InverseTransformPoint (FPVector3 position)
 Transforms a position from world space to local space. Rotation is expected to be normalized. More...
 
void LookAt (FPVector3 position, FPVector3? up=null)
 Rotates the transform so the forward vector points at position . If up is not set, will use FPVector3.Up instead. More...
 
void Rotate (FP xAngle, FP yAngle, FP zAngle, bool normalize=true)
 Applies a rotation of zAngle degrees around the z-axis, xAngle degrees around the x-axis, and yAngle degrees around the y-axis (in that order). More...
 
void Rotate (FPVector3 angles, bool normalize=true)
 Applies a rotation of angles .z degrees around the z-axis, angles .x degrees around the x-axis, and angles .y degrees around the y-axis (in that order). More...
 
void Rotate (FPVector3 axis, FP angle, bool normalize=true)
 Rotates the object around the given axis by the number of degrees defined by the given angle. More...
 
void RotateAround (FPVector3 point, FPVector3 axis, FP angle, bool rotateTransform=true)
 Rotates around a given pivot point. More...
 
void Teleport (FrameBase frame, FPQuaternion rotation)
 
void Teleport (FrameBase frame, FPVector3 position)
 
void Teleport (FrameBase frame, FPVector3 position, FPQuaternion rotation)
 
void Teleport (FrameBase frame, Transform3D *transform)
 
FPVector3 TransformDirection (FPVector3 direction)
 Transforms a direction from local space to world space. Rotation is expected to be normalized. More...
 
FPVector3 TransformPoint (FPVector3 position)
 Transforms a position from local space to world space. Rotation is expected to be normalized. More...
 

Static Public Member Functions

static Transform3D Create (FPVector3 position, FPQuaternion rotation)
 Factory create a Transform3D component. More...
 
static Transform3D Create (FPVector3 position=default)
 Factory create a Transform3D component. More...
 
static void Serialize (void *ptr, FrameSerializer serializer)
 Serializes a Transform3D into a FrameSerializer. More...
 

Public Attributes

FPVector3 Back => -Forward
 A vector pointing to local -Z axis. More...
 
FPVector3 Down => -Up
 A vector pointing to local -Y axis. More...
 
FPVector3 EulerAngles => Rotation.AsEuler
 Converts rotation to Euler angles triplet. More...
 
FPVector3 Left => -Right
 A vector pointing to local -X axis. More...
 
FPMatrix4x4 LocalToWorldMatrix => FPMatrix4x4.TRS(Position, Rotation, FPVector3.One)
 Creates local to world transformation. Rotation is expected to be normalized. More...
 
FPVector3 Position
 The world position of the entity. More...
 
Int32 PositionTeleportFrame => _positionTeleportFrame
 Last frame when a position teleport was called. Used by view to ignore interpolation. More...
 
FPQuaternion Rotation
 The rotation of the entity. More...
 
Int32 RotationTeleportFrame => _rotationTeleportFrame
 Last frame when a rotation teleport was called. Used by view to ignore interpolation. More...
 
FPMatrix4x4 WorldToLocalMatrix => FPMatrix4x4.InverseTRS(Position, Rotation, FPVector3.One)
 Creates world to local transformation. Rotation is expected to be normalized. More...
 

Static Public Attributes

const int SIZE = 8 + FPVector3.SIZE + FPQuaternion.SIZE
 The size of the component (or struct/type) in-memory inside the Frame data-buffers or stack (when passed as value parameter). Not related to the snapshot payload this occupies, which is bit-packed and compressed. More...
 

Properties

FPVector3 Forward [get]
 A vector pointing to local +Z axis. More...
 
FPVector3 Right [get]
 A vector pointing to local +X axis. More...
 
FPVector3 Up [get]
 A vector pointing to local +Y axis. More...
 

Detailed Description

The Transform3D is an entity component providing position and rotation for a 3D object.

Always use the factory create method Create(FPVector3) or Create(FPVector3, FPQuaternion) or correctly initialize the rotation Quaternion manually.

Member Function Documentation

◆ Create() [1/2]

static Transform3D Quantum.Transform3D.Create ( FPVector3  position = default)
inlinestatic

Factory create a Transform3D component.

Sets the Rotation to FPQuaternion.Identity.

Parameters
positionThe initial world position.
Returns
New initialized Transform3D component.

◆ Create() [2/2]

static Transform3D Quantum.Transform3D.Create ( FPVector3  position,
FPQuaternion  rotation 
)
inlinestatic

Factory create a Transform3D component.

Parameters
positionThe initial world position.
rotationThe initial rotation.
Returns
New initialized Transform3D component.

◆ RotateAround()

void Quantum.Transform3D.RotateAround ( FPVector3  point,
FPVector3  axis,
FP  angle,
bool  rotateTransform = true 
)
inline

Rotates around a given pivot point.

The method works as expected but does generate slightly different results than Unity's Transform.RotateAround(). The algorithm may be subject to change in future versions.

Parameters
pointThe pivot point.
axisWhat axis to rotate.
angleThe angle.
rotateTransform

◆ Serialize()

static void Quantum.Transform3D.Serialize ( void *  ptr,
FrameSerializer  serializer 
)
inlinestatic

Serializes a Transform3D into a FrameSerializer.

Parameters
ptrThe pointer to the Transform3D.
serializerThe FrameSerializer instance into which the struct will be serialized.

◆ GetHashCode()

override int Quantum.Transform3D.GetHashCode ( )
inline

Overrides the hash code generation of this type.

Returns
A hash code of the current state of this instance.

◆ InverseTransformDirection()

FPVector3 Quantum.Transform3D.InverseTransformDirection ( FPVector3  direction)

Transforms a direction from world space to local space. Rotation is expected to be normalized.

◆ TransformDirection()

FPVector3 Quantum.Transform3D.TransformDirection ( FPVector3  direction)

Transforms a direction from local space to world space. Rotation is expected to be normalized.

◆ InverseTransformPoint()

FPVector3 Quantum.Transform3D.InverseTransformPoint ( FPVector3  position)

Transforms a position from world space to local space. Rotation is expected to be normalized.

◆ TransformPoint()

FPVector3 Quantum.Transform3D.TransformPoint ( FPVector3  position)

Transforms a position from local space to world space. Rotation is expected to be normalized.

◆ LookAt()

void Quantum.Transform3D.LookAt ( FPVector3  position,
FPVector3 up = null 
)
inline

Rotates the transform so the forward vector points at position . If up is not set, will use FPVector3.Up instead.

Parameters
position
up

◆ Rotate() [1/3]

void Quantum.Transform3D.Rotate ( FPVector3  angles,
bool  normalize = true 
)
inline

Applies a rotation of angles .z degrees around the z-axis, angles .x degrees around the x-axis, and angles .y degrees around the y-axis (in that order).

Parameters
anglesEuler angles, in degrees.
normalizeIf the resultant quaternion should be normalized before being set to the Rotation. This prevents rounding error from accumulating and potentially rounding the quaternion magnitude towards zero over time.

◆ Rotate() [2/3]

void Quantum.Transform3D.Rotate ( FP  xAngle,
FP  yAngle,
FP  zAngle,
bool  normalize = true 
)
inline

Applies a rotation of zAngle degrees around the z-axis, xAngle degrees around the x-axis, and yAngle degrees around the y-axis (in that order).

Parameters
xAngle
yAngle
zAngle
normalizeIf the resultant quaternion should be normalized before being set to the Rotation. This prevents rounding error from accumulating and potentially rounding the quaternion magnitude towards zero over time.

◆ Rotate() [3/3]

void Quantum.Transform3D.Rotate ( FPVector3  axis,
FP  angle,
bool  normalize = true 
)
inline

Rotates the object around the given axis by the number of degrees defined by the given angle.

Parameters
axis
angle
normalizeIf the resultant quaternion should be normalized before being set to the Rotation. This prevents rounding error from accumulating and potentially rounding the quaternion magnitude towards zero over time.

Member Data Documentation

◆ SIZE

const int Quantum.Transform3D.SIZE = 8 + FPVector3.SIZE + FPQuaternion.SIZE
static

The size of the component (or struct/type) in-memory inside the Frame data-buffers or stack (when passed as value parameter). Not related to the snapshot payload this occupies, which is bit-packed and compressed.

◆ Position

FPVector3 Quantum.Transform3D.Position

The world position of the entity.

◆ Rotation

FPQuaternion Quantum.Transform3D.Rotation

The rotation of the entity.

◆ PositionTeleportFrame

Int32 Quantum.Transform3D.PositionTeleportFrame => _positionTeleportFrame

Last frame when a position teleport was called. Used by view to ignore interpolation.

◆ RotationTeleportFrame

Int32 Quantum.Transform3D.RotationTeleportFrame => _rotationTeleportFrame

Last frame when a rotation teleport was called. Used by view to ignore interpolation.

◆ Left

FPVector3 Quantum.Transform3D.Left => -Right

A vector pointing to local -X axis.

◆ Down

FPVector3 Quantum.Transform3D.Down => -Up

A vector pointing to local -Y axis.

◆ Back

FPVector3 Quantum.Transform3D.Back => -Forward

A vector pointing to local -Z axis.

◆ EulerAngles

FPVector3 Quantum.Transform3D.EulerAngles => Rotation.AsEuler

Converts rotation to Euler angles triplet.

See also
FPQuaternion.AsEuler

.

◆ LocalToWorldMatrix

FPMatrix4x4 Quantum.Transform3D.LocalToWorldMatrix => FPMatrix4x4.TRS(Position, Rotation, FPVector3.One)

Creates local to world transformation. Rotation is expected to be normalized.

◆ WorldToLocalMatrix

FPMatrix4x4 Quantum.Transform3D.WorldToLocalMatrix => FPMatrix4x4.InverseTRS(Position, Rotation, FPVector3.One)

Creates world to local transformation. Rotation is expected to be normalized.

Property Documentation

◆ Right

FPVector3 Quantum.Transform3D.Right
get

A vector pointing to local +X axis.

◆ Up

FPVector3 Quantum.Transform3D.Up
get

A vector pointing to local +Y axis.

◆ Forward

FPVector3 Quantum.Transform3D.Forward
get

A vector pointing to local +Z axis.