implementing first person mouse view?

Hi!

My first person mouse view is functional and working but its very slow. The reason why its slow is that im using the Robot class to center the mouse pointer in each frame after I have processed the info from the MouseMotionListerner.

The Robot-class has a mouseMove method that allows you to move the mouse as if it was the user. The problem with Robot-class is that it is sooo slow and completely useless to use to implement a mouseview.

Since you have to center the mouse every frame (to prevent the pointer from hitting the boundaries of the canvas) and because the Robot class is the only Java class that can do it, I hope you see my problem. Somehow I have to program a mouse class myself, but how..... I have no idea!

If some of you guys have done a first person free mouse-view before without using the slow Robot-class, please give a pointer as to how its done!

Thanks in advance!

[929 byte] By [AlbertSLindberga] at [2007-10-2 17:23:47]
# 1

Hi

I had the exact same problem :)

Look at my post here http://forum.java.sun.com/thread.jspa?threadID=725222&tstart=0

It contains a solution. Needing a fps camera, I deduce that you are making a 3D fps? If you are using the JOGL api u can use that wrapping implementation that someone posted at that link.

To hide the cursor do the following:

Toolkit tk = Toolkit.getDefaultToolkit();

Image pointer = tk.getImage(fileURL);

Cursor myVoidPointer= tk.createCustomCursor(pointer, new Point(0,0), "Empty");

g.setCursor(myVoidPointer);

Here fileURL represents a .gif file containing a single transparant picture. jpg's can't be transparent. g refers to a preCreated but not yet shown frame. right after this, call g.pack(); and g.setVisible(true);

I did however, before converting to LWJGL, have a problem with getting focus... LWJGL can also grab the mouse making it exclusive, meaning no focus problems!

I do however recommend you to use the JInput api. google it in and download it!

The LWJGL api (It absolutely rocks! It has OpenGL, OpenAl, FMOD, OpenIL, and JInput in easy to use wrapped classes) is the best bet!

http://lwjgl.org/download.php

I don't recommend using Java3D though. It seems like unneccesary PT to get it to function properly...

So there you go. The JInput api provides access to input devices which can give absolute movent on the

axi instead of cursor positions. Thus keeping the mouse centred is unnecesary.

Ok nuff said... LWJGL rocks in all ways!

Hope this helped?

Cheers

Climaxa at 2007-7-13 18:40:01 > top of Java-index,Other Topics,Java Game Development...
# 2

Hi again.

I just saw in your reply to the runescape question, that you're using JOGL... It's a great api but it only has graphics...

I strongly recommend converting to LWJGL. The openGL stuff stays basically the same.. (Only texture loading differs email me if you need help on this) but you get so much more! It uses a simple class called Display which wraps all the needed jargon to change from fullscreen to 320 200 screen resolution. I think it's only problem is it's difficulty adding it to an applet (haven't tried that yet though).

But it also wrap openAL which handles the 3d Sound and listener environment. FMOD can read and play mod music files (I use JMF though cause it can play movies and mp3's etc). The most important is the JInput which I think is wrapped to DirectInput cause it can give absolute movements on the axi, thus rendering the "desktop box" useless, and you can easily get the movements of the mouse (no cursor positions required). Meaning you can move the mouse from here to timbucktoo without having to wrap...

it's keyboard interface also rocks, it's so fast that if you press a button once it registers almost 5...

Anyways just email me if you have questions about LWJGL. I am also writing a 3d FPS game application which will be network enabled (only local LAN though).

Good luck with your project!

Climaxa at 2007-7-13 18:40:01 > top of Java-index,Other Topics,Java Game Development...
# 3
Hi again!I sent you an email. If you are on MSN then add me with this adress: jplindberg@hotmail.comIm planning to change to LWJGL, since JOGL cant help me much in this particular case.
AlbertSLindberga at 2007-7-13 18:40:01 > top of Java-index,Other Topics,Java Game Development...