Log in to reply
 

Rear view "mirror"


  • MODERATOR

    In all these years no proper rear view mirror thing has been implemented, mostly probably because it's impossible in some way, either camera-related, rendering-related or something else.

    What if a very basic wireframe, or even a box, using coordinates of a vehicles' bones (and peds bones), are drawn? It wouldn't be pretty or detailed, but it'd give some valuable information for the player, especially when racing or evading the cops.

    So how I envision this happening is:

    1. Get the points on entities behind the camera/vehicle
    2. Translate those points to whatever is in the camera's view (get relative coords to the camera and flip them all?)
    3. Scale the points to some miniscule size and translate them again, inside the car/in camera view
    4. Rear view mirror achieved?

    I'm not sure if some basic translation and scaling would work for this. There's also the thing about perspective. I don't think one can do anything other than a simple isometric projection with this method. Math is also an issue probably regarding scaling/fov/camera stuff where some matrices are used? idk

    I'm giving it a shot somewhen, probably.



  • @ikt said in Rear view "mirror":

    nes (and peds bones), are drawn? It wouldn't be pretty or detailed

    I've been having a lot of ideas about this topic for a while now but i dont know the coding well enough to see it through.


  • MODERATOR

    I'm excited to announce my progress on this for the last days is exactly 0.

    What the heck is wrong with this?

    foreach (var vehicle in allVehicles)
    {
        if (vehicle == playerVehicle)
            continue;
            
        var posHeadlightL = vehicle.GetBoneCoord("headlight_l");
        var posHeadlightR = vehicle.GetBoneCoord("headlight_r");
    
        var posRelHeadlightL = vehicle.GetOffsetFromWorldCoords(posHeadlightL);
        var posRelHeadlightR = vehicle.GetOffsetFromWorldCoords(posHeadlightR);
    
        posRelHeadlightL.Y = -posRelHeadlightL.Y;
        posRelHeadlightR.Y = -posRelHeadlightR.Y;
    
        var posTransHeadlightL = vehicle.GetOffsetInWorldCoords(posRelHeadlightL);
        var posTransHeadlightR = vehicle.GetOffsetInWorldCoords(posRelHeadlightR);
    
        DrawLine(posTransHeadlightL, posTransHeadlightR, Color.White);
    }
    

    edit ok that was dumb i used the wrong object, should've used the playervehicle.


  • MODERATOR

    ok enough for today

    things i can't figure out:

    • scaling and repositioning
    • making it look decent

    i suppose I could shift the reflection plane to the rear view mirror bone (if present) or (with some hacky math to translate GetOffsetFromWorldCoords and GetOffsetInWorldCoords) some coordinate that puts the "mirror" anywhere you'd want, but that's too much effort honestly

    also it's got no shading so ehhhhhhh who cares


Log in to reply
 

Looks like your connection to GTA5-Mods.com Forums was lost, please wait while we try to reconnect.