Click or drag to resize
Ab4d.SharpEngine logo

ObjImporter Class

ObjImporter can read 3D models from obj files.
Inheritance Hierarchy
SystemObject
  Ab4d.SharpEngine.UtilitiesObjImporter
    Ab4d.SharpEngine.UtilitiesReaderObj

Namespace: Ab4d.SharpEngine.Utilities
Assembly: Ab4d.SharpEngine (in Ab4d.SharpEngine.dll) Version: 4.1.9680+a1b1e43de1ad9a7e35472c33948d688d7b40ef79
Syntax
C#
public class ObjImporter

The ObjImporter type exposes the following members.

Constructors
 NameDescription
Public methodObjImporter(IBitmapIO) Constructor that only takes an optional bitmapIO and will not create the textures immediately. Also the no cache is used to read and store the textures.
Public methodObjImporter(Scene) Constructor with optional Scene object that when specified is used to cache the loaded textures. When Scene.GpuDevice is initialized, then the textures are immediately created. Otherwise, the textures are created when materials with textures are initialized.
Public methodObjImporter(VulkanDevice) Constructor with optional gpuDevice object that when specified is used to create and cache the loaded textures. When gpuDevice is null, then the textures are created when materials with textures are initialized.
Public methodObjImporter(IBitmapIO, Scene) Constructor with optional Scene object that when specified is used to cache the loaded textures. When Scene.GpuDevice is initialized, then the textures are immediately created. Otherwise, the textures are created when materials with textures are initialized.
Public methodObjImporter(IBitmapIO, VulkanDevice) Constructor with optional gpuDevice object that when specified is used to create and cache the loaded textures. When gpuDevice is null, then the textures are created when materials with textures are initialized.
Top
Properties
 NameDescription
Public propertyDefaultLineColor Gets or sets a default line color that is set to the created LineNode or MultiLineNode when the obj file does not specify line color. Default value is Color4.Black. When set to null, then the line color is set from the last used material.
Public propertyDetectEncodingFromByteOrderMarks Indicates whether to look for byte order marks at the beginning of the file to detect the text encoding (using in StreamReader constructor). Default value is true.
Public propertyErrors Gets a list of errors that occur during obj file loading.
Public propertyIgnoreErrors Gets or sets a Boolean that specifies if errors are ignored and reader tries to read as much data as possible. The error texts are written to Errors list.
Public propertyInvertYTextureCoordinate Gets or sets a boolean that specifies if Y texture coordinate is inverted. Default value is true.
Public propertyLineDepthBias Depth bias that is set to the created MultiLineNode. Default value is 0.0005f. This is used to avoid z-fighting when lines are rendered together with meshes.
Public propertyLineThickness Gets or sets the thickness of the created lines. Default value is 1.
Public propertyNamedObjects Gets a dictionary that can be used to get a 3D object by its name (key = name, value = MeshModelNode)
Public propertyRead3DLines When true (by default), then 3D lines from obj file are converted into LineNode or MultiLineNode objects. When false, then 3D lines are ignored.
Public propertyResolveResourceFunc Gets or sets a Func that returns stream from the specified resource name. This can be used to read resources from stream. The returned stream will be closed by the ObjImporter.
Public propertyUseTwoSidedMaterials When true (false by default), then BackMaterials is set to the same material as Material.
Top
Methods
 NameDescription
Public methodImport(String) Imports the 3D models from objFileName file and returns the 3D model(s) as a GroupNode that contains MeshModelNodes and other GroupNodes. The method will not return null but an empty GroupNode in case no model is read. Textures directory is the same as obj file directory.
Public methodImport(Stream, FuncString, Stream) Imports the 3D models from stream and returns the 3D model(s) as a GroupNode that contains MeshModelNodes and other GroupNodes. When the obj file have any additional resources (materials and textures), the resolveResourceFunc must be set to a method that converts resource names into Streams. The method will not return null but an empty GroupNode in case no model is read.
Public methodImport(Stream, FuncString, Stream, Material) Imports the 3D models from stream and returns the 3D model(s) as a GroupNode that contains MeshModelNodes and other GroupNodes. When the obj file have any additional resources (materials and textures), the resolveResourceFunc must be set a method that converts the resource name into Stream. The method will not return null but an empty GroupNode in case no model is read.
Public methodImport(String, String, StandardMaterial) Imports the 3D models from objFileName file and returns the 3D model(s) as a GroupNode that contains MeshModelNodes and other GroupNodes. The method will not return null but an empty GroupNode in case no model is read.
Public methodImportAsync Imports the 3D models from objFileName in the background thread. When generateGpuBuffers parameter is true (by default), then the vertex and index buffers will be also generated on the background thread. The file returns the 3D model(s) as a GroupNode that contains MeshModelNodes and other GroupNodes. The method will not return null but an empty GroupNode in case no model is read.
Public methodReadObjFileData(Stream, Boolean) Reads the obj file from specified stream and returns the ObjFileData object.
Public methodReadObjFileData(String, Boolean) Reads the objFileName file and returns the ObjFileData object. When generateMeshes is true (false by default), then also SharpEngine Meshes are generated.
Top
See Also