Page 1 of 2 12 LastLast
Results 1 to 10 of 11

Thread: Camera origin

  1. #1
    Private
    Join Date
    Jan 2013
    Location
    Hungary
    Posts
    113
    Thanks
    10
    Thanked 74 Times in 45 Posts

    Camera origin

    Hi,

    is it any method to get the origin of the camera view? I know the "tag_eye", but it works aright only in first person, but I use thirdperson in my mod. So can I solve somehow that the players shoot the center of the view?

  2. #2
    Assadministrator kung foo man's Avatar
    Join Date
    Jun 2012
    Location
    trailerpark
    Posts
    2,011
    Thanks
    2,102
    Thanked 1,084 Times in 753 Posts
    Hey, i've a good function for that, but the problem is, that it needs getStance(), which is no default function (you need to find it somewhere or maybe somebody will post here some hints).

    PHP Code:
    getRealEye()
    {
        
    player self;

        
    stance player std\player::getStance();
        
        
    offset 0;
        switch (
    stance)
        {
            case 
    "stand"offset =  20; break;
            case  
    "duck"offset =   0; break;
            case   
    "lie"offset = -30; break;
            
    //default: offset = getcvarint("offset");
        
    }

        
    realEye player getEye() + (0,0,offset);
        return 
    realEye;

    Maybe player getEye() is also already good enough?
    timescale 0.01

  3. #3
    Private
    Join Date
    Jan 2013
    Location
    Hungary
    Posts
    113
    Thanks
    10
    Thanked 74 Times in 45 Posts
    I thought for this:
    Click image for larger version. 

Name:	shot0002.jpg 
Views:	83 
Size:	432.9 KB 
ID:	314

    In 3rd person if I'm looking up/down or leaning, the player don't shoot at the center of the view camera.

  4. #4
    Assadministrator IzNoGoD's Avatar
    Join Date
    Aug 2012
    Posts
    1,718
    Thanks
    17
    Thanked 1,068 Times in 674 Posts
    If i remember correctly, the 3rd person used a few client-cvars to determine camera offsets. Maybe those will provide you with the insight you need?
    They should all start with cg_thirdperson.

  5. #5
    Private
    Join Date
    Jan 2013
    Location
    Hungary
    Posts
    113
    Thanks
    10
    Thanked 74 Times in 45 Posts
    I'd like to make only a 3rd person mod but i don't know how to solve the exact shooting.

  6. #6
    Assadministrator kung foo man's Avatar
    Join Date
    Jun 2012
    Location
    trailerpark
    Posts
    2,011
    Thanks
    2,102
    Thanked 1,084 Times in 753 Posts
    Thought some time over it, but the only solution seems to be engine hacking.

    PHP Code:
    onShoot {
        
    manipulate bullet origin for left/right leaning

    timescale 0.01

  7. #7
    Private
    Join Date
    Jan 2013
    Location
    Hungary
    Posts
    113
    Thanks
    10
    Thanked 74 Times in 45 Posts
    I thought I cannot solve this

  8. #8
    Private
    Join Date
    Jul 2013
    Posts
    14
    Thanks
    1
    Thanked 2 Times in 2 Posts
    The camera position in thirdperson is defined by a vector from the player's head, which length is the client cvar cg_thirdPersonRange, and direction can be counted by the player's up angle of view - the stock function getPlayerAngles()[0]. So,

    1) get the eye position;
    2) knowing that cg_thirdpersonrange is cheat-protected and thus can't be changed by client unless hacked/devmap, you will want to use its default value, 120;
    3) convert player angles to vector;
    4) multiply 2) by 3) and you have it.

    The only problem here is, there is NO CLIPPING! The camera position calculated by this algorithm may get into solid objects, whereas actual camera has collision check. Well, you can simply BulletTrace() it then.
    Last edited by megazor; 6th July 2013 at 05:29.

  9. #9
    Assadministrator kung foo man's Avatar
    Join Date
    Jun 2012
    Location
    trailerpark
    Posts
    2,011
    Thanks
    2,102
    Thanked 1,084 Times in 753 Posts
    Yea, that camera-position could be calculated, but he needs to modificate the origin of thirdperson-bullets
    timescale 0.01

  10. #10
    Assadministrator IzNoGoD's Avatar
    Join Date
    Aug 2012
    Posts
    1,718
    Thanks
    17
    Thanked 1,068 Times in 674 Posts
    Take a look at the cod4mod firing through walls code for ideas on that

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •