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
Interface IVertexController

All Known Implementing Classes:
  GenericVertexController

public interface IVertexController

This interface defines a VertexController. A VertexController is a way to manipulate vertices of already constructed Object3Ds. It can be added to a Mesh to alter the mesh's vertices according to the controller's implementation.
A VertexController is the only way in jPCT to gain access to vertex data of objects. This concept, which may look a bit too complicated for the task at first glance, is required to keep jPCT's internal vertex representations encapsulated while giving the possibility to modify vertices in a fast, simple and convinient way.
Usually, there's no need to implement this interface directly but to extend the abstract, generic implementation jPCT provides.

See Also:
  `GenericVertexController`, `Mesh.setVertexController(com.threed.jpct.IVertexController, boolean)`, `FrameBuffer.getLock()`

Field Summary
`static boolean` | `ALTER_SOURCE_MESH` The VertexController will modify the source data when applied, i.e.
`static boolean` | `PRESERVE_SOURCE_MESH` The VertexController will start with a "fresh" source mesh everytime it's being applied.

Method Summary
`void` | `apply()` Applies the controller's modifications to the mesh.
`void` | `cleanup()` Like setup(), this method can be overwritten to do some additional work...this time when the controller will be removed.
`void` | `destroy()` This method will be called when the controller will be removed from a Mesh.
`SimpleVector[]` | `getDestinationMesh()` Returns the destination mesh's vertex data.
`SimpleVector[]` | `getDestinationNormals()` Returns the destination mesh's normals.
`int` | `getMeshSize()` Returns the size of the mesh.
`int[]` | `getPolygonIDs(int vertex, int max)` Returns the polygon IDs of the polygons that are using the vertex "number".
`SimpleVector[]` | `getSourceMesh()` Returns the source mesh's vertex data, i.e. the vertex-data that needs modification.
`SimpleVector[]` | `getSourceNormals()` Returns the source mesh's normals, i.e. the normals that need modification.
`float[][]` | `getTangentVectors()` If available, this will return the tangent vectors for the mesh.
`boolean` | `init(Mesh mesh, boolean modify)` Initialize the VertexController with a mesh to modify and a operating mode.
`void` | `refreshMeshData()` Refreshes the controller's data with the data taken directly from the Mesh.
`boolean` | `setup()` This method can be overwritten to do some additional setup work.
`void` | `updateMesh()` Alters the actual Mesh to reflect the modifications that have been applied to the DestinationMesh- and DestinationNormals-arrays.

Field Detail

### ALTER_SOURCE_MESH

    public static final boolean ALTER_SOURCE_MESH

  The VertexController will modify the source data when applied, i.e. everything the controller does to the mesh is cumulative over time.

  See Also:
    Constant Field Values

### PRESERVE_SOURCE_MESH

    public static final boolean PRESERVE_SOURCE_MESH

  The VertexController will start with a "fresh" source mesh everytime it's being applied.

  See Also:
    Constant Field Values

Method Detail

### init

    public boolean init(Mesh mesh,
                        boolean modify)

  Initialize the VertexController with a mesh to modify and a operating mode. There is no need to call this method from inside an application.

  Parameters:
    `mesh` - the Mesh the controller should be assigned to
    `modify` - the mode
  Returns:
    true, if the controller has been intialized correctly
  See Also:
    `ALTER_SOURCE_MESH`, `PRESERVE_SOURCE_MESH`

### setup

    public boolean setup()

  This method can be overwritten to do some additional setup work. This method is called by init() and doesn't have to be called directly.

  Returns:
    true, if the setup went fine

### apply

    public void apply()

  Applies the controller's modifications to the mesh. This method has to be implemented by any specific implementation. It's where the actual work is done.
  The basic idea is to read the source vertices and normals provided by getSourceMesh() and getSourceNormals() and to put the modified results into the corresponding SimpleVectors returned by getDestinationMesh() and getDestinationNormals(). The SimpleVectors in the destination SimpleVector-array may be overwritten with the new data, while the source-arrays should remain untouched.

  See Also:
    `getSourceMesh()`, `getSourceNormals()`, `getDestinationMesh()`, `getDestinationNormals()`

### getSourceMesh

    public SimpleVector[] getSourceMesh()

  Returns the source mesh's vertex data, i.e. the vertex-data that needs modification. Every SimpleVector in this array represents a vertex in the mesh. However, there's no information which vertex exactly (because they don't have ids or something).
  Read the data from this array, but don't modify it.

  Returns:
    the source mesh's vertices

### getSourceNormals

    public SimpleVector[] getSourceNormals()

  Returns the source mesh's normals, i.e. the normals that need modification. Every SimpleVector in this array represents a normal in the mesh. The normal at the specific index is the normal of the corresponding vertex in the SourceMesh-array.
  Read the data from this array, but don't modify it.

  Returns:
    the source mesh's normals

### getDestinationMesh

    public SimpleVector[] getDestinationMesh()

  Returns the destination mesh's vertex data. The new vertices will be stored in these SimpleVectors. There's no need to replace the SimpleVectors in this array with new ones. Just set their x,y and z components to the new values.
  Write into the SimpleVectors of this array, don't read from them.

  Returns:
    the destination mesh's vertices

### getDestinationNormals

    public SimpleVector[] getDestinationNormals()

  Returns the destination mesh's normals. The new normals will be stored in these SimpleVectors. Calculating the vertex normal of a modified vertex is not always cheap. In some cases, one may get away with not modifying the normals at all. This will cause slightly wrong lighting, but eases the calculations.
  Write into the SimpleVectors of this array, don't read from them.

  Returns:
    the destination mesh's normals

### getMeshSize

    public int getMeshSize()

  Returns the size of the mesh. This is the length all SimpleVector-array returned by the methods above will have.

  Returns:
    the size of the mesh

### updateMesh

    public void updateMesh()

  Alters the actual Mesh to reflect the modifications that have been applied to the DestinationMesh- and DestinationNormals-arrays. No need to call this method directly from an application.

### refreshMeshData

    public void refreshMeshData()

  Refreshes the controller's data with the data taken directly from the Mesh. This can be useful to reflect changes to the controller that have been applied to the mesh outside of the controller.

### destroy

    public void destroy()

  This method will be called when the controller will be removed from a Mesh. No need to call this method directly.

  See Also:
    `Mesh.removeVertexController()`

### cleanup

    public void cleanup()

  Like setup(), this method can be overwritten to do some additional work...this time when the controller will be removed. This method will be called from within destroy(). No need to call it directly.

  See Also:
    `Mesh.removeVertexController()`

### getPolygonIDs

    public int[] getPolygonIDs(int vertex,
                               int max)

  Returns the polygon IDs of the polygons that are using the vertex "number". This can be used to determine which vertices belong to a polygon, which could be useful in some VertexControllers. This should be done at setup time, not at runtime.

  Parameters:
    `vertex` - the number of the vertex
    `max` - the maximum of IDs to return
  Returns:
    the IDs

### getTangentVectors

    public float[][] getTangentVectors()

  If available, this will return the tangent vectors for the mesh. For these vectors, there's no difference between source and destination. You can read from as well as write to this array.

  Returns:
    the tangent vectors or null, if none have been assigned

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