Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Game Development
  4. How to rotate/flip a texture in Qt3d C++

How to rotate/flip a texture in Qt3d C++

Scheduled Pinned Locked Moved Unsolved Game Development
4 Posts 2 Posters 556 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • ademmlerA Offline
    ademmlerA Offline
    ademmler
    wrote on last edited by
    #1

    Hi there,

    is there a way to flip/rotate a texture in Qt3D. From my code:

    auto textureImage = new Qt3DRender::QTextureImage;
        QString fileurl = "file:/path/to file";
        textureImage->setSource(QUrl(fileurl));
        auto planeImage = new Qt3DRender::QTexture2D();    
        planeImage->addTextureImage(textureImage);
    auto cylinderMaterial = new Qt3DExtras::QDiffuseSpecularMaterial();
        cylinderMaterial->setTextureScale(1.);
        cylinderMaterial->setDiffuse(QVariant::fromValue(planeImage));
    

    I am looking for something like "textureImage->setRotation" or "textureImage->setTranslation"
    or the same for "planeImage" or "cylinderMaterial" ... does it exists ? I could not find this in the documentation.

    Alexander

    kshegunovK 1 Reply Last reply
    0
    • ademmlerA ademmler

      Hi there,

      is there a way to flip/rotate a texture in Qt3D. From my code:

      auto textureImage = new Qt3DRender::QTextureImage;
          QString fileurl = "file:/path/to file";
          textureImage->setSource(QUrl(fileurl));
          auto planeImage = new Qt3DRender::QTexture2D();    
          planeImage->addTextureImage(textureImage);
      auto cylinderMaterial = new Qt3DExtras::QDiffuseSpecularMaterial();
          cylinderMaterial->setTextureScale(1.);
          cylinderMaterial->setDiffuse(QVariant::fromValue(planeImage));
      

      I am looking for something like "textureImage->setRotation" or "textureImage->setTranslation"
      or the same for "planeImage" or "cylinderMaterial" ... does it exists ? I could not find this in the documentation.

      Alexander

      kshegunovK Offline
      kshegunovK Offline
      kshegunov
      Moderators
      wrote on last edited by
      #2

      https://doc.qt.io/qt-5/qt3drender-qtextureimage.html#setMirrored

      Otherwise you're probably looking for this:
      https://doc.qt.io/qt-5/qt3drender-qpaintedtextureimage.html

      Read and abide by the Qt Code of Conduct

      ademmlerA 1 Reply Last reply
      1
      • kshegunovK kshegunov

        https://doc.qt.io/qt-5/qt3drender-qtextureimage.html#setMirrored

        Otherwise you're probably looking for this:
        https://doc.qt.io/qt-5/qt3drender-qpaintedtextureimage.html

        ademmlerA Offline
        ademmlerA Offline
        ademmler
        wrote on last edited by
        #3

        @kshegunov thx for your hints. Both classes do not offer what I am looking for.

        "setMirrored" is half the way. It Would need a "horizontal" or "vertical" option on top.

        I am looking for something like:
        textureImage->setRotation( 0-380°); or cylinderMaterial->setOrientation( 0-380°);

        kshegunovK 1 Reply Last reply
        0
        • ademmlerA ademmler

          @kshegunov thx for your hints. Both classes do not offer what I am looking for.

          "setMirrored" is half the way. It Would need a "horizontal" or "vertical" option on top.

          I am looking for something like:
          textureImage->setRotation( 0-380°); or cylinderMaterial->setOrientation( 0-380°);

          kshegunovK Offline
          kshegunovK Offline
          kshegunov
          Moderators
          wrote on last edited by
          #4

          Either draw the texture rotated with QPaintedTextureImage or generate it rotated beforehand. I see no other way.

          Read and abide by the Qt Code of Conduct

          1 Reply Last reply
          0

          • Login

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • Users
          • Groups
          • Search
          • Get Qt Extensions
          • Unsolved