Skip to content
  • 1 Votes
    4 Posts
    2k Views
    P

    @Cute3d, yes, it finally works. Idk what was wrong. Example project:https://github.com/Nonmant/Qt3DExtras-QText2DEntity-Example
    And due to god-knows-what reasons it doesn't work in debug mode. Hope, that project can help someone.

  • 0 Votes
    3 Posts
    771 Views
    E

    OK, seems like shadow casting on the default light might be broken. Turning it on caused the scene to crash.

    0_1535579011318_127c726b-5b85-4a50-b7fa-d07e02663dc9-image.png

  • Qt3D: Create mirrored object

    Solved General and Desktop
    2
    0 Votes
    2 Posts
    841 Views
    J

    Ok, solution 2 was simpler than i expected. I'll post my code below, in case someone else needs something similar. It flips a QEntity along the x-axis and the winding of the triangles. It only works with the primitive type QGeometryRenderer.Triangles.

    Jan

    void mirrorEntity(Qt3DCore::QEntity *entity) { for (QNode* node: entity->childNodes()) { if (QEntity* e = dynamic_cast<QEntity*>(node)) mirrorEntity(e); if (QGeometryRenderer* r = dynamic_cast<QGeometryRenderer*>(node)) mirrorGeometryRenderer(r); } } void mirrorGeometryRenderer(QGeometryRenderer *geometryRenderer) { QGeometry* geometry = geometryRenderer->geometry(); for (QAttribute* a : geometry->attributes()) { if (a->name() == QAttribute::defaultPositionAttributeName()) { QByteArray data = a->buffer()->data(); // flip along x-axis float *bufferContent = reinterpret_cast<float*>(data.data()); int chunkSize = a->byteStride()/sizeof(float); int positionOffset = a->byteOffset(); for (uint i=0; i<a->count()*chunkSize; i+=chunkSize) { int offsetI = i + positionOffset; bufferContent[offsetI] = -bufferContent[offsetI]; // invert x } // change winding const int size = a->byteStride(); char* tmp = new char[size]; for (int i=0; i<data.length(); i+=a->byteStride()*3) { memcpy(tmp, &data.data()[i+size], size); memcpy(&data.data()[i+size], &data.data()[i+size*2], size); memcpy(&data.data()[i+size*2], tmp, size); } delete[] tmp; a->buffer()->setData(data); break; } } }
  • 0 Votes
    1 Posts
    413 Views
    No one has replied
  • 0 Votes
    7 Posts
    6k Views
    V

    I've got the same issue with Qt3DExtras::QText2DEntity. But I found the workaround.
    Look like there is a bug? in implementation of Qt3DExtras::QText2DEntity that prevents internal initialization (QText2DEntityPrivate::setScene is never called). This happens when scene is already visible and Qt3DExtras::QText2DEntity is created with parent entity passed to constructor. The workaround I used to make it work is to pass nullptr (which is default) as parent in constructor and call ->setParent(parentEntity) in separate call.

    m_text2dLabel = new Qt3DExtras::QText2DEntity(); m_text2dLabel->setParent(parentNode);
  • 1 Votes
    2 Posts
    1k Views
    H

    There has been a question here already: https://forum.qt.io/topic/85533/qt3d-qml-geometry-bounding-box. But I couldn't really find any code in the github repository.

    What I'd suggest is you get the QGeometryRenderer from the text entity. The geometry renderer has a QGeomemtry attribute, which in turn has a set of QAttributes. There must be an attribute with a name like "vertexPosition". You need to get the QBuffer from the attribute and retrieve the vertices starting at position byteOffset (that is an attribute of QAttribute). The next vertexSize (also an attribute of QAttribute) entries should belong to the vertex position. Then continute at position byteOffset + i * byteStride, while i being the index you're reading right now. Do this for count (also an attribute) times. This way you can get all vertex positions and calculate a bounding box based on them.

  • 0 Votes
    1 Posts
    677 Views
    No one has replied
  • 0 Votes
    7 Posts
    3k Views
    O

    @Lukadriel Hi, One year passed and still waiting for the proper example. Did they give any tips?

  • 0 Votes
    1 Posts
    520 Views
    No one has replied
  • 2 Votes
    3 Posts
    2k Views
    T

    @Wieland I was afraid of that. Seems like a glaring omission. Oh well, I needed to download the sources anyway to peek at Scene3D. Thanks.

  • 0 Votes
    2 Posts
    509 Views
    G

    @jimfar Hi, I have the same problem in my Qt application... Any solutions?

  • 0 Votes
    4 Posts
    1k Views
    ?

    Hi! There is an example with 4 cameras, see Multi Viewport QML Example. The example uses the QML API but porting it to C++ shouldn't be too hard.

  • 0 Votes
    5 Posts
    2k Views
    small_birdS

    Hello, how to solve this problem? Could you please tell me the answer, thanks in advance!

  • 0 Votes
    2 Posts
    2k Views
    I

    I have reported this issue on the Qt bug tracker.
    If someone is interested: https://bugreports.qt.io/browse/QTBUG-60738

  • 0 Votes
    2 Posts
    823 Views
    mrjjM

    @chris2401
    Hi I would guess on OpenGL 2.1 but could not find and doc either :)

  • 0 Votes
    6 Posts
    3k Views
    C

    @kshegunov I think you are right. By just putting the lightentity into the camera:

    Qt3DCore::QEntity *lightEntity = new Qt3DCore::QEntity(basicCamera);

    It seems to move dynamically. Now I have to set some other things but that might have to do just with how I want my objects to show :)

  • Qt3d points and lines

    Unsolved General and Desktop
    18
    0 Votes
    18 Posts
    11k Views
    A

    Hi! I wrote resolution like @AlanWasHere, but a little clearer

    void addLine(QEntity *parentEntity, const QVector3D &srcPos, const QVector3D &targPos) { auto edgeEntity = new QEntity{parentEntity}; auto cylinder = new QCylinderMesh{edgeEntity}; auto len = srcPos.distanceToPoint(targPos); cylinder->setLength(len); cylinder->setRadius(0.1f); auto transPoint = targPos - srcPos; auto xAngle = atan(sqrt(pow(transPoint.z(), 2) + pow(transPoint.x(), 2)) / transPoint.y()) / M_PI * 180; auto yAngle = (transPoint.x() == 0 && transPoint.z() == 0) ? 0 : atan(transPoint.x() / transPoint.z()) / M_PI * 180; auto transform = new Qt3DCore::QTransform{edgeEntity}; transform->setRotationX(xAngle); transform->setRotationY(yAngle); transform->setTranslation((srcPos + targPos) / 2); auto material = new QPhongMaterial{edgeEntity}; material->setDiffuse("#ffff00"); edgeEntity->addComponent(cylinder); edgeEntity->addComponent(transform); edgeEntity->addComponent(material); }
  • 1 Votes
    29 Posts
    13k Views
    Pablo J. RoginaP

    For further reference this issue seems solved as described in this post.