A thought: Dynamic crosshair

Want to edit the game, build your own craft and missions? Here you'll find help, tools, guides and people to discuss with.

A thought: Dynamic crosshair

User avatar
Vince T
Fleet Admiral (Administrator)
Posts: 14052
Joined: Fri Apr 27, 2001 11:01 pm
Contact:

Post by Vince T » Sun Apr 05, 2020 7:10 pm

OK picking up from another thread in the closed forum, I riased the idea to make the inertia effect work in exterior mode. However this would not be doable with blue_max's cockpit inertia hook.

Now, regardless of whether or not that could be done I had some more thoughts. One was to have the crosshair in Exterior mode. It would theoretically be possible but would pretty much stop working the moment you rotate the camera around the craft. So the only time where it would be correctly placed is when the player ship is blocking the view. Great idea Vince!

Now here's a new thought, which goes more into the direction of actual OPTing: In my thouhts one could actually place a singular face with crosshair texture in front of the Exterior OPT. You could take it one step further and add a series of such crosshairs to create a sort of target lead.
Crosshairs.jpg

Now, thinking one step further, this goes once more into the hook department:
As the Dynamic Cockpit Hook incorporates the other HUD elements into the cockpit OPT, could it also project the crosshair onto the exterior?

Also, would it be possible to have individual crosshair designs on a per-ship basis?
You do not have the required permissions to view the files attached to this post.
Your ship, Captain. I need a drink. - Vince Trageton
Vince T's X-Wing HQ - where the bad guys get their gear

User avatar
keiranhalcyon7
Lieutenant JG
Posts: 599
Joined: Tue Jan 02, 2018 6:41 am

Post by keiranhalcyon7 » Sun Apr 05, 2020 9:48 pm

What if a hook could change the camera's notion of the ship's center point in exterior mode to get it out of the way of the crosshairs?

User avatar
Vince T
Fleet Admiral (Administrator)
Posts: 14052
Joined: Fri Apr 27, 2001 11:01 pm
Contact:

Post by Vince T » Sun Apr 05, 2020 10:00 pm

I wouldn't move the craft or its center. Thing is the lasers and warhead hardpoints are linked to the Base OPT, so if you move the Exterior, the weapons may be misalligned. Moving the PoV would be better, if that were possible. Ofc. you could simply slightly rotate the view and lock it again.
Your ship, Captain. I need a drink. - Vince Trageton
Vince T's X-Wing HQ - where the bad guys get their gear

User avatar
Driftwood
Admiral (Moderator)
Posts: 2174
Joined: Wed Oct 22, 2003 11:01 pm
Contact:

Post by Driftwood » Sun Apr 05, 2020 11:05 pm

As I recall I've brought this up to Blue Max previously and he seemed to think it was possible to overlay the HUD on the exterior view. However, the issue remains being the player POV being positioned immediately behind the ship and thus not very usable.

I think it's going to require Blue Max using math to work correctly though GT. I'm not 100% here, but I'm fairly certain that for the player the exterior opt overwrites the base opt on what's displayed, and somehow pulls the hardpoint data from the base opt. That shouldn't be a problem in and of itself, just starting out at the beginning of my train of thought. However, I think where it becomes an issue is that meshes have a collision "file" function whether the mesh is rendered or not, backface viewed, or not. I think the issue is that depending how far out the single face "reticle" mesh is located one would literally "run into issues" by potentially crashing into things, taking damage from explosions and lasers, ect. since I believe that the exterior opt replaces the physical base opt and inherits the stats for the player.

I think really somebody would need to render the HUD in 3rd person and then change the default exterior player POV via a hook cfg for X/Y/Z coordinates to up and slightly behind the craft similarly to the Rogue Squadron series ships, for instance to function as we'd like it to work ideally. Also it would be handy to tie in the VR/head tracking hook into this function as well since you would be able to dynamically change your viewpoint as within the cockpit. Non headtracking/VR players could obviously use a POV hat per normal to operate this function.

IMO trying to do it on a 3d model basis is going to have major unintended consequences unless there's a method yet undiscovered, or if there's no way to selectively remove collision and clipping from a given mesh, which incidentally if that's possible would open up major possibilities for atmospheric environment to orbital transitions as well as 3d represented ray shielding using slightly transparent and/or illuminated textures. I think that also perhaps begs some investigation if at all possible.

Personally I'd prefer a less invasive/more universal hook implementation of this since it could also be toggled on/off based on user preference, plus I think doing such a mundane edit to literally every opt in existence, in theory, would be a drag if there's a better way.

User avatar
keiranhalcyon7
Lieutenant JG
Posts: 599
Joined: Tue Jan 02, 2018 6:41 am

Post by keiranhalcyon7 » Mon Apr 06, 2020 12:24 am

Yeah, that's more or less what I was suggesting - don't change the engine's view of the craft's center, just have the exterior camera apply an offset, to both the camera's origin and rotation point. Combined with a version of cockpit momentum, I think a battlefront-like camera could be achievable.

User avatar
Vince T
Fleet Admiral (Administrator)
Posts: 14052
Joined: Fri Apr 27, 2001 11:01 pm
Contact:

Post by Vince T » Mon Apr 06, 2020 5:58 am

The collision would be the least of our problems. You could simply shrink the respective meshes' hitbox to 0 and move it to the center of the craft.
Your ship, Captain. I need a drink. - Vince Trageton
Vince T's X-Wing HQ - where the bad guys get their gear

User avatar
blue_max
XWAU Member
Posts: 2296
Joined: Wed Mar 20, 2019 5:12 am

Post by blue_max » Mon Apr 06, 2020 5:19 pm

Would something like this work?
ext-HUD-1.jpg
ext-HUD-2.jpg
Proof that it's possible to dogfight with it:

https://www.youtube.com/watch?v=gw6nGer ... e=youtu.be

I essentially co-opted the hyperspace effect and rendered a circle at the center of projection instead. It needs to be calibrated once so that the FOV in the effect matches the actual in-game FOV. Also, you have to estimate target lead because you get no indication when you can hit your target otherwise (unless someone knows where XWA stores this information). And, well, the rest of the HUD would have to be rendered on first principles, from information stored in XWA's heap...

... but it's possible to dogfight even with very rudimentary HUD.
You do not have the required permissions to view the files attached to this post.

User avatar
JeremyaFr
XWAU Member
Posts: 3986
Joined: Mon Jan 18, 2010 5:52 pm
Contact:

Post by JeremyaFr » Mon Apr 06, 2020 7:50 pm

Exterior View with HUD

xwa_exterior_hud.jpg
You do not have the required permissions to view the files attached to this post.

User avatar
blue_max
XWAU Member
Posts: 2296
Joined: Wed Mar 20, 2019 5:12 am

Post by blue_max » Mon Apr 06, 2020 7:55 pm

Very interesting, Jeremy; but the aiming reticle seems to be in the wrong position in that screenshot. Can it be used to aim properly?

User avatar
JeremyaFr
XWAU Member
Posts: 3986
Joined: Mon Jan 18, 2010 5:52 pm
Contact:

Post by JeremyaFr » Mon Apr 06, 2020 8:00 pm

I need to compute the reticle position to render it at the right place.

User avatar
blue_max
XWAU Member
Posts: 2296
Joined: Wed Mar 20, 2019 5:12 am

Post by blue_max » Mon Apr 06, 2020 8:02 pm

JeremyaFr wrote:
Mon Apr 06, 2020 8:00 pm
I need to compute the reticle position to render it at the right place.
I'm very interested in the details of this computation. Do please share whenever you're ready :)

User avatar
Vince T
Fleet Admiral (Administrator)
Posts: 14052
Joined: Fri Apr 27, 2001 11:01 pm
Contact:

Post by Vince T » Mon Apr 06, 2020 8:06 pm

God I'm so glad for the rock we kicked loose :D
Your ship, Captain. I need a drink. - Vince Trageton
Vince T's X-Wing HQ - where the bad guys get their gear

User avatar
JeremyaFr
XWAU Member
Posts: 3986
Joined: Mon Jan 18, 2010 5:52 pm
Contact:

Post by JeremyaFr » Mon Apr 06, 2020 8:08 pm

For now, there is a few bugs:
When you are in exterior mode, open the map and close the map, then the view goes back to cockpit view.
The same appears when you enter or exit hyperspace. The view goes back to cockpit.

User avatar
keiranhalcyon7
Lieutenant JG
Posts: 599
Joined: Tue Jan 02, 2018 6:41 am

Post by keiranhalcyon7 » Mon Apr 06, 2020 8:40 pm

Still, excellent work, Jeremy!

To the first order, the crosshairs should be placed at the intersection of the craft boresights axis and infinity. The far clipping plane may serve as an acceptable proxy. This point may or may not be on screen, depending on the degree of rotation the player has applied.

However, I would argue that a better place to put the corsshairs is on the boresights line at a distance away equal to the distance to the current target (or infinity/far clipping plane if no target is selected). This should alleviate the need to estimate how much to adjust your aim due to the camera's offset from boresights.

User avatar
JeremyaFr
XWAU Member
Posts: 3986
Joined: Mon Jan 18, 2010 5:52 pm
Contact:

Post by JeremyaFr » Tue Apr 07, 2020 12:03 pm

Hello,

When MousePositionX and MousePositionY are equal to 0, the game doesn't recalculate the reticle position.

To force the game to recalculate the reticule position, I've added this code:

Code: Select all

xwaPlayers[currentPlayerId].MousePositionX = 1;
xwaPlayers[currentPlayerId].MousePositionY = 1;
The game projects the vector (0; 0; 1000000) with the player object transform matrix.

The position is stored in these variables:

Code: Select all

// 0x068C52C
int s_V0x068C52C;

// 0x068C528
int s_V0x068C528;
So it is not needed to manually compute the reticle position. The game can do it itself.

User avatar
JeremyaFr
XWAU Member
Posts: 3986
Joined: Mon Jan 18, 2010 5:52 pm
Contact:

Post by JeremyaFr » Tue Apr 07, 2020 12:12 pm

xwa_exterior_hud_2.jpg
You do not have the required permissions to view the files attached to this post.

User avatar
blue_max
XWAU Member
Posts: 2296
Joined: Wed Mar 20, 2019 5:12 am

Post by blue_max » Tue Apr 07, 2020 3:52 pm

Great work, Jeremy! Plus, I assume, you modified something else to make the game display the HUD in exterior view.
JeremyaFr wrote:
Tue Apr 07, 2020 12:03 pm
The game projects the vector (0; 0; 1000000) with the player object transform matrix.
Where is this transform matrix?
The position is stored in these variables:

Code: Select all

// 0x068C52C
int s_V0x068C52C;

// 0x068C528
int s_V0x068C528;
Are these the offsets of MousePositionX and MousePositionY?

User avatar
blue_max
XWAU Member
Posts: 2296
Joined: Wed Mar 20, 2019 5:12 am

Post by blue_max » Tue Apr 07, 2020 4:34 pm

I'm also adding inertia to the external view:

https://www.youtube.com/watch?v=nYYV9g2 ... e=youtu.be

I'm sure both Jeremy's external view HUD and the inertia effect can be combined.

User avatar
JeremyaFr
XWAU Member
Posts: 3986
Joined: Mon Jan 18, 2010 5:52 pm
Contact:

Post by JeremyaFr » Tue Apr 07, 2020 4:40 pm

Hello,
Here is WIP version of the hook.

EDIT: link removed
Last edited by JeremyaFr on Wed Apr 08, 2020 1:51 pm, edited 1 time in total.

User avatar
JeremyaFr
XWAU Member
Posts: 3986
Joined: Mon Jan 18, 2010 5:52 pm
Contact:

Post by JeremyaFr » Tue Apr 07, 2020 4:44 pm

Hello,

The transform matrix is stored at these offsets in the MobileObject structure:

Code: Select all

/* 0x00C6 */ bool RecalculateTransformMatrix ;
/* 0x00C7 */ short TransformMatrixFrontX ;
/* 0x00C9 */ short TransformMatrixFrontY ;
/* 0x00CB */ short TransformMatrixFrontZ ;
/* 0x00CD */ short TransformMatrixRightX ;
/* 0x00CF */ short TransformMatrixRightY ;
/* 0x00D1 */ short TransformMatrixRightZ ;
/* 0x00D3 */ short TransformMatrixUpX ;
/* 0x00D5 */ short TransformMatrixUpY ;
/* 0x00D7 */ short TransformMatrixUpZ ;
The MousePositionX and MousePositionY variables are stored at these offsets in the Player structure:

Code: Select all

/* 0x01FD */ short MousePositionX ;
/* 0x01FF */ short MousePositionY ;

User avatar
DTM
Fleet Admiral (Administrator)
Posts: 2120
Joined: Tue Apr 22, 2003 11:01 pm
Contact:

Post by DTM » Tue Apr 07, 2020 4:46 pm

You guys are amazing! I'm not a big fan of arcade games, but I have to admit that this is beautiful and my son will love it !!! Thanks, great job!

User avatar
JeremyaFr
XWAU Member
Posts: 3986
Joined: Mon Jan 18, 2010 5:52 pm
Contact:

Post by JeremyaFr » Tue Apr 07, 2020 4:54 pm

blue_max wrote:
Tue Apr 07, 2020 3:52 pm
Great work, Jeremy! Plus, I assume, you modified something else to make the game display the HUD in exterior view.
When in exterior view, I call the functions that display the HUD.

User avatar
blue_max
XWAU Member
Posts: 2296
Joined: Wed Mar 20, 2019 5:12 am

Post by blue_max » Tue Apr 07, 2020 5:27 pm

Thanks for sharing, Jeremy!

User avatar
Driftwood
Admiral (Moderator)
Posts: 2174
Joined: Wed Oct 22, 2003 11:01 pm
Contact:

Post by Driftwood » Tue Apr 07, 2020 5:32 pm

You guys work fast and it looks very promising.

Also while MP isn't huge please try and make things not cause desync where at all possible to avoid mp conflict! I remember somebody mentioning that until BM fixed it, the joystick roll yaw axis fix desync Mp. I don't know how things would desync if both players have the same files though. Either way.

Just thought I'd mention this angle, Sp wise though obviously it'd be irrelevant.

User avatar
keiranhalcyon7
Lieutenant JG
Posts: 599
Joined: Tue Jan 02, 2018 6:41 am

Post by keiranhalcyon7 » Tue Apr 07, 2020 6:14 pm

blue_max wrote:
Tue Apr 07, 2020 4:34 pm
I'm also adding inertia to the external view
Would it be possible to implement it in the opposite way - that is, keep the crosshairs steady, and move the ship in the opposite direction (by adjusting both the camera origin and look-at point)?

Post Reply