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 / Help with camera viewport. Please answer!

Author
Message
3dZmaster
23
Years of Service
User Offline
Joined: 30th Jun 2003
Location: Finland
Posted: 3rd Jul 2003 17:22
Ok. I am meking a split screen game and I hava this problem. When I split the screen in two parts the parts are like... what's the word... could it be streched. So they don't look normal. When I split the screen in four part tehre isn't any problem. And in two player mode there is no reason for plitting the screen in two parts. I know you know the answer so please...
Current project: Dodge Viper Car Game (Not named yet) Other car models are going to be included soon
APEXnow
Retired Moderator
23
Years of Service
User Offline
Joined: 15th Apr 2003
Location: On a park bench
Posted: 3rd Jul 2003 18:52 Edited at: 3rd Jul 2003 20:50
[Edited for a couple of corrections]

This issue is to do with your aspect ratio for the viewing frustrom of the cameras. When you use the SET CAMERA VIEW command to instruct DarkBASIC Professional to place each camera view onto the area of the screen, the area of the camera view will always occupy a sqaure region. hence having a camera view place on one half the screen will stretch the view along it's height. The best approach I can think of to fix it is this:-

For each left and right side of the screen, create two new cameras

MAKE CAMERA 1
MAKE CAMERA 2

(Position each camera according to where each player will view your scene)

Do not use camera 0 as we will use this to view two plane objects which are being used to render the views of each other camera.

Setup an image to render the camera left camera view onto.

CREATE BITMAP 1, 512, 512
MAKE MEMBLOCK FROM BITMAP 1,1
MAKE IMAGE FROM MEMBLOCK 1,1
MAKE IMAGE FROM MEMBLOCK 2,1
DELETE MEMBLOCK 1
DELETE BITMAP 1


You now have two images for each of the cameras to render to. Each image can be textured onto two plane objects for viewing. The idea is that you will stretch the texture of each plane to meet the correct aspect ratio.

At this point, use the SET CAMERA TO IMAGE 1, 1 command to render your camera image for the left side onto the image, and SET CAMERA TO IMAGE 2, 2 to render the second camera onto the second image.

CREATE BITMAP 1, 512, 512
MAKE MEMBLOCK FROM BITMAP 1,1
MAKE IMAGE FROM MEMBLOCK 1,1
MAKE IMAGE FROM MEMBLOCK 2,1
DELETE MEMBLOCK 1
DELETE BITMAP 1
SET CAMERA TO IMAGE 1, 1, 512, 512
SET CAMERA TO IMAGE 2, 2, 512, 512


Note: You only need to call the above commands once, not every frame, since DarkBASIC Professional will continually render the camera views from each camera onto the two Images.

The next step is to texture your Images onto two plains.

Create two plain objects:

MAKE OBJECT PLAIN 1, 400, 600
MAKE OBJECT PLAIN 2, 400, 600


Now position each plain side by side:

POSITION OBJECT 1, -200, 0, 0
POSITION OBJECT 2, 200, 0, 0


(Assuming your video res is 800x600)
Texture each plain using the two images.

TEXTURE OBJECT 1, 1
TEXTURE OBJECT 2, 2


Position your default camera view to view each of the two plains so that they are directly in front of you, you will need to play with the correct position.

At this point, both plains will view a 3D scene and are then textured onto the two plains, the idea here though is that you can scale the textures to meet the correct aspect ratio of camera one and two.

One last thing, you will always need to view your 3D scene through cameras 1 and 2, never use camera 0 for your game scene, and create the plains outside of your world, somewhere where they will not interfere with your game's level or scene file.

This is just an idea of how to do it but see if it helps you, I'm sure someone can come up with a better solution that is less complicated.

MSI/AMD Athlon 1300, 256Mb, 60GbHD, SoundBlaster Live!, GeForce 4 MX440-64Mb, Win2K, DX9, DarkBASIC Pro(PUv4.1)
3dZmaster
23
Years of Service
User Offline
Joined: 30th Jun 2003
Location: Finland
Posted: 4th Jul 2003 14:50
Well this could be a solution. I'm at my summer vacation cottage right now so I can't test it. Still if anyone knows something little less copmlicated...
But big thanx to APEXnow!

Current project: Dodge Viper Car Game (Not named yet) Other car models are going to be included soon
Van B
Moderator
23
Years of Service
User Offline
Joined: 8th Oct 2002
Location: Sunnyvale
Posted: 4th Jul 2003 15:02
The multi camera idea is good, but using plains is perhaps not the best idea. I suggest employing sprites instead, just stick them at the screen coordinates then stretch them to the propper size.

Assuming images 1 and 2 are your camera renders, something like:

sprite 1,0,0,1
sprite 2,screen width()/2,0,1
stretch sprite 1,((screen width()/512.00)*50.00),((screen height()/512.00)*100.00)
stretch sprite 2,((screen width()/512.00)*50.00),((screen height()/512.00)*100.00)


Van-B

My cats breath smells of cat food.
3dZmaster
23
Years of Service
User Offline
Joined: 30th Jun 2003
Location: Finland
Posted: 4th Jul 2003 15:19
I hope that works. I got another idea for doing this at Code Snippets. But I don't know if it works 'cause I'm still at my bloody cottage

Current project: Dodge Viper Car Game (Not named yet) Other car models are going to be included soon
APEXnow
Retired Moderator
23
Years of Service
User Offline
Joined: 15th Apr 2003
Location: On a park bench
Posted: 4th Jul 2003 19:25
Quote: "The multi camera idea is good, but using plains is perhaps not the best idea. I suggest employing sprites instead, just stick them at the screen coordinates then stretch them to the propper size."


Yeah, the sprites idea sounds good too, I probably might have suggested that instead but I've never actually used any of the sprite command set under DarkBASIC Professional at all yet, either way, it will most likely be a more efficient method of display since you're cutting the 3D bottle neck out for the plain geometry etc.

Good suggestion Van B

MSI/AMD Athlon 1300, 256Mb, 60GbHD, SoundBlaster Live!, GeForce 4 MX440-64Mb, Win2K, DX9, DarkBASIC Pro(PUv4.1)
3dZmaster
23
Years of Service
User Offline
Joined: 30th Jun 2003
Location: Finland
Posted: 5th Jul 2003 13:06
Thanx guyz

Current project: Dodge Viper Car Game (Not named yet) Other car models are going to be included soon
IanM
Retired Moderator
23
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 5th Jul 2003 15:22
If you are creating two camera's and no longer need the default camera, then change its viewport to stop it being rendered - things should run a little faster then.

Login to post a reply

Server time is: 2026-07-17 13:57:45
Your offset time is: 2026-07-17 13:57:45