Page 1 of 1

Static camera

Posted: Fri Jul 09, 2010 7:12 pm
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...

Re: Static camera

Posted: Fri Jul 09, 2010 8:12 pm
by ^misantropia^
Not sure what you mean. Static as in bird view or something like CPMA's multi-view demo feature?

Re: Static camera

Posted: Sat Jul 10, 2010 10:06 am
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.

Re: Static camera

Posted: Sat Jul 10, 2010 2:03 pm
by ^misantropia^
And do you want to overlay on the player's view or show it to spectators?

Re: Static camera

Posted: Sat Jul 10, 2010 2:38 pm
by Herr W
Overlay the player's view!

Re: Static camera

Posted: Sat Jul 10, 2010 4:04 pm
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.

Re: Static camera

Posted: Sat Jul 10, 2010 4:49 pm
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.)

Re: Static camera

Posted: Wed Jul 14, 2010 8:10 pm
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.

Re: Static camera

Posted: Fri Jul 16, 2010 2:00 pm
by Herr W
Thanks a lot! Will try that out...