Static camera
-
- Posts: 1395
- Joined: Tue Feb 24, 2009 4:39 pm
- Location: Italy
Static camera
Hy guys, I just searched a bit in the forum but I didn't find anything usable(except some Nahuel's tests). I'd like to create a very simple camera fixed. Stop. You start the game and the camera stands still. That's it. I just need ONE camera (not the player camera AND this camera).
Is it possible?
thx
Is it possible?
thx
Meadow Fun!! - my first commercial game, made with FTEQW game engine
Re: Static camera
main problem is that you cannot lock the camera down without removing the player's ability to move.
set the player to MOVETYPE_NONE, stuff their m_yaw, m_pitch, cl_yawspeed, cl_pitchspeed cvars to 0, then they cannot change the direction they are looking unless they really try.
setorigin the player where you want the camera, set the player's angles to how you want them to be looking, and set fixangle = TRUE.
you have now turned the player into a static camera.
cons: you changed their cvars. people hate it if you do this, especially on public servers as it can leave cvars with bad values. people with non-default preferences will be annoyed if your mod switches between static camera mode and first-person (even if on different maps, as you will need to restore cvars to some value which is likely to be the default).
cons: the player cannot move nor turn. you're limited to just attack/jump/impulses as inputs from the player.
csqc can do a static camera easily enough. its actually just two calls different from a normal mod (assuming you know the origin/angles to use, those two values of course are what constitute those two calls). This method does not have either of the two cons I mentioned above, but would require csqc and all the compatibility issues that come with it.
set the player to MOVETYPE_NONE, stuff their m_yaw, m_pitch, cl_yawspeed, cl_pitchspeed cvars to 0, then they cannot change the direction they are looking unless they really try.
setorigin the player where you want the camera, set the player's angles to how you want them to be looking, and set fixangle = TRUE.
you have now turned the player into a static camera.
cons: you changed their cvars. people hate it if you do this, especially on public servers as it can leave cvars with bad values. people with non-default preferences will be annoyed if your mod switches between static camera mode and first-person (even if on different maps, as you will need to restore cvars to some value which is likely to be the default).
cons: the player cannot move nor turn. you're limited to just attack/jump/impulses as inputs from the player.
csqc can do a static camera easily enough. its actually just two calls different from a normal mod (assuming you know the origin/angles to use, those two values of course are what constitute those two calls). This method does not have either of the two cons I mentioned above, but would require csqc and all the compatibility issues that come with it.
-
- Posts: 1395
- Joined: Tue Feb 24, 2009 4:39 pm
- Location: Italy
Re: Static camera
Thanks Spike, you solved me 50% of the work! Now, with MOVETYPE_NONE the player can't move and this is really what I needed for.
But, unfortunately I NEED turning player abilities so I can't use your suggestion.
Using CSQC is prohibitive for me: even skilled coders seem to have problem with it and without a robust documentation It's impossible to me to do anything.
I noticed that there is in dp_extensions.qc a function named
I created a function like this
and then I put in radiant an entity named myStaticCamera but it simply doesn't nothing.
But, unfortunately I NEED turning player abilities so I can't use your suggestion.
Using CSQC is prohibitive for me: even skilled coders seem to have problem with it and without a robust documentation It's impossible to me to do anything.
I noticed that there is in dp_extensions.qc a function named
Code: Select all
//DP_SV_CLIENTCAMERA
//idea: LordHavoc, others
//darkplaces implementation: Black
//field definitions:
.entity clientcamera; // override camera entity
//description:
//allows another entity to be the camera for a client, for example a remote camera, this is similar to sending svc_setview manually except that it also changes the network culling appropriately.
Code: Select all
void() myStaticCamera =
{
clientcamera;
};
Meadow Fun!! - my first commercial game, made with FTEQW game engine
Re: Static camera
ssqc cameras are very problematic I will try a csqc camera, if i can do it i will release the code
hi, I am nahuel, I love quake and qc.
Re: Static camera
well without csqc, there is no way to force the view angle to some fixed angle without also locking the player's angle to that same exact angle.
here's your csqc code:
Your ssqc then calls this function:
Mix the csqc code with some bare csqcdefs.qc (ie: some file(s) containing system globals/fields/builtins/constants like defs.qc does for ssqc) and you have csqc overriding the view origin and angles - the origin and angles that the client generates are unaffected and the ssqc can't tell any difference.
I would personally do it with stats instead of cvars, but cvars will do the job and are easier to explain.
here's your csqc code:
Code: Select all
void(float scrwidth, float scrheight) CSQC_UpdateView =
{
//clear ent lists and reset view properties to their defaults
clearscene();
//tell the engine to do the normal 2d stuff
setviewprop(VF_DRAWCROSSHAIR, 1);
setviewprop(VF_DRAWENGINESBAR, 1);
//the magic two calls that we use to override the default org/angle (which are will currently be set to the player's origin/angle - just disable these two lines somehow if you want to disable the staticcam and all else will appear as normal)
if (cvar("staticcam"))
{
setviewprop(VF_ORIGIN, stov(cvar_string("staticcamvieworg")));
setviewprop(VF_ANGLES, stov(cvar_string("staticcamviewangle")));
}
//add the various entities with these masks to the render lists (this includes the engine-held entities)
addentities(MASK_ENGINEVIEWMODEL|MASK_NORMAL|MASK_ENGINE);
//draw the current ent lists to the screen.
renderscene();
};
Code: Select all
void(entity somecamera) ActivateStaticCam =
{
if (somecamera)
{
stuffcmd(self, strcat("set staticcamvieworg \"", vtos(somecamera.origin), "\"\n"));
stuffcmd(self, strcat("set staticcamviewangle \"", vtos(somecamera.angle), "\"\n"));
stuffcmd(self, strcat("set staticcam 1\n"));
}
else
stuffcmd(self, strcat("set staticcam 0\n"));
};
I would personally do it with stats instead of cvars, but cvars will do the job and are easier to explain.
-
- Posts: 268
- Joined: Tue Nov 24, 2009 2:20 am
- Contact:
Re: Static camera
Did you look at the camera code from custents?
Get off my lawn!Ken Thompson wrote:One of my most productive days was throwing away 1000 lines of code.
Re: Static camera
Thanks for the code, i will try, but i have some question: why would you use stats?? Implement new stats it is very simple. I thought in something like:Spike wrote: I would personally do it with stats instead of cvars, but cvars will do the job and are easier to explain.
Code: Select all
if (STAT_CAMERA > 0)
{
R_SetView(VF_ORIGIN, unknowdefinitionoforigin);
R_SetView(VF_ANGLES, unknowdefinitionofangles);
}
if (STAT_CAMERA <= 0)
{
R_SetView(VF_DRAWWORLD, 1);
R_SetView(VF_DRAWCROSSHAIR, 1);
R_SetView(VF_DRAWENGINESBAR, 0);
}
Code: Select all
R_SetView(VF_ORIGIN, stov(cvar_string("staticcamvieworg")));
R_SetView(VF_ANGLES, stov(cvar_string("staticcamviewangle")));
hi, I am nahuel, I love quake and qc.
Re: Static camera
Spike:
Currently i am using stats for everything But i am doing something wrong , the angles ant the ubication of the cameras works but you can see the problem
Sorry for this ugly code , the angles of the cameras work´s but the player is not displayed in the screen. I see the v_model everytime
http://www.youtube.com/watch?v=p7_wlGBQVLE
You can see when the player touch the trigger_camera, and dissapear Where can i find the problem??? any suggestion?? Thanks in advance
Edit:
I can fix the problem adding some "chase_active " stuffcdm when i touch the triggers, but this is the wrong way (i think)
Currently i am using stats for everything But i am doing something wrong , the angles ant the ubication of the cameras works but you can see the problem
Code: Select all
void() CSQC_UpdateView =
{
local float stat_cameras;
stat_cameras = getstatf(STAT_CAMERA );
local float stat_angles_x;
stat_angles_x = getstatf(STAT_CAMERA_ANGLES_X );
local float stat_angles_y;
stat_angles_y = getstatf(STAT_CAMERA_ANGLES_Y );
local float stat_angles_z;
stat_angles_z = getstatf(STAT_CAMERA_ANGLES_Z );
local float stat_origin_x;
stat_origin_x = getstatf(STAT_CAMERA_ORIGIN_X);
local float stat_origin_y;
stat_origin_y = getstatf(STAT_CAMERA_ORIGIN_Y);
local float stat_origin_z;
stat_origin_z = getstatf(STAT_CAMERA_ORIGIN_Z);
vid_width = cvar("vid_conwidth");
vid_height = cvar("vid_conheight");
R_ClearScene();
if (stat_cameras > 0)
{
R_SetView(VF_ORIGIN_X, stat_origin_x);
R_SetView(VF_ORIGIN_Y, stat_origin_y);
R_SetView(VF_ORIGIN_Z, stat_origin_z);
R_SetView(VF_ANGLES_X, stat_angles_x);
R_SetView(VF_ANGLES_Y, stat_angles_y);
R_SetView(VF_ANGLES_Z, stat_angles_z);
}
if (stat_cameras <= 0)
{
R_SetView(VF_DRAWWORLD, 1);
R_SetView(VF_DRAWCROSSHAIR, 1);
R_SetView(VF_DRAWENGINESBAR, 0);
}
R_AddEntities(MASK_NORMAL | MASK_ENGINE | MASK_ENGINEVIEWMODELS);
R_RenderScene();
};
Sorry for this ugly code , the angles of the cameras work´s but the player is not displayed in the screen. I see the v_model everytime
http://www.youtube.com/watch?v=p7_wlGBQVLE
You can see when the player touch the trigger_camera, and dissapear Where can i find the problem??? any suggestion?? Thanks in advance
Edit:
I can fix the problem adding some "chase_active " stuffcdm when i touch the triggers, but this is the wrong way (i think)
hi, I am nahuel, I love quake and qc.
-
- Posts: 1395
- Joined: Tue Feb 24, 2009 4:39 pm
- Location: Italy
Re: Static camera
First of all, thanks a lot Spike for your code!
I've encountered many problems during compiling so I presumed you used FTE,right? I'm using DP (but I also tested on FTE) and this is what I tried to do:
csqc (withcsprogsdefs by DP):
ssqc (and here, I know, I made a "big soup" of copying and pasting over the net ) :
Then I duplicated in radiant the info_player_start entity and I changed the classname to info_camera
Two problems:
1) when I load the map it doesn't switch to my camera (and this is reasonable because I don't know how to create a camera )
2)If I wrote in the commandline "set staticcamera 1" the camera become fixed to an angle which I didn't set (even if I tweak the angles settings in the ActivateStaticCam function) and it shows the map and the monster but not the player. Is only visible the flash of the weapon and its hit on the wall, and the weapon is still visible in first person view. On FTE same thing.
@Dreadlorde: no, I don't what is it! a mod?
@Nahuel: I'm glad you make some progress instead of me, It's 5 am and I barely know who I am now!
I've encountered many problems during compiling so I presumed you used FTE,right? I'm using DP (but I also tested on FTE) and this is what I tried to do:
csqc (withcsprogsdefs by DP):
Code: Select all
void CSQC_Init ()
{
}
void CSQC_Shutdown (void)
{
}
void CSQC_ConsoleCommand (string str)
{
};
void(float scrwidth, float scrheight) CSQC_UpdateView =
{
//clear ent lists and reset view properties to their defaults
clearscene();
//tell the engine to do the normal 2d stuff
//setviewprop(VF_DRAWCROSSHAIR, 1);
//setviewprop(VF_DRAWENGINESBAR, 1);
//setviewprop maybe for FTE?Not working on DP. I googled and found setproperty
setproperty(VF_DRAWCROSSHAIR, 1);
setproperty(VF_DRAWENGINESBAR, 1);
//the magic two calls that we use to override the default org/angle (which are will currently be set to the player's origin/angle - just disable these two lines somehow if you want to disable the staticcam and all else will appear as normal)
if (cvar("staticcam"))
{
//setviewprop(VF_ORIGIN, stov(cvar_string("staticcamvieworg")));
//setviewprop(VF_ANGLES, stov(cvar_string("staticcamviewangle")));
//like above setviewprop -> setproperty for DP
setproperty(VF_ORIGIN, stov(cvar_string("staticcamvieworg")));
setproperty(VF_ANGLES, stov(cvar_string("staticcamviewangle")));
}
//add the various entities with these masks to the render lists (this includes the engine-held entities)
//addentities(MASK_ENGINEVIEWMODEL|MASK_NORMAL|MASK_ENGINE);
//missed "S" at ENGINEVIEWMODEL
addentities(MASK_ENGINEVIEWMODELS | MASK_NORMAL | MASK_ENGINE);
//draw the current ent lists to the screen.
renderscene();
};
float CSQC_InputEvent (float event, float param, float param2)
{
};
Code: Select all
void() get_camera =
{
local entity cam;
cam = find(world, classname, "info_camera");
if (cam)
return cam;
cam = spawn();
cam.classname = "info_camera";
cam.origin = self.origin;
cam.angles = self.angles;
WriteByte(MSG_ONE, 5);
WriteEntity(MSG_ONE, cam);
};
void() info_camera = {
setmodel (self,"progs/eyes.mdl");
};
void(entity info_camera) ActivateStaticCam =
{
if (info_camera)
{
stuffcmd(self, strcat("set staticcamvieworg \"", vtos(info_camera.origin), "\"\n"));
//stuffcmd(self, strcat("set staticcamviewangle \"", vtos(info_camera.angle), "\"\n"));
// missed "s" at angle
stuffcmd(self, strcat("set staticcamviewangle \"", vtos(info_camera.angles), "\"\n"));
stuffcmd(self, strcat("set staticcam 1\n"));
}
else
stuffcmd(self, strcat("set staticcam 0\n"));
};
Two problems:
1) when I load the map it doesn't switch to my camera (and this is reasonable because I don't know how to create a camera )
2)If I wrote in the commandline "set staticcamera 1" the camera become fixed to an angle which I didn't set (even if I tweak the angles settings in the ActivateStaticCam function) and it shows the map and the monster but not the player. Is only visible the flash of the weapon and its hit on the wall, and the weapon is still visible in first person view. On FTE same thing.
@Dreadlorde: no, I don't what is it! a mod?
@Nahuel: I'm glad you make some progress instead of me, It's 5 am and I barely know who I am now!
Meadow Fun!! - my first commercial game, made with FTEQW game engine
Re: Static camera
you think I actually tested it? or even compiled it?
the builtin+constant names come from csqctest, rather than the DP-specific bare stuff, hence why you don't need those other pointless functions.
remove the MASK_ENGINEVIEWMODEL and you'll get rid of the view model.
regarding the player ent, I forgot about that, sorry. There are three possibilities, one is svc_setview so the client hides a different ent, the second is sending the player via csqc, and the third is an ssqc-based clone of the ent (movetype_follow jobbie with drawonlytoclient set).
the builtin+constant names come from csqctest, rather than the DP-specific bare stuff, hence why you don't need those other pointless functions.
remove the MASK_ENGINEVIEWMODEL and you'll get rid of the view model.
regarding the player ent, I forgot about that, sorry. There are three possibilities, one is svc_setview so the client hides a different ent, the second is sending the player via csqc, and the third is an ssqc-based clone of the ent (movetype_follow jobbie with drawonlytoclient set).
Re: Static camera
thanks for your help .Well, So i will try to send the player via CSQC. now i will release the previous version of the csqc static_camera usign the chase_camera function via csqc:)Spike wrote:you think I actually tested it? or even compiled it?
the builtin+constant names come from csqctest, rather than the DP-specific bare stuff, hence why you don't need those other pointless functions.
remove the MASK_ENGINEVIEWMODEL and you'll get rid of the view model.
regarding the player ent, I forgot about that, sorry. There are three possibilities, one is svc_setview so the client hides a different ent, the second is sending the player via csqc, and the third is an ssqc-based clone of the ent (movetype_follow jobbie with drawonlytoclient set).
hi, I am nahuel, I love quake and qc.
-
- Posts: 1395
- Joined: Tue Feb 24, 2009 4:39 pm
- Location: Italy
Re: Static camera
Thanks to you both! Nahuel's version works perfectly
Meadow Fun!! - my first commercial game, made with FTEQW game engine
Re: Static camera
I generally don't recommend sending the player via csqc unless you want to go fully into csqc. Its quite involved if you want to do it properly - doing so basically means you can't automatically utilize any engine-based prediction - this is especially true with DP right now.
csqctest (a mod you can find on fte's svn) does feature prediction, but still uses an engine builtin to do it, one which DP does not implement (its a stub, so will not crash, but won't work either).
That said, if you set the player's SendEntity field _only_ when the cam is meant to be active, you can still benefit from dp's cl_movement cvar when its not active (which is the only time when you actually can, anyway). However, this can result in the view position snapping to '0 0 0' or so if your network is saturated.
the svc_setview option is basically two lines and will still work in every engine that supports csqc, even that hacked-up winquake version. As far as I am aware, even when saturated, DP will not split the svc_setview and the stuffcmds across packets so there is no possibility of weird view positions at all.
csqctest (a mod you can find on fte's svn) does feature prediction, but still uses an engine builtin to do it, one which DP does not implement (its a stub, so will not crash, but won't work either).
That said, if you set the player's SendEntity field _only_ when the cam is meant to be active, you can still benefit from dp's cl_movement cvar when its not active (which is the only time when you actually can, anyway). However, this can result in the view position snapping to '0 0 0' or so if your network is saturated.
the svc_setview option is basically two lines and will still work in every engine that supports csqc, even that hacked-up winquake version. As far as I am aware, even when saturated, DP will not split the svc_setview and the stuffcmds across packets so there is no possibility of weird view positions at all.
Re: Static camera
I am using svc_setview via ssqc now, works very fine but when the first person view returns in darkplaces the player appears a little higher (actually almost imperceptible detail). there is any possibility to solve this problem?Spike wrote:I generally don't recommend sending the player via csqc unless you want to go fully into csqc. Its quite involved if you want to do it properly - doing so basically means you can't automatically utilize any engine-based prediction - this is especially true with DP right now.
csqctest (a mod you can find on fte's svn) does feature prediction, but still uses an engine builtin to do it, one which DP does not implement (its a stub, so will not crash, but won't work either).
That said, if you set the player's SendEntity field _only_ when the cam is meant to be active, you can still benefit from dp's cl_movement cvar when its not active (which is the only time when you actually can, anyway). However, this can result in the view position snapping to '0 0 0' or so if your network is saturated.
the svc_setview option is basically two lines and will still work in every engine that supports csqc, even that hacked-up winquake version. As far as I am aware, even when saturated, DP will not split the svc_setview and the stuffcmds across packets so there is no possibility of weird view positions at all.
hi, I am nahuel, I love quake and qc.
Re: Static camera
To Spike :
I was reading the csqctest source. Great work but I will focus on about q4player.qc and the animation
What are md5anim files???
Well, I've been reading a lot about animation in csqc and I have many questions. Well basically I try to have two different mixed animations in a model. Using the basic tutorial of Urre, (sending missiles by csqc) I'll use a simple model dpm: two box with 2 "groups" and 3 joints.
the hierarchy of the joints is of top-down
A
|
B
|
C
______
| A |
|____|
B
______
| |
|_C__|
A controls the top of the box (group) and C controls the lower (group C).
I have basically two framegroups for the model, the first is a little tremor in the group A, the second a litle tremor in the group B.
then after doing this, I only get the boxes are placed one above the other( like glued) with a strange animation:?
What suggestions can you give me?? Is incorrect the hierarchy of joints or code or both?
Thanks in advance
I was reading the csqctest source. Great work but I will focus on about q4player.qc and the animation
What are md5anim files???
Well, I've been reading a lot about animation in csqc and I have many questions. Well basically I try to have two different mixed animations in a model. Using the basic tutorial of Urre, (sending missiles by csqc) I'll use a simple model dpm: two box with 2 "groups" and 3 joints.
the hierarchy of the joints is of top-down
A
|
B
|
C
______
| A |
|____|
B
______
| |
|_C__|
A controls the top of the box (group) and C controls the lower (group C).
I have basically two framegroups for the model, the first is a little tremor in the group A, the second a litle tremor in the group B.
Code: Select all
void() RocketThink =
{
if (!self.skeletonindex)
self.skeletonindex = skel_create(self.modelindex);
self.frame = 1;
//self.frame1time
skel_build(self.skeletonindex, self, self.modelindex, 0, 0, skel_find_bone (self.skeletonindex, "B"));
self.frame = 1;
//self.frame1time
skel_build(self.skeletonindex, self, self.modelindex, 0, skel_find_bone(self.skeletonindex, "B"), skel_get_numbones(self.modelindex));
...
What suggestions can you give me?? Is incorrect the hierarchy of joints or code or both?
Thanks in advance
hi, I am nahuel, I love quake and qc.