jarp
Class Character

java.lang.Object
  extended by jarp.Character

public class Character
extends java.lang.Object

The main avatar definition class: this maintains definitions of both the static and the dynamic aspects of the avatar's skeleton and surface mesh, and provides methods to support rendering of the avatar in its current configuration.


Field Summary
static int EYEL_4CC
           
static int EYER_4CC
           
static int HEAD_4CC
           
static float METRES_TO_INCHES_FLT
          Standard avatar height is 1.8m == 70.87".
static Quaternion QUAT_Z_MINUS_PI_BY_2
          Quaternion [with components (w,x,y,z)] for a rotation by -PI/2 round the Z-axis.
static float STD_AVATAR_HEIGHT_INCHES
           
static float STD_AVATAR_HEIGHT_METRES
           
static float STD_MAX_Y_METRES
           
static boolean USE_EMBEDDED_TEXTURE
           
static boolean V21_IS_VJJ_FORMAT
           
 
Constructor Summary
Character(JAInputStream jins)
          Constructs this Character using avatar definition data from the given stream, assuming to other context/resources are required (typically used by our main(java.lang.String[]) method to read an avatar definition).
Character(java.lang.String avurl, JAInputStream jins)
           
Character(java.lang.String avurl, JAInputStream jins, java.lang.String rqstversion, javax.media.opengl.GL2 gl, javax.media.opengl.glu.gl2.GLUgl2 glu, JAOptions jopts)
          Constructs this Character using avatar definition data from the given stream.
Character(java.lang.String avurl, JAOptions jopts)
          Minimal constructor, without specific avatar definition data.
 
Method Summary
 float adjustViewYInternal()
          Returns the deviation of this character's maximum y-value from the standard one, in the character's internal units -- which are the same as GL units for a character in v3 format.
 void buildSkin()
          Computes the new mesh data for the current skeleton and morphs, and passes the result to GL for rendering.
 void draw(javax.media.opengl.GL2 gl)
          Draws this character, using the given GL interface.
 void drawNormalsColour(javax.media.opengl.GL2 gl)
          Draws the normals colour for this character, using the given GL interface.
 void generateFrame()
          Generates the mesh-rendering data for the current frame.
 void generateFrame(float camX, float camY, float camZ)
          Update mesh-data (vertex coordinates and normals) based on latest skeleton and morph data.
 AmbientManager getAmbientManager()
          Returns this character's Ambient motion manager, or null if there is none.
 Bone getBone(int id)
          Returns the bone with the given ID.
 CASFrame getInitPose()
          Returns a frame with standard timestamp and duration values, the initial skeleton pose, and an empty morph set.
 int getMeshCount()
          Returns the number of meshes for this character.
 Skeleton getSkeleton()
          Returns this character's skeleton.
 java.lang.String getVersion()
          Returns the version number string for this character.
 boolean hasV3Scaling()
          Indicates whether this character uses v3.0-style scaling.
 float heightMetres()
          Returns this character's height in metres.
 float inchesToInternal()
          Returns the scale factor needed to convert from inches to the length units used for GL rendering.
static void main(java.lang.String[] args)
          Main method converts an avatar file to JARP format.
 float maxYMetres()
          Returns this character's height above the origin, in metres.
 float metresToInternal()
          Returns the scale factor needed to convert from metres to the length units used for GL rendering -- for a v3 format avatar this unit equals the character's "intrinsic" length unit, and for a v2 format avatar it equals one inch -- assuming that this character has the standard avatar height, that is, 1.8 metres.
 float rootYMetres()
          Returns the y-coordinate of this avatar's root bone, in metres.
 void save(JAOutputStream jouts)
          Writes this Character to the given stream in ARP format v2.2 or later.
 void save(JAOutputStream jouts, java.lang.Boolean forceSep)
           
 void saveTextureFile()
          Saves this avatar's texture image to a file.
 void setFrame(CASFrame frame)
          Sets a new frame (pose) for this character.
 boolean versionIsAtLeast22()
          Indicates whether this avatar is in at least v2.2 format.
static int vStringAs3Digits(java.lang.String ver)
          Returns the given version string as a 3-digit integer.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

USE_EMBEDDED_TEXTURE

public static final boolean USE_EMBEDDED_TEXTURE
See Also:
Constant Field Values

METRES_TO_INCHES_FLT

public static final float METRES_TO_INCHES_FLT
Standard avatar height is 1.8m == 70.87".

See Also:
Constant Field Values

STD_AVATAR_HEIGHT_METRES

public static final float STD_AVATAR_HEIGHT_METRES
See Also:
Constant Field Values

STD_AVATAR_HEIGHT_INCHES

public static final float STD_AVATAR_HEIGHT_INCHES
See Also:
Constant Field Values

STD_MAX_Y_METRES

public static final float STD_MAX_Y_METRES
See Also:
Constant Field Values

HEAD_4CC

public static int HEAD_4CC

EYER_4CC

public static int EYER_4CC

EYEL_4CC

public static int EYEL_4CC

V21_IS_VJJ_FORMAT

public static boolean V21_IS_VJJ_FORMAT

QUAT_Z_MINUS_PI_BY_2

public static final Quaternion QUAT_Z_MINUS_PI_BY_2
Quaternion [with components (w,x,y,z)] for a rotation by -PI/2 round the Z-axis.

Constructor Detail

Character

public Character(java.lang.String avurl,
                 JAOptions jopts)
Minimal constructor, without specific avatar definition data.


Character

public Character(JAInputStream jins)
          throws java.io.IOException,
                 JAException
Constructs this Character using avatar definition data from the given stream, assuming to other context/resources are required (typically used by our main(java.lang.String[]) method to read an avatar definition).

Throws:
java.io.IOException
JAException

Character

public Character(java.lang.String avurl,
                 JAInputStream jins)
          throws java.io.IOException,
                 JAException
Throws:
java.io.IOException
JAException

Character

public Character(java.lang.String avurl,
                 JAInputStream jins,
                 java.lang.String rqstversion,
                 javax.media.opengl.GL2 gl,
                 javax.media.opengl.glu.gl2.GLUgl2 glu,
                 JAOptions jopts)
          throws java.io.IOException,
                 JAException
Constructs this Character using avatar definition data from the given stream.

Throws:
java.io.IOException
JAException
Method Detail

main

public static void main(java.lang.String[] args)
                 throws java.io.IOException,
                        JAException
Main method converts an avatar file to JARP format.

Throws:
java.io.IOException
JAException

getVersion

public java.lang.String getVersion()
Returns the version number string for this character.


versionIsAtLeast22

public boolean versionIsAtLeast22()
Indicates whether this avatar is in at least v2.2 format.


hasV3Scaling

public boolean hasV3Scaling()
Indicates whether this character uses v3.0-style scaling.


heightMetres

public float heightMetres()
Returns this character's height in metres.


maxYMetres

public float maxYMetres()
Returns this character's height above the origin, in metres.


inchesToInternal

public float inchesToInternal()
Returns the scale factor needed to convert from inches to the length units used for GL rendering.


metresToInternal

public float metresToInternal()
Returns the scale factor needed to convert from metres to the length units used for GL rendering -- for a v3 format avatar this unit equals the character's "intrinsic" length unit, and for a v2 format avatar it equals one inch -- assuming that this character has the standard avatar height, that is, 1.8 metres.


rootYMetres

public float rootYMetres()
Returns the y-coordinate of this avatar's root bone, in metres.


adjustViewYInternal

public float adjustViewYInternal()
Returns the deviation of this character's maximum y-value from the standard one, in the character's internal units -- which are the same as GL units for a character in v3 format.


getMeshCount

public int getMeshCount()
Returns the number of meshes for this character.


getSkeleton

public Skeleton getSkeleton()
Returns this character's skeleton.


getBone

public Bone getBone(int id)
Returns the bone with the given ID.


setFrame

public void setFrame(CASFrame frame)
Sets a new frame (pose) for this character.


getAmbientManager

public AmbientManager getAmbientManager()
Returns this character's Ambient motion manager, or null if there is none.


getInitPose

public CASFrame getInitPose()
Returns a frame with standard timestamp and duration values, the initial skeleton pose, and an empty morph set.


save

public void save(JAOutputStream jouts)
          throws java.io.IOException
Writes this Character to the given stream in ARP format v2.2 or later.

NB
W.e.f. 2007-04 we have saved only in v2.2 format; now, 2009-11, we do v3.0 as well -- the choice being dictated by what we loaded; and now, 2010-04, we also do v2.1 .

Throws:
java.io.IOException

save

public void save(JAOutputStream jouts,
                 java.lang.Boolean forceSep)
          throws java.io.IOException
Throws:
java.io.IOException

saveTextureFile

public void saveTextureFile()
                     throws java.io.IOException
Saves this avatar's texture image to a file.

Throws:
java.io.IOException

drawNormalsColour

public void drawNormalsColour(javax.media.opengl.GL2 gl)
Draws the normals colour for this character, using the given GL interface. Used for bill-board avatar loading: [#UNUSED#]


draw

public void draw(javax.media.opengl.GL2 gl)
Draws this character, using the given GL interface.


generateFrame

public void generateFrame()
                   throws JAException
Generates the mesh-rendering data for the current frame.

Throws:
JAException

generateFrame

public void generateFrame(float camX,
                          float camY,
                          float camZ)
                   throws JAException
Update mesh-data (vertex coordinates and normals) based on latest skeleton and morph data.

Throws:
JAException

buildSkin

public void buildSkin()
               throws JAException
Computes the new mesh data for the current skeleton and morphs, and passes the result to GL for rendering.

Throws:
JAException

vStringAs3Digits

public static int vStringAs3Digits(java.lang.String ver)
Returns the given version string as a 3-digit integer.