UVW mapping Rollercoaster track

Become a member of the CGSociety

Connect, Share, and Learn with our Large Growing CG Art Community. It's Free!

 
Thread Tools Display Modes
  12 December 2017
UVW mapping Rollercoaster track

Hey everyone,

I wrote a little script that generates a rollercoaster track from a CSV file containing matrix values for location, pitch, yaw and roll of the track. It works by placing a predefined cross section of track at every point in the CSV file and applying a crosssection and surface modifier to it. This method however, leaves me without mapping coordinates for the rails. Any idea how I can tackle this problem? Maybe a different method for creating the rails? Anyway here's the code I got so far:

f = 0
tiespacer = 1
executed = 0
trackdataarray = #()
trackcomponents = #()
rollout bu "Convert spline data"(
   button csvselect "Select CSV file"
   label CSVpresent "No CSV file selected"
   dropdownlist coastertype "Select coaster style" items:#("Vekoma MK1101", "Togo Default")
   spinner heartline "Heartline value" type:#worldunits range:[-10,10,0]
   button generate "Generate track"
   button finalize "Finalize track"
   
   on csvselect pressed do(
      f = getopenfilename caption:"Select CSV file" types:"Excel(*.csv)"
      if getFilenameType f != ".csv" then(
         messagebox "That's not a CSV file"
         CSVpresent.text = "No CSV file selected"
      )
      else(
      CSVpresent.text = filenameFromPath f
      )
   )
      
   on generate pressed do(
      if f == 0 or getFilenameType f != ".csv" then(
         messageBox "No CSV file selected"
      )
      else(
         trackstyle = getFilenamePath(getSourceFileName()) + "\\No Limits spline translator\\" + coastertype.selected +".max"
         if doesFileExist trackstyle == true then(
            mergeMAXFile trackstyle #select
            selection.pivot = [0,0,heartline.value]
            trackcomponents = for s in selection collect s.name
            trackdata = openFile f
            while not eof trackdata do(
               linevalue = ("#(" + readline trackdata + ")")
               trackdataarray = append trackdataarray linevalue
            )
            deleteitem trackdataarray 1
            for t in trackcomponents do(
               for a in trackdataarray do(
                  subarray = execute a
                  if substring t 1 3 != "Tie" then(
                     copyobj = getNodeByName t
                     copiedobj = copy copyobj
                     objmatrix = matrix3[subarray[5], subarray[7]*-1, subarray[6]] [subarray[8], subarray[10]*-1, subarray[9]] [subarray[11], subarray[13]*-1, subarray[12]] [subarray[2], subarray[4]*-1, subarray[3]]
                     copiedobj.transform = objmatrix
                  )
                  else(
                     if tiespacer == 1 then(
                        copyobj = getNodeByName t
                        copiedobj = copy copyobj
                        objmatrix = matrix3[subarray[5], subarray[7]*-1, subarray[6]] [subarray[8], subarray[10]*-1, subarray[9]] [subarray[11], subarray[13]*-1, subarray[12]] [subarray[2], subarray[4]*-1, subarray[3]]
                        copiedobj.transform = objmatrix
                        tiespacer = 0
                     )
                     else(
                        tiespacer = 1
                     )
                  )
               )
            )
            delete selection
            executed = 1
         )
         else(
            messagebox "source file couldn't be found, please make sure it's in the right directory"
         )
      )
   )
   on finalize pressed do(
      if executed == 0 then(
         messagebox "No track was created yet"
      )
      else(
         modifierarray = #()
         for a in trackcomponents do(
            railarray = #()
            for o in objects do(
               if iskindof o splineShape do(
                  if substring a 1 3 == substring (o.name) 1 3 do(
                     --print o.name
                     railarray = append railarray o
                  )
               )
            )
            while railarray.count > 1 do(
               addAndWeld railarray[1] railarray[2] 0
               deleteItem railarray 2
            )
            masterobj = railarray[1]
            modifierarray = append modifierarray masterobj
         )
         cro = crosssection()
         sur = surface()
         sur.threshold = 0
         sur.steps = 1
                  
         for i in modifierarray do(
            if i != undefined do(
               addmodifier i cro
               addmodifier i sur
            )
         )
         redrawviews()
      )
   )
)
createDialog bu

Last edited by PaulvMontfort : 12 December 2017 at 10:51 AM.
 
  12 December 2017
I managed to solve my problem but if anyone still has an idea how to tackle this problem, let me know. I'm open to better solutions. What I did was add a uvw map with face map type and then add an unwrap_UVW and perform an "unfold strip from loop" function. Here's the result:


 
  12 December 2017
You can use matrix as a coordsys to create rails.

delete objects

p = Circle radius:250 displayrendermesh:false
addModifier p ( Normalize_Spl length:20 )
addModifier p ( Noisemodifier scale:300 strength:[0,0,150] )
convertToSplineShape p


b = Rectangle width:30 length:60 displayrendermesh:false
pc = Path_Constraint follow:on axis:2 path:p bank:on
b.pos.controller = pc


matrixValues = for i = 1 to 100 by 5 collect (
 
 pc.percent = i;
 b.transform
 
)


shp = splineShape wirecolor:blue name:(uniqueName "rails_") render_mapcoords:on displayrendermesh:on thickness:8 realWorldMapSize:on
addnewspline shp
addnewspline shp

for m in matrixValues do (
  
 Ellipse width:25 length:100 transform:m wirecolor:yellow displayrendermesh:false
 
 in coordsys m (
  
  addKnot shp 1 #smooth #curve [-5,-40,0]
  addKnot shp 2 #smooth #curve [-5,40,0]
   
 )
 
 
)
close shp 1
close shp 2
updateshape shp

map = checker()
map.coords.realWorldScale = true
map.coords.U_Tiling = 0.15
map.coords.V_Tiling = 0.15



shp.material = Standardmaterial diffuseMap:map
showTextureMap shp.material true

meditMaterials[1] = shp.material
 
  12 December 2017
Thanks for your reply Serejah, there's only one problem you get using your method. The mapping coordinates don't bank along with the track. This is crusial for mapping those stripes you get from the wheels of the coaster train.
 
  12 December 2017
Try Sweep modifier with Banking:on on these rails splines.
 
reply share thread



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
CGSociety
Society of Digital Artists
www.cgsociety.org

Powered by vBulletin
Copyright 2000 - 2006,
Jelsoft Enterprises Ltd.
Minimize Ads
Forum Jump
Miscellaneous

All times are GMT. The time now is 03:22 PM.


Powered by vBulletin
Copyright ©2000 - 2018, Jelsoft Enterprises Ltd.