org.jmonkeyengine.tralala
Class Utilities

java.lang.Object
  extended by org.jmonkeyengine.tralala.Utilities

public final class Utilities
extends java.lang.Object


Field Summary
static com.jme3.scene.shape.Quad IDENTITY_QUAD
           
static float MAX_ANGLE_X
           
static float MIN_ANGLE_X
          We force character to not be able to exceed rotation limits.
static java.lang.String NEW_LINE_CHARACTER
           
 
Constructor Summary
Utilities()
           
 
Method Summary
static void addInList(com.jme3.math.Quaternion p1, java.util.List<java.lang.Float> array)
           
static void addInList(com.jme3.math.Vector2f p1, java.util.List<java.lang.Float> array)
           
static void addInList(com.jme3.math.Vector3f p1, java.util.List<java.lang.Float> array)
           
static void appendSpaces(java.lang.StringBuilder sb, int numberOfSpaces)
           
static com.jme3.scene.Geometry createArrow(com.jme3.material.Material mat, com.jme3.math.Vector3f pos, com.jme3.math.Vector3f dir)
           
static com.jme3.scene.Node createBillboard(com.jme3.material.Material mat, float radius)
           
static com.jme3.scene.Node createDebugNormals(com.jme3.scene.Mesh mesh, com.jme3.material.Material mat, float scale)
           
static com.jme3.scene.Geometry createHorizontalQuad(float x, float y, float z, float width, float length)
           
static com.jme3.scene.Geometry createLine(com.jme3.material.Material mat, com.jme3.math.Vector3f startPosition, com.jme3.math.Vector3f endPosition)
           
static com.jme3.scene.Geometry createLine(java.lang.String name, com.jme3.material.Material mat, com.jme3.math.Vector3f startPosition, com.jme3.math.Vector3f endPosition)
           
static com.jme3.scene.shape.Box createLowerLeftBox(float x, float y, float z)
          Lower left corner is at (0,0,0) and top right corner is at (x,y,z)
static com.jme3.math.Plane createPlane(com.jme3.math.Vector3f planeOrigin, com.jme3.math.Vector3f planeNormal)
           
static com.jme3.scene.Geometry createPoint(com.jme3.material.Material mat, com.jme3.math.Vector3f position)
           
static com.jme3.scene.Node createSelectionCircle(com.jme3.material.Material mat, float scale, int points)
           
static com.jme3.scene.Node createWorldGrid(com.jme3.material.Material mat, int xi, int yi)
           
static com.jme3.scene.Node createWorldGrid(com.jme3.material.Material mat, com.jme3.material.Material axisMat, int xi, int yi, boolean centered)
          Debug Lines
static java.util.ArrayList<java.lang.Byte> getAsList(byte[] array)
           
static java.util.ArrayList<java.lang.Float> getAsList(float[] array)
           
static java.util.ArrayList<java.lang.Float>[] getAsList(float[][] array)
           
static java.util.ArrayList<java.lang.Short> getAsList(short[] array)
           
static byte[] getByteArray(java.nio.ByteBuffer buff)
          Create a new byte[] array and populate it with the given ByteBuffer's contents.
static float getDistanceOfPointFromPlane(com.jme3.math.Vector3f pointToBeMeasured, com.jme3.math.Vector3f anyPointOfPlane, com.jme3.math.Vector3f planeNormal)
          Distance formula from Koen Samyn : http://knol.google.com/k/plane-equation-in-3d#

static java.lang.String getExtension(java.io.File f)
           
static com.jme3.material.Material getLightingMaterial(java.lang.String texturePath, java.lang.String normalPath, java.lang.String parallaxPath, float shiness, com.jme3.asset.AssetManager assetManager)
           
static java.net.InetAddress getMyIpAddress()
           
static com.jme3.math.Vector3f getPositionOnPlane(com.jme3.math.Vector3f pointToBeCentered, com.jme3.math.Vector3f planeOrigin, com.jme3.math.Vector3f planeNormal)
           
static java.lang.String getPrefix(java.lang.String name)
           
static com.jme3.math.Quaternion getQuaternionFromArray(java.util.List<java.lang.Float> array, int i)
           
static short[] getShortArray(java.nio.ShortBuffer buff)
          Create a new short[] array and populate it with the given ShortBuffer's contents.
static java.util.List<java.io.File> getSubfiles(java.io.File file)
           
static java.util.List<java.io.File> getSubfiles(java.io.File file, java.util.List<java.io.File> fileList)
           
static com.jme3.math.Vector3f getSummetricPosition(com.jme3.math.Vector3f pointToBeMirrored, com.jme3.math.Vector3f planeOrigin, com.jme3.math.Vector3f planeNormal)
          Symmetry formula from Koen Samyn : http://knol.google.com/k/mirroring-a-point-on-a-3d-plane# Same info on wikipedia : http://en.wikipedia.org/wiki/Reflection_%28mathematics%29
static com.jme3.scene.VertexBuffer.Type getTexCoordType(int i)
           
static com.jme3.material.Material getUnshadedMaterial(java.lang.String texturePath, com.jme3.math.ColorRGBA color, com.jme3.asset.AssetManager assetManager)
           
static com.jme3.material.Material getUnshadedMaterial(com.jme3.texture.Texture texture, com.jme3.math.ColorRGBA color, com.jme3.material.RenderState.BlendMode mode, com.jme3.asset.AssetManager assetManager)
           
static com.jme3.math.Vector2f getVector2FromArray(float[] array, int i)
           
static com.jme3.math.Vector2f[] getVector2FromArray(java.util.List<java.lang.Float>[] array, int i)
           
static com.jme3.math.Vector2f getVector2FromArray(java.util.List<java.lang.Float> array, int i)
           
static com.jme3.math.Vector3f getVector3FromArray(float[] array, int i)
           
static com.jme3.math.Vector3f getVector3FromArray(java.util.List<java.lang.Float> array, int i)
           
static java.lang.String IpToString(java.net.InetSocketAddress address)
           
static boolean isBlank(java.lang.String str)
           
static com.jme3.math.Vector3f localToWorldCoordinatesIgnoreHeight(float dx, float dy, float dz, float rotationX, float rotationY)
          Converts local cordinates "(dx,dy,dz)" to world coordinates based on Vector3D "rotation".
static byte[] merge(byte[] f1, byte[] f2)
           
static float[] merge(float[] f1, float[] f2)
           
static java.nio.FloatBuffer merge(java.nio.FloatBuffer f1, java.nio.FloatBuffer f2)
           
static short[] merge(short[] f1, short[] f2)
           
static java.nio.ShortBuffer merge(java.nio.ShortBuffer f1, java.nio.ShortBuffer f2)
           
static void printErrorLine()
           
static java.util.ArrayList<java.lang.String> readFile(java.io.File file)
           
static java.util.ArrayList<java.lang.String> readFile(java.io.File file, java.lang.String encoding)
           
static java.lang.String readFileAsString(java.io.File file)
           
static java.lang.String readFileAsString(java.io.File file, java.lang.String encoding)
           
static java.lang.String readFileAsString(java.lang.String file)
           
static void saveFile(java.io.File file, java.lang.String whatToSave)
           
static void saveFile(java.io.File file, java.lang.String whatToSave, java.lang.String encoding)
           
static void setInArray(com.jme3.math.Vector2f p1, float[] array, int i)
           
static void setInArray(com.jme3.math.Vector3f p1, float[] array, int i)
           
static void sleep(int millis)
           
static java.io.InputStream StringToInputStream(java.lang.String s)
           
static byte[] toByteArray(java.util.Collection<java.lang.Byte> array)
           
static float[] toFloatArray(java.util.Collection<java.lang.Float> array)
           
static float[][] toFloatArray(java.util.Collection<java.lang.Float>[] array)
           
static short[] toShortArray(java.util.Collection<java.lang.Short> array)
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

MIN_ANGLE_X

public static final float MIN_ANGLE_X
We force character to not be able to exceed rotation limits. Because it will turn the world upside down.

See Also:
Constant Field Values

MAX_ANGLE_X

public static final float MAX_ANGLE_X
See Also:
Constant Field Values

IDENTITY_QUAD

public static final com.jme3.scene.shape.Quad IDENTITY_QUAD

NEW_LINE_CHARACTER

public static final java.lang.String NEW_LINE_CHARACTER
Constructor Detail

Utilities

public Utilities()
Method Detail

createBillboard

public static com.jme3.scene.Node createBillboard(com.jme3.material.Material mat,
                                                  float radius)

getUnshadedMaterial

public static com.jme3.material.Material getUnshadedMaterial(java.lang.String texturePath,
                                                             com.jme3.math.ColorRGBA color,
                                                             com.jme3.asset.AssetManager assetManager)

getUnshadedMaterial

public static com.jme3.material.Material getUnshadedMaterial(com.jme3.texture.Texture texture,
                                                             com.jme3.math.ColorRGBA color,
                                                             com.jme3.material.RenderState.BlendMode mode,
                                                             com.jme3.asset.AssetManager assetManager)

getLightingMaterial

public static com.jme3.material.Material getLightingMaterial(java.lang.String texturePath,
                                                             java.lang.String normalPath,
                                                             java.lang.String parallaxPath,
                                                             float shiness,
                                                             com.jme3.asset.AssetManager assetManager)

printErrorLine

public static void printErrorLine()

getSubfiles

public static java.util.List<java.io.File> getSubfiles(java.io.File file)

getSubfiles

public static java.util.List<java.io.File> getSubfiles(java.io.File file,
                                                       java.util.List<java.io.File> fileList)

isBlank

public static boolean isBlank(java.lang.String str)

StringToInputStream

public static java.io.InputStream StringToInputStream(java.lang.String s)

appendSpaces

public static void appendSpaces(java.lang.StringBuilder sb,
                                int numberOfSpaces)

IpToString

public static java.lang.String IpToString(java.net.InetSocketAddress address)

getMyIpAddress

public static java.net.InetAddress getMyIpAddress()

sleep

public static void sleep(int millis)

getPrefix

public static java.lang.String getPrefix(java.lang.String name)

getExtension

public static java.lang.String getExtension(java.io.File f)

readFile

public static java.util.ArrayList<java.lang.String> readFile(java.io.File file)

readFile

public static java.util.ArrayList<java.lang.String> readFile(java.io.File file,
                                                             java.lang.String encoding)

readFileAsString

public static java.lang.String readFileAsString(java.lang.String file)

readFileAsString

public static java.lang.String readFileAsString(java.io.File file)

readFileAsString

public static java.lang.String readFileAsString(java.io.File file,
                                                java.lang.String encoding)

saveFile

public static void saveFile(java.io.File file,
                            java.lang.String whatToSave)

saveFile

public static void saveFile(java.io.File file,
                            java.lang.String whatToSave,
                            java.lang.String encoding)

getDistanceOfPointFromPlane

public static float getDistanceOfPointFromPlane(com.jme3.math.Vector3f pointToBeMeasured,
                                                com.jme3.math.Vector3f anyPointOfPlane,
                                                com.jme3.math.Vector3f planeNormal)
Distance formula from Koen Samyn : http://knol.google.com/k/plane-equation-in-3d#

Parameters:
pointToBeMeasured - the Point you want to find its distance from plane.
anyPointOfPlane - any plane's point e.g plane's origin
planeNormal - the plane's Normal at the "anyPointOfPlane"

getSummetricPosition

public static com.jme3.math.Vector3f getSummetricPosition(com.jme3.math.Vector3f pointToBeMirrored,
                                                          com.jme3.math.Vector3f planeOrigin,
                                                          com.jme3.math.Vector3f planeNormal)
Symmetry formula from Koen Samyn : http://knol.google.com/k/mirroring-a-point-on-a-3d-plane# Same info on wikipedia : http://en.wikipedia.org/wiki/Reflection_%28mathematics%29

Parameters:
pointToBeMirrored - the Point you want to find its symmetric
planeOrigin - the planeOrigin e.g (0,0,0)
planeNormal - the planeNormal is a vector that points upward from the plane e.g Vector3f.UNIT_Z

getPositionOnPlane

public static com.jme3.math.Vector3f getPositionOnPlane(com.jme3.math.Vector3f pointToBeCentered,
                                                        com.jme3.math.Vector3f planeOrigin,
                                                        com.jme3.math.Vector3f planeNormal)

merge

public static float[] merge(float[] f1,
                            float[] f2)

merge

public static short[] merge(short[] f1,
                            short[] f2)

merge

public static byte[] merge(byte[] f1,
                           byte[] f2)

merge

public static java.nio.FloatBuffer merge(java.nio.FloatBuffer f1,
                                         java.nio.FloatBuffer f2)

merge

public static java.nio.ShortBuffer merge(java.nio.ShortBuffer f1,
                                         java.nio.ShortBuffer f2)

getTexCoordType

public static com.jme3.scene.VertexBuffer.Type getTexCoordType(int i)

getVector3FromArray

public static com.jme3.math.Vector3f getVector3FromArray(float[] array,
                                                         int i)

getVector3FromArray

public static com.jme3.math.Vector3f getVector3FromArray(java.util.List<java.lang.Float> array,
                                                         int i)

getVector2FromArray

public static com.jme3.math.Vector2f getVector2FromArray(float[] array,
                                                         int i)

getVector2FromArray

public static com.jme3.math.Vector2f getVector2FromArray(java.util.List<java.lang.Float> array,
                                                         int i)

getVector2FromArray

public static com.jme3.math.Vector2f[] getVector2FromArray(java.util.List<java.lang.Float>[] array,
                                                           int i)

getQuaternionFromArray

public static com.jme3.math.Quaternion getQuaternionFromArray(java.util.List<java.lang.Float> array,
                                                              int i)

getAsList

public static java.util.ArrayList<java.lang.Byte> getAsList(byte[] array)

getAsList

public static java.util.ArrayList<java.lang.Short> getAsList(short[] array)

getAsList

public static java.util.ArrayList<java.lang.Float> getAsList(float[] array)

getAsList

public static java.util.ArrayList<java.lang.Float>[] getAsList(float[][] array)

toByteArray

public static byte[] toByteArray(java.util.Collection<java.lang.Byte> array)

toShortArray

public static short[] toShortArray(java.util.Collection<java.lang.Short> array)

toFloatArray

public static float[] toFloatArray(java.util.Collection<java.lang.Float> array)

toFloatArray

public static float[][] toFloatArray(java.util.Collection<java.lang.Float>[] array)

addInList

public static void addInList(com.jme3.math.Quaternion p1,
                             java.util.List<java.lang.Float> array)

addInList

public static void addInList(com.jme3.math.Vector3f p1,
                             java.util.List<java.lang.Float> array)

addInList

public static void addInList(com.jme3.math.Vector2f p1,
                             java.util.List<java.lang.Float> array)

setInArray

public static void setInArray(com.jme3.math.Vector3f p1,
                              float[] array,
                              int i)

setInArray

public static void setInArray(com.jme3.math.Vector2f p1,
                              float[] array,
                              int i)

createPoint

public static com.jme3.scene.Geometry createPoint(com.jme3.material.Material mat,
                                                  com.jme3.math.Vector3f position)

createPlane

public static com.jme3.math.Plane createPlane(com.jme3.math.Vector3f planeOrigin,
                                              com.jme3.math.Vector3f planeNormal)

createArrow

public static com.jme3.scene.Geometry createArrow(com.jme3.material.Material mat,
                                                  com.jme3.math.Vector3f pos,
                                                  com.jme3.math.Vector3f dir)

createLine

public static com.jme3.scene.Geometry createLine(com.jme3.material.Material mat,
                                                 com.jme3.math.Vector3f startPosition,
                                                 com.jme3.math.Vector3f endPosition)

createLine

public static com.jme3.scene.Geometry createLine(java.lang.String name,
                                                 com.jme3.material.Material mat,
                                                 com.jme3.math.Vector3f startPosition,
                                                 com.jme3.math.Vector3f endPosition)

createLowerLeftBox

public static com.jme3.scene.shape.Box createLowerLeftBox(float x,
                                                          float y,
                                                          float z)
Lower left corner is at (0,0,0) and top right corner is at (x,y,z)


createHorizontalQuad

public static com.jme3.scene.Geometry createHorizontalQuad(float x,
                                                           float y,
                                                           float z,
                                                           float width,
                                                           float length)

createDebugNormals

public static com.jme3.scene.Node createDebugNormals(com.jme3.scene.Mesh mesh,
                                                     com.jme3.material.Material mat,
                                                     float scale)

createSelectionCircle

public static com.jme3.scene.Node createSelectionCircle(com.jme3.material.Material mat,
                                                        float scale,
                                                        int points)

createWorldGrid

public static com.jme3.scene.Node createWorldGrid(com.jme3.material.Material mat,
                                                  int xi,
                                                  int yi)

createWorldGrid

public static com.jme3.scene.Node createWorldGrid(com.jme3.material.Material mat,
                                                  com.jme3.material.Material axisMat,
                                                  int xi,
                                                  int yi,
                                                  boolean centered)
Debug Lines


getShortArray

public static short[] getShortArray(java.nio.ShortBuffer buff)
Create a new short[] array and populate it with the given ShortBuffer's contents.

Parameters:
buff - the ShortBuffer to read from
Returns:
a new short array populated from the ShortBuffer

getByteArray

public static byte[] getByteArray(java.nio.ByteBuffer buff)
Create a new byte[] array and populate it with the given ByteBuffer's contents.

Parameters:
buff - the ByteBuffer to read from
Returns:
a new byte array populated from the ByteBuffer

localToWorldCoordinatesIgnoreHeight

public static com.jme3.math.Vector3f localToWorldCoordinatesIgnoreHeight(float dx,
                                                                         float dy,
                                                                         float dz,
                                                                         float rotationX,
                                                                         float rotationY)
Converts local cordinates "(dx,dy,dz)" to world coordinates based on Vector3D "rotation". More info : This kind of deplacement generaly used for player movement (in shooting game ...). The x rotation is 'ignored' for the calculation of the deplacement. This result that if you look upward and you want to move forward, the deplacement is calculated like if your were parallely to the ground.