Static camera

Locked
Herr W
Posts: 90
Joined: Tue May 16, 2006 8:53 am

Static camera

Post by Herr W »

Hi everyone!

My question today is, if there is a not to complicated (still a coding dope :dork: ) way to create a static camera perspective for the player. It's for my Monkeys of Doom, mobile version again. I have something like a cage match in mind...
[color=#FF0000]Visit MONKEYS of DOOM at [url]http://www.monkeysofdoom.org[/url][/color]
^misantropia^
Posts: 4022
Joined: Sat Mar 12, 2005 6:24 pm

Re: Static camera

Post by ^misantropia^ »

Not sure what you mean. Static as in bird view or something like CPMA's multi-view demo feature?
Herr W
Posts: 90
Joined: Tue May 16, 2006 8:53 am

Re: Static camera

Post by Herr W »

I was thinking of a fixed camera, always showing the same view. Like the one pointing at the podium after a match.
[color=#FF0000]Visit MONKEYS of DOOM at [url]http://www.monkeysofdoom.org[/url][/color]
^misantropia^
Posts: 4022
Joined: Sat Mar 12, 2005 6:24 pm

Re: Static camera

Post by ^misantropia^ »

And do you want to overlay on the player's view or show it to spectators?
Herr W
Posts: 90
Joined: Tue May 16, 2006 8:53 am

Re: Static camera

Post by Herr W »

Overlay the player's view!
[color=#FF0000]Visit MONKEYS of DOOM at [url]http://www.monkeysofdoom.org[/url][/color]
^misantropia^
Posts: 4022
Joined: Sat Mar 12, 2005 6:24 pm

Re: Static camera

Post by ^misantropia^ »

Okay, that is roughly what multi-view demos do (and it's pretty advanced stuff, unfortunately). Essentially, you need to create portal camera entity so your static camera becomes part of the player's PVS. That's the hard part. Overlaying it onto the player's view is relatively easy, just call trap_R_RenderScene() with a custom refdef.

I actually used to have some proof-of-concept code that does just that (except that the camera viewpoint is not static but that is besides the point) but I'll be damned if I can find it.
Herr W
Posts: 90
Joined: Tue May 16, 2006 8:53 am

Re: Static camera

Post by Herr W »

Damn, I hoped there would be a nice simple trick... :rolleyes:

Sounds as if it's far beyond my capabilities unless you lead me through it step by step (what I really can't expect). I think it's smarter to test the effekt first by simulating it with two phones, one in spectator's mode as monitor and the other one for steering. Maybe it sucks completely and I can save us a lot of time and nerves... :D

(Will post the result here.)
[color=#FF0000]Visit MONKEYS of DOOM at [url]http://www.monkeysofdoom.org[/url][/color]
Hxrmn
Posts: 17
Joined: Fri Jun 11, 2010 5:52 am

Re: Static camera

Post by Hxrmn »

Here's an example, you need to supply origin and angles though (vec3_t)
In your cgame when you draw your scene (CG_Draw2D) in cg_draw.c you make a call to your function that does the following

Code: Select all

   refdef_t		refdef;

	memset( &refdef, 0, sizeof( refdef ) );

	VectorCopy( origin, refdef.vieworigin );
   AnglesToAxis( angles, refdef.viewaxis );

	refdef.fov_x = 30;
	refdef.fov_y = 30;

	refdef.x = 0;
	refdef.y = 0;
	refdef.width = 128;
	refdef.height = 128;

	refdef.time = cg.time;

	trap_R_ClearScene();
        //What you want to render goes here, for example here we render just about everything
	CG_AddPacketEntities();
	CG_AddMarks();
	CG_AddParticles ();
	CG_AddLocalEntities();
	trap_R_RenderScene( &refdef );
You still need to do the PVS stuff on the server, this can be done by adding a portal entity.
Create an entity and set it's svFlags to SVF_PORTAL|SVF_BROADCAST and set origin2 to the location you want
the clients to be able to see.

I can't remember this step exactly, you'll have to look around the quake3 source code a bit to see how it's done if my
code doesn't work.

Code: Select all

yourEntity->r.svFlags = SVF_PORTAL|SVF_BROADCAST;
VectorCopy(location,yourEntity->s.origin2);
//where location is a vec3_t.
Herr W
Posts: 90
Joined: Tue May 16, 2006 8:53 am

Re: Static camera

Post by Herr W »

Thanks a lot! Will try that out...
[color=#FF0000]Visit MONKEYS of DOOM at [url]http://www.monkeysofdoom.org[/url][/color]
Locked