QML加载并显示具有颜色属性的.ply网格 [英] QML load and display .ply mesh with color attributes

查看:217
本文介绍了QML加载并显示具有颜色属性的.ply网格的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用QML从Stanford PLY文件中加载具有每个顶点颜色信息的简单多维数据集.

I am trying to load a simple cube with per-vertex color information from a Stanford PLY file using QML.

我的实体看起来像这样:

My entity looks like this:

Entity
{
    id: circle

    property Material materialPoint: Material {
        effect: Effect {
            techniques: Technique {
                renderPasses: RenderPass {
                    shaderProgram: ShaderProgram {
                        vertexShaderCode: loadSource("qrc:/imports/org/aid/shared/geometry/shaders/point.vert")
                        fragmentShaderCode: loadSource("qrc:/imports/org/aid/shared/geometry/shaders/point.frag")
                    }
                }
            }
        }
        parameters: Parameter { name: "pointSize"; value: 2 }
    }

    property alias translation: circleTransform.translation
    property alias rotation : circleTransform.rotationZ


    Mesh
    {
        id: circleMesh
        source: "qrc:/resources/models/rg.ply"
    }

    Transform
    {
        id: circleTransform
        scale : 1
    }


    components:
        [materialPoint, circleTransform, circleMesh]
}

我还尝试用专门为解决此问题而创建的默认Qt材质替换material属性: property Material materialPoint: PerVertexColorMaterial {}. 不幸的是,场景中没有可见的每个顶点的颜色.

I have also tried replacing the material property with the default Qt material purposely created to solve this problem: property Material materialPoint: PerVertexColorMaterial {}. Unfortunately, there are no per-vertex colors visible in the scene.

在QML中,是否有建议的方法来导入带有顶点颜色数据的PLY文件? (我想如果有人用C ++编写逻辑并为此创建一个专门的QML实体,就有可能实现这一目标,但功能应该已经可用.)

Is there any recommended way of importing a PLY file with vertex color data in QML? (I suppose it is possible to achieve this if one writes the logic in C++ and creates a specialized QML entity for doing so, but the functionality should be available already).

推荐答案

在Qt3D中加载PLY不包含您所注意到的颜色.恐怕目前Qt3D的课程还没达到标准.

Loading PLY in Qt3D doesn't include color as you've noticed. Par for the course for Qt3D at the moment, I'm afraid.

您可以:

构建并加载 Qt Assimp Sceneparser插件确实支持PLY中的颜色属性,或者:

build and load the Qt Assimp Sceneparser plugin which does support color attributes in PLY, or:

用C ++编写自己的Qt3D几何加载器.当需要在每个顶点中加载带有额外数据的自定义OBJ模型时,我已经做了类似的事情.加载程序代码非常易于使用,您只需对其进行修改即可读取额外的数据,并且可以在Qt3D本身中修改代码,也可以创建一个插件并将其加载到您的应用程序中以使其正常工作.

Write your own Qt3D geometry loader in C++. I have done similar when needing to load a custom OBJ model with extra data in each vertex. The loader code is pretty straightforward to work with, you need only modify it to read the extra data, and you can either modify the code in Qt3D itself, or create a plugin and load it in your application for this to work.

注意:创建专门的QML实体不是.加载程序将以QMesh的形式读取您的文件.

Note: it is not necessary to create a specialized QML entity. The loader will read your file in as QMesh.

这篇关于QML加载并显示具有颜色属性的.ply网格的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆