public class LXModel extends Object implements LXSerializable
LXStructure
and LXFixture
APIs to dynamically generate
a model.
In cases where fixed-model programming is preferred, it is recommended to use
the LXModelBuilder
class to aid in model construction.Modifier and Type | Class and Description |
---|---|
static class |
LXModel.Key
A collection of helpful pre-defined constants for the most common model
key types.
|
static interface |
LXModel.Listener
Listener interface for changes to the location of points in a model
|
LXSerializable.Utils
Modifier and Type | Field and Description |
---|---|
LXVector |
average
Average position in the model (weighted by point density)
|
float |
ax
Average x point
|
float |
ay
Average y point
|
float |
az
Average z point
|
LXVector |
center
Center position in the model (half-way between extremes)
|
LXModel[] |
children
An immutable list of all the children of this model
|
float |
cx
Center of the model in x space
|
float |
cy
Center of the model in y space
|
float |
cz
Center of the model in z space
|
List<String> |
keys
A list of String keys by which this model type can be identified.
|
Map<String,String> |
metaData
An immutable map of String key/value pairs, metadata on the model object
|
List<LXOutput> |
outputs
An ordered list of outputs that should be sent for this model.
|
LXPoint[] |
points
An immutable list of all the points in this model
|
float |
rcMax
Greatest radius from center of model, this is only valid
on the top-level LXModel
|
float |
rcMin
Smallest radius from center of model, this is only
valid on the top-level LXModel
|
float |
rcRange
Range of radial values from center of model, only validd
on the top-level LXModel
|
float |
rMax
Greatest radius from origin (0, 0)
|
float |
rMin
Smallest radius from origin (0, 0)
|
float |
rRange
Range of radial values from origin (0, 0)
|
int |
size
Total number of points in the model
|
LXMatrix |
transform
A transform matrix that represents the positioning of this model
in the global space, if part of the structure.
|
float |
xMax
Maximum x value
|
float |
xMin
Minimum x value
|
float |
xRange
Range of x values
|
float |
yMax
Maximum y value
|
float |
yMin
Minimum y value
|
float |
yRange
Range of y values
|
float |
zMax
Maximum z value
|
float |
zMin
Minimum z value
|
float |
zRange
Range of z values
|
Modifier | Constructor and Description |
---|---|
|
LXModel()
Constructs a null model with no points
|
|
LXModel(List<LXPoint> points)
Constructs a model from a list of points
|
|
LXModel(List<LXPoint> points,
LXModel[] children)
Constructs a model with a given set of points and pre-constructed children.
|
|
LXModel(List<LXPoint> points,
LXModel[] children,
Map<String,String> metaData,
String... keys)
Constructs a model with a given set of points and pre-constructed submodels.
|
|
LXModel(List<LXPoint> points,
LXModel[] children,
String... keys)
Constructs a model with a given set of points and pre-constructed submodels.
|
|
LXModel(List<LXPoint> points,
Map<String,String> metaData,
String... keys)
Constructs a model from a list of points
|
|
LXModel(List<LXPoint> points,
String... keys)
Constructs a model from a list of points
|
|
LXModel(LXModel[] children)
Constructs a model from the given submodels.
|
|
LXModel(LXModelBuilder builder) |
protected |
LXModel(LXModelBuilder builder,
boolean isRoot) |
Modifier and Type | Method and Description |
---|---|
LXModel |
addListener(LXModel.Listener listener) |
LXModel |
bang()
Should be invoked when some of the geometry inside a model has been changed, but the
total point count and structure is the same.
|
List<LXModel> |
children(String key)
Returns a list of all the direct child components by particular key.
|
void |
dispose() |
int |
getGeneration()
Returns an integer identifying the generation of this model.
|
LXModel |
getParent() |
String |
getPath() |
List<LXPoint> |
getPoints()
Accessor for a list of all points in the model.
|
void |
load(LX lx,
JsonObject object)
Restores this instance from a JSON object
|
String |
meta(String key)
Gets a meta data property
|
LXModel |
normalizePoints()
Sets the normalized values of all the points in this model (xn, yn, zn)
relative to this model's absolute bounds.
|
LXModel |
reindexPoints()
Reindexes all the points in this model from 0 up to the number of points.
|
LXModel |
removeListener(LXModel.Listener listener) |
void |
save(LX lx,
JsonObject object)
Serializes this instance into the JSON object
|
List<LXModel> |
sub(String key)
Returns a list of all the submodel components by particular key, at any level of depth, may be
many levels of descendants contained here
|
int[] |
toIndexBuffer()
Creates an index buffer of all the point indices in this model.
|
int[] |
toIndexBuffer(int offset,
int length)
Creates an index buffer of a subset of points in this model.
|
LXModel |
update()
Update the meta-values in this model.
|
LXModel |
update(boolean normalize)
Update the averages and mins/maxes of the model.
|
LXModel |
update(boolean normalize,
boolean recurse)
Updates the averages and min/maxes of the model
|
public final LXMatrix transform
public final LXPoint[] points
public final Map<String,String> metaData
public final LXModel[] children
public final List<LXOutput> outputs
public final List<String> keys
children(String)
and sub(String)
methods to dynamically navigate this model's hierarchy.public final int size
public final LXVector center
public final LXVector average
public float cx
public float cy
public float cz
public float ax
public float ay
public float az
public float xMin
public float xMax
public float xRange
public float yMin
public float yMax
public float yRange
public float zMin
public float zMax
public float zRange
public float rMin
public float rMax
public float rRange
public float rcMin
public float rcMax
public float rcRange
public LXModel()
public LXModel(List<LXPoint> points)
points
- Points in the modelpublic LXModel(List<LXPoint> points, String... keys)
points
- Points in the modelkeys
- Key identifiers for the model typepublic LXModel(List<LXPoint> points, Map<String,String> metaData, String... keys)
points
- Points in the modelmetaData
- Metadata for the modelkeys
- Key identifiers for the model typepublic LXModel(List<LXPoint> points, LXModel[] children)
points
- Points in this modelchildren
- Pre-built direct child model arraypublic LXModel(List<LXPoint> points, LXModel[] children, String... keys)
points
- Points in this modelchildren
- Pre-built direct submodel child arraykeys
- Key identifier for this modelpublic LXModel(List<LXPoint> points, LXModel[] children, Map<String,String> metaData, String... keys)
points
- Points in this modelchildren
- Pre-built direct submodel child arraymetaData
- Metadata mapkeys
- Key identifier for this modelpublic LXModel(LXModel[] children)
children
- Sub-modelspublic LXModel(LXModelBuilder builder)
protected LXModel(LXModelBuilder builder, boolean isRoot)
public LXModel getParent()
public String getPath()
public LXModel reindexPoints()
public List<LXModel> children(String key)
key
- Child key typepublic List<LXModel> sub(String key)
key
- Submodel keypublic String meta(String key)
key
- Meta data keypublic final LXModel addListener(LXModel.Listener listener)
public final LXModel removeListener(LXModel.Listener listener)
public LXModel update()
public LXModel update(boolean normalize)
normalize
- If true, normalize the points relative to this modelpublic LXModel update(boolean normalize, boolean recurse)
normalize
- If true, normalize the points relative to this modelrecurse
- If true, compute averages for sub-models as wellpublic LXModel bang()
public int getGeneration()
public int[] toIndexBuffer()
public int[] toIndexBuffer(int offset, int length)
offset
- Initial offset into this model's pointslength
- Length of the index bufferpublic LXModel normalizePoints()
public List<LXPoint> getPoints()
public void save(LX lx, JsonObject object)
LXSerializable
save
in interface LXSerializable
lx
- LX instanceobject
- Object to serialize intopublic void load(LX lx, JsonObject object)
LXSerializable
load
in interface LXSerializable
lx
- LX instanceobject
- Object to deserializepublic void dispose()
LX library by Mark C. Slee. © 2012-2020