Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. QVector3D maths in QML

QVector3D maths in QML

Scheduled Pinned Locked Moved QML and Qt Quick
2 Posts 2 Posters 1.6k Views 1 Watching
  • 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.
  • 0 Offline
    0 Offline
    02JanDal
    wrote on last edited by
    #1

    Hello,

    I have the following piece of code:
    @function move(length){
    var direction = cam.eye - cam.center;
    cam.eye += direction * length;
    cam.center += direction * length;
    }@

    cam is a Camera object (from Qt3D), and thus cam.eye and cam.center are vector3d's.

    The piece of code is supposed to move the eye (user) towards the center point, and also moving the center point, so that we don't get errors when reaching it.

    length specifies the length to move.

    The problem is I get the following error for line 3 in the above code:
    @Error: Cannot assign QString to QVector3D@

    I am not to confident with QML yet, so it probably is something very simple.

    Jan

    1 Reply Last reply
    0
    • M Offline
      M Offline
      mbrasser
      wrote on last edited by
      #2

      Hi,

      Javascript does not support operator overloading the way C++ does, so +/-/* do not perform vector manipulations the way you'd expect.

      For QtQuick 2.0 a number of functions have been added (see https://qt.gitorious.org/qt/qtdeclarative/commit/42f9444e983b5257241c17242471ca63f208c3f6 for details) to handle this. For QtQuick 1.x you may need to manipulate the sub-values directly (or Qt3D may provide more convenient ways of handling this, I'm not sure).

      Regards,
      Michael

      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