bezier patch spec

2007-01-29
2013-05-28
  • Fredrik Brännbacka

    I'm working on the maya exporter and wonder how the bezier patches is specified in scene file?

    /Smaragden

     
    • Christopher Kulla

      They isn't a syntax for patches at the moment, the only code that uses the bezier patches is the builtin teapot/gumbo models.

      You can create the patches yourself via the janino-tesselatable primtive but that isn't a good solution for an exporter since there's a java class size limitation.

      I'd be happy to add a general way to specify patches - just tell me what syntax is most convenient for you.

       
    • Fredrik Brännbacka

      It would be nice to have something simple for patches like this.

      object {
        type patch
        [4 4]
        [-4 4 0  -2 4 0  0 4 0  2 4 0  4 4 0
        -4 2 0  -2 2 0  0 2 0  2 2 0  4 2 0
        -4 0 0  -2 0 0  0 0 0  2 0 0  4 0 0
        -4 -2 0  -2 -2 0  0 -2 0  2 -2 0  4 -2 0
        -4 4 0  -2 -4 0  0 -4 0  2 -4 0  4 -4 0]
        tesselation 4 4
      }

      similar to RIB
      Where [4 4] is the number of u and v spans and then comes all the cv location and then the tesselation specified in splits per span u and v.

      Actually it doesn't mather much to me how you do it but because there is a standard in RIB i think it may be unnecessary to reinvent the wheel.

      Thanks for a great renderer. I will let you all know about the progress of the exporter.

      /Smaragden

       
      • Christopher Kulla

        I just committed support for this to SVN. The syntax goes like this:

        object {
            shader my_shader
            type bezier-mesh
            n 4 7 ## number of cvs in u and v (nu,nv)
                wrap false false ## this is equivalent to renderman's uwrap/vwrap option (optional and defaults to false)
                ## cv data - should be in the same order as in the RI spec
                ## there should be exactly nu * nv points here
            points 3.2 0 2.25 3.2 -0.15 2.25 2.8 -0.15 2.25 2.8 0 2.25 3.45 0 2.3625 3.45 -0.15 2.3625 2.9 -0.25 2.325 2.9 0 2.325 3.525 0 2.34375 3.525 -0.25 2.34375 2.8 -0.25 2.325 2.8 0 2.325 3.3 0 2.25 3.3 -0.25 2.25 2.7 -0.25 2.25 2.7 0 2.25 2.4 0 1.875 2.4 -0.25 1.875 2.3 -0.25 1.95 2.3 0 1.95 3.1 0 0.675 3.1 -0.66 0.675 2.6 -0.66 1.275 2.6 0 1.275 1.7 0 0.45 1.7 -0.66 0.45 1.7 -0.66 1.275 1.7 0 1.275
        }

        Please let me know if something doesn't work as you expect.

        Are you adding bezier patch support to the maya exporter?

         
    • Anonymous - 2007-01-31

      Hi,
      played around with it a bit and tried to figure out how to read nurbs values in XSI and export them. This is what I got so far:
      http://img393.imageshack.us/img393/2034/nurbseh3.jpg

      (top XSI, bottom SunFlow)

      Here are the basic scene objects (materials, light, image are missing)

      camera {
        type pinhole
        eye -10.8212 10.4671 6.26885
        target 9.46548 -0.0757214 3.96465
        up 0 1 0
        fov 53.638
        aspect 1.33333
      }

      object {
        shader "Material4"
        type bezier-mesh
        n 7 7
        wrap false false
        points 5.48055 0 2.66476 6.14721 0 2.66476 7.48055 0 2.66476 9.48055 0 2.66476 11.4805 0 2.66476 12.8139 0.653888 2.66476 13.4805 0 2.66476 5.48055 0 1.99809 6.14721 0 1.99809 7.48055 0 1.99809 9.48055 0 1.99809 11.4805 0 1.99809 12.8139 0.653888 1.99809 13.4805 0.653888 1.99809 5.48055 0 0.664761 6.14721 0 0.664761 7.48055 -1.65227 0.664761 9.48055 -1.65227 0.664761 11.4805 0 0.664761 12.8139 0.653888 0.664761 13.4805 0.653888 0.664761 5.48055 0 -1.33524 6.14721 0 -1.33524 7.48055 0 -1.33524 9.48055 0 -1.33524 11.4805 0 -1.33524 12.8139 0 -1.33524 13.4805 0 -1.33524 5.48055 -1.17831 -3.33524 6.14721 -1.17831 -3.33524 7.48055 0 -3.33524 9.48055 0 -3.33524 11.4805 1.43131 -3.33524 12.8139 1.43131 -3.33524 13.4805 0 -3.33524 5.48055 -1.17831 -4.66857 6.14721 -1.17831 -4.66857 7.48055 0 -4.66857 9.48055 0 -4.66857 11.4805 0 -4.66857 12.8139 0 -4.66857 13.4805 0 -4.66857 5.48055 -1.17831 -5.33524 6.14721 -1.17831 -5.33524 7.48055 0 -5.33524 9.48055 0 -5.33524 11.4805 0 -5.33524 12.8139 0 -5.33524 13.4805 0 -5.33524
      }

      object {
        shader "Material3"
        type bezier-mesh
        n 7 7
        wrap false false
        points 5.48055 0 12.0048 6.14721 0 12.0048 7.48055 0 12.0048 9.48055 0 12.0048 11.4805 0 12.0048 12.8139 0.653888 12.0048 13.4805 0 12.0048 5.48055 0 11.3381 6.14721 0 11.3381 7.48055 0 11.3381 9.48055 0 11.3381 11.4805 0 11.3381 12.8139 0.653888 11.3381 13.4805 0.653888 11.3381 5.48055 0 10.0048 6.14721 0 10.0048 7.48055 -1.65227 10.0048 9.48055 -1.65227 10.0048 11.4805 0 10.0048 12.8139 0.653888 10.0048 13.4805 0.653888 10.0048 5.48055 0 8.00478 6.14721 0 8.00478 7.48055 0 8.00478 9.48055 0 8.00478 11.4805 0 8.00478 12.8139 0 8.00478 13.4805 0 8.00478 5.48055 -1.17831 6.00478 6.14721 -1.17831 6.00478 7.48055 0 6.00478 9.48055 0 6.00478 11.4805 1.43131 6.00478 12.8139 1.43131 6.00478 13.4805 0 6.00478 5.48055 -1.17831 4.67144 6.14721 -1.17831 4.67144 7.48055 0 4.67144 9.48055 0 4.67144 11.4805 0 4.67144 12.8139 0 4.67144 13.4805 0 4.67144 5.48055 -1.17831 4.00478 6.14721 -1.17831 4.00478 7.48055 0 4.00478 9.48055 0 4.00478 11.4805 0 4.00478 12.8139 0 4.00478 13.4805 0 4.00478
      }

      There is a seam in the middle. Don't know why.

       
      • Christopher Kulla

        I didn't spot anything right away. Could you post the snippet of code you are using to export these?

         
        • Anonymous - 2007-01-31

          sure. Hope that helps:

          // get the nurbs object
          NurbsSurfaceMesh surf(o.GetActivePrimitive().GetGeometry());
          CNurbsSurfaceRefArray  surfaces = surf.GetSurfaces();
          NurbsSurface nSurface(surfaces[0]);
          CNurbsSurfaceData out;
          nSurface.Get(siSINurbs,out);

          // convert local-coord into global-coord
          CTransformation localTransformation = o.GetKinematics().GetLocal().GetTransform();
          KinematicState  gs = o.GetKinematics().GetGlobal();
          CTransformation gt = gs.GetTransform();

          sObj << "  type bezier-mesh\n";
          sObj << "  n "<<out.m_lNbUControlPoints <<" "<<out.m_lNbVControlPoints <<"\n";
          sObj << "  wrap false false\n";
          sObj << "  points ";

          // get the points
          CControlPointRefArray ca = nSurface.GetControlPoints(); 
          for (int j=0; j<ca.GetCount();j++){
            ControlPoint cp = ca.GetItem(j);
            Point point(ca.GetItem(j) );
            CVector3 pos(MapObjectPositionToWorldSpace(  gt,  point.GetPosition()));
            sObj << pos.GetX() << " "<< pos.GetY() << " "<< pos.GetZ() << " ";
          }

           
          • Christopher Kulla

            I'm pretty sure the code is correct on my side. Can you try exporting a slightly larger bezier mesh? Perhaps the error will become more visible that way.

            Also, the code you are using suggests the mesh is actually nurbs. Did you check the w component of the control points? If it isn't 1 you might try dividing through by it.

             
    • Anonymous - 2007-02-09

      Will check that later.

       

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:





No, thanks