Split screen?

Posted By: themuzikman

Split screen? - 01/30/14 07:12

Hello,

I was wondering if anyone could tell me how to make a split screen (side by side) with two cameras that are right next to each other.

I'm trying to experiment with some stereoscopic (3D) videos and so I need two cameras side by side and I need the right camera to show up on the left side of the screen and the left camera to display on the right side.



Sounds simple enough but I'm so out of the loop, it's been over 10 years since I've done any programming in 3DGS wink

I would like the cameras to be attached to the player, so that they are in a fixed position. As the player walks around, the two cameras are still in the same relative position.

Thanks in advance!
-Dan
Posted By: themuzikman

Re: Split screen? - 01/30/14 07:16

Also, here's some pictures I took last week while hiking. This is what I would like it to look like on the screen. Left camera is on the right, and vice versa. When you cross your eyes, or look at the pictures and "unfocus" your eyes, a new 3D picture will appear.





Posted By: LemmyTheSlayer

Re: Split screen? - 01/30/14 10:57

what you need is a VIEW struct. take a look here:
http://conitec.net/beta/aview-name.htm
Posted By: themuzikman

Re: Split screen? - 01/31/14 16:43

Thank you for the response. I'm still unsure where to put that code or how to use it, though haha.
Posted By: LemmyTheSlayer

Re: Split screen? - 01/31/14 17:07

this is how you could use it:

Code:
///////////////////////////////
#include <acknex.h>
#include <default.c>

///////////////////////////////

VIEW* camera2 = {
   flags = SHOW;
}


function main() {
   level_load(NULL);
   
   camera.size_x = screen_size.x/2 - 2;
   
   camera2.size_x = screen_size.x/2 - 2;
   camera2.pos_x = screen_size.x/2 + 2;
   
   camera.x = -65;
   camera.y = 42;
   camera.pan = -26;
   
   camera2.x = -64;
   camera2.y = -50;
   camera2.z = 50;
   camera2.pan = 42;
   camera2.tilt = -29;
   
   ENTITY* cube = ent_create(CUBE_MDL,nullvector,NULL);
   
   while(1) {
      cube.pan += 4*time_step;
      wait(1);
   }
}

Posted By: themuzikman

Re: Split screen? - 01/31/14 17:25

Awesome! Thank you! Now how can I get it to work as my main camera set up in a level instead of only displaying the cube?
And also to be set up as a flythrough or player camera, and so that both cameras move together.
Posted By: themuzikman

Re: Split screen? - 01/31/14 17:51

Ok, nevermind I got it to load my level, but how do I attach these two cameras to the player so that they will both move with it?

Edit: Haha I can make the left camera follow the player, but the right camera is still stationary.
Posted By: LemmyTheSlayer

Re: Split screen? - 01/31/14 18:46

Code:
VECTOR* offset1 = {...};
VECTOR* offset2 = {...};

...

vec_set(camera.x,player.x);
vec_add(camera.x,offset1);
vec_set(camera2.x,player.x);
vec_add(camera2.x,offset2);


you have to choose offset1 and offset2 accordingly, of course
Posted By: themuzikman

Re: Split screen? - 01/31/14 19:05

Thanks! What would I typically put in the brackets, though?
Posted By: LemmyTheSlayer

Re: Split screen? - 01/31/14 19:17

the offsets are vectors that point from the player to the cameras.
something like that should be okay in the beginning:
Code:
VECTOR* offset1 = {0,-distance,0};
VECTOR* offset2 = {0, distance,0};


of course you have to find a decent value for distance that fits well with your pictures.
Posted By: themuzikman

Re: Split screen? - 01/31/14 19:29

This is what I have in my main script:

Code:
VIEW* camera2 = {
   flags = SHOW;
}

   VECTOR* offset1 = {0,-distance,0};
   VECTOR* offset2 = {0, distance,0};

   
function main() {
	video_screen = 2;
	video_mode = 9;
   level_load("newtest.wmb");
      
   camera.size_x = screen_size.x/2 - 2;
   camera2.size_x = screen_size.x/2 - 2;
   camera2.pos_x = screen_size.x/2 + 2;
   

   camera.x = -75;
   camera.y = 42;
   camera.pan = 0;
   
   camera2.x = -75;
   camera2.y = -42;
  //camera2.z = 50;
   camera2.pan = 0;
   //camera2.tilt = -29;
   

vec_set(camera.x,player.x);
vec_add(camera.x,offset1);
vec_set(camera2.x,player.x);
vec_add(camera2.x,offset2);
   

}



I'm getting a syntax error at VECTOR* offset1 = {0,-distance,0};, so I assume I just don't have something in the right order.
Posted By: LemmyTheSlayer

Re: Split screen? - 01/31/14 19:44

distance is not defined. replace it with some value.
Code:
VECTOR* offset1 = {0,-10,0};
VECTOR* offset2 = {0, 10,0};


maybe you should also have a look here
Posted By: themuzikman

Re: Split screen? - 01/31/14 19:51

Thanks, I looked in the tutorial but I didn't see anything for this vector thing. Or for cameras. And I didn't see anything specifically like this in the manual...

I'm still getting the same syntax error, though. Other than that, I've gotten it looking good now. Thank you.
Posted By: LemmyTheSlayer

Re: Split screen? - 01/31/14 21:19

sorry, my mistake. this is how it is supposed to look like:
Code:
VECTOR* offset1 = {
    x = 0;
    y = -10;
    z = 0
};

VECTOR* offset2 = {
    x = 0;
    y = 10;
    z = 0
};

Posted By: themuzikman

Re: Split screen? - 01/31/14 22:11

Should be:
Code:
VECTOR* offset1 = {
    x = 0;
    y = -10;
    z = 0;
}

VECTOR* offset2 = {
    x = 0;
    y = 10;
    z = 0;
}



wink

So now that fixes my startup error, but my right camera is still in a fixed position.
Posted By: LemmyTheSlayer

Re: Split screen? - 01/31/14 22:27

you have to create a player and move it.
refer to the tutorials for that one.
Posted By: themuzikman

Re: Split screen? - 01/31/14 22:30

Well I already have a player and the left camera works with it, but the right camera is static and seems to be fixed on a random coordinate...

If I try it without a player, then the two cameras are in the correct position, but unable to move the camera, obviously...
Posted By: LemmyTheSlayer

Re: Split screen? - 01/31/14 22:35

you have put the vec_set and vec_add stuff in a loop, haven't you?
Posted By: themuzikman

Re: Split screen? - 01/31/14 22:49

I haven't changed that from what you posted...
Posted By: LemmyTheSlayer

Re: Split screen? - 01/31/14 22:56

if it's not in a loop, the camera position is only updated once.
you want it to be constantly updated.
Posted By: themuzikman

Re: Split screen? - 01/31/14 22:58

That certainly makes sense. I looked in the manual/ tutorial for loop examples, but nothing with the "loop" keyword...
Posted By: LemmyTheSlayer

Re: Split screen? - 01/31/14 23:35

i would advise you to do the whole tutorial.
presumably 3dgs changed a lot in the last 10 years.
Posted By: themuzikman

Re: Split screen? - 02/01/14 00:54

I see it's done with while and wait as I thought, but even though adding it to my script changes the camera angle a little bit on the right screen, it still isn't following the player...
Posted By: Reconnoiter

Re: Split screen? - 02/13/14 11:59

Maybe you already fixed this themuzikman, otherwise just add this in the while in your player code;

Code:
vec_set (camera.x, vector (-200, 50, 70)); // simple camera code, play with these values
vec_rotate (camera.x, my.pan); // this example creates a camera that sits 200 quants behind the player and 50 quants to the left
vec_add (camera.x, my.x); // and 70 quants above its origin
camera.pan = my.pan; // the camera will have the same pan angle with the player

vec_set (camera2.x, vector (-200, -50, 70)); // simple camera code, play with these values
vec_rotate (camera2.x, my.pan); // this example creates a camera that sits 200 quants behind the player and 50 quants to the right
vec_add (camera2.x, my.x); // and 70 quants above its origin
camera2.pan = my.pan; // the camera will have the same pan angle with the player

Posted By: themuzikman

Re: Split screen? - 02/14/14 03:43

Thank you very much! I tried this and it seems to function properly except that camera 2 doesn't follow my mouse movement on the Y axis... I thought if I added

Code:
vec_set(camera.y,player.y);
vec_add(camera.y,offset1);

etc..



that it might work, but it makes no difference at all... Just one step away from getting this thing to work! Haha
Posted By: Reconnoiter

Re: Split screen? - 02/14/14 11:38

Ah yeah the problem is that the code still only takes the player.pan into account. Try this (I have tested it, it should work with you to):

Code:
ANGLE player_angle;
player_angle.pan = player.pan;
player_angle.tilt = player.tilt; //or camera.tilt, depends on what you move with mouse_force.y
player_angle.roll = player.roll;
vec_set (camera.x, vector (-200, 50, 70)); // simple camera code, play with these values
vec_rotate (camera.x, player_angle); // this example creates a camera that sits 200 quants behind the player and 50 quants to the left
vec_add (camera.x, player.x); // and 70 quants above its origin
camera.pan = player.pan;
camera.tilt = player.tilt; //you can leave this out if you move camera.tilt directly through mouse_force.y

vec_set (camera2.x, vector (-200, -50, 70)); // simple camera code, play with these values
vec_rotate (camera2.x, player_angle); // this example creates a camera that sits 200 quants behind the player and 50 quants to the right
vec_add (camera2.x, player.x); // and 70 quants above its origin
camera2.pan = player.pan;
camera2.tilt = player.tilt; //you can leave this out if you move camera.tilt directly through mouse_force.y

Posted By: themuzikman

Re: Split screen? - 02/16/14 02:11

Thanks, I forgot that 'tilt' is the value for angling the camera up and down as pan is for moving it left and right...

However, it's still not working, but I will start a new script tonight from scratch and see if I can figure out why it's not working over here...
Posted By: Reconnoiter

Re: Split screen? - 02/16/14 11:22

Take a good look at 'mouse_force.y' in your script. And at camera.tilt and player.tilt. I advise you to do the Lite-c tutorial to refresh your memory wink. It should not take you to long.
© 2024 lite-C Forums