2 Replies Latest reply on Aug 1, 2006 6:14 AM by SuperTank

    Getting a vertex point

    SuperTank
      Hello,
      I am trying to deform a plane (lingo primitive). You see, I want the closest vertex point at the location of a mouse click to jump down alittle in the world space. However, this is where I'm having somewhat of a problem.

      I want to avoid looping through each vector in the vertexList and by this way getting the vertex closest to my mouseclick. It just seams to demanding by the computer.

      So I thought I'd first start figuring out what row and column of vertices the clicked occured on, and using this information easily calculate the index to use in the VertexList.

      I thought I'd get the mouse's "impact" coordinates using ModelsUnderLoc() and then use the isectPosition-property. And this seames to work, my plane is 50 in length and isectPosition´s z-coordinate goes between -25 to +25. So I guess I've put that aside (just incase you guys wanted to know).

      I'd now thought I'd calculate the row by writing:


      tisec = tr[1].isectPosition
      _z = tisec.z

      tTileLength = (float( pLengthVertices )/pLength)

      -- to get a value from 0-50 instead of -25 - +25
      toffsetZ = pLength/2

      row = _z + toffsetZ
      row = row * tTileLength

      But this doesnt give me the result I was hoping for.

      Any ideas?

      Thanks. :)

      ( more code can be obtained at http://supertank.mine.nu/movie_help.dir )