WavefrontMesh QML Type▲
-
Import Statement: import Qt.labs.wavefrontmesh 1.4
-
Since:: Qt 5.12
-
Group: WavefrontMesh is part of qtquick-effects
Detailed Description▲
WavefrontMesh reads the geometry from a Wavefront .obj file and generates a two-dimensional geometry from this. If the .obj file contains a three-dimensional shape, it will be orthographically projected, onto a plane. If defined, this is given by projectionPlaneV and projectionPlaneW. Otherwise, the first face encountered in the data will be used to determine the projection plane.
If the file contains texture coordinates, these will also be used. Otherwise, the vertexes of the object will be normalized and used.
The mesh can be used in a ShaderEffect to define the shaded geometry. The geometry will be normalized before use, so the position and scale of the input objects have no impact on the result.
Some Wavefront exporters will change the source scene's coordinate system before exporting it. This can cause unexpected results when Qt applies the projection. If the visual results are not as you expect, try checking the export parameters and the documentation of the editor tool to see if this is the case.
For instance, the following example takes an .obj file containing a standard torus and visualizes the automatically generated texture coordinates.
Sélectionnez
|
Since the input is a 3D torus, we need to define the projection plane. This would not be necessary when using a 2D shape as input. We use the XY plane in this case, because of the orientation of the input.
Property Documentation▲
lastError : enumeration▲
This property holds the last error, if any, that occurred when parsing the source or building the mesh.
-
WavefrontMesh.NoError No error has occurred.
-
WavefrontMesh.InvalidSourceError The source was not recognized as a valid .obj file.
-
WavefrontMesh.UnsupportedFaceShapeError The faces in the source is of an unsupported type. WavefrontMesh only supports triangles and convex quads.
-
WavefrontMesh.UnsupportedIndexSizeError The source shape is too large. Only 16 bit indexes are supported.
-
WavefrontMesh.FileNotFoundError The source file was not found.
-
WavefrontMesh.MissingPositionAttributeError The 'qt_Vertex' attribute is missing from the shaders.
-
WavefrontMesh.MissingTextureCoordinateAttributeError The texture coordinate attribute in the shaders is wrongly named. Use 'qt_MultiTexCoord0'.
-
WavefrontMesh.MissingPositionAndTextureCoordinateAttributesError Both the 'qt_Vertex' and 'qt_MultiTexCoord0' attributes are missing from the shaders.
-
WavefrontMesh.TooManyAttributesError The shaders expect too many attributes (maximum is two: Position, 'qt_Vertex', and texture coordinate, 'qt_MultiTexCoord0').
-
WavefrontMesh.InvalidPlaneDefinitionError The V and W vectors in the plane cannot be null, nor parallel to each other.
projectionPlaneV : vector3d▲
Since the Wavefront .obj format describes an object in 3D space, the coordinates have to be projected into 2D before they can be displayed in Qt Quick.
This will be done in WavefrontMesh by an orthographic projection onto an appropriate plane.
The projectionPlaneV is one of two vectors in the plane in 3D space. If either this, or projectionPlaneW is set to (0, 0, 0) (the default), then the plane will be detected based on the first encountered face in the data set.
projectionPlaneV and projectionPlaneW cannot be parallel vectors.
projectionPlaneW : vector3d▲
Since the Wavefront .obj format describes an object in 3D space, the coordinates have to be projected into 2D before they can be displayed in Qt Quick.
This will be done in WavefrontMesh by an orthographic projection onto an appropriate plane.
The projectionPlaneW is one of two vectors in the plane in 3D space. If either this, or projectionPlaneV is set to (0, 0, 0) (the default), then the plane will be detected based on the first encountered face in the data set.
projectionPlaneV and projectionPlaneW cannot be parallel vectors.
source : url▲
This property holds the URL of the source. This must be either a local file or in qrc. The source will be read as a Wavefront .obj file and the geometry will be updated.