3rd Person Camera

A forum to store posts deemed exceptionally wise and useful

What do you think of the camera?

Great!!
33
46%
Good
25
35%
Bad
7
10%
Terrible
7
10%
 
Total votes: 72

Guest

Post by Guest »

nah luvcraft, that isnt it....


I think it has something to do with the createDevice call
AssiDragon
Posts: 158
Joined: Wed Apr 28, 2004 11:03 am
Location: Hungary
Contact:

Post by AssiDragon »

Homer wrote:
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.
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.
I will do it soon. I just merged it with Newton :wink: but I will put it up tonight - when I will arrive back at home from uni. Around 9-10 GMT. :)
Staring through eyes of hate we kill
Are we controlled, or is our own will...?
(Edguy)
AssiDragon
Posts: 158
Joined: Wed Apr 28, 2004 11:03 am
Location: Hungary
Contact:

Post by AssiDragon »

*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.
Staring through eyes of hate we kill
Are we controlled, or is our own will...?
(Edguy)
rsdl
Posts: 13
Joined: Wed May 05, 2004 6:57 am
Location: Soviet Canuckistan

Post by rsdl »

That's awesome work AssiDragon!! I've got a question though, how do i re-enable the mouse rotation controls? Because i want to try and use the mouse movements to control the direction of the character instead of having to use to keys to turn the character around.

thanks in advance!
AssiDragon
Posts: 158
Joined: Wed Apr 28, 2004 11:03 am
Location: Hungary
Contact:

Post by AssiDragon »

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. :wink:
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)
etcaptor
Posts: 871
Joined: Fri Apr 09, 2004 10:32 pm
Location: Valhalla
Contact:

md2 animation with luvcraft's camera

Post by etcaptor »

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.
AssiDragon
Posts: 158
Joined: Wed Apr 28, 2004 11:03 am
Location: Hungary
Contact:

Post by AssiDragon »

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. :)
Staring through eyes of hate we kill
Are we controlled, or is our own will...?
(Edguy)
Guest

Post by Guest »

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?
rsdl
Posts: 13
Joined: Wed May 05, 2004 6:57 am
Location: Soviet Canuckistan

Post by rsdl »

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:
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?
[/quote]
AssiDragon
Posts: 158
Joined: Wed Apr 28, 2004 11:03 am
Location: Hungary
Contact:

Post by AssiDragon »

I am not seeing your code or having any idea how you did it, so I might be wrong. But I guess am not 8)

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)
etcaptor
Posts: 871
Joined: Fri Apr 09, 2004 10:32 pm
Location: Valhalla
Contact:

Post by etcaptor »

ThANKS AssiDragon,
but I cannot assign two animations witch luvcraft cam code /main.cpp/
When I trying to use stand animation when player is idle, I lose almost all frames of second animation /when player run/.
I cannot find the correct place in code to switch this animations.
rsdl
Posts: 13
Joined: Wed May 05, 2004 6:57 am
Location: Soviet Canuckistan

Post by rsdl »

AssiDragon, i wrote bunch of code in the resolve_controls() function to find out the amount the cursor moved from the original point:

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));
	}
then, inside the FixedCam function (i'm using the fixed cam and not the rubber cam), there's a simple setRotation

Code: Select all

	camera->setRotation(core::vector3df(0,0,mainCam_rotate));
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
etcaptor
Posts: 871
Joined: Fri Apr 09, 2004 10:32 pm
Location: Valhalla
Contact:

Post by etcaptor »

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:

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;
      }
  .................
  .................
}
AssiDragon
Posts: 158
Joined: Wed Apr 28, 2004 11:03 am
Location: Hungary
Contact:

Post by AssiDragon »

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:

Code: Select all

float CamOffSetH = 50f;
float Height = 30f;
Then change it this way:

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;
	}
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).
Staring through eyes of hate we kill
Are we controlled, or is our own will...?
(Edguy)
rsdl
Posts: 13
Joined: Wed May 05, 2004 6:57 am
Location: Soviet Canuckistan

Post by rsdl »

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 :D
Post Reply