User:Barche/Mesh Modifier Types

From K-3D

Jump to: navigation, search

One-to-one modifiers

This type of modifier takes exactly one input mesh and produces exactly one output mesh. This means it can easily fit into the pipeline between the original mesh source and the final mesh sink, usually the mesh instance.

Usage

From the context menu, select the modifier that is to be used, and it will automatically be inserted into the pipeline(s) of the selected mesh(es). If multiple meshes are selected, one modifier will be created for each mesh, and the properties of the modifiers will all be connected to the "first" modifier, which will have its properties shown in the node properties panel. This means that editing these properties will affect the entire selection.

Implemented interfaces

A one-to-one mesh modifier must implement the interfaces k3d::imesh_sink and k3d::imesh_source. Some convenience classes have been defined to make the implementation easier:

Examples

Most modifiers fall into this category, i.e. TranslatePoints, ExtrudeFaces, ...

Many-to-one modifiers

This type of modifier takes any number of input meshes, and produces exactly one output mesh.

Usage

Again, the modifier is simply selected from the context menu. For each selected mesh, the UI code will create a user property in the modifier, and connect the "transformed_mesh" property of the MeshInstance as input. All visibility properties of the input MeshInstances are disabled, and the output mesh of the modifier is sent to a new MeshInstance.

Implemented interfaces

A many-to-one interface must implement the k3d::imulti_mesh_sink and k3d::imesh_source interfaces. The k3d::imulti_mesh_sink interface will be defined as follows:

class imulti_mesh_sink :
	public virtual iunknown
{
public:
	/// Defines a collection of properties
	typedef std::vector<iproperty*> properties_t;
	
	/// Returns the collection of properties that store the input meshes
	virtual const properties_t mesh_input_properties() = 0;
	

protected:
	imulti_mesh_sink() {}
	imulti_mesh_sink(const imulti_mesh_sink&) {}
	imulti_mesh_sink& operator=(const imulti_mesh_sink&) { return *this; }
	virtual ~imulti_mesh_sink() {}
};

Examples

At the time of writing (K-3D 0.7.4.0), the only examples are CGALBoolean and MergeMesh.

The hypothetical one-to-many modifier

This type of modifier does not exist yet, but it would take one input mesh and create N output meshes. The output would again be stored in user properties, and the new interface k3d::imulti_mesh_source would have to declare a method that indicates how many outputs will be generated. A possible example would be a plugin that splits an input mesh that has multiple polyhedra or primitives into a separate mesh for each.

The even more hypothetical many-to-many modifier

This modifier would take any number of input meshes (based on the selection) and produce any number of outputs. At first glance, I can't think of any applications needing this.