class FoxModel
package foxlite
extends FoxObject › FoxBasic
implements IFoxCullable
extended by FoxFlxSprite, FoxPostProcess, FoxPanoramaSky, FoxInstancedModel
Constructor
Variables
frustumCulling:Bool
If enabled, this will perform frustum culling, meaning this object will disable its rendering when it's not visible by the camera. If you have many many objects on-screen that shouldn't be visible off-screen, keep this enabled
deactivateWhenCulled:Bool = false
If true, this object will not call update(). Keep in mind this will disable
any logic you've put here if extending this class.
cullMargin:Float = 1
The scale for the meshes extents, increase this if your object gets culled too early
culled:Bool = false
This value is set per-camera at draw time, indicating if the model has been culled
To disable these calculations, set frustumCulling to disabled
curLod:Int = 0
The current level of detail for this mesh
Can be changed to swap LODs at runtime (if the meshes have any)
This has no effect if the meshes have no LODs
cacheBounds:BoundingBox = new BoundingBox()
Precalculated bounds for all meshes of this model
Updates when a mesh is added/removed
Note: Vertex data updated manually are not accounted for this,
you'd have to rebuild the mesh bounds via fromExtents()
__prevTransform:Matrix3D = new Matrix3D()
This is the object's transform from a previous frame, used for motion vector calculations.
Having to calculate previous transforms on empty objects is a bit pointless, so that's why this is here.
groups:Array<Int> = [0]
The draw groups from a scene this object will be drawn on.
Used mainly to separate meshes in passes in an optimized manner.
Note: When changing this array manually, always set FoxRenderer.mustRebuildDrawGroups to true
to ensure proper updating.
There are dedicated functions for this below:
addToDrawGroup(group)removeFromDrawGroup(group)setDrawGroupAt(i, group)
meshes:Array<FoxMesh> = []
Meshes that will be rendered by this model, they inherit this model transform.
Note: When changing this array manually, always set FoxRenderer.mustRebuildDrawGroups to true
to ensure proper updating.
There are dedicated functions for this below:
setMeshAt(i, mesh)addMesh(mesh)removeMesh(mesh)removeMeshByIndex(mesh)
materialOverride:FoxMaterial = null
If set, this material will be applied to every mesh of this model when rendering.
materialOverlay:FoxMaterial = null
If set, this material will be applied over every mesh of this model.
This will draw the meshes again using this material.
perMeshMaterialOverride:Array<FoxMaterial> = []
An array for each mesh which can have an overriden material.
Set it to its respective index to override it. Null to remove it.
perMeshMaterialOverlay:Array<FoxMaterial> = []
An array for each mesh which can have an overlay material.
Set it to its respective index to override it. Null to remove it.
castColoredShadows:Bool = false
If true, this model will cast colored shadows, useful for tinted transluscent objects (stained glass, liquids, fabric).
Requires castShadows to be true.
Note: This is not implemented yet.
Methods
getMeshMaterialOverride(meshIdx:Int):FoxMaterial
Shortcut to get an overriden material from a mesh by index
setMeshMaterialOverride(meshIdx:Int, mat:FoxMaterial):Void
Shortcut to assign an overriden material from a mesh by index
getMeshMaterialOverlay(meshIdx:Int):FoxMaterial
Shortcut to get an overriden material from a mesh by index
setMeshMaterialOverlay(meshIdx:Int, mat:FoxMaterial):Void
Shortcut to assign an overriden material from a mesh by index
loadJSON(name:String):Null<{meshes:Array<FoxMesh>, materials:Map<String, FoxMaterial>}>
Loads a FoxLite JSON model
loadOBJ(name:String, ?extraShaderFlags:Array<String>, ?customShaderPath:String):Null<{meshes:Array<FoxMesh>, materials:Map<String, FoxMaterial>}>
computeBounds(output:BoundingBox):Void
Gets the expanded combined bounding box of all meshes inside this model
Parameters:
output | the Bounding Box where to store the result |
|---|
testAndCull(camera:FoxCamera):Void
Performs frustum culling by checking the sorrounding bounding box against a camera frustum