Class Model.Surface
- Enclosing class:
- Model
A OBJ surface is a single unit of rendering. A new surface is created any
time an OBJ file issues face commands after declaring a new object, group,
or material. surfacees doe not have their own ModelView matrix. That is
stored in the Model that groups them together.
We currently only support fully specified polygonal surfaces. We do not support any freeform drawing commands, even though those are included in the OBJ specification.
-
Constructor Summary
ConstructorsConstructorDescriptionSurface(ModelInfo root, ModelInfo.Group info) Creates this surface with the given AST.Surface(ModelInfo root, ModelInfo.Group info, boolean buffer) Creates this surface with the given AST. -
Method Summary
Modifier and TypeMethodDescriptionbooleanReturns true if an OpenGL buffer was successfully built for this surface.Returns the vertex buffer storing the drawing dataintgetIndex()Returns the smoothing index for this surface.Returns the material associated with this surface.Returns the name of the material associated with this surface.getMesh()Returns theObjMeshfor storing the drawing dataReturns the object that this surface is associated with.voidSets the object that this surface is associated with.com.badlogic.gdx.utils.ObjectSet<String>getTags()Returns the group tags associated with this surface.booleanReturns true if this surface has the given tag.voidsetIndex(int value) Sets the smoothing index for this surface.voidsetMaterial(Material material) Sets the material associated with this surface.voidsetMaterialName(String name) Sets the name of the material associated with this surface.
-
Constructor Details
-
Surface
Creates this surface with the given AST.This method will build the vertices and mesh information for the surface. However, it will only not create the OpenGL buffer.
- Parameters:
root- The AST rootinfo- The AST for this particular surface
-
Surface
Creates this surface with the given AST.This method will build the vertices and mesh information for the surface. However, it will only create the OpenGL buffer if the parameter buffer is true. This allows us to create meshes off of the main thread (and allocate the buffer once back on the main thread).
- Parameters:
root- The AST rootinfo- The AST for this particular surfacebuffer- Whether to construct the OpenGL buffer
-
-
Method Details
-
createBuffer
public boolean createBuffer()Returns true if an OpenGL buffer was successfully built for this surface.If the surface is already built this method will return true. Otherwise, it will attempt to build the surface and return true on success. This method should only be called on the main thread. It exists to support asset loading off the main thread.
- Returns:
- true if an OpenGL buffer was successfully built for this surface.
-
getIndex
public int getIndex()Returns the smoothing index for this surface.As per the OBJ specification, this value is 0 by default.
- Returns:
- the smoothing index for this surface.
-
setIndex
public void setIndex(int value) Sets the smoothing index for this surface.As per the OBJ specification, this value is 0 by default.
- Parameters:
value- The smoothing index for this surface.
-
getObject
Returns the object that this surface is associated with.Objects are defined with the o command in OBJ files. This value is the empty string by default.
- Returns:
- the object that this surface is associated with.
-
getObject
Sets the object that this surface is associated with.Objects are defined with the o command in OBJ files. This value is the empty string by default.
- Parameters:
value- The object that this surface is associated with.
-
getTags
Returns the group tags associated with this surface.This tag set is returned by reference. That means modifying this set will modify the associated tags.
- Returns:
- the group tags associated with this surface.
-
hasTag
Returns true if this surface has the given tag.- Parameters:
tag- The tag to query- Returns:
- true if this surface has the given tag.
-
getMesh
Returns theObjMeshfor storing the drawing dataObjMesh objects store the geometry but are independent of any OpenGL buffer. This method is read-only, as it is unsafe to modify the mesh without updating the associated OpenGL buffer.
- Returns:
- the CUGL surface for storing the drawing data
-
getBuffer
Returns the vertex buffer storing the drawing dataUnlike the
ObjMesh, the vertex buffer stores the geometry in a format to be used by OpenGL.- Returns:
- the vertex buffer storing the drawing data
-
getMaterialName
Returns the name of the material associated with this surface.If the surface has no material, this will return the empty string.
- Returns:
- the name of the material associated with this surface.
-
setMaterialName
Sets the name of the material associated with this surface.If the surface has no material, this will return the empty string.
- Parameters:
name- The name of the material associated with this surface.
-
getMaterial
Returns the material associated with this surface.If the surface has no material, it will drawn using a default white color.
- Returns:
- the material associated with this surface.
-
setMaterial
Sets the material associated with this surface.If the surface has no material, it will drawn using a default white color.
- Parameters:
material- The material associated with this surface.
-