Package de.coreengine.util
Class Toolbox
- java.lang.Object
-
- de.coreengine.util.Toolbox
-
public class Toolbox extends Object
Class that contains some useful functions- Author:
- Darius Dinger
-
-
Constructor Summary
Constructors Constructor Description Toolbox()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static float[]
addElement(float[] array, float element)
Adding an float element to an float arraystatic int[]
addElement(int[] array, int element)
Adding an int element to an int arraystatic <T> T[]
addElement(T[] array, T element)
Adding an element to an arraystatic String
arrayToString(float[] arr, String seperator)
Convert a float array into a stringstatic float[]
calcTangent(float v0x, float v0y, float v0z, float v1x, float v1y, float v1z, float v2x, float v2y, float v2z, float v0u, float v0v, float v1u, float v1v, float v2u, float v2v)
Calculating tangent for a trianglestatic Color
generateRandomColor()
static float[]
matrixToFloatArray(javax.vecmath.Matrix4f mat)
Transforming a matrix4f from vecmtath to a 16 valued float array.
Maybe not the most performant procedure...static float
max(float... values)
Getting the greatest float of valuesstatic float
min(float... values)
Getting the smallest float of valuesstatic float
randomFloat(float min, float max)
Generating a random float between min and maxstatic int
randomInt(int min, int max)
Generating a random integer between min and maxstatic javax.vecmath.Vector2f
randomVector(javax.vecmath.Vector2f min, javax.vecmath.Vector2f max)
Generating random vector between min and maxstatic javax.vecmath.Vector3f
randomVector(javax.vecmath.Vector3f min, javax.vecmath.Vector3f max)
Generating random vector between min and maxstatic float[]
stringToArrayf(String str, String seperator)
Convert a string into a float arraystatic int[]
stringToArrayi(String str, String seperator)
Convert a string into a integer arraystatic float[]
toArrayf(List<Float> floats)
Converting a list of floats into a float array.static int[]
toArrayi(List<Integer> ints)
Converting a list of integers into a int array.
-
-
-
Method Detail
-
addElement
public static <T> T[] addElement(T[] array, T element)
Adding an element to an array- Type Parameters:
T
- Type of the array data- Parameters:
array
- Array where the element should be addedelement
- Element to add into array- Returns:
- New array with element added
-
addElement
public static int[] addElement(int[] array, int element)
Adding an int element to an int array- Parameters:
array
- Array where the element should be addedelement
- Element to add into array- Returns:
- New array with element added
-
addElement
public static float[] addElement(float[] array, float element)
Adding an float element to an float array- Parameters:
array
- Array where the element should be addedelement
- Element to add into array- Returns:
- New array with element added
-
matrixToFloatArray
public static float[] matrixToFloatArray(javax.vecmath.Matrix4f mat)
Transforming a matrix4f from vecmtath to a 16 valued float array.
Maybe not the most performant procedure...- Parameters:
mat
- Matrix to transform- Returns:
- Transformed float array
-
generateRandomColor
public static Color generateRandomColor()
- Returns:
- Random color
-
toArrayf
public static float[] toArrayf(List<Float> floats)
Converting a list of floats into a float array. Because java hates that...- Parameters:
floats
- Float list to convert- Returns:
- Converted float array
-
toArrayi
public static int[] toArrayi(List<Integer> ints)
Converting a list of integers into a int array.- Parameters:
ints
- Integer list to convert- Returns:
- Converted int array
-
arrayToString
public static String arrayToString(float[] arr, String seperator)
Convert a float array into a string- Parameters:
arr
- Array to convertseperator
- Sperator of the string- Returns:
- Generated string
-
stringToArrayf
public static float[] stringToArrayf(String str, String seperator)
Convert a string into a float array- Parameters:
str
- String to convertseperator
- Seperator of the string- Returns:
- Generated float array
-
stringToArrayi
public static int[] stringToArrayi(String str, String seperator)
Convert a string into a integer array- Parameters:
str
- String to convertseperator
- Seperator of the string- Returns:
- Generated int array
-
randomFloat
public static float randomFloat(float min, float max)
Generating a random float between min and max- Parameters:
min
- Min value of the floatmax
- Max value of the float- Returns:
- Generated value
-
randomInt
public static int randomInt(int min, int max)
Generating a random integer between min and max- Parameters:
min
- Min value of the integermax
- Max value of the integer- Returns:
- Generated value
-
randomVector
public static javax.vecmath.Vector3f randomVector(javax.vecmath.Vector3f min, javax.vecmath.Vector3f max)
Generating random vector between min and max- Parameters:
min
- Min vector valuesmax
- Max vector values- Returns:
- Generated vector
-
randomVector
public static javax.vecmath.Vector2f randomVector(javax.vecmath.Vector2f min, javax.vecmath.Vector2f max)
Generating random vector between min and max- Parameters:
min
- Min vector valuesmax
- Max vector values- Returns:
- Generated vector
-
min
public static float min(float... values)
Getting the smallest float of values- Parameters:
values
- Floats to gets smallest from- Returns:
- Smallest float of values
-
max
public static float max(float... values)
Getting the greatest float of values- Parameters:
values
- Floats to gets greatest from- Returns:
- Greatest float of values
-
calcTangent
public static float[] calcTangent(float v0x, float v0y, float v0z, float v1x, float v1y, float v1z, float v2x, float v2y, float v2z, float v0u, float v0v, float v1u, float v1v, float v2u, float v2v)
Calculating tangent for a triangle- Parameters:
v0x
- X coordinate of vertex 0v0y
- Y coordinate of vertex 0v0z
- Z coordinate of vertex 0v1x
- X coordinate of vertex 1v1y
- Y coordinate of vertex 1v1z
- Z coordinate of vertex 1v2x
- X coordinate of vertex 2v2y
- Y coordinate of vertex 2v2z
- Z coordinate of vertex 2v0u
- U coordinate of vertex 0v0v
- V coordinate of vertex 0v1u
- U coordinate of vertex 1v1v
- V coordinate of vertex 1v2u
- U coordinate of vertex 2v2v
- V coordinate of vertex 2- Returns:
- Tangent as float array [x, y, z]
-
-