java.lang.Object
com.marginallyclever.ro3.factories.Factory
com.marginallyclever.ro3.mesh.MeshFactory
MeshFactory loads a mesh from a file using one of many MeshLoader classes. It also keeps a pool of
all mesh loaded so that only one instance of each shape is loaded.-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidAdd a mesh to the pool if it is not already present.booleanMakes sure to only load one instance of each source file.Get a mesh from the pool, loading it if necessary, and applying a scale factor.getMaterialPath(String absolutePath) getResources(Lifetime lifetime) Get all meshes in the pool with a specific lifetime.booleanhasMaterial(String absolutePath) voidvoidremoveFromPool(Mesh mesh) Remove a mesh from the pool.voidClear all meshes with lifetime SCENE from the pool.voidunloadAll(com.jogamp.opengl.GL3 gl) Unload all meshes in the pool from OpenGL memory.Methods inherited from class com.marginallyclever.ro3.factories.Factory
addItemListener, removeItemListener
-
Constructor Details
-
MeshFactory
public MeshFactory()
-
-
Method Details
-
get
Makes sure to only load one instance of each source file. Loads all the data immediately. Loads at the default scale.- Parameters:
lifetime- the lifetime of the meshfilename- file from which to load. It may be "filename.ext" or "zipfile.zip:filename.ext"- Returns:
- a non-null instance of Mesh. It may contain nothing.
-
get
Get a mesh from the pool, loading it if necessary, and applying a scale factor.- Parameters:
lifetime- the lifetime of the meshfilename- file from which to load. It may be "filename.ext" or "zipfile.zip:filename.ext"scaleFactor- the scale factor to apply to the mesh- Returns:
- a non-null instance of Mesh. It may contain nothing.
-
reload
-
getAllExtensions
-
canLoad
-
hasMaterial
-
getMaterialPath
-
getAllSourcesForExport
-
getResources
-
getAllResources
-
removeSceneResources
public void removeSceneResources()Clear all meshes with lifetime SCENE from the pool.- Specified by:
removeSceneResourcesin classFactory
-
addToPool
-
removeFromPool
Remove a mesh from the pool.- Parameters:
mesh- the mesh to remove
-
unloadAll
public void unloadAll(com.jogamp.opengl.GL3 gl) Unload all meshes in the pool from OpenGL memory. This must be called from the OpenGL thread.- Parameters:
gl- the OpenGL context
-