Package org.jzy3d.io.obj
Class OBJFile
- java.lang.Object
-
- org.jzy3d.io.obj.OBJFile
-
public class OBJFile extends Object
Translated from C++ Version: nvModel.h - Model support class The nvModel class implements an interface for a multipurpose model object. This class is useful for loading and formatting meshes for use by OpenGL. It can compute face normals, tangents, and adjacency information. The class supports the obj file format. Author: Evan Hart Email: sdkfeedback@nvidia.com Copyright (c) NVIDIA Corporation. All rights reserved.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description classOBJFile.IdxSetstatic classOBJFile.PrimTypeEnumeration of primitive types
-
Field Summary
Fields Modifier and Type Field Description protected booleanautoNormalWill calculate normals if they are missingprotected IntBufferindices_protected List<Integer>nIndex_protected intnOffset_protected List<Float>normals_static intNumPrimTypesprotected intopenEdges_protected List<Integer>pIndex_protected intpOffset_protected List<Float>positions_protected intposSize_protected FloatBuffervertices_protected intvtxSize_
-
Constructor Summary
Constructors Constructor Description OBJFile()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclearNormals()voidcompileModel()This function takes the raw model data in the internal structures, and attempts to bring it to a format directly accepted for vertex array style rendering.BoundingBox3dcomputeBoundingBox()Returns the points defining the axis-aligned bounding box containing the model.IntBuffergetCompiledIndices()intgetCompiledNormalOffset()intgetCompiledPositionOffset()intgetCompiledVertexCount()intgetCompiledVertexSize()FloatBuffergetCompiledVertices()intgetIndexCount()intgetNormalCount()List<Integer>getNormalIndices()List<Float>getNormals()intgetNormalSize()intgetOpenEdgeCount()intgetPositionCount()List<Integer>getPositionIndices()List<Float>getPositions()intgetPositionSize()booleanhasNormals()booleanloadModelFromFile(File file)booleanloadModelFromFilename(String file)booleanloadModelFromStream(InputStream inputStream)This function attempts to determine the type of the filename passed as a parameter.booleanloadModelFromURL(URL fileURL)booleanparseObjFace(String line, int[][] idx, boolean hasNormals)Face FormatvoidparseObjVertex(String line, float[] val)Vertex/Normal FormatStringtoString()
-
-
-
Field Detail
-
NumPrimTypes
public static final int NumPrimTypes
- See Also:
- Constant Field Values
-
autoNormal
protected boolean autoNormal
Will calculate normals if they are missing
-
posSize_
protected int posSize_
-
indices_
protected IntBuffer indices_
-
vertices_
protected FloatBuffer vertices_
-
pOffset_
protected int pOffset_
-
nOffset_
protected int nOffset_
-
vtxSize_
protected int vtxSize_
-
openEdges_
protected int openEdges_
-
-
Method Detail
-
loadModelFromFilename
public boolean loadModelFromFilename(String file)
-
loadModelFromURL
public boolean loadModelFromURL(URL fileURL)
-
loadModelFromFile
public boolean loadModelFromFile(File file)
-
loadModelFromStream
public boolean loadModelFromStream(InputStream inputStream)
This function attempts to determine the type of the filename passed as a parameter. If it understands that file type, it attempts to parse and load the file into its raw data structures. If the file type is recognized and successfully parsed, the function returns true, otherwise it returns false.
-
parseObjVertex
public void parseObjVertex(String line, float[] val)
Vertex/Normal Formatv 1.0 0.0 0.0 vn 0.0 1.0 0.0 n : normal
-
parseObjFace
public boolean parseObjFace(String line, int[][] idx, boolean hasNormals)
Face Formatf v1/vt1/vn1 v2/vt2/vn2 v3/vt3/vn3 t : texture n : normal
-
compileModel
public void compileModel()
This function takes the raw model data in the internal structures, and attempts to bring it to a format directly accepted for vertex array style rendering. This means that a unique compiled vertex will exist for each unique combination of position, normal, tex coords, etc that are used in the model. The prim parameter, tells the model what type of index list to compile. By default it compiles a simple triangle mesh with no connectivity.
-
computeBoundingBox
public BoundingBox3d computeBoundingBox()
Returns the points defining the axis-aligned bounding box containing the model.
-
clearNormals
public void clearNormals()
-
hasNormals
public boolean hasNormals()
-
getPositionSize
public int getPositionSize()
-
getNormalSize
public int getNormalSize()
-
getPositionCount
public int getPositionCount()
-
getNormalCount
public int getNormalCount()
-
getIndexCount
public int getIndexCount()
-
getCompiledVertices
public FloatBuffer getCompiledVertices()
-
getCompiledIndices
public IntBuffer getCompiledIndices()
-
getCompiledPositionOffset
public int getCompiledPositionOffset()
-
getCompiledNormalOffset
public int getCompiledNormalOffset()
-
getCompiledVertexSize
public int getCompiledVertexSize()
-
getCompiledVertexCount
public int getCompiledVertexCount()
-
getOpenEdgeCount
public int getOpenEdgeCount()
-
-