1 Reply Latest reply on Aug 16, 2006 10:14 AM by tedalde2

    dragging a small texture around a HUGE plane

    Jez Cheesman
      I'm trying to get a small texture to be able to be dragged around a huge plane by the user.

      I can move the texture using this line:
      member("Scene2").shader("planeShader").TextureTransformList[2].position = vector( 0.52000, 0.35000, 0.00 )

      and I thought I could substitute the vector at the end of the line with the one generated by:

      sprite(2).camera.spriteSpaceToWorldSpace(point(the mouseH, the mouseV))

      but the vector values needed have to be between -1 and 1, and the vector values returned are between
      -- vector( 415.64, 105.08, -601.04 )
      and
      -- vector( 1016.63, 324.66, -162.84 )

      how do the returned vectors from "spriteSpaceToWorldSpace" relate to the object in the 3D world, under the mouse lolcation?

      or am i going about this the wrong way (to drag a small texture round a plane)

      Any help greatfully received
      Jez.
        • 1. Re: dragging a small texture around a HUGE plane
          tedalde2 Level 2
          What you probably want to use is modelsUnderLoc(). When using the #detailed flag, it returns a list of models under a 2D sprite-relative point (which can be the cursor location). Check out the documentation on this method.

          Then use the #detailed info to determine if/where on the plane the cursor is intersecting. The property is iSectPosition. Use the vector derived from iSectPosition to determine your UV coordinates for the texture (probably just multiply it times a float to get it scaled properly).

          I used this basic procedure to drag models onto a plane, but the concept should apply to texture coordinates also. Though note it can get tricky when you drag the cursor off the sprite/stage/window, when to stop dragging, etc. You need to setup all those little caveats.