How to rotate a 3D shape?



  • Hello dev community!, I'm new in Qt and I'm glad to part of this community.

    I've been investigating how to rotate a basic shape from their origin axis by using the mouse drag event.

    I've been studying the Qt documentation and found for the mouse events the following methods:

    void QGraphicsItem::mouseMoveEvent(QGraphicsSceneMouseEvent * event)
    void QGraphicsItem::mousePressEvent(QGraphicsSceneMouseEvent * event)
    

    On the other hand, I also these methods for rotating the shapes:

    void QGraphicsItem::setTransformOriginPoint(const QPointF & origin)
    

    I've been trying to rotate a basic cuboidmesh unsuccessfully.

    Thanks and grettings!


  • Qt Champions 2017

    Hi,
    I don't follow, the graphics view framework deals with 2D images, how does a mesh factor into it?



  • Hi,

    You're right kshegunov, it seems that 'QGraphicsItem' api is more focused on 2D rendering scenes.

    At the moment I used a 'QOrbitCameraController' type to get an orbital rotation from the shape around the scene:

    Qt3DExtras::QOrbitCameraController *orbitCamController = new Qt3DExtras::QOrbitCameraController(rootEntity);
    
    orbitCamController->setCamera(cameraEntity);
    

    I'll investigating to try get the right rotation.

    Greetings!


  • Qt Champions 2017

    @Joaquin-M.-Parrilla said in How to rotate a 3D shape?:

    more focused

    exclusively so.

    At the moment I used a 'QOrbitCameraController'

    This is a different module entirely. Take a look at Qt3DCore::QTransform for a transformation component (you attach it to your entity exactly as you do for QMesh).



  • I'm going to check out right now!!

    Thanks for helping!!


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.