Qt3D dynamic texture

不想你离开。 提交于 2019-12-06 14:27:09

Well, after a long time, here is the solution I used:

Only store a QString containing the path to the texture in c++ and create all the Texture object in QML. The QML looks like this:

MyDynamicTextureMaterial { // Custom material passing a Texture2D to the shader
    id: myMaterial

    texture: Texture2D {
        id: myTexture
        minificationFilter: Texture.Linear
        magnificationFilter: Texture.Linear
        wrapMode {
            x: WrapMode.Repeat
            y: WrapMode.Repeat
        }
        maximumAnisotropy: 16.0
        TextureImage {
            id: textureImage
            layer: 0
            mipLevel: 0
            source: cppObjectReference.texturePath ? cppObjectReference.texturePath : ""
        }
    }
}

cppObjectReference is a reference to a cpp object I created. This object simply needs a property of type QString with Read, Write and Notify options

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!