QPerVertexColorMateral Qusetion



  • I use a ply file with color for each vertex, namely:
    ply
    format ascii 1.0
    element vertex 5
    property float32 x
    property float32 y
    property float32 z
    property uchar red
    property uchar green
    property uchar blue
    element face 6
    property list uint8 int32 vertex_index
    end_header
    0 0 0 225 0 0
    10 5 0 0 225 0
    10 -5 0 0 0 225
    7 2 4 225 225 0
    7 -2 4 0 225 225
    3 0 4 3
    3 0 3 1
    3 4 1 3
    3 2 1 4
    3 0 2 4
    3 0 2 1

    However, Qt 3D shows it as I black object, while MeshLab show the color. The code snippet shows the material and lighting:
    Qt3DExtras::QPerVertexColorMaterial *material = new Qt3DExtras::QPerVertexColorMaterial;

    Qt3DRender::QMesh *flyingwedgeMesh = new Qt3DRender::QMesh;
    flyingwedgeMesh->setMeshName("FlyingWedge");
    flyingwedgeMesh->setSource(data);
    Qt3DCore::QTransform *flyingwedgeTransform = new Qt3DCore::QTransform;
    flyingwedgeTransform->setScale3D(QVector3D(1.0, 1.0, 1.0));
    Qt3DRender::QFrontFace *frontFace = new Qt3DRender::QFrontFace(rootEntity);
    frontFace->setDirection(Qt3DRender::QFrontFace::CounterClockWise);
    flyingwedge->addComponent(flyingwedgeMesh);
    flyingwedge->addComponent(material);
    flyingwedge->addComponent(flyingwedgeTransform);
    
    Qt3DCore::QEntity *lightEntity = new Qt3DCore::QEntity(rootEntity);
    Qt3DRender::QPointLight *light = new Qt3DRender::QPointLight(lightEntity);
    light->setColor("white");
    light->setIntensity(0.5);
    lightEntity->addComponent(light);
    Qt3DCore::QTransform *lightTransform = new Qt3DCore::QTransform(lightEntity);
    lightTransform->setTranslation(QVector3D(60, 0, 40.0f));
    lightEntity->addComponent(lightTransform);
    

    What am I missing?


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.