Package heronarts.lx.model
Class LXModel
java.lang.Object
heronarts.lx.model.LXNormalizationBounds
heronarts.lx.model.LXModel
 All Implemented Interfaces:
LXSerializable
 Direct Known Subclasses:
GridModel
,GridModel.Strip
,LXFixture.Submodel
,LXView
,StripModel
An LXModel is a representation of a set of points in 3D space. Each LXPoint
corresponds to a single point. Though the positions of points may be updated,
a model is immutable. Its overall structure, number of points, and hierarchy
of submodels may not be changed once it has been created.
This class should generally not be used directly to construct model objects.
It is heavily preferred to use the
LXStructure
and LXFixture
APIs to dynamically generate
a model.
In cases where fixedmodel programming is preferred, it is recommended to use
the LXModelBuilder
class to aid in model construction.
Nested Class Summary
Modifier and TypeClassDescriptionstatic enum
An enumeration of common geometry helper types.static interface
Defines a function that computes geometric data for a pointstatic interface
Listener interface for changes to the location of points in a modelstatic class
A collection of helpful predefined constants for the most common model tag types.Nested classes/interfaces inherited from interface heronarts.lx.LXSerializable
LXSerializable.Utils

Field Summary
Modifier and TypeFieldDescriptionfinal LXVector
Deprecated.float
Average x pointfloat
Average y pointfloat
Average z pointfloat
Angle of this model's center about the origin in the xz plane (clockwise rotation about the upwards vertical Yaxis) 0 is pointing straight ahead (+z axis) HALF_PI is to the right (+x axis) PI is backwards (z axis) 1.5*PI is to the left (x axis)final LXVector
Deprecated.final LXModel[]
An immutable list of all the children of this modelfloat
Angle of this point between the yvalue and the xz plane 0 is flat HALF_PI is upwards (+y axis) HALF_PI is downwards (y axis)An immutable map of String key/value pairs, metadata on the model objectAn ordered list of outputs that should be sent for this model.final LXPoint[]
An immutable list of all the points in this modelfloat
Greatest radius from center of model, this is only valid on the toplevel LXModelfloat
Smallest radius from center of model, this is only valid on the toplevel LXModelfloat
Range of radial values from center of model, only valid on the toplevel LXModelfloat
Greatest radius from origin (0, 0)float
Smallest radius from origin (0, 0)float
Range of radial values from origin (0, 0)final int
Total number of points in the modelA list of String tags by which this model type can be identified.final LXMatrix
A transform matrix that represents the positioning of this model in the global space, if part of the structure. 
Constructor Summary
ModifierConstructorDescriptionLXModel()
Constructs a null model with no pointsConstructs a model from the given submodels.LXModel
(LXModel[] children, LXNormalizationBounds bounds) Constructs a model from the given submodels.LXModel
(LXModel[] children, LXNormalizationBounds bounds, String... tags) Constructs a model from the given submodels.LXModel
(LXModelBuilder builder) Deprecated.protected
LXModel
(LXModelBuilder builder, boolean isRoot) Deprecated.Constructs a model from a list of pointsConstructs a model with a given set of points and preconstructed children.Constructs a model with a given set of points and preconstructed submodels.LXModel
(List<LXPoint> points, LXModel[] children, LXNormalizationBounds bounds, Map<String, String> metaData, List<String> tags) Constructs a model with a given set of points and preconstructed submodels.Constructs a model with a given set of points and preconstructed submodels.Constructs a model with a given set of points and preconstructed submodels.Constructs a model with a given set of points and preconstructed submodels.Constructs a model from a list of pointsConstructs a model from a list of points 
Method Summary
Modifier and TypeMethodDescriptionfinal LXModel
addListener
(LXModel.Listener listener) Returns the first ancestor of this model with the given tag, if it exists.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.Returns a list of all the direct child components by particular tag.float[]
computeGeometry
(LXModel.GeometryFunction function) Dynamically computes an array of geometry values for all the points in this model.boolean
Determine whether the given descendant is contained by this model, at any level of hierarchy.void
debugPrint
(PrintStream out) void
dispose()
int
Returns an integer identifying the generation of this model.float[]
getGeometry
(LXModel.Geometry geometry) Gets a computed geometry array for all the points in this model, indexed by LXPoint.index.float[]
getGeometry
(LXModel.GeometryFunction function) Gets a computed geometry array for all the points in this model, indexed by LXPoint.index.Returns the model which defines the space in which this model's points are normalized, based upon the xMin/xMax/xRange etc.Returns the larger model which contains this model, if there is one.getPath()
Accessor for a list of all points in the model.getRoot()
Returns the root model that this is derived fromvoid
load
(LX lx, JsonObject object) Restores this instance from a JSON objectGets a meta data propertySets the normalized values of all the points in this model (xn, yn, zn) relative to this model's absolute bounds.Reindexes all the points in this model from 0 up to the number of points.final LXModel
removeListener
(LXModel.Listener listener) void
save
(LX lx, JsonObject object) Serializes this instance into the JSON objectReturns a list of all the submodel components by particular tag, at any level of depth, may be many levels of descendants contained hereint[]
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.update()
Update the metavalues in this model.update
(boolean normalize) Update the averages and mins/maxes of the model.update
(boolean normalize, boolean recurse) Updates the averages and min/maxes of the modelvalidateTags
(List<String> tags)

Field Details

transform
A transform matrix that represents the positioning of this model in the global space, if part of the structure. For manually constructed models this value is undefined. 
points
An immutable list of all the points in this model 
metaData
An immutable map of String key/value pairs, metadata on the model object 
children
An immutable list of all the children of this model 
outputs
An ordered list of outputs that should be sent for this model. 
tags
A list of String tags by which this model type can be identified. Tags are nonempty strings. These tags can be used with thechildren(String)
andsub(String)
methods to dynamically navigate this model's hierarchy. 
size
public final int sizeTotal number of points in the model 
center
Deprecated.Center position in the model (halfway between extremes) 
average
Deprecated.Average position in the model (weighted by point density) 
ax
public float axAverage x point 
ay
public float ayAverage y point 
az
public float azAverage z point 
rMin
public float rMinSmallest radius from origin (0, 0) 
rMax
public float rMaxGreatest radius from origin (0, 0) 
rRange
public float rRangeRange of radial values from origin (0, 0) 
rcMin
public float rcMinSmallest radius from center of model, this is only valid on the toplevel LXModel 
rcMax
public float rcMaxGreatest radius from center of model, this is only valid on the toplevel LXModel 
rcRange
public float rcRangeRange of radial values from center of model, only valid on the toplevel LXModel 
azimuth
public float azimuthAngle of this model's center about the origin in the xz plane (clockwise rotation about the upwards vertical Yaxis) 0 is pointing straight ahead (+z axis) HALF_PI is to the right (+x axis) PI is backwards (z axis) 1.5*PI is to the left (x axis) 
elevation
public float elevationAngle of this point between the yvalue and the xz plane 0 is flat HALF_PI is upwards (+y axis) HALF_PI is downwards (y axis)


Constructor Details

LXModel
public LXModel()Constructs a null model with no points 
LXModel
Constructs a model from a list of points Parameters:
points
 Points in the model

LXModel
Constructs a model from a list of points Parameters:
points
 Points in the modeltags
 Tag identifiers for the model type

LXModel
Constructs a model from a list of points Parameters:
points
 Points in the modelmetaData
 Metadata for the modeltags
 Tag identifiers for the model type

LXModel
Constructs a model with a given set of points and preconstructed children. In this case, points from the children are not added to the points array, they are assumed to already be contained by the points list. Parameters:
points
 Points in this modelchildren
 Prebuilt direct child model array

LXModel
Constructs a model with a given set of points and preconstructed submodels. In this case, points from the submodels are not added to the points array, they are assumed to already be contained by the points list. Parameters:
points
 Points in this modelchildren
 Prebuilt direct submodel child arraytags
 Tag identifier for this model

LXModel
public LXModel(List<LXPoint> points, LXModel[] children, LXNormalizationBounds bounds, String... tags) Constructs a model with a given set of points and preconstructed submodels. In this case, points from the submodels are not added to the points array, they are assumed to already be contained by the points list. Parameters:
points
 Points in this modelchildren
 Prebuilt direct submodel child arraybounds
 Normalization boundstags
 Tag identifier for this model

LXModel
public LXModel(List<LXPoint> points, LXModel[] children, Map<String, String> metaData, String... tags) Constructs a model with a given set of points and preconstructed submodels. In this case, points from the submodels are not added to the points array, they are assumed to already be contained by the points list. Parameters:
points
 Points in this modelchildren
 Prebuilt direct submodel child arraymetaData
 Metadata maptags
 Tag identifier for this model

LXModel
public LXModel(List<LXPoint> points, LXModel[] children, Map<String, String> metaData, List<String> tags) Constructs a model with a given set of points and preconstructed submodels. In this case, points from the submodels are not added to the points array, they are assumed to already be contained by the points list. Parameters:
points
 Points in this modelchildren
 Prebuilt direct submodel child arraymetaData
 Metadata maptags
 Tag identifier for this model

LXModel
public LXModel(List<LXPoint> points, LXModel[] children, LXNormalizationBounds bounds, Map<String, String> metaData, List<String> tags) Constructs a model with a given set of points and preconstructed submodels. In this case, points from the submodels are not added to the points array, they are assumed to already be contained by the points list. Parameters:
points
 Points in this modelchildren
 Prebuilt direct submodel child arraybounds
 Normalization bounds, if different from the model itselfmetaData
 Metadata maptags
 Tag identifier for this model

LXModel
Constructs a model from the given submodels. The point list is generated from all points in the submodels, on the assumption that they have not yet been added. Parameters:
children
 Submodels

LXModel
Constructs a model from the given submodels. The point list is generated from all points in the submodels, on the assumption that they have not yet been added. Parameters:
children
 Submodelsbounds
 Bounds

LXModel
Constructs a model from the given submodels. The point list is generated from all points in the submodels, on the assumption that they have not yet been added. Parameters:
children
 Submodelsbounds
 Normalization boundstags
 Tags

LXModel
Deprecated. 
LXModel
Deprecated.


Method Details

validateTags

getNormalizationBounds
Returns the model which defines the space in which this model's points are normalized, based upon the xMin/xMax/xRange etc. By default, this is the model itself. Returns:
 Model that defines normalization ranges for points

getRoot
Returns the root model that this is derived from Returns:
 Root model that this model belongs to, potentially this

getParent
Returns the larger model which contains this model, if there is one. May be null. Returns:
 Model containing this model, or null

contains
Determine whether the given descendant is contained by this model, at any level of hierarchy. Parameters:
descendant
 Descendant submodel Returns:
 true if the descendant is contained by this model tree

getPath

reindexPoints
Reindexes all the points in this model from 0 up to the number of points. Returns:
 this

children
Returns a list of all the direct child components by particular tag. Children are only onelevel deep. Parameters:
tag
 Child tag type Returns:
 List of direct children by type

sub
Returns a list of all the submodel components by particular tag, at any level of depth, may be many levels of descendants contained here Parameters:
tag
 Submodel tag Returns:
 List of all descendant submodels

ancestor
Returns the first ancestor of this model with the given tag, if it exists. Parameters:
tag
 Tag to search ancestors for Returns:
 Nearest ancestor with tag, or null

meta
Gets a meta data property Parameters:
key
 Meta data key Returns:
 Value if there is one, otherwise null

addListener

removeListener

update
Update the metavalues in this model. Renormalizes the points relative to this model and recomputes its averages. Returns:
 this

update
Update the averages and mins/maxes of the model. Parameters:
normalize
 If true, normalize the points relative to this model Returns:
 this

update
Updates the averages and min/maxes of the model Parameters:
normalize
 If true, normalize the points relative to this modelrecurse
 If true, compute averages for submodels as well Returns:
 this

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. Will increment a sentinel value and notify listeners of the change. Returns:
 this

getGeneration
public int getGeneration()Returns an integer identifying the generation of this model. Each time geometry in the model is changed, this value is incremented; Returns:
 Monotonically increasing integer verson number of the geometry revision

toIndexBuffer
public int[] toIndexBuffer()Creates an index buffer of all the point indices in this model. Returns:
 Index buffer of all points in this model, containing their global color indices

toIndexBuffer
public int[] toIndexBuffer(int offset, int length) Creates an index buffer of a subset of points in this model. Parameters:
offset
 Initial offset into this model's pointslength
 Length of the index buffer Returns:
 Array that contains the global color buffer indices for the specified points in this model

normalizePoints
Sets the normalized values of all the points in this model (xn, yn, zn) relative to this model's absolute bounds. Returns:
 this

getPoints
Accessor for a list of all points in the model. Generally preferable to directly access the points array when iterating over a full buffer, but this is useful for situations where a container is needed. Returns:
 List of all points

getGeometry
Gets a computed geometry array for all the points in this model, indexed by LXPoint.index. Note that the array is not guaranteed to be complete, it will only contain valid values for points in this model. This method makes use of caching and should be cheap for repeated calls on the same model, but could incur significant CPU cost the first time it is invoked for a given geometry type, or if the model geometry has changed. Parameters:
geometry
 Geometry type Returns:
 Geometry array

getGeometry
Gets a computed geometry array for all the points in this model, indexed by LXPoint.index. Note that the array is not guaranteed to be complete, it will only contain valid values for points in this model. This method makes use of caching and should be cheap for repeated calls on the same model, but could incur significant CPU cost the first time it is invoked for a given geometry type, or if the model geometry has changed. Parameters:
function
 Geometry function Returns:
 Geometry array

computeGeometry
Dynamically computes an array of geometry values for all the points in this model. This is an expensive CPU operation that runs math against all points in the model, it should be used carefully and results should be cached if desired. Parameters:
function
 Geometry function Returns:
 Array of geometry values indexed by LXPoint.index

save
Description copied from interface:LXSerializable
Serializes this instance into the JSON object Specified by:
save
in interfaceLXSerializable
 Parameters:
lx
 LX instanceobject
 Object to serialize into

load
Description copied from interface:LXSerializable
Restores this instance from a JSON object Specified by:
load
in interfaceLXSerializable
 Parameters:
lx
 LX instanceobject
 Object to deserialize

dispose
public void dispose() 
debugPrint
