Change texture-coordinates of cursor?

Hi



In my space-shooting game I want to have an ingame-cursor with the following texture:





As you should see, the cursor should point to the center of the image. But normally the

cursor points to the left-upper-corner of the image. How can I change this? I’m using

AbsoluteMouse and just attach a TextureState to it. As far as I know neither

TextureState nor Texture does have a method that could solve my problem.

Hope you can help me :).

Texture.setTranslation(Vector3f)

dhdd said:

Texture.setTranslation(Vector3f)


I tried, but I don't think that setTranslation() does the thing I want. It seems to
cut the image. If I set the translation to new Vector3f(0.5f, 0.5f, 0f), the cursor
is just half of its size. Or I just don't know how to use it right *g*.

try (-0.5, 0.5, 0) or  (-0.5, -0.5, 0)



have you tried setting the localTranslation of the Geometry you are applying your texturestate to?

Your suggestions don't work, too. I think you didn't understand what I want to do.

I want to change the location of the texture from my cursor, so the mouse-cursor

points to the center of this texture and not at the left-upper-corner. There is no

real geometry. And changing the localTranslation of the mouse would only change

the position of the mouse cursor on screen.

youre right … damn it  :wink:

I thought there was a method to set the point that actually performed the click in the cursor texture, but that was in Java2D, so I don't know if the same applies here.  :expressionless:

Change the hotspot…


MouseInput.get().setHardwareCursor(myCursorFile, hotspotX, hotspotY);



The X and Y coordinates work from the top left corner of your mouse texture. Figure out where the little dot is (MS paint should work) and set those as your X and Y hotspots.
Trussell said:

Change the hotspot..

MouseInput.get().setHardwareCursor(myCursorFile, hotspotX, hotspotY);



The X and Y coordinates work from the top left corner of your mouse texture. Figure out where the little dot is (MS paint should work) and set those as your X and Y hotspots.


The problem with this is, that I would have to switch my whole Mouse-Input-Implementation because
I'm using an extention of AbsoluteMouse. And there I'm attaching an AlphaState, so my Mouse-Cursor
has transparency. I do not find a way to attach an AlphaState to MouseInput.get() *g*. Well, and in
my Menu (using FengGUI) sometimes the Mouse-Cursor switches into the System-Default-Cursor...
And last and least... if I'm not in fullscreen-mode, the mouse is able to get out of the window, which
I want to avoid in my game. So I don't think that using MouseInput instead of AbsoluteMouse is a
good solution for my (small) problem ;)

You don’t need an alpha-state for transparency.



Go download IrfanView, open your picture file. Click File > Save As… select GIF from the drop down menu, and another menu should open up. The bottom check box should say pick transparency color or something like that. When you click OK, it will show the image, and you just click on whatever color should be transparent.



Then just do the thing mentioned above and all will be well.



Not sure about your Feng problems… most likely it’s your GUI and not your mouse (I don’t have that problem). And you could always keep your mouse inside the screen using a few simple lines in your update method:



Psuedocode:
if mouse x-pos is greater than width of window
then set the x-pos to the width of the window

if mouse x-pos is less than 0
then set the x-pos to 0

if mouse y-pos is greater than height of window
then set the y-pos to the height of the window

if mouse y-pos is less than 0
then set the y-pos to 0