User:Caste/GSoC Application

From K-3D

Jump to: navigation, search

Google Summer of Code - NURBS Modeling Tools


K-3D has full support for NURBS in its codebase and several basic shapes included, but it still has a lack of features other modeling software provides to create and modify NURBS patches and curves easily. My proposal is to create a set of basic NURBS modeling tools for K-3D which provide the user with some fundamental functionality for NURBS editing.

The plugins I want to contribute can be differentiated by the input/output they use.

The first set of them deals with curves only, they are not necessary for displaying, but are used by the following plugins which create surfaces from one or more curves. And last but not least I propose to add some plugins which alter surfaces.

I'll use the bonding time to get familiar with the code base, and if despite of that I won't be able to submit all my proposed plugins within time, I'll keep submitting them after GSoc for sure.


Overview of the plugins to create a basic set of modeling tools :

As the NURBS tools which come with K-3D up to now just provide methods to create closed curves, I propose to add these:

Another series of plugins I'd like to add use curves as input and output NURBS patches, these would be:

And the third step are plugins dealing with NURBS patches:

These all might be joined to a library libk3dnurbs-modeling-tools.


Create a basic NURBS curve

This plugin will be pretty much the same as the nurbs_circle plugin in libk3dnurbs, only that it will create a single curve instead of a curve loop.

DONE - See screenshot below and the patch in the tracker

Concatenate two NURBS curves

Let the user choose each one control point of 2 curves, these will be merged to a single point (the middle of both) and the second curve will be added to the nurbs_curves array of the first one (->mesh_modifier of the first input curve!).

More detailed plan

Best method I found up to now is the following:

  • Create a python script which takes the 2 selected curves(meshes) and creates inputs for the C++ module from these, furthermore it will toggle visibility of the input meshes
  • The C++ module will have 2 input meshes, looks for the selected points in these (only one end-control-point per mesh), connects the curves continuously or not, and creates a mesh storing the two curves

Insert/Remove Knots from a curve

Change the number of knots and respectively the number of control points. If the number increases the curve won't be changed (through evaluating he position on the curve), if it decreases detail might get lost.

At first - for the sake of simplicity - I'll change the number of control points with the number of knots. Editing multiplicity to gain even more control over the shape might be added later (same thing for surfaces).

Opening/Closing curves

  • Close: Append a new curve to the given one with a user defined number of knots and connect the ends by it.
  • Open: let the user select a control point at which the curve gets "cut", the selected control point will be duplicated.

Create cap

Creates a planar NURBS surface using the given (closed) curve as outline.

Extrude a curve

Takes the given curve as u for the new surface, the v coordinates increase linearly. If the curve consists of several connected curves, this will loop through all of them and extrude them. User can choose whether to create caps or not.


Similar to Extrude a curve, but this time the curve does not get extruded along a line but the second input curve is used to modulate the v values so the curve is extruded along another curve.

(See for a screenshot)


Rotate the selected curve around the y-axis and thus create a NURBS patch whose outward shape is specified by the curve.

(See for a screenshot)

Implementation will create a circle and sweep it along the selected curve.


Creates a bevelled surface from a closed curve, the user can specify the radius of bevelling and the length.

(See for a screenshot)

Impelentation works the same way as sweep again, the curve gets sweeped along a NURBS curve defined by the radius and length parameter.

Trim a NURBS patch by a curve loop

If the user has created a NURBS patch and a closed curve he can pass these both to this plugin and will receive a patch trimmed by the curve. To use several trim curves on one patch, you can apply this plugin several times, passing the modified patch and the new curve to the next occurrence of the plugin.

Bart's gprim factory comes in handy here as it provides functionality to add trimming curves easily.

Knot Insertion/Removal for surfaces

The number of knots - and thereby the number of control points - should be editable by the user. For simplicity this plugin will increase/decrease the number of spans in u and v direction simultaneously, later this might be changed. Aim of this plugin is not only to make the number of these points variable, but also remaining the curve's shape while adding the new points by evaluating their position according to the given NURBS patch. So as an example if you had a 4x4 grid of control points on your patch and increase by 2, you should have a 6x6 patch having the same shape.

Lossless knot removal will not be possible as you can't keep all the detail then.

For the sake of simplicity at first I'll change the number of control points with the number of knots. Editing multiplicity to gain even more control over the shape might be added later (same thing as for curves).

Detach Patch

Internally creates a NURBS surface using only the selection of the edited mesh, checks whether this is a valid NURBS surface (using k3d::validate_nurbs_patches), does the same for the remaining control points & knots of the edited mesh, if both patches are valid then the selection gets detached.


if time allows to code this one, too..

This tool should move the selected control points along the underlying surface normals. This does only work on continuous surfaces with at least one derivation. So dont try this where 2 surfaces are attached without smoothing or at end points of a surface.

I'll try to just ignore the non-derivable points and approximate the normal by interpolating the surrounding ones.

Attach Patches

If you have 2 surfaces you can connect these using the attach plugin. If these don't have the same span, the knot insertion plugin will be used to increase the span matching the more detailed one. Then these to surfaces will get connected either

  • without blending -> no changes will be made to the positions of control points, the surface will thus not be continuous
  • with blending -> the points at the edges will be positioned as if the surfaces were already connected, and their position calculated by the rest of the surface

Extrude NURBS surface

extrude a surface along a curve -> extrude the edges along the curve, if the curve was not closed: cap the ends with the surface which has been passed in

Sample Plugin

I wrote the first plugin on the list of proposed ones as a sample. You can create a nurbs curve, apply number of control points, order and how far newly created points will be distanced.

He're is a screenshot of what you can produce with it: nurbs_curve.png

And the surce code can be found here:

About me

I just have passed the first semester for my Bachelor of Computer Science (with all A grades) at the "Technische Universit�t Darmstadt", Germany. I'm interested in graphics programming ever since I saw a computer, I started to learn C++ when I was 14 (so 6 years ago), moved on to OpenGL and now I'm maintaining the NeHe site([[1]]) for OpenGL tutorials together with a good friend from London.

I'm also pretty interested in math and physics, these were my major fields of study at school when graduating from school and receiving my Abitur (with A grades) ( Abitur = final exam from German secondary school qualifying for university admission or matriculation (says ). I also passed the first round of the International Physics Olympiad and the "Bundeswettbewerb f�r Informatik" - same thing for Computer Science - but concentrated on my graduation then. Furthermore I participated at several German math competitions like "Tag der Mathematik".

Agenda for this summer

  • before May 26 - play around with the curve editing plugins to get some more familiar with the code base and K-3D possibilities
  • July 4 - my semester at Uni ends, I'll have time to concentrate on K-3D fully now
  • until July 7 - curve editing plugins must be finished, the curve->patch plugins should be progressing at this time, mid-term evaluation
  • August 11 - after a month of fulltime programming on the plugins they all should be done, including tests, documentation and wiki-howtos
  • until September 1 - final evaluation, last polishing on the code, submitting to google code

I know that 2 of my 5 exams for uni are dated at end of september so these won't influence my work. I don't know the dates for the other 3 yet, but as I do not have any other occupation in the time between July 4 and October, this should not be a problem.

No big vacations or anything planned there :)

Personal tools