com.motorola.iden.micro3d
Class Quadrangle

java.lang.Object
  |
  +--com.motorola.iden.micro3d.Object3D
        |
        +--com.motorola.iden.micro3d.Primitive
              |
              +--com.motorola.iden.micro3d.Quadrangle

public class Quadrangle
extends Primitive

Quadrangle primitive. The Quadrangle primitive is a quadrilateral polygon that is defined by four points. A quadrangle can be rendered either with a solid color or texture mapped. If a texture has been assigned to a quadrangle then the quadrangle will be rendered with that texture; otherwise, the quadrangle will be rendered with the specified color. The blending type is applicable to the quadrangle regardless of whether it is rendered with a solid color or with a texture. If a sphere texture has been assigned to a quadrangle, the environment mapping will be enabled for that quadrangle. The Quadrangle can use any of the supported shading modes and is affected by lighting parameters. In order for the quadrangle to be affected by lighting parameters, it must have either a face normal or a normal for each of its vertices. If no normals are assigned to the quadrangle, it will be not be affected by lighting and shading parameters.

A quadrangle is defined by four Vector3D objects which contain the coordinates of the four points that define the polygon. Therefore the valid vertex IDs for the Quadrangle are Primitive.VERTEX_A, Primitive.VERTEX_B, Primitive.VERTEX_C, and Primitive.VERTEX_D. In order to assign a face normal for the quadrangle the constant Primitive.FACE_NORMAL is used. For assigning normals to vertices the vertex constants are combined with the Primitive.NORMAL constant. For example, to assign a normal to vertex B, the vertex ID would be (Primitive.VERTEX_B | Primitive.NORMAL). When assigning vertex normals it is important to assign a vertex normal for each vertex. If any of the vertices does not have a normal assigned to it, the quadrangle will not be affected by lighting parameters. A quadrangle cannot have a face normal and vertex normals assigned to it at the same time. When a face normal is assigned to a quadrangle, the vertex normals are automatically discarded. Similarily, once a vertex normal is assigned to a quadrangle, its face normal will be discarded.

When a texture is assigned to a quadrangle, it is necessary to specify how the texture will be applied to the quadrangle. This is accomplished by specifing X and Y coordinates for each of the quadrangle's vertices. Those X and Y coordinates are then mapped to the target texture.


MOTOROLA and the Stylized M Logo are registered trademarks of Motorola, Inc. Reg. U.S. Pat. & Tm. Off.
© COPYRIGHT 2003-2004 MOTOROLA, Inc. All Rights Reserved.


Fields inherited from class com.motorola.iden.micro3d.Primitive
BLENDING_ADD, BLENDING_HALF, BLENDING_NONE, BLENDING_SUB, FACE_NORMAL, NORMAL, VERTEX_A, VERTEX_B, VERTEX_C, VERTEX_D
 
Constructor Summary
Quadrangle(Vector3D vertexA, Vector3D vertexB, Vector3D vertexC, Vector3D vertexD, int textureXA, int textureYA, int textureXB, int textureYB, int textureXC, int textureYC, int textureXD, int textureYD, Layout3D layout, Texture texture)
          Creates a Quadrangle primitive with the vertices at the positions specified by vertexA, vertexB, vertexC, and vertexD parameters.
Quadrangle(Vector3D vertexA, Vector3D vertexB, Vector3D vertexC, Vector3D vertexD, Layout3D layout, int color)
          Creates a Quadrangle primitive with the vertices at the positions specified by the vertexA, vertexB, vertexC, and vertexD parameters.
Quadrangle(Vector3D vertexA, Vector3D vertexB, Vector3D vertexC, Vector3D vertexD, Vector3D faceNormal, int textureXA, int textureYA, int textureXB, int textureYB, int textureXC, int textureYC, int textureXD, int textureYD, Layout3D layout, Texture texture)
          Creates a Quadrangle primitive with the vertices at the positions specified by vertexA, vertexB, vertexC, and vertexD and oriented with the normal specified by the faceNormal parameter.
Quadrangle(Vector3D vertexA, Vector3D vertexB, Vector3D vertexC, Vector3D vertexD, Vector3D faceNormal, Layout3D layout, int color)
          Creates a Quadrangle primitive with the vertices at the positions specified by vertexA, vertexB, vertexC, and vertexD parameters and oriented with the normal specified with faceNormal parameter.
Quadrangle(Vector3D vertexA, Vector3D vertexB, Vector3D vertexC, Vector3D vertexD, Vector3D normalA, Vector3D normalB, Vector3D normalC, Vector3D normalD, int textureXA, int textureYA, int textureXB, int textureYB, int textureXC, int textureYC, int textureXD, int textureYD, Layout3D layout, Texture texture)
          Creates a Quadrangle primitive with the vertices at the positions specified by vertexA, vertexB, vertexC, and vertexD parameters and oriented with normals specified for each vertex.
Quadrangle(Vector3D vertexA, Vector3D vertexB, Vector3D vertexC, Vector3D vertexD, Vector3D normalA, Vector3D normalB, Vector3D normalC, Vector3D normalD, Layout3D layout, int color)
          Creates a Quadrangle primitive with the vertices at the positions specified by vertexA, vertexB, vertexC, and vertexD parameters and oriented with the normal specified for each vertex.
 
Method Summary
 int getTextureCoordinateX(int vertexID)
          Returns the X component of the texture coordinate for the specified vertex.
 int getTextureCoordinateY(int vertexID)
          Returns the Y component of the texture coordinate for the specified vertex.
 Vector3D getVector(int vectorID)
          Returns the Vector3D for the specified vector.
 void setTextureCoordinates(int vertexID, int x, int y)
          Sets the texture coordinates for the specified vertex.
 void setVector(int vectorID, Vector3D vector)
          Sets the specified vertex to the Vector3D provided.
 
Methods inherited from class com.motorola.iden.micro3d.Primitive
enableColorKeyTransparency, getBlendingType, getColor, hasColorKeyTransparency, setBlendingType, setColor
 
Methods inherited from class com.motorola.iden.micro3d.Object3D
getLayout, getSphereTexture, getTexture, setLayout, setSphereTexture, setTexture
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Quadrangle

public Quadrangle(Vector3D vertexA,
                  Vector3D vertexB,
                  Vector3D vertexC,
                  Vector3D vertexD,
                  int textureXA,
                  int textureYA,
                  int textureXB,
                  int textureYB,
                  int textureXC,
                  int textureYC,
                  int textureXD,
                  int textureYD,
                  Layout3D layout,
                  Texture texture)
           throws java.lang.NullPointerException
Creates a Quadrangle primitive with the vertices at the positions specified by vertexA, vertexB, vertexC, and vertexD parameters. The Quadrangle will be rendered using the specified texture and Layout3D. Portions of the Texture to use for the quadrangle can be specified using the textureXA, textureYA, textureXB, textureYB, textureXC, textureYC, textureXD, and textureYD parameters.

The specified vertices cannot be null. If the specified Layout3D is null the Quadrangle will not be rendered. If the Texture is set to null the Quadrangle will be rendered with the default color.

Parameters:
vertexA - vertex A of the Quadrangle.
vertexB - vertex B of the Quadrangle.
vertexC - vertex C of the Quadrangle.
vertexD - vertex D of the Quadrangle.
textureXA - the x coordinate in the texture that will map to the vertex A of the Quadrangle.
textureYA - the y coordinate in the texture that will map to the vertex A of the Quadrangle.
textureXB - the x coordinate in the texture that will map to the vertex B of the Quadrangle.
textureYB - the y coordinate in the texture that will map to the vertex B of the Quadrangle.
textureXC - the x coordinate in the texture that will map to the vertex C of the Quadrangle.
textureYC - the y coordinate in the texture that will map to the vertex C of the Quadrangle.
textureXD - the x coordinate in the texture that will map to the vertex D of the Quadrangle.
textureYD - the y coordinate in the texture that will map to the vertex D of the Quadrangle.
layout - the Layout3D to use to render this Quadrangle.
texture - the Texture to use when rendering this Quadrangle.
Throws:
java.lang.NullPointerException - if any of the specified vertices are null.

Quadrangle

public Quadrangle(Vector3D vertexA,
                  Vector3D vertexB,
                  Vector3D vertexC,
                  Vector3D vertexD,
                  Vector3D faceNormal,
                  int textureXA,
                  int textureYA,
                  int textureXB,
                  int textureYB,
                  int textureXC,
                  int textureYC,
                  int textureXD,
                  int textureYD,
                  Layout3D layout,
                  Texture texture)
           throws java.lang.NullPointerException
Creates a Quadrangle primitive with the vertices at the positions specified by vertexA, vertexB, vertexC, and vertexD and oriented with the normal specified by the faceNormal parameter. The Quadrangle will be rendered using the specified texture and Layout3D. Portions of the Texture to use for the quadrangle can be specified using the textureXA, textureYA, textureXB, textureYB, textureXC, textureYC, textureXD, and textureYD parameters.

The specified vertices cannot be null. If the specified Layout3D is null the Quadrangle will not be rendered. If the Texture is set to null the Quadrangle will be rendered with the default color.

Parameters:
vertexA - vertex A of the Quadrangle.
vertexB - vertex B of the Quadrangle.
vertexC - vertex C of the Quadrangle.
vertexD - vertex D of the Quadrangle.
faceNormal - the face normal of the Quadrangle.
textureXA - the x coordinate in the texture that will map to the vertex A of the Quadrangle.
textureYA - the y coordinate in the texture that will map to the vertex A of the Quadrangle.
textureXB - the x coordinate in the texture that will map to the vertex B of the Quadrangle.
textureYB - the y coordinate in the texture that will map to the vertex B of the Quadrangle.
textureXC - the x coordinate in the texture that will map to the vertex C of the Quadrangle.
textureYC - the y coordinate in the texture that will map to the vertex C of the Quadrangle.
textureXD - the x coordinate in the texture that will map to the vertex D of the Quadrangle.
textureYD - the y coordinate in the texture that will map to the vertex D of the Quadrangle.
layout - the Layout3D to use to render this Quadrangle.
texture - the Texture to use when rendering this Quadrangle.
Throws:
java.lang.NullPointerException - if any of the specified vertices or the face normal are null.

Quadrangle

public Quadrangle(Vector3D vertexA,
                  Vector3D vertexB,
                  Vector3D vertexC,
                  Vector3D vertexD,
                  Vector3D normalA,
                  Vector3D normalB,
                  Vector3D normalC,
                  Vector3D normalD,
                  int textureXA,
                  int textureYA,
                  int textureXB,
                  int textureYB,
                  int textureXC,
                  int textureYC,
                  int textureXD,
                  int textureYD,
                  Layout3D layout,
                  Texture texture)
           throws java.lang.NullPointerException
Creates a Quadrangle primitive with the vertices at the positions specified by vertexA, vertexB, vertexC, and vertexD parameters and oriented with normals specified for each vertex. The Quadrangle will be rendered using the specified texture and Layout3D. Portions of the Texture to use for the quadrangle can be specified using the textureXA, textureYA, textureXB, textureYB, textureXC, textureYC, textureXD, and textureYD parameters.

The specified vertices cannot be null. If the specified Layout3D is null the Quadrangle will not be rendered. If the Texture is set to null the Quadrangle will be rendered with the default color.

Parameters:
vertexA - vertex A of the Quadrangle.
vertexB - vertex B of the Quadrangle.
vertexC - vertex C of the Quadrangle.
vertexD - vertex D of the Quadrangle.
normalA - the normal at vertex A of the Quadrangle.
normalB - the normal at vertex B of the Quadrangle.
normalC - the normal at vertex C of the Quadrangle.
normalD - the normal at vertex D of the Quadrangle.
textureXA - the x coordinate in the texture that will map to the vertex A of the Quadrangle.
textureYA - the y coordinate in the texture that will map to the vertex A of the Quadrangle.
textureXB - the x coordinate in the texture that will map to the vertex B of the Quadrangle.
textureYB - the y coordinate in the texture that will map to the vertex B of the Quadrangle.
textureXC - the x coordinate in the texture that will map to the vertex C of the Quadrangle.
textureYC - the y coordinate in the texture that will map to the vertex C of the Quadrangle.
textureXD - the x coordinate in the texture that will map to the vertex D of the Quadrangle.
textureYD - the y coordinate in the texture that will map to the vertex D of the Quadrangle.
layout - the Layout3D to use to render this Quadrangle.
texture - the Texture to use when rendering this Quadrangle.
Throws:
java.lang.NullPointerException - if any of the specified vertices or normals are null.

Quadrangle

public Quadrangle(Vector3D vertexA,
                  Vector3D vertexB,
                  Vector3D vertexC,
                  Vector3D vertexD,
                  Layout3D layout,
                  int color)
Creates a Quadrangle primitive with the vertices at the positions specified by the vertexA, vertexB, vertexC, and vertexD parameters. The Quadrangle will be rendered using the specified color and Layout3D.

The specified vertices cannot be null. If the specified Layout3D is null the Quadrangle will not be rendered. See Graphics for information on specifying RGB color values.

Parameters:
vertexA - vertex A of the Quadrangle.
vertexB - vertex B of the Quadrangle.
vertexC - vertex C of the Quadrangle.
vertexD - vertex D of the Quadrangle.
layout - the Layout3D to use to render this Quadrangle.
color - the color to use when rendering this Quadrangle.
Throws:
java.lang.NullPointerException - if any of the specified vertices are null.
See Also:
Graphics

Quadrangle

public Quadrangle(Vector3D vertexA,
                  Vector3D vertexB,
                  Vector3D vertexC,
                  Vector3D vertexD,
                  Vector3D faceNormal,
                  Layout3D layout,
                  int color)
Creates a Quadrangle primitive with the vertices at the positions specified by vertexA, vertexB, vertexC, and vertexD parameters and oriented with the normal specified with faceNormal parameter. The Quadrangle will be rendered using the specified color and Layout3D.

The specified vertices cannot be null. If the specified Layout3D is null the Quadrangle will not be rendered. See Graphics for information on specifying RGB color values.

Parameters:
vertexA - vertex A of the Quadrangle.
vertexB - vertex B of the Quadrangle.
vertexC - vertex C of the Quadrangle.
vertexD - vertex D of the Quadrangle.
faceNormal - the face normal of the Quadrangle.
layout - the Layout3D to use to render this Quadrangle.
color - the color to use when rendering this Quadrangle.
Throws:
java.lang.NullPointerException - if any of the specified vertices or the face normal are null.
See Also:
Graphics

Quadrangle

public Quadrangle(Vector3D vertexA,
                  Vector3D vertexB,
                  Vector3D vertexC,
                  Vector3D vertexD,
                  Vector3D normalA,
                  Vector3D normalB,
                  Vector3D normalC,
                  Vector3D normalD,
                  Layout3D layout,
                  int color)
Creates a Quadrangle primitive with the vertices at the positions specified by vertexA, vertexB, vertexC, and vertexD parameters and oriented with the normal specified for each vertex. The Quadrangle will be rendered using the specified color and Layout3D.

The specified vertices cannot be null. If the specified Layout3D is null the Quadrangle will not be rendered. See Graphics for information on specifying RGB color values.

Parameters:
vertexA - vertex A of the Quadrangle.
vertexB - vertex B of the Quadrangle.
vertexC - vertex C of the Quadrangle.
vertexD - vertex D of the Quadrangle.
normalA - the normal at vertex A of the Quadrangle.
normalB - the normal at vertex B of the Quadrangle.
normalC - the normal at vertex C of the Quadrangle.
normalD - the normal at vertex D of the Quadrangle.
layout - the Layout3D to use to render this Quadrangle.
color - the color to use when rendering this Quadrangle.
Throws:
java.lang.NullPointerException - if any of the specified vertices or normals are null.
See Also:
Graphics
Method Detail

getVector

public Vector3D getVector(int vectorID)
                   throws java.lang.IllegalArgumentException
Returns the Vector3D for the specified vector. Quadrangle supports the constants Primitive.VERTEX_A, Primitive.VERTEX_B, Primitive.VERTEX_C, Primitive.VERTEX_D, Primitive.FACE_NORMAL, and Primitive.NORMAL.

Overrides:
getVector in class Primitive
Parameters:
vectorID - the ID of the vector to return.
Returns:
the Vector3D for the specified vector.
Throws:
java.lang.IllegalArgumentException - if an invalid vectorID is specified.
See Also:
Primitive.VERTEX_A, Primitive.VERTEX_B, Primitive.VERTEX_C, Primitive.VERTEX_D, Primitive.FACE_NORMAL, Primitive.NORMAL

setVector

public void setVector(int vectorID,
                      Vector3D vector)
               throws java.lang.NullPointerException,
                      java.lang.IllegalArgumentException
Sets the specified vertex to the Vector3D provided.

. A quadrangle is defined by four Vector3D objects which contain the coordinates of the four points that define the polygon. Therefore the valid vertex IDs for the Quadrangle are Primitive.VERTEX_A, Primitive.VERTEX_B, Primitive.VERTEX_C, and Primitive.VERTEX_D. In order to assign a face normal for the quadrangle the constant Primitive.FACE_NORMAL is used. For assigning normals to vertices the vertex constants are combined with the Primitive.NORMAL constant. For example, to assign a normal to vertex B, the vertex ID would be (Primitive.VERTEX_B | Primitive.NORMAL). When assigning vertex normals it is important to assign a vertex normal for each vertex. If any of the vertices does not have a normal assigned to it, the quadrangle will not be affected by lighting parameters. A quadrangle cannot have a face normal and vertex normals assigned to it at the same time. When a face normal is assigned to a quadrangle, the vertex normals are automatically discarded. Similarily, once a vertex normal is assigned to a quadrangle, its face normal will be discarded.

Overrides:
setVector in class Primitive
Parameters:
vectorID - the ID of the vector being set.
vector - the Vector3D to set.
Throws:
java.lang.IllegalArgumentException - if an invalid vectorID is specified.
java.lang.NullPointerException - if the vector is null.
See Also:
Primitive.VERTEX_A, Primitive.VERTEX_B, Primitive.VERTEX_C, Primitive.VERTEX_D, Primitive.FACE_NORMAL, Primitive.NORMAL

getTextureCoordinateX

public int getTextureCoordinateX(int vertexID)
                          throws java.lang.IllegalArgumentException
Returns the X component of the texture coordinate for the specified vertex.

Parameters:
vertexID - vertex.
Returns:
the X component of the texture coordinate for the specified vertex.
Throws:
java.lang.IllegalArgumentException - if the specified vertexID is invalid.
See Also:
Primitive.VERTEX_A, Primitive.VERTEX_B, Primitive.VERTEX_C, Primitive.VERTEX_D

getTextureCoordinateY

public int getTextureCoordinateY(int vertexID)
                          throws java.lang.IllegalArgumentException
Returns the Y component of the texture coordinate for the specified vertex.

Parameters:
vertexID - vertex.
Returns:
the Y component of the texture coordinate for the specified vertex.
Throws:
java.lang.IllegalArgumentException - if the specified vertexID is invalid.
See Also:
Primitive.VERTEX_A, Primitive.VERTEX_B, Primitive.VERTEX_C, Primitive.VERTEX_D

setTextureCoordinates

public void setTextureCoordinates(int vertexID,
                                  int x,
                                  int y)
                           throws java.lang.IllegalArgumentException
Sets the texture coordinates for the specified vertex. No error checking is done on the texture coordinates. If the texture coordinates define a region that is outside the texture boundaries, the quadrangle will not be rendered correctly.

Parameters:
vertexID - vertex.
x - X coordinate.
y - Y coordinate.
Throws:
java.lang.IllegalArgumentException - if the specified vertexID is invalid.
See Also:
Primitive.VERTEX_A, Primitive.VERTEX_B, Primitive.VERTEX_C, Primitive.VERTEX_D