a3dAPI
Class a3dUTIL

java.lang.Object
  |
  +--a3dAPI.a3dUTIL

public class a3dUTIL
extends java.lang.Object

This class offers some routines you can find useful when using anfy3dAPI. This class is not needed by any component of anfy3dAPI

Author:
Andrea Fasce

Constructor Summary
a3dUTIL()
           
 
Method Summary
static void angleAxisToQuat(float[] a, float[] b)
          Convert an angleAxis to a quaternion
static void concatenateMatrix(float[] a, float[] b, float[] c)
          Concatenates matrices (matrices are 4x3)
static int[] convertToTri(int[] a, boolean ccw)
          convert a common vrml-like vertex index into a triangles vertex index
static java.lang.Object generateNormals(float[] points, int[] faces, float angle)
          Generate normals for a shape (like in vrml model) then use getNormal() and getNormalI()
static float[] getNormal(java.lang.Object tmp)
          returns the normals
static int[] getNormalI(java.lang.Object tmp)
          returns the normalsI
static int[] imgGrabber(java.awt.Image img, int[] aspect)
          Grabs pixels from an Image
static int[] imgLoad(java.lang.String imgName, int[] aspect, java.awt.Component component)
          Loads and grab an image
static int[] imgLoad(java.net.URL imgName, int[] aspect, java.awt.Component component)
          Loads and grab an image
static java.awt.Image imgWait(java.awt.Image image, java.awt.Component component)
          Waits an image to be loaded
static void invertMatrix(float[] m, float[] d)
          invert a matrix
static void positionMatrix(float x, float y, float z, float[] a)
          create a position matrix
static void quatToAngleAxis(float[] a, float[] b)
          Convert a quaternion to an angleAxis
static void rotationMatrix(float rx, float ry, float rz, float rw, float[] m)
          generate a rotation matrix given an axis-angle
static void rotxMatrix(float angle, float[] a)
          rotate around x axis
static void rotyMatrix(float angle, float[] a)
          rotate around y axis
static void rotzMatrix(float angle, float[] a)
          rotate around z axis
static void scaleMatrix(float x, float y, float z, float[] a)
          scale matrix
static void slerp(float[] a, float[] b, float alpha, float[] c)
          slerp torugh the shortest path
static void transformMatrix(float tx, float ty, float tz, float cx, float cy, float cz, float rx, float ry, float rz, float rw, float sx, float sy, float sz, float srx, float sry, float srz, float srw, float[] m, float[] m1)
          generic transformation matrix
static void transposeMatrix(float[] a, float[] b)
          transpose a matrix
static void unitMatrix(float[] a)
          initialize a unit matrix
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

a3dUTIL

public a3dUTIL()
Method Detail

imgWait

public static final java.awt.Image imgWait(java.awt.Image image,
                                           java.awt.Component component)
Waits an image to be loaded

imgLoad

public static final int[] imgLoad(java.net.URL imgName,
                                  int[] aspect,
                                  java.awt.Component component)
Loads and grab an image
Parameters:
imgName - URL of the image to load
aspect - a length 2 array that will be filled with width and height
component - a valid component
Returns:
an array containing the datas of the image

imgLoad

public static final int[] imgLoad(java.lang.String imgName,
                                  int[] aspect,
                                  java.awt.Component component)
Loads and grab an image
Parameters:
imgName - name of the image to load
aspect - a length 2 array that will be filled with width and height
component - a valid component
Returns:
an array containing the datas of the image

imgGrabber

public static final int[] imgGrabber(java.awt.Image img,
                                     int[] aspect)
Grabs pixels from an Image
Parameters:
img - image to grab
aspect - an array of length 2 that will be filled with the width of the image (aspect[0]) and the height of the image (aspect[1])
Returns:
an array containing the datas of the image array[0] = float normals[], array[1] = int normalsI[]

concatenateMatrix

public static final void concatenateMatrix(float[] a,
                                           float[] b,
                                           float[] c)
Concatenates matrices (matrices are 4x3)
Parameters:
a - start matrix
b - matrix to concatenate to
c - destination matrix

unitMatrix

public static final void unitMatrix(float[] a)
initialize a unit matrix
Parameters:
a - 4x3 matrix to initialize to unit matrix

rotationMatrix

public static final void rotationMatrix(float rx,
                                        float ry,
                                        float rz,
                                        float rw,
                                        float[] m)
generate a rotation matrix given an axis-angle
Parameters:
rx - angleaxis x
ry - angleaxis y
rz - angleaxis z
rw - angleaxis angle
m - destination matrix

transposeMatrix

public static final void transposeMatrix(float[] a,
                                         float[] b)
transpose a matrix
Parameters:
a - matrix to transpose
b - destination matrix

invertMatrix

public static final void invertMatrix(float[] m,
                                      float[] d)
invert a matrix
Parameters:
a - matrix to transpose
b - destination matrix

transformMatrix

public static final void transformMatrix(float tx,
                                         float ty,
                                         float tz,
                                         float cx,
                                         float cy,
                                         float cz,
                                         float rx,
                                         float ry,
                                         float rz,
                                         float rw,
                                         float sx,
                                         float sy,
                                         float sz,
                                         float srx,
                                         float sry,
                                         float srz,
                                         float srw,
                                         float[] m,
                                         float[] m1)
generic transformation matrix
Parameters:
tx - x position
ty - y position
tz - z position
cx - center x
cy - center y
cz - center z
rx - angleaxis x
ry - angleaxis y
rz - angleaxis z
rw - angleaxis angle
sx - scale x
sy - scale y
sz - scale z
srx - scale angleaxis x
sry - scale angleaxis y
srz - scale angleaxis z
srw - scale angleaxis angle
m - destination matrix
m1 - temp matrix

positionMatrix

public static final void positionMatrix(float x,
                                        float y,
                                        float z,
                                        float[] a)
create a position matrix
Parameters:
a - matrix to initialize to translation matrix
x - x position
y - y position
z - z position

scaleMatrix

public static final void scaleMatrix(float x,
                                     float y,
                                     float z,
                                     float[] a)
scale matrix
Parameters:
a - matrix to initialize to scale matrix
x - scale x
y - scale y
z - scale z

rotxMatrix

public static final void rotxMatrix(float angle,
                                    float[] a)
rotate around x axis
Parameters:
angle - angle in radians
a - matrix to initialize to x rotation

rotyMatrix

public static final void rotyMatrix(float angle,
                                    float[] a)
rotate around y axis
Parameters:
angle - angle in radians
a - matrix to initialize to y rotation

rotzMatrix

public static final void rotzMatrix(float angle,
                                    float[] a)
rotate around z axis
Parameters:
angle - angle in radians
a - matrix to initialize to z rotation

convertToTri

public static final int[] convertToTri(int[] a,
                                       boolean ccw)
convert a common vrml-like vertex index into a triangles vertex index
Parameters:
a - an array of integers representing a coordIndex in vrml97 format
ccw - order of this face edges
Returns:
an array of int that contains the index in a triangle array-like form

generateNormals

public static final java.lang.Object generateNormals(float[] points,
                                                     int[] faces,
                                                     float angle)
Generate normals for a shape (like in vrml model) then use getNormal() and getNormalI()
Parameters:
angle - creaseAngle (in radians)
points - array of points
faces - array of point indices
Returns:
an Object that contains the normals and that should be passed as a parameter to the getNormal and getNormalI

getNormal

public static final float[] getNormal(java.lang.Object tmp)
returns the normals
Parameters:
tmp - the Object returned from generateNormals()
Returns:
an array of floats that contains the normals

getNormalI

public static final int[] getNormalI(java.lang.Object tmp)
returns the normalsI
Parameters:
tmp - the Object returned from generateNormals()
Returns:
an array of int that contains the normalsI

angleAxisToQuat

public static final void angleAxisToQuat(float[] a,
                                         float[] b)
Convert an angleAxis to a quaternion
Parameters:
a - source angleAxis (a 4 float array [x,y,z,angle])
b - destination quaternion (a 4 float array [x,y,z,w])

quatToAngleAxis

public static final void quatToAngleAxis(float[] a,
                                         float[] b)
Convert a quaternion to an angleAxis
Parameters:
a - source quaternion (a 4 float array [x,y,z,w])
b - destination angleAxis (a 4 float array [x,y,z,angle])

slerp

public static final void slerp(float[] a,
                               float[] b,
                               float alpha,
                               float[] c)
slerp torugh the shortest path
Parameters:
a - starting quaternion
b - ending quaternion
alpha - alpha value
c - destination quaternion


(C)2000 by Andrea Fasce