3rd Person Camera
-
- Posts: 158
- Joined: Wed Apr 28, 2004 11:03 am
- Location: Hungary
- Contact:
I will do it soon. I just merged it with Newton but I will put it up tonight - when I will arrive back at home from uni. Around 9-10 GMT.Homer wrote:Great! Can you please upload these files? I have some problems with my 3rd person camera, so I would be very happy if I could try your code.AssiDragon wrote:On a sidenote, I broke the camera into camera.cpp, main.cpp and main.h files so it's relatively easy to put it into other stuffs if someone needs it - camera is now being handled by two functions, depending what you want.
Staring through eyes of hate we kill
Are we controlled, or is our own will...?
(Edguy)
Are we controlled, or is our own will...?
(Edguy)
-
- Posts: 158
- Joined: Wed Apr 28, 2004 11:03 am
- Location: Hungary
- Contact:
*eck*
So, a bit late but here it is... I was struggling to make newton work with the player MD2 modell, so far without any success :/ if someone can help me it'd be very appreciated.
Here is the thing you asked though:
With newton: http://assidragon.uw.hu/programming/new ... camera.ZIP
Without newton, plain 3rd view: http://assidragon.uw.hu/programming/simple3rdview.zip
In Newton one there is a problem (you can go through boxes) but I dont consider that important - actually, I want to make collisions purely Newton based and not mix it with Irrlicht... but that would take figuring how to get that darn MD2 work with Newton. Gah.
So, a bit late but here it is... I was struggling to make newton work with the player MD2 modell, so far without any success :/ if someone can help me it'd be very appreciated.
Here is the thing you asked though:
With newton: http://assidragon.uw.hu/programming/new ... camera.ZIP
Without newton, plain 3rd view: http://assidragon.uw.hu/programming/simple3rdview.zip
In Newton one there is a problem (you can go through boxes) but I dont consider that important - actually, I want to make collisions purely Newton based and not mix it with Irrlicht... but that would take figuring how to get that darn MD2 work with Newton. Gah.
Staring through eyes of hate we kill
Are we controlled, or is our own will...?
(Edguy)
Are we controlled, or is our own will...?
(Edguy)
-
- Posts: 158
- Joined: Wed Apr 28, 2004 11:03 am
- Location: Hungary
- Contact:
I think you could do it with checking the mouse's X and Y coordinates and rotate the view accordingly.
EDIT: adding some guidelines. Set the X and Y mousecoordinates to the middle of the screen at startup. Then check how did the mouse coords change, rotate the player and view accordingly, and then set them back to the middle of the screen. That way you can keep rotating the player with mouse in any way as long as you want.
EDIT: adding some guidelines. Set the X and Y mousecoordinates to the middle of the screen at startup. Then check how did the mouse coords change, rotate the player and view accordingly, and then set them back to the middle of the screen. That way you can keep rotating the player with mouse in any way as long as you want.
Last edited by AssiDragon on Wed May 05, 2004 2:55 pm, edited 1 time in total.
Staring through eyes of hate we kill
Are we controlled, or is our own will...?
(Edguy)
Are we controlled, or is our own will...?
(Edguy)
md2 animation with luvcraft's camera
Hi luvcraft,
I cannot to reach to right md2 animation with your camera code, when player is idle an when player walk. Any idea? Can you help me?
Thanks in advance.
I cannot to reach to right md2 animation with your camera code, when player is idle an when player walk. Any idea? Can you help me?
Thanks in advance.
-
- Posts: 158
- Joined: Wed Apr 28, 2004 11:03 am
- Location: Hungary
- Contact:
Quake2 default MD2 framelist:
(framename, first frame number of that frame, last frame number of the rame)
FRAME_stand 0 -- 39
FRAME_run 40 -- 41
FRAME_attack 46 -- 53
FRAME_pain 54 -- 65
FRAME_jump 66 -- 71
FRAME_flip 72 -- 83
FRAME_salute 84 -- 94
FRAME_taunt 95 -- 111
FRAME_wave 112 -- 122
FRAME_point 123 -- 134
FRAME_crstnd 135 -- 153
FRAME_crwalk 154 -- 159
FRAME_crattak 160 -- 168
FRAME_crpain 169 -- 172
FRAME_crdeath 173 -- 177
FRAME_death 178 -- 197
These are all the moves a default Quake2 player MD2 can perform.
(framename, first frame number of that frame, last frame number of the rame)
FRAME_stand 0 -- 39
FRAME_run 40 -- 41
FRAME_attack 46 -- 53
FRAME_pain 54 -- 65
FRAME_jump 66 -- 71
FRAME_flip 72 -- 83
FRAME_salute 84 -- 94
FRAME_taunt 95 -- 111
FRAME_wave 112 -- 122
FRAME_point 123 -- 134
FRAME_crstnd 135 -- 153
FRAME_crwalk 154 -- 159
FRAME_crattak 160 -- 168
FRAME_crpain 169 -- 172
FRAME_crdeath 173 -- 177
FRAME_death 178 -- 197
These are all the moves a default Quake2 player MD2 can perform.
Staring through eyes of hate we kill
Are we controlled, or is our own will...?
(Edguy)
Are we controlled, or is our own will...?
(Edguy)
uhh..forgot to enter my username. Oh and another thing, how would you go about adding new controls to the app? such as strafing or crouching.
that was me btw:
that was me btw:
[/quote]awesome! thanks for the tip AssiDragon! And the md2 framelist But i can't seem to get X axis rotation working (up/down), it's probably because the cam functions control the cam before the mouse controls kicks in eh?
-
- Posts: 158
- Joined: Wed Apr 28, 2004 11:03 am
- Location: Hungary
- Contact:
I am not seeing your code or having any idea how you did it, so I might be wrong. But I guess am not
The camera update functions update the camera position according to the player position, and some external modifiers - HEIGHT for RubberChaseCam and CamOffSetH (or sg like that) for FixedChaseCam.
I'd advise taking out those things from being defined, and use them variables (int or maybe unsigned int because peeps dont really wanna use negative numbers I guess). Then you could change those values directly according to the mouse X changes, ,and the camupdate functions would already take that into count.
I guess you did it otherwise, and the problem with your method is while you make the camera go up and down the update function will overwrite your changes.
The camera update functions update the camera position according to the player position, and some external modifiers - HEIGHT for RubberChaseCam and CamOffSetH (or sg like that) for FixedChaseCam.
I'd advise taking out those things from being defined, and use them variables (int or maybe unsigned int because peeps dont really wanna use negative numbers I guess). Then you could change those values directly according to the mouse X changes, ,and the camupdate functions would already take that into count.
I guess you did it otherwise, and the problem with your method is while you make the camera go up and down the update function will overwrite your changes.
Staring through eyes of hate we kill
Are we controlled, or is our own will...?
(Edguy)
Are we controlled, or is our own will...?
(Edguy)
AssiDragon, i wrote bunch of code in the resolve_controls() function to find out the amount the cursor moved from the original point:
then, inside the FixedCam function (i'm using the fixed cam and not the rubber cam), there's a simple setRotation
mainCam_rotate is the rotation amount. It doesn't seem to work. I hope you can help.
Oh, and another question, how do you add actions like straffing and/or crouching? I don't see how you coded the actual action for the model.
etCaptor: try using setFrameLoop, i.e. model->setFrameLoop(firstframe#,secondframe#);
the walk loop is from frame 0 to 320, the run loop is from 320 to 360
Code: Select all
// Z ROTATION (UP & DOWN) - CAMERA SHOULD ROTATE NOT CHARACTER ON Z AXIS
if ((previousMousePosition.Y < device->getCursorControl()->getPosition().Y)
||
(previousMousePosition.Y > device->getCursorControl()->getPosition().Y))
{
mainCam_rotate += device->getCursorControl()->getPosition().Y - previousMousePosition.Y;
cam->setRotation(core::vector3df(0,0,mainCam_rotate));
}
Code: Select all
camera->setRotation(core::vector3df(0,0,mainCam_rotate));
Oh, and another question, how do you add actions like straffing and/or crouching? I don't see how you coded the actual action for the model.
etCaptor: try using setFrameLoop, i.e. model->setFrameLoop(firstframe#,secondframe#);
the walk loop is from frame 0 to 320, the run loop is from 320 to 360
Well, I have tryed to set animations, when player stand and run. For now this code works /I use luvcraft's camera code/
In class lass MyEventReceiver I use this modification:
In class lass MyEventReceiver I use this modification:
Code: Select all
bool playerisrunning;
bool playerisstanding;
class MyEventReceiver : public IEventReceiver
{
..............
.............
if(k)
{
if(event.KeyInput.PressedDown)
{
controls |= k;
if(!playerisrunning)
{
p1->setFrameLoop(320, 360);
playerisrunning = true;
playerisstanding = false;
}
}
else
{
controls ^= k;
if(!controls & C_UP + C_DOWN +C_LEFT + C_RIGHT)
if(!playerisstanding)
{
//p1->setFrameLoop(0, 79*8);
p1->setMD2Animation(irr::scene::EMAT_STAND);
playerisstanding = true;
playerisrunning =false;
}
}
return true;
}
.................
.................
}
-
- Posts: 158
- Joined: Wed Apr 28, 2004 11:03 am
- Location: Hungary
- Contact:
rsdl, I don't know if the setRotation was in the right place with inside Fixedcam function. What about my method? Try it this way:
Remove the two definitions and add these instead of them:
Then change it this way:
And you don't have to edit anything else because the FixedCamUpdate function uses CamOffSetH to determine the camera's offset anyway.
As for strafing - the code sets the changes in a "moving" variable, but it's only a single number (it's a simple tutorial you see). To do strafing and such, you have to change moving to vector3df moving, so it can store the moving velocity for all 3 dimensions. Moving is added to the player just a bit above teh line FixedCameraUpdate(stuff here); line in the main code.
As for the MD2 - I will check it when I will be able to compile and check it myself (in uni atm you see).
Remove the two definitions and add these instead of them:
Code: Select all
float CamOffSetH = 50f;
float Height = 30f;
Code: Select all
// Z ROTATION (UP & DOWN) - CAMERA SHOULD ROTATE NOT CHARACTER ON Z AXIS
if ((previousMousePosition.Y < device->getCursorControl()->getPosition().Y)
||
(previousMousePosition.Y > device->getCursorControl()->getPosition().Y))
{
CamOffSetH = device->getCursorControl()->getPosition().Y - previousMousePosition.Y;
}
As for strafing - the code sets the changes in a "moving" variable, but it's only a single number (it's a simple tutorial you see). To do strafing and such, you have to change moving to vector3df moving, so it can store the moving velocity for all 3 dimensions. Moving is added to the player just a bit above teh line FixedCameraUpdate(stuff here); line in the main code.
As for the MD2 - I will check it when I will be able to compile and check it myself (in uni atm you see).
Staring through eyes of hate we kill
Are we controlled, or is our own will...?
(Edguy)
Are we controlled, or is our own will...?
(Edguy)
hey AssiDragon. Thanks for all your help! THey're appreciated. I got straffing and the Z axis mouse to work. I did the straffing by adding another invisible node, but this one is positioned to the left of the character instead of 1.0f in front of it. That way, i can just move to that direction using the existing code