Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

AppGameKit Classic Chat / First Person Camera (Linux / Raspberry Pi)

Author
Message
tboy
11
Years of Service
User Offline
Joined: 1st Jan 2013
Location: UK
Posted: 2nd Jun 2022 19:25 Edited at: 2nd Jun 2022 19:28
I know I should post this on Raspberry Pi forum but I'm not sure if anyone reads it anymore

I've been trying to implement a first person camera and I couldn't seem to get it working correctly even when
I hide the cursor using SetRawMouseVisible(0).

Looking at the Tier 2 code (Line : 4302 LinuxCore.cpp)

The original code is:


Change GLFW_CURSOR_HIDDEN to GLFW_CURSOR_DISABLED seems to solve the issue.

Working version:


When I build a new version of AppGameKit on the Pi4 and use the following code I get the desired first person camera.



Is this a problem on any other platform? Can anyone confirm this?
Virtual Nomad
Moderator
18
Years of Service
Recently Online
Joined: 14th Dec 2005
Location: SF Bay Area, USA
Posted: 2nd Jun 2022 19:52 Edited at: 2nd Jun 2022 20:00
i know nothing about linux but a quick search for glfwSetInputMode provided THIS:
Quote: "If the mode is GLFW_CURSOR, the value must be one of the following cursor modes:

GLFW_CURSOR_NORMAL makes the cursor visible and behaving normally.
GLFW_CURSOR_HIDDEN makes the cursor invisible when it is over the content area of the window but does not restrict the cursor from leaving.
GLFW_CURSOR_DISABLED hides and grabs the cursor, providing virtual and unlimited cursor movement. This is useful for implementing for example 3D camera controls."

where GLFW_CURSOR_DISABLED appears ideal behavior for MouseLook considering it seems to automatically park the cursor vs having to reposition it each frame as i do in this example so that i can retrieve MouseX/Y delta values.

with that, i can't say that there is anything wrong with the original code since i believe it's doing what it's supposed to do while i also can't say that i've seen your method of MouseLook before:

otherwise, i have seen the method i've used in the heightmap snippet a thousand times on the forums (and why i picked up the practice and, perhaps, suggest that you do?).

meanwhile, if there's an equivalent to GLFW_CURSOR_DISABLED on all OSs then i'd love to see the command added.

/2ยข
tboy
11
Years of Service
User Offline
Joined: 1st Jan 2013
Location: UK
Posted: 2nd Jun 2022 22:02
I have tried the method you use before and it works but I wanted to come up with an even easier way.

Changing GLFW_CURSOR_HIDDEN to GLFW_CURSOR_DISABLED seems to work on Linux / Raspberry Pi but I also
see they use this method with HTML5 so will probably need the same change.

I suppose it's not a problem if the current solution works for everyone but I always like to keep things simple.

What do you think Virtual Nomad is it worth asking for an update for the Linux and HTML5 version of AppGameKit?
Virtual Nomad
Moderator
18
Years of Service
Recently Online
Joined: 14th Dec 2005
Location: SF Bay Area, USA
Posted: 3rd Jun 2022 01:31 Edited at: 3rd Jun 2022 07:16
asking rarely hurts but you want GLFW_CURSOR_DISABLED behavior as a new command like SetRawMouseDisabled() and not change SetRawMouseVisible(), right?

otherwise, providing the ability to disable the mouse completely sounds like opening a gateway to/from hell for irresponsible coders

meanwhile, i'd rather have GetRawMouseDeltaX/Y() added (which should have been in since GetRawMouseWheelDelta() was. it was a glaring omission when migrating from DBPro which had it natively, i believe).

alas, it's a few lines of code to replicate and i'd much rather have some other features and/or bug fixes...
adambiser
AGK Developer
8
Years of Service
User Offline
Joined: 16th Sep 2015
Location: US
Posted: 6th Jun 2022 15:52
When doing a mouse look, doesn't one have to use the mouse delta from screen center, rather than just the mouse x/y?
With a delta, RotateCameraLocal/Global/X/Y might be easier than SetCameraRotation.



SetRawMouseVisible's behavior shouldn't be changed. Maybe I want to hide the OS mouse and render my own at the mouse position.
I think CaptureRawMouse is a better name than SetRawMouseDisabled.
tboy
11
Years of Service
User Offline
Joined: 1st Jan 2013
Location: UK
Posted: 6th Jun 2022 20:28 Edited at: 6th Jun 2022 20:46
I think CaptureRawMouse should be added to Tier 1 and Tier 2 as using glfwSetInputMode( g_pWindow, GLFW_CURSOR, visible ? GLFW_CURSOR_NORMAL : GLFW_CURSOR_DISABLED );
makes things much easier for an FPS camera as it hides the cursor and 'captures' the mouse.

I don't know what is better but I think;

mouseY = agk::GetRawMouseX()*0.1;
mouseX = agk::GetRawMouseY()*0.1;
agk::SetCameraRotation(1, mouseX, mouseY, 0.0);


looks like a nice easy solution for a product like AppGameKit, it's also quite smooth (atleast on the Raspberry Pi )

Added to my version of Tier2, seems to work!

Attachments

Login to view attachments

Login to post a reply

Server time is: 2024-04-26 23:38:41
Your offset time is: 2024-04-26 23:38:41