0
$\begingroup$

I'm trying to create a track mod for Assetto Corsa of the Kartodromo Evora track. Initially I tried importing elevation data with BlenderGIS (OpenTopography), but the data available there isn't accurate enough. Luckily, I have a GPS trace of myself driving a kart there recorded with very good accuracy.
This is the track model I made using BlenderGIS: blender_example_1 And this is how the GPS trace looks like: (I have a list of longitudes, latitudes and altitudes) gps_trace

I haven't really done anything advanced in Blender yet, so I don't know how to attack this one. The goal is to make it so the track is elevated according to the elevation data from the GPS trace.

The track model is also connected to the off-track area, where I don't really care about the elevation, but it's important that the off-track and on-track connection is smooth and doesn't contain any holes, so when modifying the track model elevation I will also need to modify the off-track model so that it all stays intact.

Note that I can't just recreate a plane along the GPS trace as it does not follow the middle of the track and does not contain any information about the width of the track. I must use the existing track model and apply the elevation to it.

Any help as for how should I approach solving this will be much appreciated.

$\endgroup$
4
  • $\begingroup$ Could you provide your Blender file using blend-exchange.com, with your GPS trace already imported ? $\endgroup$ Commented May 15 at 16:29
  • $\begingroup$ Sure. How can I import the GPS trace though? Currently it's just seating in some CSV but I can easily convert it to anything else $\endgroup$
    – Yuval.R
    Commented May 15 at 16:32
  • $\begingroup$ Open the csv in Blender, then pack external resourvces to embed it. $\endgroup$
    – Leander
    Commented May 15 at 16:35
  • $\begingroup$ Done, attached to the question. Let me know if I did anything wrong. $\endgroup$
    – Yuval.R
    Commented May 15 at 16:45

1 Answer 1

1
$\begingroup$

This script should do the trick.

import csv
import bpy
from bpy import data as D
from bpy import context as C
import bmesh

OBJECT_NAME = "TestObj"
CSV_PATH = r"Paste the path to your csv here"

coords = []

with open(CSV_PATH) as csvfile:
    reader = csv.reader(csvfile)
    for row in reader:
        coords.append(row)
        
  
mesh = D.meshes.new(name=OBJECT_NAME)

obj = D.objects.new(name=OBJECT_NAME, object_data=mesh)

C.collection.objects.link(obj)

bm = bmesh.new()
verts = []
for i, co in enumerate(coords):
    if i == 0:
        v = bm.verts.new(co)
        verts.append(v)
    else:
        geom = bmesh.ops.extrude_vert_indiv(bm, verts=[verts[-1]])
        new_vert = geom['verts'][0]
        new_vert.co = co
        verts.append(new_vert)

bm.to_mesh(mesh)
    
            

Once you generate that you will probably need to reorient/scale the mesh, it might be a bit all over the place. Then just Alt+C, convert to curve, then you can extrude it and control the twist to change the plane of the road.

After that you can convert the generated curve to a mesh and shrinkwrap your existing mesh to it. Something like this: enter image description here

$\endgroup$
3
  • $\begingroup$ Correct me if I'm mistaken, but this simply takes the GPS trace, then creates a brand new plane following it, right? If that is the case, please read the note I added to the bottom of my question - this solution won't work for my use-case. $\endgroup$
    – Yuval.R
    Commented May 15 at 17:04
  • $\begingroup$ I edited my answer, I think that this should work for you. $\endgroup$
    – Jakemoyo
    Commented May 15 at 17:11
  • 1
    $\begingroup$ Yep, ok, this works. Well, the general idea works at least. Had to do a lot of manual tweaking - but I guess that's to be expected. Thanks! $\endgroup$
    – Yuval.R
    Commented May 15 at 19:52

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .