#875 Add support for collision with Cones.

to be defined
new
nobody
None
enhancement
major
Physics engines
2.1.0-dev
2014-06-09
2014-05-07
simon wood
No

As per discussion on the mailing list there is a request for detecting collisions with Cones rendered around the track surface.

This ticket is intended as a location for some quick proof of concept code.

The supplied track is attached, but has a problem that the first row of cones are grouped together (called 'Color_01.026') where as the others are separate rendered objects.

Locations (as imported into Blender) are described in attached files.

18 Attachments

Discussion

1 2 > >> (Page 1 of 2)
  • simon wood
    simon wood
    2014-05-07

     
  • simon wood
    simon wood
    2014-05-07

     
  • simon wood
    simon wood
    2014-05-07

    With the Simuv4 dumping the corner locations of the car, when almost hitting the 'Color_01.000: (197.95593, 218.97064, 0)' cone head on:
    https://sourceforge.net/p/speed-dreams/code/HEAD/tree/trunk/src/modules/simu/simuv4/collide.cpp#l86

    SDW Corner 0 195.118149 218.365875
    SDW Corner 1 195.154892 220.175507
    SDW Corner 2 190.709061 218.455414
    SDW Corner 3 190.745804 220.265045
    

    So it looks like the co-ordinate systems line up. We just need to work out how to evaluate the collisions and what to do when they actually occur...

     
  • simon wood
    simon wood
    2014-05-07

     
  • simon wood
    simon wood
    2014-05-08

    First rough attempt/proof of concept

     
  • simon wood
    simon wood
    2014-05-09

    Some thinking out loud, regarding how libSOLID works
    http://solid.sourceforge.net/solid2.html#SEC14

    nitially, the default response is nil and all pairs of objects have a default response. If for an object pair, one of the objects has an object response defined, then this response overrules the default response. A pair response overrules any object or default response. If for both objects there is an object response defined, then one of the responses is chosen. In this case, one of the responses may be forced to be chosen by defining it as a pair response.

    So at present we have a 'default response' (SimCarCollideResponse) and an 'object response' (SimCarWallCollideResponse). The 2nd is for Walls (fixed-objects) and takes presedence over car-car collisions (which defer to the 1st).

    If we add another class of objects for the cones we will have to figure out how place them in the scheme of things, which probably means an 'object response'. Do we register all of the cones, or use our current concept of pre-selecting the ones near the car(s)?

    If the cones become movable then that could get even more complicated.

     
  • simon wood
    simon wood
    2014-05-09

    Another patch, this one uses libSOLID to more accurately detect collisions

     
  • simon wood
    simon wood
    2014-05-09

    Stress test

     
  • beaglejoe
    beaglejoe
    2014-05-09

    Builds and works on Windows 7. Nice!

     
  • simon wood
    simon wood
    2014-05-10

    How to limit rotation on Windows

     
  • simon wood
    simon wood
    2014-05-11

    ... its full of cones.

     
  • simon wood
    simon wood
    2014-05-11

     
  • simon wood
    simon wood
    2014-05-12

    updated to adjust mat references

     
  • simon wood
    simon wood
    2014-05-12

    Blender and AC3D cones

     
  • simon wood
    simon wood
    2014-05-12

     
  • simon wood
    simon wood
    2014-05-12

    I made some more appropriately sized cones in blender and exported to ac3d.

    $ python grid_fill.py >> slalom01.ac
    

    The edit the resultant file to add in the material lines from the cones and adjust the number the of kids.

     
  • simon wood
    simon wood
    2014-05-14

    alternating groups of cones on left and right

     
  • simon wood
    simon wood
    2014-05-14

     
  • simon wood
    simon wood
    2014-05-14

     
  • simon wood
    simon wood
    2014-05-14

    Got the 'flow' a little better. Can add cones quickly and easily to track.

    1. Generate track
    2. Add cones
    3. Edit track to insert Material statements and change number of kids.

    $ sd2-trackgen -c oval -n slalom01 -a slalom01.xml
    $ python grid_fill.2.py >> slalom01.ac
    $ vim slalom01.ac cone2.ac -o
    
    AC3Db
    MATERIAL "" rgb 0.4 0.4 0.4  amb 0.8 0.8 0.8  emis 0.4 0.4 0.4  spec 0.5 0.5 0.5  shi 50  trans 0
    -- Add materials statements as follows
    MATERIAL "DefaultWhite" rgb 1.0000 1.0000 1.0000  amb 0.2000 0.2000 0.2000  emis 0.0000 0.0000 0.0000  spec 0.5000 0.5000 0.5000  shi 10 trans 0.0000
    MATERIAL "Cone" rgb 0.8000 0.2351 0.0497  amb 1.0000 1.0000 1.0000  emis 0.0000 0.0000 0.0000  spec 0.5000 0.5000 0.5000  shi 50 trans 0.0000
    MATERIAL "Base" rgb 0.1329 0.1329 0.1329  amb 1.0000 1.0000 1.0000  emis 0.0000 0.0000 0.0000  spec 0.5000 0.5000 0.5000  shi 50 trans 0.0000
    --
    OBJECT world
    kids 2
    OBJECT group
    name "track"
    kids 97 <-- add '70' (see cone2.ac.h to get actual number) to this = 167
    OBJECT group
    name "TKMN0"
    

    Since we're using a compiled in list of cones you have to copy the 'cones2.ac.h' and then rebuild

    $ cp cone2.ac.h /storage/speed-dreams-git-svn/src/modules/simu/simuv4/
    $ cd /storage/speed-dreams-git-svn/
    $ make
    

    You should then be 'good to go'.
    Simon

     
  • simon wood
    simon wood
    2014-05-14

    Rotated cones appear OK in Blender, but not in game.

     
  • simon wood
    simon wood
    2014-05-14

    I started looking at how I could rotate (laying down) cones, and it appears that it's pretty easy

                                    # and give some rotation
                                    # default "rot 1 0 0 0 1 0 0 0 1"
                                    if (rot == 1):
                                            print "rot 0 -1 0 1 0 0 0 0 1"
                                    if (rot == 2):
                                            print "rot -1 0 0 0 -1 0 0 0 1"
                                    if (rot == 3):
                                            print "rot 0 1 0 -1 0 0 0 0 1"
    

    However the rotated cones do not appear in game (only the 'rot=0' ones do). Importing the '.ac' into blender shows that they are there.

    Perhaps a bug in the speeddreams '.ac' reader.... the file has bits like

    OBJECT poly
    name "Base"
    loc 425.3 0.2500001 -220.0
    rot 0 -1 0 1 0 0 0 0 1
    numvert 32
    0.7673042 -0.1815715 -0.0153098
    
     
  • simon wood
    simon wood
    2014-05-14

    much less detailed cones (less faces/vertices)

     
  • simon wood
    simon wood
    2014-05-14

    Regarding rotation, it appears that order statements in '.ac' file is important. The following 'works', but rotates in game to opposite direction to that seen in Blender.

    OBJECT poly
    name "Base"
    rot 0 -1 0 1 0 0 0 0 1
    loc 425.3 0.2500001 -220.0
    numvert 32
    0.7673042 -0.1815715 -0.0153098
    
     
  • simon wood
    simon wood
    2014-05-15

     
1 2 > >> (Page 1 of 2)