利用者:Eman-/SummerOfCode2005/libNurbana Integration

提供: wiki
移動先: 案内検索

Curves and Surfaces - libNurbana Integration

January 2009:

  • Local Refine/subdivide tool (replace original Subdivide tool)
  • Degree elevate/reduce with weighted and cyclic surfaces
  • Theme UI colours
  • Fix bugs
    • Add new control points bug
    • Skinning
    • BevelOb
  • Test backwards compatibility with complex models
  • Ensure original Blender functionality still works

September 2008:

Eman - Week Starting September 22nd 2008:

  • Subdivision for endtied/clamped curves and surfaces
  • Subdivision/Knot Insertion for cyclic surfaces, rational splines and open knots
    • This is a missing feature in Nurbana, Twingy/Justin is helping rewrite the algorithm
  • Reverse compatibility with old Blender files (forwards compatibility too?)
  • Delta caching optimisation

Eman - Week Starting September 29nd 2008:

  • Integrate ideasman/Campbell's changes from HEAD
    • Fix resulting memory issues
    • Refactor NURBS_Generate to handle 1D arrays, for tilt, radius etc.
  • Fix Isolines with incremental calculation optimisation
  • Examine Refine and Degree Elevate/Decrease and evaluate suitability for immediate inclusion.
  • Make stable, test, etc.

UI changes (please help if you can):

  • Edit Knot Vector (Nurb.knotsu and Nurb.knotsv in blender\makesdna\DNA_curve_types.h ) (Needs review) --zaghaghi
  • Change CV Cage to be a little less obtrusive
    • Make it complete for cyclical surfaces?
  • make CVs themselves more obvious
  • Fix Normals/Shading issue on cyclic curves
  • UI for selecting specific point on curve surface

Old Content

Much of the information is out of date and does not apply to the current state of the nurbs/ branch.

Review:

The summer has flown by, and I am pleased to say that I have completed this project more-or-less as described in the original proposal.

My proposal mentioned two principal goals:

  • Firstly to modify Nurbana's C++ codebase to a be more libraryesque, and then expose this functionality via a C API.
  • Secondly to convert Blender's current NURBS backend to use the new libNurbana API.


The first goal took a considerable amount of time and work. Nurbana was in a pre-release alpha state and was written to be an application not a library. Furthermore Nurbana made use of SDL threads. After much code refactoring, reorganisation and reduction, and recoding some portions to remove dependancies, I produced a working chunk of dependancy-free core code which I could integrate into the Blender tree as a library. The fact that Nurbana is written in C++ meant that I also had to write a C API to wrap calls. I decided to call the new library libNurbana to differenciate it from the application version of Nurbana while still paying homage to it's origins. Like Nurbana, libNurbana is released under the LGPL. This portion of the project accounted for more than half my time spent on this project.


The second goal: to convert Blender's NURBS backend is essentially complete. An unforeseen complication (the fact that Blender used row-centric arrays for control points, and Nurbana uses column-centric) made this process much slower than I would have liked. Despite the need for a lot of recoding, the functionality is now in place (although much testing is still needed). This can be clearly seen by looking at the default NURBS primitives:

Dev-primitivesfinal.png


The other deliverables mentioned in my proposal were explicitly stated to be "time dependent deliverables" because I suspected from the outset that I would not have enough time to complete them. I have completed one:

  • Cardinal spline with variable tension (a cardinal spline is a unique spline because the curve passes throught all its control points)

Dev-cardinalfinal1.png


Dev-cardinalfinal2.png


Another proposed type was B-Spline, but after discussion with Ton, I decided to modify this goal slightly. The old method for manipulating NURBS Knots in Blender was cumbersome and unintuitive. I have implemented an automatic knot system which mimics the style of B-Splines with the added bonus of the curve/surface still being rational. Cyclic surfaces get automatically assigned a periodic knot vector, and non-cyclic surfaces get an 'endtied' bsplinesque open knot vector. I think that this method offers a much more intuitive method to model splines and surfaces and should help limit confusion surrounding NURBS somewhat.

Another small modification which I have made, and hope to continue to improve on is to the UI. I have changed the buttons which display in editmode depending on the type of curve.

It might appear that Blender now functions in much the same way as it did initially, this is not the case. The NURBS backend of Blender has been completely replaced with a mechanism which interfaces with libNurbana's API. I did my utmost to ensure that Blender continued to behave in the same manner in order to maintain a level of back compatibility (some modifications still need to be done). This interface can now be used to implement new features very quickly. This new extensibility for Blender's NURBS system was the main purpose of this project.

libNurbana features that I hope to implement soon:

  • Isolines
  • Non-destructive subdivision
  • Blending
  • Non-destructive Lofting
  • Rhino import/export for NURBS

And old Blender NURBS surface displayed using libNurbana backend:

Dev-oldsurface.png

Original Spec:

Goals:

The purpose of this project is to examine the current curves and surfaces code in Blender and to integrate Nurbana*. I hope to add some new functionality immediately and also to update Blender's existing curves/surfaces code to allow the addition of future functionality more easily. Any backend changes will happen in a way which is transparent to the user, and if possible a redesign of the current NURBS UI will improve the usability of the system from the frontend.

  • Nurbana is/was a NURBS modeling tool written in C++ by Justin Shumaker. He donated the source to Blender. It will be granted a new lease of life as "libNurbana" by this project.

Implementation:

Structure

The new NURBS functionality will be introduced in a module which will be based on Nurbana, and probably be called libNurbana. Blender will interact with this module via a C API similar to other C++ modules in Blender e.g. the Inverse Kinematics module. For the time being only NURBS computation will be handled by libNurbana. Hopefully this diagram might help to explain: (grey boxes depict data structures, arrows are data flow)

Dev-blender.gif


New Code

  • =./intern/nurbana/extern/nurbana.h= is the C interface for Nurbana, this will allow Blender to access the C++ functions in the same way as IK_solver.h in the IK module
  • =./intern/nurbana/intern/(.h&.cpp)= will be Nurbana files, I will reduce the number of these as much as possible
  • =./source/blender/blenkernel/intern/nurbs.c= will call Nurbana functions, converting internal Blender =Nurbs= and =BPoint= structs into an acceptable common format shared by =./intern/nurbana/extern/nurbana.h=.
  • =./source/blender/blenkernel/BKE_nurbs.h= is the header file for new Blender NURBS functions
  • =./source/blender/src/editnurbs.c= will provide editing functionality (update: editnurbs.c did not prove to be necessary)

Modifications to existing code

  • Additional Curves (see above): =curves.c editcurves.c displist.c=
  • Improved UI for old curves, Uniform B-Splines, Cardinal Splines and new NURBS interface
  • New menu items

Dependancies

  • New code will depend on =Nurb= and =BPoint= like before (hopefully without modifications)
  • Nurbana and Blender will be independent but will require a definition of =Nurb_extern= in order to share NURBS data. This will be defined in nurbana.h
  • For the time being only NURBS curves and surfaces will depend on Nurbana, other curves could perhaps be ported later if beneficial.
  • Since the same dna structs are being used, saving and loading old CU_NURBS curves should be seamless
  • libNurbana will have no external dependencies and should be useful to any application in need of NURBS functionality.

Extra:

Change

This design is likely to evolve and change somewhat over the course of the Implementation. Updates will be noted here.

Help

Due to the sheer scope of this project, and since its main focus is the backend code, some assistance might be required with the frontend improvements. A complete overhaul is probably in order, and some help (towards the end) with the overall UI design would be good. I will do my best to complete this project within the Google Summer of Code timeframe, but I think that making any promises about when the UI aspects will happen would be over-ambitious.

Thanks

I wouldn't have got this far without the sterling efforts of Ton, Chris Want, Martin Poirier and #blendercoders. An extra special thank you to Justin Shumaker for all his help with Nurbana, and 'just in time' bugfixes. Thanks to Google for the opportunity :)


-- EmmanuelStone - 23 Jul 2005