Monday, September 6th 2010, 11:39am UTC+2

You are not logged in.

  • Login
  • Register

hannes

Wolfmod Dev.

1

Friday, November 23rd 2007, 11:47pm

Adding Camtrace 3D support to your fav game! Here for example Wolfenstein Enemy Territory

Hello,

Basically this should be no problem at all if you have the Game Source code of the Game.

I will just paste my source i used for the uv-movieMod (worked for RTCW, ET, Q3 and basically also for QW)

What do we need?

getViewPos -> prints the current camera position
setViewPos -> sets the current camera position
freecam -> init the camera

thats basically all you need to play camtrace cams. I will not go into detail (for example how to add a new console command)

Console Command setViewPos aka freecamSetPos:

Source code

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
/*
=================
Cmd_SetFreecamPos_f
mmMod  Setfreecampos
=================
*/
void Cmd_SetFreecamPos_f( void ) {
vec3_torigin, angles;
charbuffer[MAX_TOKEN_CHARS];
inti;

if ( trap_Argc() < 3 ) {
CG_Printf("usage: setviewpos x y z pitch yaw roll\n");
return;
}

VectorClear( angles );

for ( i = 0 ; i < 3 ; i++ ) {
trap_Argv( i + 1, buffer, sizeof( buffer ) );
origin[i] = atof( buffer );
}

trap_Argv( 5, buffer, sizeof( buffer ) );
angles[YAW] = atof( buffer );
trap_Argv( 4, buffer, sizeof( buffer ) );
angles[PITCH] = atof( buffer );
trap_Argv( 6, buffer, sizeof( buffer ) );
angles[ROLL] = atof( buffer );

VectorCopy( origin, cg.demoCamPos );
VectorCopy( angles, cg.demoCamAngles );

}


freecam -> start the freecam

Source code

1
2
3
4
5
6
7
8
9
10
11
12
/*
=============
CT_DemoCam

Adds a new freecam to the game
=============
*/
static void CT_DemoCam( void ) {
cg.demoCam = cg.demoCam ? 0 : 1;
VectorCopy(cg.refdef.vieworg,cg.demoCamPos);
VectorCopy(cg.refdefViewAngles,cg.demoCamAngles);
}


getViewPos aka viewpos - Be sure to have the excat same syntax

Source code

1
2
3
4
5
6
7
8
9
10
11
12
/*
=============
CG_Viewpos_f
[22.10.07] Hannes altered for camtrace 3D
Debugging command to print the current position
=============
*/
static void CG_Viewpos_f (void) {
CG_Printf ("(%f %f %f) : %f %f %f : %i\n", 
(float)cg.refdef.vieworg[0], (float)cg.refdef.vieworg[1], (float)cg.refdef.vieworg[2], 
(float)cg.refdefViewAngles[PITCH], (float)cg.refdefViewAngles[YAW], (float)cg.refdefViewAngles[ROLL],(int)cg.time);
}


Now we need to tell the engine to render the current campos and not the firstPerson pos: (cg_view -> CG_CalcViewValues)

Source code

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
//mmMod - Freecam
if (cg.demoCam) {
float fov = cg_fov.value;
float x;

//flymove...
//put this somewhere else maybe ?
mm_move.fmove = 0;
mm_move.smove = 0;
mm_move.umove = 0;

if (mm_move.forward) {

mm_move.fmove += 127;
}
if (mm_move.backward) {

mm_move.fmove -= 127;
}
if (mm_move.left) {

mm_move.smove -= 127;
}
if (mm_move.right) {

mm_move.smove += 127;

}
if (mm_move.up) {

mm_move.umove += 127;

}
if (mm_move.down) {

mm_move.umove -= 127;

}

CG_PmoveSingle();
//flymove...


VectorCopy(cg.demoCamPos, cg.refdef_current->vieworg );
VectorCopy(cg.demoCamAngles,cg.refdefViewAngles);



AnglesToAxis( cg.refdefViewAngles, cg.refdef_current->viewaxis );

x = cg.refdef.width / tan( fov / 360 * M_PI );
cg.refdef_current->fov_y = atan2( cg.refdef_current->height, x );
cg.refdef_current->fov_y = cg.refdef_current->fov_y * 360 / M_PI;
cg.refdef_current->fov_x = fov;

return 0;
}
//mmMod - Freecam


you can ignore the pmove stuff here, but we had to port all that from the game to the client which is a bit more in to depth here.

Hope it helped
  • Go to the top of the page

metaL

Beginner

2

Tuesday, August 25th 2009, 6:05pm

Will this work for Wolfenstein too Hannes? Or will you configure a new program/ updated version for Wolfenstein? :D
  • Go to the top of the page

hannes

Wolfmod Dev.

3

Tuesday, August 25th 2009, 6:20pm

we will support wolf, just like we did support etqw
  • Go to the top of the page

Rate this thread