Package rosequartz.gfx
Class ModelInstance
java.lang.Object
rosequartz.gfx.ModelInstance
- All Implemented Interfaces:
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 Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionGets the model matrix.Gets the model rotation matrix.reset()Resets the model instance.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.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.Rotates the model instance around a given point by a given amount per axis IN RADIANS.Rotates the model instance around 0,0,0 (local space) by a given amount per axis IN RADIANS.Rotates the model instance around a given point by a given amount per axis IN RADIANS.Rotates the model instance around a given point by a given amount per axis IN RADIANS.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.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.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.rotateDegrees(Vec3 xyz)Rotates the model instance around 0,0,0 (local space) by a given amount per axis IN DEGREES.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.rotateDegrees(Vec3 xyz, Vec3 centerXYZ)Rotates the model instance around a given point by a given amount per axis IN DEGREES.scale(float xyz)Scales the model instance by a given factor.scale(float x, float y, float z)Scales the model instance by a given factor.Scales the model instance by a given factor.setPosition(float x, float y, float z)Sets the position of the model instance.setPosition(Vec3 xyz)Sets the position of the model instance.setPositionRelative(float dx, float dy, float dz)Sets the position of the model instance relative to its current position, essentially moving it.setPositionRelative(Vec3 dxyz)Sets the position of the model instance relative to its current position, essentially moving it.
-
Constructor Details
-
ModelInstance
public ModelInstance()Creates a new Instance of any 3D Model.
-
-
Method Details
-
reset
Resets the model instance.- Returns:
- this
-
scale
Scales the model instance by a given factor.- Parameters:
x- scale factor for x-axisy- scale factor for x-axisz- scale factor for x-axis- Returns:
- this
-
scale
Scales the model instance by a given factor.- Parameters:
xyz- scale factor- Returns:
- this
-
scale
Scales the model instance by a given factor.- Parameters:
xyz- scale factors- Returns:
- this
-
rotate
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 RADIANSy- rotation on y-axis IN RADIANSz- rotation on z-axis IN RADIANS- Returns:
- this
-
rotate
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 RADIANSy- rotation on y-axis IN RADIANSz- rotation on z-axis IN RADIANScenterX- position of center of rotation on x-axiscenterY- position of center of rotation on y-axiscenterZ- position of center of rotation on z-axis- Returns:
- this
-
rotate
Rotates the model instance around a given point by a given amount per axis IN RADIANS.- Parameters:
xyz- rotation IN RADIANScenterX- position of center of rotation on x-axiscenterY- position of center of rotation on y-axiscenterZ- position of center of rotation on z-axis- Returns:
- this
-
rotate
Rotates the model instance around a given point by a given amount per axis IN RADIANS.- Parameters:
x- rotation on x-axis IN RADIANSy- rotation on y-axis IN RADIANSz- rotation on z-axis IN RADIANScenterXYZ- position of center of rotation- Returns:
- this
-
rotate
Rotates the model instance around a given point by a given amount per axis IN RADIANS.- Parameters:
xyz- rotation IN RADIANScenterXYZ- position of center of rotation- Returns:
- this
-
rotateDegrees
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 DEGREESy- rotation on y-axis IN DEGREESz- rotation on z-axis IN DEGREES- Returns:
- this
-
rotateDegrees
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 DEGREESy- rotation on y-axis IN DEGREESz- rotation on z-axis IN DEGREEScenterX- position of center of rotation on x-axiscenterY- position of center of rotation on y-axiscenterZ- position of center of rotation on z-axis- Returns:
- this
-
rotateDegrees
Rotates the model instance around a given point by a given amount per axis IN DEGREES.- Parameters:
xyz- rotation IN DEGREEScenterX- position of center of rotation on x-axiscenterY- position of center of rotation on y-axiscenterZ- position of center of rotation on z-axis- Returns:
- this
-
rotateDegrees
Rotates the model instance around a given point by a given amount per axis IN DEGREES.- Parameters:
x- rotation on x-axis IN DEGREESy- rotation on y-axis IN DEGREESz- rotation on z-axis IN DEGREEScenterXYZ- position of center of rotation- Returns:
- this
-
rotateDegrees
Rotates the model instance around a given point by a given amount per axis IN DEGREES.- Parameters:
xyz- rotation IN DEGREEScenterXYZ- position of center of rotation- Returns:
- this
-
setPosition
Sets the position of the model instance.- Parameters:
x- position on x-axisy- position on y-axisz- position on z-axis- Returns:
- this
-
setPosition
Sets the position of the model instance.- Parameters:
xyz- position- Returns:
- this
-
setPositionRelative
Sets the position of the model instance relative to its current position, essentially moving it.- Parameters:
dx- position difference on the x-axisdy- position difference on the y-axisdz- position difference on the z-axis- Returns:
- this
-
setPositionRelative
Sets the position of the model instance relative to its current position, essentially moving it.- Parameters:
dxyz- position difference- Returns:
- this
-
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
Gets the model rotation matrix. This matrix is meant to be applied to the normal vector.- Returns:
- model rotation matrix
-