Log in to reply

[SCRIPT][WIP] Auto-play vehicle spawn and camera preset tool.

  • As most of you know, I can get caught up by requests every now and again, although for some strange reason, the people making the requests always seem to disappear for the majority of the project. :\

    So anyway, this thread peaked my interest https://forums.gta5-mods.com/topic/5940/automatic-vehicle-spawn-and-rotation

    I kinda like the camera idea and I'm also a fan of automation of processes, so it got me interested. Although typically, since posting the initial post, the OP hasn't been back online.

    So anyway, I started this yesterday and so far have this.

    The idea behind the way it works is a two-stage mod. On the one hand, is the preset creator, where you have control of a custom camera that allows full free movement, or targeted movement around vehicle bones. It is fully gamepad controlled and you have FOV controls available on the triggers, as well as being able to switch into offset mode to give the camera an offset for the target positions.

    As you can see from the video, you basically lock onto different bones or move the camera freely, and then add that position as a preset. The cameras will be saved as offsets from the bones, rather than absolute positions, that will mean that if vehicles are bigger or smaller, the camera won't be affected by changes in vehicle size... hopefully.

    Once a preset is stored, you can go back to that at any point and make adjustments as required. I will also be adding the ability to save preset files (the loading is already there, I just haven't got a file to load yet because I haven't added the save feature :slight_smile: ), which you will then be able to use in playback mode. This will be a full screen, hud-free, slideshow type mode, with screenfades etc.

    You will also see that there is a vehicle name in the menu and this is for the ability to cycle through loaded sets of vehicles. So if you have a collection of addons you want screenshots for, you could create a text file with their names in it, add a set of camera positions and then automatically apply those positions to each vehicle in turn, either videoing the process, or taking a screengrab on each screen.

    I have no idea how needed this is, or how useful this is... but it's another learning process for myself, so if nothing comes of it, I will have learned some new tricks. :)

    You'll have to forgive the topic title... I have no idea what to call this... suggestions on a postcard to...

  • Funny how the minute you post something, the ideas start jumping into your head... A whole new category of preset parameters just came to me that I think could make this useful.

    Weather: Set this globally for the whole preset. I think the weather changes too slowly for this to be effective per shot, but it might work for the whole playback sequence.
    Time of Day: Set a time per camera preset
    Lights: On/Off/Auto based on time of day.
    Doors: Open/Closed on a per-door basis

    I would like to get DOF in there but for the life of me, I cannot get it working reliably. I have a camera-effects test mod and in there it works perfectly, when I try and add the same lines of code into any other mod, it seems to fail miserably and I have no idea why. :(

    The daft thing is, if I run a second mod that does nothing but apply the DOF effect, that effect carries over into the mod it won't work in... bizarre just doesn't seem to cover it.

    Edit: I could probably add Roof and Window position to this list as well.

  • So last night was mainly involved with the implementation of a workaround for a game-engine limitation. GetOffsetFromWorldCoords() is a really useful function but it has limitations in that it has to be entity based. You can't do this for instance:

    Vector3 _bonePosition = new Vector3(100,100,100);
    Vector3 _cameraPosition = new Vector3(150,150,150);
    Vector3 _offset = _position.GetOffsetFromWorldCoords(_cameraPosition);

    I needed that function to be location based, so my solution was to spawn a golf ball, make it invisible and then as you switch through each bone preset, it locates itself at the bone position and inherits the rotation of the vehicle. That way, I can save and load offset positions that are relative to that bone, rather than the whole vehicle. That should mean that as vehicles change size, the camera remains in (relatively) the same position.

    I could have done it by using a scaling factor but that means having to store the scale of the original vehicle in the preset and relying on the fact that any additions to that preset set, are done using the same vehicle. That introduces a risk of error, so it's not a viable option.

    I have also fixed an annoying quirk that caused the left and right offset control to get flipped when you were on the opposite side of an object.

    Saving camera presets is now implemented, which basically dumps out (so far) a collection of lines like this:


    I was going to use XML but to be honest, XML parsing and writing is a pain in the backside and just adds a huge overhead of text for no positive benefit. The colon : character is being used as I cannot rely on the comma being used as a delimiter in countries where it is also used as a decimal separator. I might need to change that though when I add time to the presets.

    Edit: LMAO, I can be so dumb sometimes... :blush:

  • So as a result of last night and today we now have multiple menus working to give us a separate camera and environment/vehicle menus... all of which works quite nicely.

    One issue that the environment/vehicle menu did raise, was with car doors. I wanted to have it so you could open individual doors as required but of course, not all vehicles have all doors, or any doors for that matter. The problem with that is you might create a preset that looks inside the back door but have a vehicle in your list that only has three doors. So you're suddenly faced with a nice close-up of, well... a door... not ideal.

    I have a system in place that can validate the vehicle against a set of bones, and I could make it so that if you have a preset where say door_dside_r is supposed to be open but there is no bone for that in the model, then it could skip to the next preset. We shall see...

    My aim for today is to get the playback mode working with the screen fades and everything, so that I can get an idea of how worthwhile this is all going to be. It's only been a couple/few days so far, so if it turns out to be not very good, I haven't lost much. And considering the person who posted the request has not been back on site since, I think I can consider the time I already spent on that as a lost cause anyway... so a few more days lost isn't going to change much.

  • Managed to get a reasonably functional playback mode now implemented. It isn't doing the full bone-relative camera placement yet using the offsets but this shows the preset playback and vehicle switching, which seems to work fairly well. What I mean by that, is that it is calculating absolute positions and using them, rather than relative positions which I intend for it to use in the final version.

    Still plenty to do but I quite like where it's at right now and considering the stupid bugs I have been adding, it's almost a miracle. :D

    Also managed to get preset loading and saving working fine now, which means I don't have to mess about creating a new set every time I test something.

    Edit: Sorry for the silent movie syndrome my videos usually have, I don't have time to put them to music, they're just functionality demos. :D

  • One small final update on this before I quit for the night... just added a random time of day feature to make sure that changing the time between presets works. Added a check that turned the lights on between certain periods and I like the fact that even though you're seeing the same set of camera angles, you're not seeing the same picture. One car might be at noon, the next at sunset and maybe the next at late night with its lights on.

    It's kinda like a GTAV screensaver. :D

  • Just a small update at this stage in the day. Spent some time cleaning up the menu code so that functions that were assigned to the existing "Spawn Vehicle" option are now moved directly into the "Camera Mode" function, which streamlines the main menu down to just two entries. Spent far too long chasing more stupid bugs as a result. :blush:

    Added some code that will identify if the engine is at the front of the car or the back. That will mean that when I get the offset system fully in place, the camera will shift to the back of a rear-engine car and look forwards, rather than be at the front looking backwards.

    Also considering whether to allow this to cater for motorcycles or not... I think some of them would look really nice in this but it's another case of validating the existence of bones to do so. Things like number of wheels and lights cause a problem, so that will need dealing with. I'm not going to be extending this to aircraft, helicopters and boats at this time though, I want to concentrate on similar types of vehicles.

  • So tonight has been a bit of a fight, again caused by lack of concentration and observation. So this is just a small demo of how the offset system works. If you notice the shot towards the steering wheel, it always looks at the wheel no matter how low or high the vehicle is. Just after doing all this, I realised that I might have gone the long way round to solving a problem that wasn't really a problem... pretty much describes anything I do programming wise. :(

    You'll also notice that whilst I set the cameras on a front-engine vehicle, when the first vehicle appears in the playback, the view orients itself to the rear, where the engine is on that car... so at least that bit works.

    It's also got the more streamlined menu in this (well, it hasn't got the spawn option in, it's been moved into the camera mode when you enter it), plus the time of day changes... there's probably not much visual change since the last version but watching a pretty video is nicer than reading my waffling text. :D It's also recorded on my Windows 10 version, so it looks a bit nicer than usual... although trying to convert the HEVC video was a complete pain. 400MB and YouTube lets me upload it and then says "Nope, can't process that" :angry:

    Anyway, enough talk, more pictures. (I've just re-uploaded this with the glitches removed, hence the new thumbnail)

  • @LeeC2202 looks great for screenshots and looks like it could be useful for driving with new camera angles as well.

  • @Willief23 The person who posted the original request wanted something for screenshots and it probably has very little use beyond that. My thinking was that if people regularly took screenshots of vehicles, they could simply add them to a list, create a set of presets and let the mod play them. Set your screen-capture software to capture at regular intervals, and you've got an auto-grabber system.

    Because it works in the game engine though, it means you've got control over time (or even weather if that's what people want), so you don't have to record multiple video clips to take screenshots in the Rockstar editor at different times of day.. I just wish I could get the damned DOF working. :(

    Edit: And the forum disappears under a sea of spam... time to take Zebedee's advice methinks.


    Ah, now I got a better understanding what you're trying to accomplish. This system combined with V Autodrive eg.
    Astonishing what your coding. Hats off.

  • After doing what felt like 15 rounds with Mike Tyson (a programming version of Mike Tyson that is), I have finally got the Extras Menu fully working. This menu allows you to set individual times of day for a particular preset, or you can choose to let the mod choose a random time of day for you. Any times chosen between 19:00 and 07:00 will result in the lights coming on if you are in random mode. If you are in a specified time mode, you can choose the light state manually.

    You now also have control of four opening doors etc... Boot, Bonnet, Driver's door and front passenger door. I was going to allow opening of all doors but it seemed fairly pointless considering what is in the back of most cars. These are also selectable, in any combination on a per-preset basis.

    Sorry if you're getting bored with the videos, at least this one has a bit more variety with addons and vanilla cars included. :slight_smile: It does also demonstrate how being able to choose a time-slot can really optimise the camera position... 2nd preset. It also shows how even a long estate vehicle maintains the relative offset position, so I think that part was worth adding after all... and after looking more into it, I don't think the game did have options that would work as well as this system did.

    I'm probably going to include car rotation when you first start camera mode as well, as placing based on the player's rotation isn't ideal... it's just easy for now.

    Edit: And I had another encounter with the now typical "Let's not do things as standard because I'm making a vehicle mod" problem. Found an addon car where you couldn't see into the engine, so instead of just locating the engine dummy where the engine would be, they left it out completely... why? Put the bleeding things in if they're supposed to be there for goodness sakes... jeez!!! :angry:

  • Well this afternoon was a major stresser... one of those where the problem I had seemed so relatively simple to fix but I just couldn't get my head round it but as usual, it was something vital to this working. Tonight, it just clicked into place and everything worked.

    That's probably the biggest part of being a non-coder that people might struggle to understand... and that's the frustration from your mind seeing a problem but it sometimes struggles to break down the basic logic required to solve it. It causes a frustration spiral that just takes you further away from solving the problem and it's why distractions, no matter how small or insignificant they might seem, can be like putting a brick wall in front of the problem.

    What are the end results of this you might ask? Well it now makes the whole system portable. And as I discovered last night while things still weren't quite working right, can sometimes throw up some unique moments. Now remembering that this is on my development version of GTAV where I sacrifice graphical quality for fluidity and stability, this picture popped up. I had created a set of presets in the area behind Trevor's house (where I do all my testing), so there's not much to see there. But while testing I thought, I know, I'll drive to the lakeside and play back those presets... and got this.

    alt text

    So that's how this now works, you create presets, drive to a location, load the presets and play them back and they will play with all the preset camera angles, time of day etc... in that location, not where you created the preset.

    What I am hoping for from this tool, is to hand people the ability to have a flexible, portable creation tool. Where instead of having to drive to a location, create a clip at the right time of day, then go into the editor to try and find a screenshot, you have the power to manipulate the time of day, the position of the car, the position of doors etc... And if the time of day isn't quite right for the shot, then you load the presets, make an adjustment and it now is. If the position of the car isn't quite right, you adjust the car, load the presets and now it is.

    So it's a tool that has limited use but I think it offers unlimited potential for both planned and spontaneous image grabbing and as I found with my other camera mod, that's pretty rewarding.

    I''ll add an Edit: instead of queue jumping again... I have now added bone validation code to the playback process, so that any troublesome vehicles with missing bones will simply miss their turn with that preset. Luckily, having found one that already caused this problem, I had a perfect test vehicle. :D

  • :angry: FFS!!! And now it's NativeUI's turn... am I being illogical here?

    UIMenuListItem.Enabled = true, should mean that you can change the value.
    UIMenuListItem.Enabled = false, should mean that you can't change the value.

    Except NativeUI says "Nah, Enabled = false just means we draw it in grey"... what is the point??? *sigh*

    In all the years I have been doing app development, any control that is disabled ceases to function. You can't click it, you can't change it, it's disabled... it doesn't work. :angry:

    I could fix it but then I'd have an even more unique version of NativeUI... time for bed.

  • So putting last night's fiasco to bed, today has been a bit more productive, albeit with the re-occurrence of a strange bug... I get a lot of those. :\

    Today I have added support for motorcycles using a bone-substitution process. Basically I check to see if the Vehicle.ClassType is a motorcycle, get the current bone which is car specific and then use that value to pull an equivalent value out of a motorcycle bone list. But of course... it could never be just that easy could it... there's always a catch... and there was.

    Getting the coordinate of a vehicle bone, always seemed to return the world position of that bone. Getting the coordinate of some motorcycle bones, returned the position as an offset, not an absolute position.

    So for example, the seat positions got me this:

    [15:28:35] --->> Vehicle bone: seat_pside_f
    [15:28:35] --->> Motorcycle bone: seat_f
    [15:28:35] --->> Position: X: 1964.5840, Y: 3840.9970, Z: 32.0892

    But the headlight got me this:

    [15:28:47] --->> Vehicle bone: headlight_l
    [15:28:47] --->> Motorcycle bone: headlight_l
    [15:28:47] --->> Position: X: 0.8251, Y: 3.9543, Z: 0.6595

    And that was on the Akuma which does have left and right headlights. Oddly, the taillight_r got me a world coordinate. But anyway, all I do is check to see if the X value is less than 20, (which should cover any motorcycle distance from origin to headlight) and if it is, I add the position to the actual vehicle position to get the world coordinate... that seems to work.

    But the end result is that cars or motorcycles can be included in the vehicle list, which is a good thing. :D

    Edit: I am sure you've probably spotted my stupid mistake by now (and now have a better idea of the type I make). Check the X value for being less than 20??? That's going to work really well when the bike is on the left side of the map, where everything in the X is less than 20. :blush: More like check all three values (X, Y and Z) are all less than 20, as there is no way you can be at that location in the map.

  • A night of complete and utter failure as far as progress goes. Spent far too much time troubleshooting problems on here and far too much of that time handing out wrong information... and knowing my luck, incorrect code as well. :(

    Edit: I was right about the code, not so much incorrect, just completely useless as it duplicated a function already provided by the game. :angry:

  • So after yesterday's wasted day (although it's always nice to top up the psychology study), I think it's time to move on with this... There are a couple of things I am going to look at adding today, see if they add anything aesthetically... if not, they will come out again.

    The first one is a result of adding the motorcycle support, that got me thinking... cars always sit flat on the ground but because motorcycles don't and I inherit their rotation, it created some nice off-angle shots. So I'm going to add an option in the Extras menu for random minor rotations to be added. Nothing major, maybe just a maximum of +/- 20 degrees or so.

    I am also going to dig out my screen effects test mod and see if any of those can add anything to the whole visual appearance thing. Possibly not but as this is solely a cosmetic endeavour, why not give it a go I say. :D

    Whilst I was wasting time on a weather mod yesterday, it did reinforce a concern I had about adding a weather option. Everything would be fine apart from those cases where the transition was from wet to dry weather. The puddles remain behind and I'm not sure if that would have a negative effect. Saying that, if I do add it, it will mean yesterday wasn't a total washout (forgive the pun). Worst case is it's another menu option that gets added and removed... it's not like my life is running to a schedule or anything, so I might add that as well. :slight_smile:

  • Frack!! It seems my PC has chosen today to die. I hope it's just a dead cooler, anything more could spell the end of the PC road. :(

    Edit: Well my Corsair water cooler heads for the bin and an old blood-covered fan-cooler takes its place.... really wasn't the day for my PC to play up. :angry: I think part of me wishes the PC had given up altogether, would solve so many problems... but it hasn't, so on we go. *sigh*

  • @LeeC2202 Blood covered fan? :)

  • @Akila_Reigns From the cuts on my hands... it didn't go in easily and given my already fragile state of mind, much rage ensued and blood did flow. :(

  • @LeeC2202 Oh I thought you managed to murder someone with a cooler fan. :smile:
    Edit: Just joking, please don't change to Hyde. Still joking. Sorry about that.

  • @Akila_Reigns :D I had a Zalaman copper cooler years ago that was basically 2KG of copper. I imagine it might just be possible with something like that... This was just a big cooler in a tight corner of my case, an annoying pair of fan clips I couldn't reach and some very sharp cooler fins that shredded my knuckles.

  • @LeeC2202 Get a phase change unit. With some cotton to cover your ears. ;)
    Well, I shouldn't be dragging this thread off topic, good luck with your murderous fan. :smile:

  • @Akila_Reigns No worries. :slight_smile:

  • Today has seen the addition of Screen Effects and Weather to the Extras Menu, so this is just a short video showing what this is capable of now.

    A set of presets were created near Trevor's trailer and then played back on the lakeside. You'll notice that the Porsche only goes through two settings, that's because the playback skips any presets that use a bone not present in the vehicle.

    Need to add the new settings to the save and load options and fix a few little problems. Random camera rotations are still under work but should be in by the end of the day.

Log in to reply

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