Page 1 of 2 12 LastLast
Results 1 to 30 of 35

Thread: Sal's Useful Scripts - Tree collisions

  1. #1
    Team Fusion Salmo's Avatar
    Join Date
    Nov 2011
    Posts
    2,332
    Post Thanks / Like
    Total Downloaded
    191.25 MB

    Sal's Useful Scripts - Tree collisions

    This is NOT a solution to tree collissions (YET). I'm posting here to generate discussion/innovation from our C# coders about approaches to detecting tree collisions. My method in pseudo-code is ...

    1. Define each forest areas as a polygon (a set of 2D points)
    2. Make a list of each polygons forrest array (ie a list of 2D points that describe the perimeter of the forest)
    3. Test (frequently) to see if an aircraft is inside a forest polygon & below tree height. (NOTE - This is probblematic as it would be processor intensive).
    4. If so, destroy the aircraft.

    Code:
    using System;
    using maddox.game;
    using maddox.game.world;
    using System.Collections.Generic;
    using maddox.GP;
    using System.Threading;
    using System.ComponentModel;
    using System.Diagnostics;
    
    public class Mission : AMission
    {
        bool DEBUG = true;      // turn on debugging messages in the console
        BackgroundWorker BGworker;
        Stopwatch WorkTimer = new Stopwatch();
    
        List<Point2d[]> forests = new List<Point2d[]>();    // array of polygons around each forrest area on map
        double TreeHeightMetres = 10;   // notional tree height
    
    
        public override void OnBattleStarted()
        {
            base.OnBattleStarted();
    
            BGworker = new BackgroundWorker();
            BGworker.DoWork += new DoWorkEventHandler(BGworker_DoWork);
            BGworker.ProgressChanged += new ProgressChangedEventHandler
                    (BGworker_ProgressChanged);
            BGworker.RunWorkerCompleted += new RunWorkerCompletedEventHandler
                    (BGworker_RunWorkerCompleted);
            BGworker.WorkerReportsProgress = true;
            BGworker.WorkerSupportsCancellation = true;
    
            WorkTimer.Start();
            if (DEBUG) Console.WriteLine("background worker started");
            BGworker.RunWorkerAsync(GetAircraftsList());
        }
    
        public override void OnTickGame()
        {
            base.OnTickGame();
            
            // check for tree collissions
            if (WorkTimer.Elapsed.TotalSeconds > 30)
            {
                if (DEBUG) Console.WriteLine("checking if background worker is running");
                if (!BGworker.IsBusy)
                {   // restart the background worker
                    if (DEBUG) Console.WriteLine("background worker restarted");
                    BGworker.RunWorkerAsync(GetAircraftsList());
                }
                WorkTimer.Restart();
           }
        }
    
        private bool IsPointInsidePolygon(Point2d[] polygon, Point3d point)
        {
            bool isInside = false;
            for (int i = 0, j = polygon.Length - 1; i < polygon.Length; j = i++)
            {
    
                if (((polygon[i].y > point.y) != (polygon[j].y > point.y)) &&
                (point.x < (polygon[j].x - polygon[i].x) * (point.y - polygon[i].y) / (polygon[j].y - polygon[i].y) + polygon[i].x))
                {
                    isInside = !isInside;
                }
            }
            return isInside;
        }
    
        public List<AiAircraft> GetAircraftsList()
        {
            // make a list of all aircraft in the game
            List<AiAircraft> result = new List<AiAircraft>();
            for (int army = 0; army < GamePlay.gpArmies().Length - 1; army++) // for all armies
            {
                List<AiAirGroup> airgroups = new List<AiAirGroup>(GamePlay.gpAirGroups(army));
                for (int i = 0; i < airgroups.Count; i++) // for all airgroups
                {
                    List<AiActor> aircrafts = new List<AiActor>(airgroups[i].GetItems());
                    for (int j = 0; j < aircrafts.Count; j++) // for all aircraft within an airgroup
                    {
                        result.Add(aircrafts[j] as AiAircraft);
                    }
                }
            }
            return result;
        }
    
        public Point2d[] GetBoundingRectangle(Point2d[] points)
        {
            double xmax = double.MinValue;
            double ymax = double.MinValue;
            double xmin = double.MaxValue;
            double ymin = double.MaxValue;
            // get the maximum & minimum x y points
            for (int i= 0; i < points.Length-1; i++)
            {
                if (points[i].x > xmax) xmax = points[i].x;
                if (points[i].y > ymax) ymax = points[i].y;
                if (points[i].x < xmin) xmin = points[i].x;
                if (points[i].y < ymin) ymin = points[i].y;
            }
    
          return new Point2d[]{new Point2d(xmin, ymax), 
                               new Point2d(xmax, ymax), 
                               new Point2d(xmin, ymin), 
                               new Point2d(xmax, ymin)};
    
        }
            
        // ------------------------
        // background worker
        // ------------------------
    
        void BGworker_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
        {
            // The background process is complete. We need to inspect
            // our response to see if an error occurred, a cancel was
            // requested or if we completed successfully.  
            if (e.Cancelled)
            {
                //lblStatus.Text = "Task Cancelled.";
                if (DEBUG) Console.WriteLine("background worker cancelled");
            }
    
            // Check to see if an error occurred in the background process.
    
            else if (e.Error != null)
            {
                //lblStatus.Text = "Error while performing background operation.";
                if (DEBUG) Console.WriteLine("background worker error " + e.Error.Message);
            }
            else
            {
                // Everything completed normally.
                //lblStatus.Text = "Task Completed...";
                if (DEBUG) Console.WriteLine("background worker done");
            }
        }
    
        void BGworker_ProgressChanged(object sender, ProgressChangedEventArgs e)
        {
    
        }
    
        void BGworker_DoWork(object sender, DoWorkEventArgs e)
        {
            // check for tree collissions
            for (int army = 0; army < GamePlay.gpArmies().Length - 1; army++) // for all armies
            {
                if (DEBUG) Console.WriteLine("Processing army " + army.ToString());
                List<AiAirGroup> airgroups = new List<AiAirGroup>(GamePlay.gpAirGroups(army));
                for (int i = 0; i < airgroups.Count; i++ ) // for all airgroups
                {
                    if (DEBUG) Console.WriteLine("Processing airgroup " + airgroups[i].Name().ToString());
                    List<AiActor> aircrafts = new List<AiActor>(airgroups[i].GetItems());
                    for (int j = 0; j < aircrafts.Count; j++) // for all aircraft within an airgroup
                    {
                        if (DEBUG) Console.WriteLine("Processing aircraft " + aircrafts[j].Name().ToString());
                        if (aircrafts[j].Pos().z < TreeHeightMetres && aircrafts[j].IsAlive() && (aircrafts[j] as AiAircraft).IsAirborne())
                        {   // aircraft is lower than tree height, alive & airborne
                            if (DEBUG) Console.WriteLine("Found collision candidate " + aircrafts[j].Name().ToString());
                            for (int k = 0; k < forests.Count; k++) // for all forest polygons
                            {
                                if (IsPointInsidePolygon(forests[k], aircrafts[j].Pos())) // plane inside a forrest?
                                {
                                    (aircrafts[j] as AiAircraft).hitLimb(part.LimbNames.WingL0, 1);    // tree collission occurred
                                    if (DEBUG) Console.WriteLine("background worker aircraft hitnamedpart");
                                }
                            }
                        }
                    }
                }
            }
        }
            
        private static bool CircleEnclosesPoints(Point2d center, float radius2, List<Point2d> points, 
            int skip1, int skip2, int skip3)
        {   // Return true if the indicated circle encloses all of the points.
            for (int i = 0; i < points.Count; i++)
            {
                if ((i != skip1) && (i != skip2) && (i != skip3))
                {
                    Point2d point = points[i];
                    float dx = (float)(center.x - point.x);
                    float dy = (float)(center.y - point.y);
                    float test_radius2 = dx * dx + dy * dy;
                    if (test_radius2 > radius2) return false;
                }
            }
            return true;
        }
    
    }
    Last edited by Salmo; Jun-09-2015 at 09:38.

  2. Likes ♣_Spiritus_♣, ATAG_Lolsav liked this post
  3. #2
    Ace Combat Wombat's Avatar
    Join Date
    Jul 2013
    Location
    Western Aust,N.S.W.,Queensland ,Tasmania
    Posts
    775
    Post Thanks / Like
    Blog Entries
    2
    Total Downloaded
    141.17 MB

    Re: Sal's Useful Scripts - Tree collisions

    I know not this Wizardry you talk of but I sure would like to see this put into play.

  4. Likes GunnyMac liked this post
  5. #3
    Veteran Combat pilot
    Join Date
    Aug 2012
    Posts
    211
    Post Thanks / Like
    Total Downloaded
    33.38 MB

    Re: Sal's Useful Scripts - Tree collisions

    Salmo vous pouvez nous donner un exemple avec une mission (mis + cs)

    Salmo Can you give us an example with a mission (mis + cs)

  6. #4
    ATAG_Colander's Avatar
    Join Date
    Nov 2011
    Location
    Bir Tawil
    Posts
    11,128
    Post Thanks / Like
    Total Downloaded
    255.73 MB

    Re: Sal's Useful Scripts - Tree collisions

    Salmo,

    You can save a LOT cpu by doing a pre-filter with a box or a circle before doing point in polygon.

  7. #5
    Team Fusion Salmo's Avatar
    Join Date
    Nov 2011
    Posts
    2,332
    Post Thanks / Like
    Total Downloaded
    191.25 MB

    Re: Sal's Useful Scripts - Tree collisions

    Quote Originally Posted by ATAG_Colander View Post
    Salmo,

    You can save a LOT cpu by doing a pre-filter with a box or a circle before doing point in polygon.
    Thankyou Colander. This was just a starting point, of course any algorithm will need optimising. thankyou for the advice

    If the test is going to be run multiple times there are ways to pre-calculate tables to help, such as a grid of cells marked as [definitely inside (green in image), outside (red), and maybe (blue)], only points that fall in the blue cells need to be tested against the polygon.
    Last edited by Salmo; Jun-08-2015 at 10:38.

  8. #6
    ATAG_Colander's Avatar
    Join Date
    Nov 2011
    Location
    Bir Tawil
    Posts
    11,128
    Post Thanks / Like
    Total Downloaded
    255.73 MB

    Re: Sal's Useful Scripts - Tree collisions

    Yes, you could pre-calculate a bitmap but it will eat up memory fast if you want quality.
    You have to be detailed as you don't want to mark a collision when a plane 10 meters outside the forest.

  9. #7
    Ace
    Join Date
    May 2013
    Location
    Stamford, Lincs, UK
    Posts
    1,033
    Post Thanks / Like
    Blog Entries
    8
    Total Downloaded
    7.46 MB

    Re: Sal's Useful Scripts - Tree collisions

    Interesting idea Salmo. My concern is there must be a shed load of forest areas on the Channel map. To map each one to a polygon, you're really going to have to do it manually yes? Is that practical?

  10. #8
    Admin ATAG_Snapper's Avatar
    Join Date
    Nov 2011
    Location
    Kitchener, Ontario, Canada
    Posts
    11,630
    Post Thanks / Like
    Total Downloaded
    406.29 MB

    Re: Sal's Useful Scripts - Tree collisions

    As a temporary work around, would it be possible to toggle trees on/off by a keyboard or joystick button? This would negate any gaming advantage to evading detection/pursuit by running through trees.


    HP Omen Laptop 15, AMD Ryzen 5 5600H 16 GB DDR4 RAM, NVIDIA GeForce RTX 3060 Laptop GPU 6 GB VRAM Win 11 64 bit 22H2 (KB5020044), Nvidia GeForce Driver ver 527.56, TrackIR 5, Gear Falcon Trim Box, Gear Falcon Throttle Quadrant, TM16000 joystick, TM Warthog HOTAS, CH Quadrant, Saitek Pro Combat rudder pedals
    VR: None
    Installation path: C:\Program Files (x86)\Steam\steamapps\common\IL-2 Sturmovik Cliffs of Dover Blitz

  11. #9
    ATAG_Colander's Avatar
    Join Date
    Nov 2011
    Location
    Bir Tawil
    Posts
    11,128
    Post Thanks / Like
    Total Downloaded
    255.73 MB

    Re: Sal's Useful Scripts - Tree collisions

    Quote Originally Posted by ATAG_Snapper View Post
    As a temporary work around, would it be possible to toggle trees on/off by a keyboard or joystick button? This would negate any gaming advantage to evading detection/pursuit by running through trees.
    Well, that's the other problem. Trees should not be off for low end systems but there should be something like 1946 "trees" instead.

  12. #10
    Supporting Member
    Join Date
    Dec 2011
    Posts
    1,009
    Post Thanks / Like
    Total Downloaded
    820.0 KB

    Re: Sal's Useful Scripts - Tree collisions

    Quote Originally Posted by SoW Reddog View Post
    Interesting idea Salmo. My concern is there must be a shed load of forest areas on the Channel map. To map each one to a polygon, you're really going to have to do it manually yes? Is that practical?
    Me thinks Salmo has that part covered, not a manual task. It is more about the shear amount of data to be calculated while game is running.

  13. #11
    Public Relations ATAG_Lewis's Avatar
    Join Date
    Jan 2012
    Location
    Sheffield UK
    Posts
    7,253
    Post Thanks / Like
    Total Downloaded
    506.15 MB

    Re: Sal's Useful Scripts - Tree collisions

    Quote Originally Posted by Combat Wombat View Post
    I know not this Wizardry you talk of
    lol.....hahaha...not just me then
    "The trouble with the world is that the stupid are cocksure and the intelligent are full of doubt.'' - Bertrand Russell
    1.618 - You know this number?
    My Turing machine :CPU: Intel Core i7 2700K 3.50GHz Sandybridge, Motherboard: Asus Maximus IV Extreme -Z Intel Z68 (Socket 1155) PCI-Express DDR3,
    RAM: 8GB (2x4GB) DDR3 Dual Channel Kit, Graphics Card: Nvidia GeForce GTX 970 4096MB GDDR5, OS:Windows 10
    Joystick: Microsoft Sidewinder II ForceFeedback Joystick, Throttle: CH Products Pro Throttle
    ATAG_Lewis Youtube Channel

  14. #12
    Ace
    Join Date
    May 2013
    Location
    Stamford, Lincs, UK
    Posts
    1,033
    Post Thanks / Like
    Blog Entries
    8
    Total Downloaded
    7.46 MB

    Re: Sal's Useful Scripts - Tree collisions

    Quote Originally Posted by ATAG_Marmus View Post
    Me thinks Salmo has that part covered, not a manual task. It is more about the shear amount of data to be calculated while game is running.
    Oh yes? Cool. How?

    What about areas where roads or rivers pass through blocks of trees? Will there be a gap which is flyable with a small enough wingspan?

    In reference to the calculation, I would start by checking aircraft altitude, you don't need to calculate location of anything that's above tree height, or indeed still on the ground.

  15. #13
    Team Fusion Salmo's Avatar
    Join Date
    Nov 2011
    Posts
    2,332
    Post Thanks / Like
    Total Downloaded
    191.25 MB

    Re: Sal's Useful Scripts - Tree collisions

    Thankyou for comments gents. This will be quite a difficult nut to crack for all the reasons mentioned by comments above. 1st post updated with some WIP code for anyone who wants to play with. Code does not work though.

    PROBLEMS
    1. How to define forest areas? - In this case, I propose polygons, but there may be a more efficient method.
    2. How to detect aircraft collisions?
    * minimum number of testing cycles/CPU use needed.
    * test for conditions that will exclude most aircraft first (pre-filter) ie only airborn aircraft below a cetrtain altitude need testing.
    * how to get aircraft altitude above ground level?
    3. How to detect which part of the aircraft has the collission & break that part? - Would it be better to use the code's already built 3D model hit-box algorithms?
    Last edited by Salmo; Jun-09-2015 at 09:42.

  16. #14
    Ace
    Join Date
    May 2013
    Location
    Stamford, Lincs, UK
    Posts
    1,033
    Post Thanks / Like
    Blog Entries
    8
    Total Downloaded
    7.46 MB

    Re: Sal's Useful Scripts - Tree collisions

    1. Not sure I can offer an alternative, unless you can pick up the ground texture (LANDTEX?) at the aircraft's location, similar to what is done with the ASR scripts.
    2a. probably have to test every second?
    b. Exclude any aircraft already collided, on the ground or above the tree threshold
    c. Easy. Use the parameter.ASL/AGL (forgotten exactly, but have code at home)
    3. Why bother detecting/determining what part is hit. If the object is to penalise anyone in the trees, then make it punative. Loss of both wings should suffice....

  17. #15
    Ace
    Join Date
    May 2013
    Location
    Stamford, Lincs, UK
    Posts
    1,033
    Post Thanks / Like
    Blog Entries
    8
    Total Downloaded
    7.46 MB

    Re: Sal's Useful Scripts - Tree collisions

    In your loops, I'd also have a break after a collision is detected, as it doesn't need to check any further.

    Additionally, if you have a notional "centre" location of each area, you could restrict the forest areas you want to check by limiting those within say 2km of the planes location. Lots of checks avoided?

  18. #16
    Team Fusion Salmo's Avatar
    Join Date
    Nov 2011
    Posts
    2,332
    Post Thanks / Like
    Total Downloaded
    191.25 MB

    Re: Sal's Useful Scripts - Tree collisions

    Those that have some interest in this might care to look into the maddox.core.IMesh interface & the maddox.core.WHMesh methods. There are detectcollision methods in there

  19. #17
    Supporting Member
    Join Date
    Dec 2011
    Posts
    1,009
    Post Thanks / Like
    Total Downloaded
    820.0 KB

    Re: Sal's Useful Scripts - Tree collisions

    Quote Originally Posted by SoW Reddog View Post
    Oh yes? Cool. How?

    What about areas where roads or rivers pass through blocks of trees? Will there be a gap which is flyable with a small enough wingspan?

    In reference to the calculation, I would start by checking aircraft altitude, you don't need to calculate location of anything that's above tree height, or indeed still on the ground.
    I believe it was published in a TF update a while back. There are splines that define the outlines of all tree areas (and roads and rivers, and other objects). The splines would probably be too much data to process, but I would think they could be modified via code to produce a simpler generic outline, similar to how Salmo mentioned above. This simpler outline could be produced from the spline files as a separate, static, smaller database.

    As an alternate path, the tree groups are always from one texture (at least the majority of them are). If I recall properly, I believe Salmo already discovered the built in code to check the texture on ground at each location. A comparison could be done against this to see if plane is over the texture at a certain low elevation. This would definitely be "less" perfect because in some cases the trees are suppressed via a tree mask. But may give better performance.

  20. #18
    Supporting Member Tinkicker's Avatar
    Join Date
    Nov 2014
    Location
    North Yorkshire
    Posts
    413
    Post Thanks / Like
    Total Downloaded
    0

    Re: Sal's Useful Scripts - Tree collisions

    Firstly as a bomber boy, tree collisions will mean suicide for me. The only chance of surviving when the tab 71 boys are online is to put my shaking, cannon shell riddled, control surface challenged plot onto the ground asap and hide in a french girls hayloft. Finding a field large enough to put down in without ploughing through a hedgerow and exploding would be virtually impossible from low level.

    On a more serious note, a small town between my usual initial point and final run in to the airfield target to the south of calais (campaigne du guines) has a small town with either a flagpole or an antenna on top of a building that I have hit on a couple of occasions and lost a wing.

    Would a quick fix be to put a significant number of these poles into the trees? Maybe 30 in each forest at the top of low hills especially. Sure you would not die by hitting every tree, but if you cheat and habitually fly through them, then you are not going to survive very long and
    they would be virtually invisible hidden in the trees. It would certainly be a deterrent.

    Of course, just clipping the tops of trees is a different thing than to deliberately fly through them and it was common for ac to come back from low level missions with upper branches caught in the undersides.
    Last edited by Tinkicker; Jun-17-2015 at 01:03.

  21. #19
    Novice Pilot
    Join Date
    Jul 2013
    Posts
    50
    Post Thanks / Like
    Blog Entries
    2
    Total Downloaded
    78.01 MB

    Re: Sal's Useful Scripts - Tree collisions

    This is interesting approach to trees collisions.

    I am trying to think the best way to get it done and for the moment just wondering about SpeedTree ... and how its done under the hood ....look for SpeedTreeCore_v5.2_VC100MTDLL.dll also.

    Trying to build whole array of polygons will be very time consuming process, just imagine doing that for all maps and maybe some new ones in future.

    You can try to use IMesh interface to see how its done with existing objects but it will be kind of "reinventing the wheel" situation, where rebuilding whole interface for trees will take long long ... probably too long hours by looking at the way its written.

    Colander was mentioning IL2 1946 where only patches of trees where causing collisions. I think that would be easier to achieve just for beginning...
    For instance look at gameWorld.maddox.game where You have LandTypes enum. Just imagine You could have Your trees defined there. Of course You would get Your height from aircraft.getParameter(part.ParameterTypes.Z_Altitu deAGL , i); or aircraft.getParameter(part.ParameterTypes.Z_Altitu deMSL , i); but still there will be some major data lookup for trees it self....

    I am not trying to drag You off the idea though.... just different perspective.

  22. #20
    Team Fusion ♣_Spiritus_♣'s Avatar
    Join Date
    Dec 2013
    Location
    The Demon-Haunted World: Science as a Candle in the Dark
    Posts
    5,600
    Post Thanks / Like
    Blog Entries
    2
    Total Downloaded
    0

    Re: Sal's Useful Scripts - Tree collisions

    Just bumping this since there is more talk about it in the forums.

  23. #21
    ATAG Member ATAG_Ribbs's Avatar
    Join Date
    Jan 2012
    Posts
    1,943
    Post Thanks / Like
    Total Downloaded
    4.11 MB

    Re: Sal's Useful Scripts - Tree collisions

    Isn't there " some " palm trees in the oasis's in the desert maps..since they have to be created in the fmb. Won't those have collision properties? I'm sure if there is 1 tree on the map I will run into it. Haha.

    Cheers
    Ribbs
    Cheers
    Ribbs

    INTEL I5 4670 /16 MB DDR3/ MSI Z97 PCMATE MB
    MSI GTX 1060 3 GIG
    WIN 7 64
    MS Sidewinder 2 precision pro Saitek x52 throttle quadrant


    By ATAG_Lewis

  24. #22
    Ace 1lokos's Avatar
    Join Date
    Jan 2012
    Posts
    5,323
    Post Thanks / Like
    Total Downloaded
    1.04 GB

    Re: Sal's Useful Scripts - Tree collisions

    Make a new object for FMB, a invisible pole to be used as "tree trunk", Misson Builders can place in random places around bases to act as trap.

  25. #23
    Ace
    Join Date
    May 2015
    Location
    Kansas City, Missouri area
    Posts
    515
    Post Thanks / Like
    Total Downloaded
    130.02 MB

    Re: Sal's Useful Scripts - Tree collisions

    Another thought--not the complete answer but maybe a start.

    Maybe don't even check for trees in flight. This is the situation now & presumably checking for trees all the time could be a framerate killer.

    But . . . check upon landing. So if you land on an open field or whatever, fine, no problem. But if you choose to land in a forested area - KABOOM. Or perhaps not inevitable KABOOM but a slightly higher chance of KABOOM than if landing in a field (see below).

    This would add a least a bit of differentiation between forest & field landings, with zero frame-rate consequences.

    FYI I've been doing a bit of research into crash landings and it turns out interestingly enough that (nowadays anyway--can't say for certain about the situation during WWII) in fact most crash landings are quite survivable if the landing is done in a controlled way. >90% survival rate as a rule.

    The interesting point thought is that landing in a forested area has about the same survival rate as (say) landing in an open field. It turns out that the trees are actually a pretty good 'cushion', slowing you down bit by bit (as various parts of your plane are removed--but still). Obviously if you plow straight into a giant tree trunk at full speed that is quite bad, but statistically it doesn't happen very often. There is a slight chance of mishap on trying to climb out if your plane happens to end up hung up in the trees many feet above the ground. But generally speaking from a statistical standpoint, the chance of survival landing in a field vs landing in a forest are both very high--well over 90%. Your chance of dying if you land in a forest vs a field is somewhat higher (6% fatality rate vs 3% for field landings) and your chance of slight or serious injury is somewhat higher for forest vs field landings.

    http://www.equipped.org/watertrees.htm
    http://www.equipped.org/ditchingmyths.htm
    Last edited by TWC_Flug; Feb-11-2017 at 13:32.

  26. Likes 1lokos liked this post
  27. #24
    ATAG Member ATAG_Lolsav's Avatar
    Join Date
    Jun 2012
    Posts
    4,684
    Post Thanks / Like
    Blog Entries
    1
    Total Downloaded
    16.32 MB

    Re: Sal's Useful Scripts - Tree collisions

    What i am about to suggest might be obvious to some and shows the lack of knowledge how C# works.

    But here goes nothing.

    It has been sugested to look over SpeedTreeCore_v5.2_VC100MTDLL.dll. I guess that would be ideal. Now i got myself thinking of something utterly simple, so simple i might suggest something stupid.

    That specific dll has to send information to the game. Isnt it possible to catch when that information flows and links it to the game? Taking that moment to update where the trees are? Am i beeing silly?

  28. #25
    Novice Pilot
    Join Date
    Jul 2013
    Posts
    50
    Post Thanks / Like
    Blog Entries
    2
    Total Downloaded
    78.01 MB

    Re: Sal's Useful Scripts - Tree collisions

    There is problem with this file while it is compiled with Microsoft Visual C/C++(2010)[msvcrt].

    The code I am getting out is a mess. No names for functions, variables etc... So there is little chance You will find what You need.

    https://dl.dropboxusercontent.com/u/...VC100MTDLL.txt
    Last edited by Nephilim; Feb-15-2017 at 08:25.

  29. #26
    Novice Pilot
    Join Date
    Jul 2013
    Posts
    50
    Post Thanks / Like
    Blog Entries
    2
    Total Downloaded
    78.01 MB

    Re: Sal's Useful Scripts - Tree collisions

    Have a look at those data from full mission builder and tell me where are they coming from.
    Looks like forest and single trees areas are defined somewhere already.

    trees.jpg

    trees1.jpgtrees2.jpg

  30. #27
    Ace Wolf's Avatar
    Join Date
    Feb 2012
    Posts
    1,297
    Post Thanks / Like
    Total Downloaded
    63.02 MB

    Re: Sal's Useful Scripts - Tree collisions

    I used to build maps for Arma 2 and Arma 3.

    The tools are there and maybe able to use for clod.
    You can take satellite data and create the map meshes. You use colour bands for the heights and use templates of forests and grasses that generate on map overlays. The tools are incredible and powerful and can generate maps with detail incredibly easily and quickly

    A similar process could be adopted for clod with the tools.

    https://dev.arma3.com/post/oprep-terrain-processor
    ATAG_Wolf
    __________________
    Win10, 64bit Ultra
    Asus P8P67Pro MB
    Intel i7-2600K
    Coursair 16GB (4x 4GB), DDR3-1600MHz
    Gainward Nvidia 980GTX
    850-Watt Modular Power Supply
    WIN10 and COD on Gskill SSD 240GB
    40" Panasonic LCD
    TrackIR5 +
    Thrustmaster Warthog stick, throttle & pedals

  31. Likes ATAG_Ribbs liked this post
  32. #28
    ATAG Member ATAG_Ribbs's Avatar
    Join Date
    Jan 2012
    Posts
    1,943
    Post Thanks / Like
    Total Downloaded
    4.11 MB

    Re: Sal's Useful Scripts - Tree collisions

    I've always wondered if they could make the collision detection client side.. only give collision properties to the trees inside of a certain radius around your aircraft or vehicle. Like a give and take senerio. That would relieve the stress off the server and game engine wouldn't it. The bubble around the players aircraft wouldn't have to be that big. Just thinking out loud...

    Cheers.
    Ribbs
    Cheers
    Ribbs

    INTEL I5 4670 /16 MB DDR3/ MSI Z97 PCMATE MB
    MSI GTX 1060 3 GIG
    WIN 7 64
    MS Sidewinder 2 precision pro Saitek x52 throttle quadrant


    By ATAG_Lewis

  33. #29
    ATAG Member ATAG_Flare's Avatar
    Join Date
    Oct 2013
    Location
    Interior BC --> Kingston ON
    Posts
    2,801
    Post Thanks / Like
    Total Downloaded
    383.91 MB

    Re: Sal's Useful Scripts - Tree collisions

    Quote Originally Posted by ATAG_Ribbs View Post
    I've always wondered if they could make the collision detection client side.. only give collision properties to the trees inside of a certain radius around your aircraft or vehicle. Like a give and take senerio. That would relieve the stress off the server and game engine wouldn't it. The bubble around the players aircraft wouldn't have to be that big. Just thinking out loud...

    Cheers.
    Ribbs
    Would it still have to be server side though if AI aircraft are involved? But I do think that only detecting collisions in a radius around your plane is a good idea.

  34. #30
    Ace
    Join Date
    May 2015
    Location
    Kansas City, Missouri area
    Posts
    515
    Post Thanks / Like
    Total Downloaded
    130.02 MB

    Re: Sal's Useful Scripts - Tree collisions

    OK, here is my random thought for the day.

    The issue of knowing where the trees are & whether the aircraft has collided with a tree visible to it, is only ONE of the problems you need to solve here.

    A more fundamental problem is this: Some people fly with no trees. Some people fly with minimal trees. Some people fly with moderate trees. And some people fly with LOTS of trees.

    So one pilot turns off all trees and can fly through forests with impunity. The next person has max trees turned on and can't fly 5 feet into the forest without exploding.

    Person number 3 has minimal trees turned on. So he flies through the forest but just dodges the occasional tree here & there and survives no problem. But person #4, the opponent of #3 who is on his tail as they fly through the forest, has trees turned up to MAX. So following the EXACTLY same flight path as pilot #3, pilot #4 crashes into trees left and right. Because pilot #4's setting is on MAX trees, and he has a LOT more trees to deal with.

    So, any solution to tree collisions has to deal with these two facts:

    #1. Each pilot sees a different number of trees depending on their graphics settings

    #2. We probably want to encourage people to fly with trees on, not to turn them off to gain an unfair advantage

    #3. People bitch about the unfairness of it all the time, but in fact some people just can't turn on trees because their graphics/computer is relatively weak and turning on trees makes CloD unplayable. (I'm one of these people.) Unless we want to drive everyone off from CloD who lacks a $600 graphics card, we have to allow that some people will turn off trees, or turn them down. We don't want to unfairly give these "no tree people" either and unfair advantage OR an unfair DISadvantage.

    So, here is a solution that takes all that into account and also requires little in the way of graphical horsepower.

    #1. You don't try to plot individual tree collisions at all. Rather, you track 'forested areas' and also a certain height that the forested areas have. So, say 40 above any forested area becomes a "no fly zone".

    #2. You don't really make planes blow up KABOOM just for flying in a forested area at 20 ft AGL. Rather (just as in real life) you start to get little bits of damage accumulating that add up over time if you are stupid enough to keep flying low through the forest for an extended period of time. You knock the tip of a wing off, you nick your propeller, you knock a hole in your wing or tail, that type of stuff. The type of stuff that, if it keeps accumulating, will inevitable lead to your plane losing performance and your opponent besting you because those little knicks have knocked 40 KTS off your a/c speed and you don't have left aileron control any more.

    #3. This type of damage isn't awarded by specific collision detection, but rather on a probabilistic way depending on how long your are flying too low within the forest zone. So you fly low in the forest zone for 10 seconds, maybe you have a 10% (or 25% or 50%--whatever) chance of having one of these performance-degrading bits of damage happen to your aircraft.


    So here is how this would work out of implemented this way (I believe!):

    #1. Everyone would avoid the forests. Whether you fly with a lot of trees or no trees, you would soon learn that flying low over the forests is a bad idea, and people wouldn't do it as a rule.

    #2. This stops people (who, say, have trees turned low or off) from flying through the forest unfairly in order to escape from people who fly with trees on. If they try to fly through the forest, they will soon start accumulating this minor damage and will soon realize this is a very bad idea.

    #3. Yet, if you are sufficiently desperate you might still CHOOSE to fly through the forest, as perhaps that accumulated damage is the least bad of your options at the moment. But--this is not unlike the choice to fly right through a real forest. Yes, by luck & good piloting you might survive and maybe if you have ten 109s on your tail that is your least-bad option at the moment. And maybe you will be able to fly down there and crash-land in the forest and the ten 109s won't follow you there because they don't want to accumulate damage from the inevitable tree-crashes and they aren't as desperate as you are. Again, our 'simulated forest' has the same effect on pilot behavior as an actual forest would--both for the people who might try flying through the forest as a desperation maneuver, and those who might choose to follow them right on down and risk consequences themselves, or choose to safely stay up and monitor how long it will take the desperate pilot to ruin his plane by flying through the forest like an idiot.

    #4. This 'simulated forest' approach is fair to pilots who fly with lots of trees, moderate trees, low trees, and NO trees alike. Because everyone can **see** where a forest is and will know to avoid flying too low in those locations. Even people who fly with NO trees on know where the forest is (because of the ground coloration etc)--they just can't see the individual trees. So if there is a rule like "never fly lower than 40 feet AGL above forested areas or you risk aircraft damage", that is a rule every pilot can follow easily, regardless of graphics settings.

    In short #1: This probabilistic approach to damage while flying through forested areas would be fair to all pilots whatever their settings and would discourage all pilots from flying through forests, while still allowing it as a desperation emergency maneuver that might work sometimes.

    In short #2: It has 90% of the benefit of detecting actual tree collisions with none of the drawbacks (e.g., the hit on framerate is bound to be quite huge under any 'actual collision detection' type of scheme) and a number of benefits that detecting actual tree collisions will never have in CloD.

Page 1 of 2 12 LastLast

Bookmarks

Posting Permissions

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