Class ModelInstance

java.lang.Object
rosequartz.gfx.ModelInstance
All Implemented Interfaces:
Serializable

public class ModelInstance extends Object implements Serializable
Represents one instance of a 3D Model. The instance stores position, rotation and scale and can return a Model Matrix.
See Also:
Serialized Form
  • Constructor Details

    • ModelInstance

      public ModelInstance()
      Creates a new Instance of any 3D Model.
  • Method Details

    • reset

      public ModelInstance reset()
      Resets the model instance.
      Returns:
      this
    • scale

      public ModelInstance scale(float x, float y, float z)
      Scales the model instance by a given factor.
      Parameters:
      x - scale factor for x-axis
      y - scale factor for x-axis
      z - scale factor for x-axis
      Returns:
      this
    • scale

      public ModelInstance scale(float xyz)
      Scales the model instance by a given factor.
      Parameters:
      xyz - scale factor
      Returns:
      this
    • scale

      public ModelInstance scale(Vec3 xyz)
      Scales the model instance by a given factor.
      Parameters:
      xyz - scale factors
      Returns:
      this
    • rotate

      public ModelInstance rotate(float x, float y, float z)
      Rotates the model instance around 0,0,0 (local space) by a given amount per axis IN RADIANS.
      Parameters:
      x - rotation on x-axis IN RADIANS
      y - rotation on y-axis IN RADIANS
      z - rotation on z-axis IN RADIANS
      Returns:
      this
    • rotate

      public ModelInstance rotate(Vec3 xyz)
      Rotates the model instance around 0,0,0 (local space) by a given amount per axis IN RADIANS.
      Parameters:
      xyz - rotation IN RADIANS
      Returns:
      this
    • rotate

      public ModelInstance rotate(float x, float y, float z, float centerX, float centerY, float centerZ)
      Rotates the model instance around a given point by a given amount per axis IN RADIANS.
      Parameters:
      x - rotation on x-axis IN RADIANS
      y - rotation on y-axis IN RADIANS
      z - rotation on z-axis IN RADIANS
      centerX - position of center of rotation on x-axis
      centerY - position of center of rotation on y-axis
      centerZ - position of center of rotation on z-axis
      Returns:
      this
    • rotate

      public ModelInstance rotate(Vec3 xyz, float centerX, float centerY, float centerZ)
      Rotates the model instance around a given point by a given amount per axis IN RADIANS.
      Parameters:
      xyz - rotation IN RADIANS
      centerX - position of center of rotation on x-axis
      centerY - position of center of rotation on y-axis
      centerZ - position of center of rotation on z-axis
      Returns:
      this
    • rotate

      public ModelInstance rotate(float x, float y, float z, Vec3 centerXYZ)
      Rotates the model instance around a given point by a given amount per axis IN RADIANS.
      Parameters:
      x - rotation on x-axis IN RADIANS
      y - rotation on y-axis IN RADIANS
      z - rotation on z-axis IN RADIANS
      centerXYZ - position of center of rotation
      Returns:
      this
    • rotate

      public ModelInstance rotate(Vec3 xyz, Vec3 centerXYZ)
      Rotates the model instance around a given point by a given amount per axis IN RADIANS.
      Parameters:
      xyz - rotation IN RADIANS
      centerXYZ - position of center of rotation
      Returns:
      this
    • rotateDegrees

      public ModelInstance rotateDegrees(float x, float y, float z)
      Rotates the model instance around 0,0,0 (local space) by a given amount per axis IN DEGREES.
      Parameters:
      x - rotation on x-axis IN DEGREES
      y - rotation on y-axis IN DEGREES
      z - rotation on z-axis IN DEGREES
      Returns:
      this
    • rotateDegrees

      public ModelInstance rotateDegrees(Vec3 xyz)
      Rotates the model instance around 0,0,0 (local space) by a given amount per axis IN DEGREES.
      Parameters:
      xyz - rotation IN DEGREES
      Returns:
      this
    • rotateDegrees

      public ModelInstance rotateDegrees(float x, float y, float z, float centerX, float centerY, float centerZ)
      Rotates the model instance around a given point by a given amount per axis IN DEGREES.
      Parameters:
      x - rotation on x-axis IN DEGREES
      y - rotation on y-axis IN DEGREES
      z - rotation on z-axis IN DEGREES
      centerX - position of center of rotation on x-axis
      centerY - position of center of rotation on y-axis
      centerZ - position of center of rotation on z-axis
      Returns:
      this
    • rotateDegrees

      public ModelInstance rotateDegrees(Vec3 xyz, float centerX, float centerY, float centerZ)
      Rotates the model instance around a given point by a given amount per axis IN DEGREES.
      Parameters:
      xyz - rotation IN DEGREES
      centerX - position of center of rotation on x-axis
      centerY - position of center of rotation on y-axis
      centerZ - position of center of rotation on z-axis
      Returns:
      this
    • rotateDegrees

      public ModelInstance rotateDegrees(float x, float y, float z, Vec3 centerXYZ)
      Rotates the model instance around a given point by a given amount per axis IN DEGREES.
      Parameters:
      x - rotation on x-axis IN DEGREES
      y - rotation on y-axis IN DEGREES
      z - rotation on z-axis IN DEGREES
      centerXYZ - position of center of rotation
      Returns:
      this
    • rotateDegrees

      public ModelInstance rotateDegrees(Vec3 xyz, Vec3 centerXYZ)
      Rotates the model instance around a given point by a given amount per axis IN DEGREES.
      Parameters:
      xyz - rotation IN DEGREES
      centerXYZ - position of center of rotation
      Returns:
      this
    • setPosition

      public ModelInstance setPosition(float x, float y, float z)
      Sets the position of the model instance.
      Parameters:
      x - position on x-axis
      y - position on y-axis
      z - position on z-axis
      Returns:
      this
    • setPosition

      public ModelInstance setPosition(Vec3 xyz)
      Sets the position of the model instance.
      Parameters:
      xyz - position
      Returns:
      this
    • setPositionRelative

      public ModelInstance setPositionRelative(float dx, float dy, float dz)
      Sets the position of the model instance relative to its current position, essentially moving it.
      Parameters:
      dx - position difference on the x-axis
      dy - position difference on the y-axis
      dz - position difference on the z-axis
      Returns:
      this
    • setPositionRelative

      public ModelInstance setPositionRelative(Vec3 dxyz)
      Sets the position of the model instance relative to its current position, essentially moving it.
      Parameters:
      dxyz - position difference
      Returns:
      this
    • getModelMatrix

      public Mat4 getModelMatrix()
      Gets the model matrix. Applying this to the vertex position inside the vertex shader applies the scaling, rotations and position.
      Returns:
      model matrix
    • getModelRotationMatrix

      public Mat4 getModelRotationMatrix()
      Gets the model rotation matrix. This matrix is meant to be applied to the normal vector.
      Returns:
      model rotation matrix