Translating spatial coords to coords on its texture

Hello!



I've found out how to paint small dots of black color on the walls, floor etc. in the model I'm working on. I have a point located on the floor, but how do I find the corresponding point on my texture (x,y)? Are there any convenience methods for this that I haven't found yet? I need to know which pixels to paint…



Here's what I'm trying to do…


      Vector3f intersection = new Vector3f();

      // Here's a large chunk of code where I find the point in the scene where I'm gonna paint (intersection)

      Spatial s = spatials.get(index);      
      TextureState ts = (TextureState)s.getRenderState(StateType.Texture);
      TextureManager.releaseTexture(ts.getTexture(1));
      Graphics2D g2d = (Graphics2D)images[index].getGraphics();
      g2d.setColor(Color.GRAY.darker().darker());
      g2d.fillOval(0, 0, 3, 3); // Need to get the correct coordinates and replace (0,0)
      
      Texture newTex = TextureManager.loadTexture(images[index],
            Texture.MinificationFilter.Trilinear,
            Texture.MagnificationFilter.Bilinear, 1, false);
      ts.setTexture(newTex, 1);
      s.updateRenderState();


Thanks in advance for any tip that might help  :)