public abstract class J3DIndexAccessor
extends java.lang.Object
Read indices in a JOGLGeometry
or a Java3D GeometryArray
.
Provides an abstraction layer above the numerous vertex formats and data storage options available in Java3D.
An index accessor is not ready until it has been reset(...)
at
least once with valid parameters. Normally an accessor of the correct type
is acquired from the factory cons(...)
, which also performs an
initial reset. It is not correct to do a relative read()
immediately after reset; instead do an absolute read(...)
or next()
first.
Note that indexCount
, validIndexCount
and initialIndexIndex
are cached at reset(...)
, and if any of these
parameters changes in the underlying geometry it is the caller's
responsibility to call reset(...)
again.
Most operations return this
to facilitate operation chaining.
Copyright (C) 2008 Marsette A. Vona, III
This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
Modifier and Type | Class and Description |
---|---|
static class |
J3DIndexAccessor.J3DCoordOnlyIndexAccessor
This impl handles coord-index-only by-copy index storage.
|
static class |
J3DIndexAccessor.J3DCopyIndexAccessor
This impl handles by-copy index storage.
|
static class |
J3DIndexAccessor.J3DRefIndexAccessor
This impl handles by-ref index storage, which is necessarily
coord-index-only.
|
static class |
J3DIndexAccessor.JOGLIndexAccessor
This impl handles
JOGLGeometry . |
Modifier and Type | Field and Description |
---|---|
int |
colorIndex
current color component index
|
int |
coordIndex
current coordinate component index
|
private static java.lang.String |
cvsid |
protected javax.media.j3d.IndexedGeometryArray |
iga
currently referenced
IndexedGeometryArray , if any |
int |
indexCount
size of index storage
|
int |
indexIndex
current position relative to initial valid index
|
int |
initialIndexIndex
index of first valid index relative to start of index storage
|
protected JOGLGeometry |
jg
currently referenced
JOGLGeometry , if any |
int |
normalIndex
current normal component index
|
private static J3DIndexAccessor[] |
protos
set of prototype implementations for
cons(...) |
int |
texCoordIndex
current texture coordinate index
|
int |
validIndexCount
number of valid indices
|
Constructor and Description |
---|
J3DIndexAccessor() |
Modifier and Type | Method and Description |
---|---|
J3DIndexAccessor |
advance(int num)
seek(int) relative to indexIndex |
abstract boolean |
checkFormat(javax.media.j3d.IndexedGeometryArray iga)
Check if the class, storage type, and vertex format of iga is
compatible with this accessor implementation.
|
boolean |
checkFormat(JOGLGeometry jg)
Similar to
checkFormat(IndexedGeometryArray) . |
boolean |
componentIndicesSame()
Check if each component index is either negative or equal to
coordIndex . |
static J3DIndexAccessor |
cons(javax.media.j3d.IndexedGeometryArray iga)
Factory method to cons a new accessor of the appropriate type for the
class, storage type, and vertex format of iga.
|
static J3DIndexAccessor |
cons(JOGLGeometry jg)
similar to
cons(IndexedGeometryArray) |
static J3DIndexAccessor[] |
consAll()
covers
consAll(J3DIndexAccessor[]) , makes a new array |
static J3DIndexAccessor[] |
consAll(J3DIndexAccessor[] impls)
Cons a new instance of each available implementation.
|
static int |
getNumImplementations()
get the number of available implementations
|
boolean |
hasNext()
covers
hasNext(int) with num = 1 |
boolean |
hasNext(int num)
Check if the next num subsequent calls to
next() will
read indices at or before the end of the valid index range. |
abstract J3DIndexAccessor |
newInstance()
make a new instance of this accessor implementation
|
J3DIndexAccessor |
next()
increment
indexIndex , read(int) |
abstract J3DIndexAccessor |
read()
Access the index storage and read the index at
indexIndex . |
J3DIndexAccessor |
read(int index)
|
J3DIndexAccessor |
readRaw(int index)
convenience cover
seekRaw(int) , read() |
J3DIndexAccessor |
reset()
reset internal indices but continue referencing current geometry
|
J3DIndexAccessor |
reset(javax.media.j3d.IndexedGeometryArray iga)
Reset this accessor so that the subsequent call to
next() reads
the first valid vertex in ga. |
J3DIndexAccessor |
reset(JOGLGeometry jg)
similar to
reset(IndexedGeometryArray) |
protected J3DIndexAccessor |
resetImpl()
Common impl of
reset(IndexedGeometryArray) and reset(JOGLGeometry) . |
J3DIndexAccessor |
seek(int index)
Reposition the internal pointer(s) so that the subsequent call to
read() will read vertex index relative to the first valid
vertex. |
J3DIndexAccessor |
seekRaw(int index)
Reposition the internal pointer(s) so that the subsequent call to
read() will read vertex index relative to the start of
vertex storage. |
private static final java.lang.String cvsid
public int indexIndex
public int indexCount
public int validIndexCount
public int initialIndexIndex
public int texCoordIndex
public int colorIndex
public int normalIndex
public int coordIndex
protected javax.media.j3d.IndexedGeometryArray iga
IndexedGeometryArray
, if anyprotected JOGLGeometry jg
JOGLGeometry
, if anyprivate static final J3DIndexAccessor[] protos
cons(...)
public static int getNumImplementations()
public static J3DIndexAccessor[] consAll(J3DIndexAccessor[] impls)
Cons a new instance of each available implementation.
impls
- if non-null and at least length getNumImplementations()
the new instances are collected here, else a new
array is consedgetNumImplementations()
elements are
set to instances of each available implementationpublic static J3DIndexAccessor[] consAll()
consAll(J3DIndexAccessor[])
, makes a new arraypublic static J3DIndexAccessor cons(javax.media.j3d.IndexedGeometryArray iga)
Factory method to cons a new accessor of the appropriate type for the class, storage type, and vertex format of iga.
The returned accessor is newly consed and already reset(IndexedGeometryArray)
given the passed parameters. It may be
re-used by further reset()
s.
public static J3DIndexAccessor cons(JOGLGeometry jg)
cons(IndexedGeometryArray)
public J3DIndexAccessor reset(javax.media.j3d.IndexedGeometryArray iga)
Reset this accessor so that the subsequent call to next()
reads
the first valid vertex in ga.
iga
- the geometry, or null to clear the previous internal referencejava.lang.IllegalArgumentException
- if iga is non-null and fails
checkFormat(javax.media.j3d.IndexedGeometryArray)
public J3DIndexAccessor reset(JOGLGeometry jg)
reset(IndexedGeometryArray)
protected J3DIndexAccessor resetImpl()
Common impl of reset(IndexedGeometryArray)
and reset(JOGLGeometry)
.
public J3DIndexAccessor reset()
public J3DIndexAccessor seek(int index)
Reposition the internal pointer(s) so that the subsequent call to
read()
will read vertex index relative to the first valid
vertex.
index
- the index of the vertex to read, with the first valid
vertex at index 0 (may be outside the valid range)public J3DIndexAccessor advance(int num)
seek(int)
relative to indexIndex
public J3DIndexAccessor seekRaw(int index)
Reposition the internal pointer(s) so that the subsequent call to
read()
will read vertex index relative to the start of
vertex storage.
index
- the index of the vertex to read relative to start of vertex
storagepublic J3DIndexAccessor read(int index)
public J3DIndexAccessor readRaw(int index)
seekRaw(int)
, read()
public abstract J3DIndexAccessor read()
Access the index storage and read the index at indexIndex
.
Note: if indexIndex
is outside the legal bounds for the index
storage then the underlying access method will throw an exception
according to the storage type.
public boolean hasNext(int num)
Check if the next num subsequent calls to next()
will
read indices at or before the end of the valid index range.
Note that this can include an invalid index before the start of the valid range, if that is the current position of the accessor.
public boolean hasNext()
hasNext(int)
with num = 1public J3DIndexAccessor next()
indexIndex
, read(int)
public boolean componentIndicesSame()
Check if each component index is either negative or equal to coordIndex
.
public abstract boolean checkFormat(javax.media.j3d.IndexedGeometryArray iga)
Check if the class, storage type, and vertex format of iga is compatible with this accessor implementation.
public boolean checkFormat(JOGLGeometry jg)
Similar to checkFormat(IndexedGeometryArray)
.
Default impl returns false.
public abstract J3DIndexAccessor newInstance()