46 #include <QSharedPointer>
57 using namespace DISP3DLIB;
58 using namespace Eigen;
65 : Qt3DRender::QGeometryRenderer()
74 const MatrixX3f& tMatNorm,
75 const MatrixXi& tMatTris,
76 const MatrixX4f& tMatColors,
77 Qt3DRender::QGeometryRenderer::PrimitiveType primitiveType)
78 : Qt3DRender::QGeometryRenderer()
79 , m_iNumVert(tMatVert.rows())
104 m_pIndexAttribute->setAttributeType(QT_COMPATIBILITY_3D::QAttribute::IndexAttribute);
105 m_pIndexAttribute->setVertexBaseType(QT_COMPATIBILITY_3D::QAttribute::UnsignedInt);
110 m_pVertexAttribute->setAttributeType(QT_COMPATIBILITY_3D::QAttribute::VertexAttribute);
115 m_pVertexAttribute->setName(QT_COMPATIBILITY_3D::QAttribute::defaultPositionAttributeName());
119 m_pNormalAttribute->setAttributeType(QT_COMPATIBILITY_3D::QAttribute::VertexAttribute);
124 m_pNormalAttribute->setName(QT_COMPATIBILITY_3D::QAttribute::defaultNormalAttributeName());
128 m_pColorAttribute->setAttributeType(QT_COMPATIBILITY_3D::QAttribute::VertexAttribute);
133 m_pColorAttribute->setName(QT_COMPATIBILITY_3D::QAttribute::defaultColorAttributeName());
161 QByteArray colorBufferData;
162 colorBufferData.resize(tMatColors.rows() * 4 * (
int)
sizeof(
float));
163 float *rawColorArray =
reinterpret_cast<float *
>(colorBufferData.data());
167 for(
int i = 0; i < tMatColors.rows(); ++i) {
168 rawColorArray[idxColor++] = tMatColors(i,0);
169 rawColorArray[idxColor++] = tMatColors(i,1);
170 rawColorArray[idxColor++] = tMatColors(i,2);
171 rawColorArray[idxColor++] = tMatColors(i,3);
185 QByteArray normalBufferData;
186 normalBufferData.resize(tMatNorm.rows() * 3 * (
int)
sizeof(
float));
187 float *rawNormalArray =
reinterpret_cast<float *
>(normalBufferData.data());
190 for(
int i = 0; i < tMatNorm.rows(); ++i) {
192 rawNormalArray[idxNorm++] = tMatNorm(i,0);
193 rawNormalArray[idxNorm++] = tMatNorm(i,1);
194 rawNormalArray[idxNorm++] = tMatNorm(i,2);
207 QByteArray vertexBufferData;
208 vertexBufferData.resize(tMatVert.rows() * 3 * (
int)
sizeof(
float));
209 float *rawVertexArray =
reinterpret_cast<float *
>(vertexBufferData.data());
212 for(
int i = 0; i < tMatVert.rows(); ++i) {
213 rawVertexArray[idxVert++] = (tMatVert(i,0));
214 rawVertexArray[idxVert++] = (tMatVert(i,1));
215 rawVertexArray[idxVert++] = (tMatVert(i,2));
228 QByteArray indexBufferData;
230 const uint iIndicesCount = tMatTris.rows() * tMatTris.cols();
231 indexBufferData.resize(iIndicesCount * (
int)
sizeof(uint));
233 uint *rawIndexArray =
reinterpret_cast<uint *
>(indexBufferData.data());
236 for(
int i = 0; i < tMatTris.rows(); ++i) {
238 for(
int f = 0; f < tMatTris.cols(); ++f) {
239 rawIndexArray[idxTris++] = tMatTris(i,f);
248 this->setVerticesPerPatch(tMatTris.cols());
249 this->setVertexCount(tMatTris.rows()*3);
255 const MatrixX3f& tMatNorm,
256 const MatrixXi& tMatTris,
257 const MatrixX4f& tMatColors,
258 Qt3DRender::QGeometryRenderer::PrimitiveType primitiveType)
267 this->setPrimitiveType(primitiveType);