Search Unity

exported control vertices for the wave nurbs control splines

Discussion in 'Scripting' started by Mike4, Aug 28, 2014.

  1. Mike4

    Mike4

    Joined:
    Oct 24, 2013
    Posts:
    92
  2. hpjohn

    hpjohn

    Joined:
    Aug 14, 2012
    Posts:
    2,190
    Maxscript/Melscript to create nodes (transforms) at the control points
    then in Unity, import asset post processor to do something with those transforms
     
  3. Mike4

    Mike4

    Joined:
    Oct 24, 2013
    Posts:
    92
    Thanks but holy cow that seems a lot of new stuff to learn. Would anyone have the time to do that for me in a most simple Unity project? I've never used Maya etc.
     
  4. hpjohn

    hpjohn

    Joined:
    Aug 14, 2012
    Posts:
    2,190
    This isn't exactly a simple task. It's pretty far from simple. Unity doesn't even have any built-in support for nurbs surfaces.

    Heres a small sample of Maxscript from when I did something like this with splines (note: not nurbs)
    It iterates over all the knots in a spline, and creates nodes in hierarchy, with a '#' deliminated naming scheme, so that my import postprocessor can easily find and identify transforms.
    Code (CSharp):
    1.     if(selection.count != 1 or (classof selection[1] != SplineShape and classof selection[1] != Line) ) do (
    2.         messagebox "Select a single spline"
    3.         return null
    4.     )
    5.     for k = 1 to (numKnots $ 1) do    (
    6.         if(getKnotType $ 1 k == #corner) do (
    7.             messagebox "No corners please, bezier only"
    8.             return null
    9.         )
    10.     )
    11.     l = point name:($.name + "Points") position:$.position
    12.     for k = 1 to (numKnots $ 1) do    (
    13.         knt = getKnotPoint $ 1 k
    14.         in_vec = getInVec $ 1 k
    15.         out_vec = getOutVec $ 1 k
    16.         if(in_vec == knt) do (in_vec = 2*knt - out_vec)
    17.         if(out_vec == knt) do (out_vec = 2*knt - in_vec)
    18.         p = point name:($.name + "#knot" + k as string) position:knt
    19.         p.parent = l
    20.         o=point name:($.name + "#knot" + k as string + "#handleIn") position:in_vec
    21.         o.parent = p
    22.         o2 = point name:($.name + "#knot" + k as string + "#handleOut") position:out_vec
    23.         o2.parent = p
    24.     )
    25.  
    It will be different for Melscript (maya), and you'll have to go learn MEL (this forum is for Unity)
     
  5. Mike4

    Mike4

    Joined:
    Oct 24, 2013
    Posts:
    92
    Thanks. Could I avoid all this by installing Maya and save as another format that unity could use?
     
  6. hpjohn

    hpjohn

    Joined:
    Aug 14, 2012
    Posts:
    2,190
    It won't change the fact that Unity has no concept of what nurbs are
    The file formats that it can import (fbx,obj,etc) dont even have the ability to store nurbs and splines (i think - whenever i export to FBX from max i get warnings that splines will be ignored).
     
  7. Mike4

    Mike4

    Joined:
    Oct 24, 2013
    Posts:
    92
    Tried to install the Maya demo on win8.1 for hours without success! Twice it refused me a 30days demo licence.-
    I'm used to Blender so could you save the wave 1.5 as obj or .3ds and pm etc. it to me? Unity seems to import Blender animations. Even if the animation would not work it might be helpful for me. Thanks in advance.