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.

DarkBASIC Professional Discussion / Screen image vs texture mapped image.

Author
Message
Rich Dersheimer
AGK Developer
17
Years of Service
User Offline
Joined: 1st Jul 2009
Location: Inside the box
Posted: 6th Apr 2011 23:10
Here's the premise...

A large plane textured with a background image. Since SCROLL BACKDROP no longer works, I'll scroll the texture on the plane.

Is there a formula to size the plane so that the camera image (looking at the plane) is exactly the same as if I had pasted the image on the screen in 2D?

For instance, it seems that using an 800x600 window, an 800x600 plane, and a camera distance of -500z gives a very close match with the pasted full screen image, as illustrated in the snippet below. Hit "s" or "c" to change the display.



But it's not exact.

Quel
17
Years of Service
User Offline
Joined: 13th Mar 2009
Location:
Posted: 6th Apr 2011 23:22
Sorry i don't have time to look more into it, but as i can remember sprites have UV scrolling too. Maybe that could be easier for you, look it up in the help.
Rich Dersheimer
AGK Developer
17
Years of Service
User Offline
Joined: 1st Jul 2009
Location: Inside the box
Posted: 6th Apr 2011 23:37
Yah, I've done that with sprites, but what I have in mind is for the 3D environment. I forget the term for it, but when I work with Lightwave 3D, you can assign an object to show a background image that exactly matches the bitmap of the image. So, the user wouldn't realize a 3D screen was even there until, SWOOSH!, the whole screen rotates away as a spinning cube.

I'm probably not explaining it very well. Just looking for an exact method of matching a textured plane with a 2D image, but it might not even be possible.

Green Gandalf
VIP Member
21
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 7th Apr 2011 00:12
I think you need to offset the plain by half a pixel as in this snippet:



I guess the correct Z value should be computed from the camera's FOV and the screen's height but I'm not sure. That method gives a Z value very close to your 500 which is perhaps not a coincidence.
Rich Dersheimer
AGK Developer
17
Years of Service
User Offline
Joined: 1st Jul 2009
Location: Inside the box
Posted: 7th Apr 2011 00:45 Edited at: 7th Apr 2011 00:55
Okay, I'll try that. And I'll look into the FOV, I hadn't thought of messing with that. Thankee!

EDIT:Well, that half "pixel" did the trick, the camera image and the pasted image are identical. On to sizes besides 800x600!

Umm, FOV is 61.9621391296 and screen height is 600. What calculation gives 500 from that?

Matty H
17
Years of Service
User Offline
Joined: 7th Oct 2008
Location: England
Posted: 7th Apr 2011 01:12
I've just been working on something similar to this, here is the code, its in GDK but you get the point



I was using camera 1, the distance is the camera distance from the plane, I think this may help.

Green Gandalf
VIP Member
21
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 7th Apr 2011 01:32
Quote: "Umm, FOV is 61.9621391296 and screen height is 600. What calculation gives 500 from that?"


Basic trigonometry. The following calculation uses the right-angled triangle with side screenheight/2 and angle FOV/2. The second side is the camera depth and is about 499.6577 according to DBPro. The formula is:

Rich Dersheimer
AGK Developer
17
Years of Service
User Offline
Joined: 1st Jul 2009
Location: Inside the box
Posted: 7th Apr 2011 18:57
Thanks guys, between the two examples, I'm sure I can figure out how to get what I want!

BatVink
Moderator
23
Years of Service
User Offline
Joined: 4th Apr 2003
Location: Gods own County, UK
Posted: 8th Apr 2011 00:02
I use this in all my projects. I didn't write it, and I've never tried to understand it, I just know it has worked for all screen sizes...




pictionaryjr
17
Years of Service
User Offline
Joined: 12th Mar 2009
Location:
Posted: 8th Apr 2011 01:24
i almost got a function working for you. i'll post it in a second. it even rotates the object and repositions it for the camera. you'll have to take off the lighting effects on the object tho

pictionaryjr
17
Years of Service
User Offline
Joined: 12th Mar 2009
Location:
Posted: 8th Apr 2011 01:54
Done

The threedrm functions have to come with it because those are my functions so i don't have to rewrite my 3d rotation matrix maths all over again every time.

All you have to do is create a plane thats 1,1 in size and texture it with your background, take the setting off for it so its not effected by any light. and then just run this function in your main loop.


Green Gandalf
VIP Member
21
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 8th Apr 2011 23:12
@BatVink

Quote: "I use this in all my projects. I didn't write it, and I've never tried to understand it, I just know it has worked for all screen sizes..."


How can that work? Don't you need to know what gdist is and where the camera is? Perhaps there's something you're not telling us - or something simple I've missed?

Login to post a reply

Server time is: 2026-07-17 13:58:52
Your offset time is: 2026-07-17 13:58:52