I'm trying to make a dashed line in quick3d. I made the line with
QQuick3DGeometry, and exposed it to qml, all good.Then I tried to apply a
custom texture with QQuick3DTextureData, using a texture made with 2 colors
with size of 2x1 pixels, but I only get to see the first color.
I sucessfully did in the past a dashed line example with raw OpenGL see here:
Bitbucket
|
|
| |
Bitbucket
|
|
|
Here is the small qt quick 3d example that is failling:
LineDashed.zip
|
|
| |
LineDashed.zip
|
|
|
Any help is welcome.
The relevant code is:
// main.qmlView3D { id: view3D visible: true anchors.fill:
parent ...... importScene: sceneRoot
Node { id: sceneRoot
...... // solid line, all good Line {
p0: Qt.vector3d(-55, 55, 0) p1: Qt.vector3d(55, -55, 0)
baseColor: "red" //visible: false }
// dashed line, error: only the first color is show
Line_dashed { p0: Qt.vector3d(-80, -40, 0) p1:
Qt.vector3d(80, 80, 0) color1: "orange" color2:
"yellow" //visible: false }
}//Node: sceneRoot
}//View3D}
// Line_dashed.qml
import QtQuick 2.12import QtQuick3D 1.15import Entity_Line 1.0import
LineTexture 1.0
Node {
property alias p0: line.p0 property alias p1: line.p1 property alias
color1: lineTex.color1 property alias color2: lineTex.color2
Model { geometry: EntityLine { id: line p0:
Qt.vector3d(-55, -55, 50) p1: Qt.vector3d(55, 55, 50) }
materials: DefaultMaterial { id: material
lighting: DefaultMaterial.NoLighting diffuseMap: Texture {
textureData: LineTexture { id: lineTex
//color1: "blue" //color2: "white" }
magFilter: Texture.Nearest minFilter:
Texture.Nearest mappingMode: Texture.UV scaleU:
2 scaleV: 1 } }
pickable: true property bool isPicked: false }}
// custom texture
void LineTexture::generateTextureData(){ m_textureData.resize(2 * 4 * sizeof
(float)); //QByteArray float *p = reinterpret_cast<float
*>(m_textureData.data()); *p++ = m_color1.redF(); *p++ =
m_color1.greenF(); *p++ = m_color1.blueF(); *p++ = m_color1.alphaF();
*p++ = m_color2.redF(); *p++ = m_color2.greenF(); *p++ =
m_color2.blueF(); *p++ = m_color2.alphaF();
setTextureData(m_textureData); setSize(QSize(2,1));
//setFormat(QQuick3DTextureData::Format::RGBA8);
setFormat(QQuick3DTextureData::Format::RGBA32F); setHasTransparency(true);}
CheersJoão
_______________________________________________
Interest mailing list
[email protected]
https://lists.qt-project.org/listinfo/interest