41 mPositionAttribute->setAttributeType( Qt3DQAttribute::VertexAttribute );
42 mPositionAttribute->setBuffer( mVertexBuffer );
43 mPositionAttribute->setVertexBaseType( Qt3DQAttribute::Float );
44 mPositionAttribute->setVertexSize( 3 );
45 mPositionAttribute->setByteOffset( 0 );
46 mPositionAttribute->setByteStride( 3 *
sizeof(
float ) );
47 mPositionAttribute->setName( Qt3DQAttribute::defaultPositionAttributeName() );
49 addAttribute( mPositionAttribute );
55 QByteArray vertexBufferData;
56 vertexBufferData.resize( vertices.size() * 3 *
sizeof(
float ) );
57 float *rawVertexArray =
reinterpret_cast<float *
>( vertexBufferData.data() );
59 for (
const auto &v : vertices )
61 rawVertexArray[idx++] = v.x();
62 rawVertexArray[idx++] = v.y();
63 rawVertexArray[idx++] = v.z();
66 mVertexCount = vertices.count();
67 mVertexBuffer->setData( vertexBufferData );