Retro Rendering Mode and mainCamera.WorldToScreenPoint()

Discuss coding questions, pull requests, and implementation details.
Post Reply
User avatar
Hazelnut
Posts: 2873
Joined: Sat Aug 26, 2017 2:46 pm
Contact:

Retro Rendering Mode and mainCamera.WorldToScreenPoint()

Post by Hazelnut »

The locator device in my Archaeologists mod uses mainCamera.WorldToScreenPoint() to show the indicator on the HUD. The same thing is used by the quest debugger for quest building doors.

When retro rendering mode is switched on however, this no longer works correctly for either the quest debugger or the locator device. The markers move about kinda strangely as you change the camera view angle. (without moving in the world) They should stay in the same place relative to the world. I've tried to figure out what to change when retro is enabled but I don't understand how it's been done exactly. I can see that render textures are being used but no idea why it changes the screen point used for these HUD indicators.

Does anyone have any ideas or clues as to why this is happening? Hoping to get a thread I can follow to work out how to translate the coordinates returned from this camera function. Maybe a different camera needs to be used, but I can't find one.
See my mod code for examples of how to change various aspects of DFU: https://github.com/ajrb/dfunity-mods

User avatar
Interkarma
Posts: 6583
Joined: Sun Mar 22, 2015 1:51 am

Re: Retro Rendering Mode and mainCamera.WorldToScreenPoint()

Post by Interkarma »

Retro mode renders to one of two render textures, either 320x200 or 320x154 (large HUD enabled and docked). I have a feeling that WorldToScreenPoint() will always use viewport area (screenspace) and not the camera render target.

You'll probably have to do a little math to get the right screen point. You can see this in the other direction when player clicks into view with active mouse cursor. I had to account for both target heights and scale mouse position on render target relative to input mouse coordinates on viewport.

https://github.com/Interkarma/daggerfal ... te.cs#L264

Hopefully that is of some help.

User avatar
Hazelnut
Posts: 2873
Joined: Sat Aug 26, 2017 2:46 pm
Contact:

Re: Retro Rendering Mode and mainCamera.WorldToScreenPoint()

Post by Hazelnut »

Thanks mate!

Just needed to have an idea in my head. I'd seen the code in PlayerActivate but until you explained I didn't realise I needed to reverse it.

All fixed up now and v1.5.1 of the guild is released. :)
See my mod code for examples of how to change various aspects of DFU: https://github.com/ajrb/dfunity-mods

User avatar
Interkarma
Posts: 6583
Joined: Sun Mar 22, 2015 1:51 am

Re: Retro Rendering Mode and mainCamera.WorldToScreenPoint()

Post by Interkarma »

Happy that helped! :)

Post Reply