Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## com.threed.jpct
Class PolygonManager

    java.lang.Object
      com.threed.jpct.PolygonManager

public class PolygonManager
extends java.lang.Object

A PolygonManager is part of each Object3D and can be obtained from that object. It allows to access an object's polygonal data that's normally hidden inside of jPCT.
The polygon ID that most methods require can be obtained by "wild guessing", by picking a specific polygon or from a CollisionEvent.
When using a PolygonManager on a compiled object, it may be required to synchronize your changes to the FrameBuffer by using the FrameBuffer's lock object.

See Also:
  `Object3D.getPolygonManager()`, `CollisionEvent`, `FrameBuffer.getLock()`

Method Summary
`void` | `addTexture(int polyID, int tid, int mode)` Adds a texture to next free stage, if another free stage is available.
`int` | `getMaxPolygonID()` Returns the maximum polygon ID for the object.
`int` | `getPolygonTexture(int polyID)` Returns the texture ID of a polygon or -1 in case of an error.
`int[]` | `getPolygonTextures(int polyID)` Returns the texture IDs of a polygon or null in case of an error.
`SimpleVector` | `getTextureUV(int polyID, int vertexNumber)` Returns the normalized texture coordinates mapped to a SimpleVector's x and y component.
`SimpleVector` | `getTransformedNormal(int polyID)` Returns a polygon's face normal transformed into world space.
`SimpleVector` | `getTransformedVertex(int polyID, int vertexNumber)` Returns a polygon's vertex transformed into world space.
`void` | `setPolygonTexture(int polyID, int textureID)` Sets the texture for a polygon.
`void` | `setPolygonTexture(int polyID, TextureInfo tInf)` Sets the textures and its coordinates for a polygon.
`void` | `setVertexAlpha(int polyID, int vertexNumber, float alpha)` Sets the alpha value for an objects vertex.

Methods inherited from class java.lang.Object
`equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Method Detail

### getPolygonTexture

    public int getPolygonTexture(int polyID)

  Returns the texture ID of a polygon or -1 in case of an error. The corresponding texture can be obtained from the TextureManager.

  Parameters:
    `polyID` - int the ID of the polygon
  Returns:
    the texture ID or -1
  See Also:
    `TextureManager.getTextureByID(int)`

### getPolygonTextures

    public int[] getPolygonTextures(int polyID)

  Returns the texture IDs of a polygon or null in case of an error. The corresponding textures can be obtained from the TextureManager. The returned array is allowed to contain TextureManager.TEXTURE_NOTFOUND-IDs. In that case, you can break after finding the first one.

  Parameters:
    `polyID` - int the ID of the polygon
  Returns:
    the texture ID or null
  See Also:
    `TextureManager.getTextureByID(int)`

### setPolygonTexture

    public void setPolygonTexture(int polyID,
                                  int textureID)

  Sets the texture for a polygon. The texture ID is the ID of the texture in the World instance to which this object is assigned. It can be obtained by calling TextureManager.getTextureID(). The polygon's ID is what the picking methods in Interact2D or a CollisionEvent may return.

  Parameters:
    `polyID` - the ID of the polygon
    `textureID` - the ID of the texture

### addTexture

    public void addTexture(int polyID,
                           int tid,
                           int mode)

  Adds a texture to next free stage, if another free stage is available.

  Parameters:
    `polyID` - the polygon id
    `tid` - the texture's id
    `mode` - the blending mode (as defined in TextureInfo)
  See Also:
    `TextureInfo`

### setPolygonTexture

    public void setPolygonTexture(int polyID,
                                  TextureInfo tInf)

  Sets the textures and its coordinates for a polygon. This method uses a TextureInfo instance, i.e. you may change texture coordinates and assign/remove multiple textures per polygon (supported by the OpenGL renderes only ATM).

  Parameters:
    `polyID` - int the ID of the polygon
    `tInf` - TextureInfo the TextureInfo containing the new texturing information

### setVertexAlpha

    public void setVertexAlpha(int polyID,
                               int vertexNumber,
                               float alpha)

  Sets the alpha value for an objects vertex. Once done on an object, the overall transparency value for this object is obsolete and all transparency will be calculated using the alpha values assigned to the vertices, whose default is 1. The software renderer ignores this value.

  Parameters:
    `polyID` - int the ID of the polygon
    `vertexNumber` - int the number if the vertex (0..2)
    `alpha` - the new alpha value in a range of (0..1)

### getTransformedVertex

    public SimpleVector getTransformedVertex(int polyID,
                                             int vertexNumber)

  Returns a polygon's vertex transformed into world space.

  Parameters:
    `polyID` - int the ID of the polygon
    `vertexNumber` - int the number if the vertex (0..2)
  Returns:
    the vertex or null in case of an error

### getTextureUV

    public SimpleVector getTextureUV(int polyID,
                                     int vertexNumber)

  Returns the normalized texture coordinates mapped to a SimpleVector's x and y component.

  Parameters:
    `polyID` - int the ID of the polygon
    `vertexNumber` - int the number if the vertex (0..2)
  Returns:
    SimpleVector u and v in SimpleVector.x and .y

### getTransformedNormal

    public SimpleVector getTransformedNormal(int polyID)

  Returns a polygon's face normal transformed into world space.

  Parameters:
    `polyID` - int the ID of the polygon
  Returns:
    the normal or null in case of an error

### getMaxPolygonID

    public int getMaxPolygonID()

  Returns the maximum polygon ID for the object.

  Returns:
    the maximum ID.

Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD