neuray API Programmer's Manual

mi::neuraylib::ISimple_mesh Class Reference

[Leaf nodes]

Description

Interface representing the geometry of on-demand meshes. There are five different types of data arrays: for points, normals, texture coordinates, derivatives, and motion vectors. The data array for points is mandatory, all other data arrays are optional. Each type exists at most once, except for texture coordinates where one data array is used per texture space.

The data arrays are referenced via the indices stored at the triangle vertices. Note that only one index is used for all arrays together, hence, all arrays have the same length.

The pointers returned by the various methods have to be valid as long as the interface is valid.

Note:

The callback that returns an instance of this interface might be executed several times, e.g., in a first pass to retrieve the characteristics of the simple mesh, like number of points, triangles, etc., and in a second pass to access the actual mesh data, i.e., the point vectors, triangles indices, and so on. This does not matter if the implementation of this interface is just a thin adaptor to existing data structures. But if the existing data structures need to be converted to implement this interface it is recommended to do the data conversion lazily when the data arrays and triangle indices are actually requested.

See also:

mi::neuraylib::IOn_demand_mesh, mi::neuraylib::IOn_demand_mesh_callback

Public Member Functions

virtual Uint32 data_size() const =0
Returns the size of the data arrays.
virtual const Float32_3_structget_derivatives() const =0
Returns the data array for derivatives. More...
virtual const Uint32get_material_indices() const =0
Returns the array of material indices. More...
virtual Uint32 get_motion_vector_count() const =0
Returns the number of motion vectors per point. More...
virtual const Float32_3_structget_motion_vectors() const =0
Returns the data array for motion vectors. More...
virtual const Float32_3_structget_normals() const =0
Returns the data array for normals. More...
virtual const Float32_3_structget_points() const =0
Returns the data array for points. More...
virtual const Float32get_texture_coordinates( Uint32 texture_space_id) const =0
Returns the data array for a texture space. More...
virtual Uint32 get_texture_dimension( Uint32 texture_space_id) const =0
Returns the dimension of a texture space. More...
virtual const Uint32_3_structget_triangles() const =0
Returns the array of triangle indices. More...
virtual const Float32get_userdata( Uint32 userdata_id) const =0
Returns a userdata array. More...
virtual Uint32 get_userdata_dimension( Uint32 userdata_id) const =0
Returns the dimension of a userdata array. More...
virtual const char* get_userdata_name( Uint32 userdata_id) const =0
Returns the name of a userdata array. More...
virtual bool  has_unique_material() const =0
Indicates whether all triangles use the same material.
virtual Uint32 triangles_size() const =0
Returns the number of triangles.

Member Functions

virtual Uint32 mi::​neuraylib::​ISimple_mesh::data_size() const [pure virtual]

Returns the size of the data arrays.

virtual const Float32_3_struct* mi::​neuraylib::​ISimple_mesh::get_derivatives() const [pure virtual]

Returns the data array for derivatives. Derivatives are computed w.r.t. to the first texture space. If there are no derivatives, i.e., the methods returns NULL, the derivatives are approximated internally based on the mesh data and the texture coordinates of the first texture space.

Note:

This data array contains 2 * data_size() elements of type mi::Float32_3_struct. The derivatives w.r.t. dU and dV are consecutively stored in that order per index.

Returns

A pointer to the first element of the data array for derivatives, or NULL if there are no derivatives.

virtual const Uint32* mi::​neuraylib::​ISimple_mesh::get_material_indices() const [pure virtual]

Returns the array of material indices. If has_unique_material() returns true, the length of the array is 1. Otherwise, the length is given by triangles_size() (one material index per triangle).

Note:

For best performance it is recommended to sort the triangles by their material index such that when looping over all triangles the material index changes as infrequently as possible.

virtual Uint32 mi::​neuraylib::​ISimple_mesh::get_motion_vector_count() const [pure virtual]

Returns the number of motion vectors per point.

Returns

The number of motion vectors per point, or 0 if there are no motion vectors available.

virtual const Float32_3_struct* mi::​neuraylib::​ISimple_mesh::get_motion_vectors() const [pure virtual]

Returns the data array for motion vectors.

Note:

This data array contains get_motion_vector_count() * data_size() elements of type mi::Float32_3_struct. The elements for one point are stored consecutively.

Returns

A pointer to the first element of the data array for motion vectors, or NULL if there are no motion vectors available.

virtual const Float32_3_struct* mi::​neuraylib::​ISimple_mesh::get_normals() const [pure virtual]

Returns the data array for normals. If there are no normals, i.e., the methods returns NULL, face normals will be used.

Returns

A pointer to the first element of the data array for normals, or NULL if there are no normals available.

virtual const Float32_3_struct* mi::​neuraylib::​ISimple_mesh::get_points() const [pure virtual]

Returns the data array for points.

Returns

A pointer to the first element of the data array for points (never NULL , unless data_size() and triangles_size() both return 0).

virtual const Float32* mi::​neuraylib::​ISimple_mesh::get_texture_coordinates( Uint32 texture_space_id) const [pure virtual]

Returns the data array for a texture space.

Note:
  • Texture spaces need to use consecutive texture space IDs starting with 0. The number of texture spaces is limited to mi::neuraylib::ATTR_TEXTURE_NUM.

  • This data array contains get_texture_dimension() * data_size() elements of type mi::Float32. The elements for one single point are stored consecutively.

Parameters

texture_space_id
The ID of the texture space.

Returns

A pointer to the first element of the data array for this texture space, or NULL if there is no texture space with the given ID.

virtual Uint32 mi::​neuraylib::​ISimple_mesh::get_texture_dimension( Uint32 texture_space_id) const [pure virtual]

Returns the dimension of a texture space. The dimension of a texture space is the dimension of the vector data stored for each triangle vertex. Typically, the dimension is 2 representing UV texture coordinates.

Note:

Texture spaces need to use consecutive texture space IDs starting with 0. The number of texture spaces is limited to mi::neuraylib::ATTR_TEXTURE_NUM.

Parameters

texture_space_id
The ID of the texture space.

Returns

The dimension of this texture space, or 0 if there is no texture space with the given ID.

virtual const Uint32_3_struct* mi::​neuraylib::​ISimple_mesh::get_triangles() const [pure virtual]

Returns the array of triangle indices. These indices reference the corresponding elements in the data arrays. The indices represent the vertices in CCW order.

Note:

For best performance it is recommended to sort the triangles by their material index such that when looping over all triangles the material index changes as infrequently as possible.

virtual const Float32* mi::​neuraylib::​ISimple_mesh::get_userdata( Uint32 userdata_id) const [pure virtual]

Returns a userdata array.

Note:
  • Userdata arrays need to use consecutive userdata IDs starting with 0. The number of userdata arrays is limited to mi::neuraylib::ATTR_USER_NUM.

  • This data array contains get_userdata_dimension() * data_size() elements of type mi::Float32. The elements for one single point are stored consecutively.

Parameters

userdata_id
The ID of the userdata array.

Returns

A pointer to the first element of the data array for this userdata array, or NULL if there is no userdata array with the given ID.

virtual Uint32 mi::​neuraylib::​ISimple_mesh::get_userdata_dimension( Uint32 userdata_id) const [pure virtual]

Returns the dimension of a userdata array. The dimension of a userdata array is the dimension of the vector data stored for each triangle vertex.

Note:

Userdata arrays need to use consecutive userdata IDs starting with 0. The number of userdata arrays is limited to mi::neuraylib::ATTR_USER_NUM.

Parameters

userdata_id
The ID of the userdata array.

Returns

The dimension of this userdata array, or 0 if there is no userdata array with the given ID.

virtual const char* mi::​neuraylib::​ISimple_mesh::get_userdata_name( Uint32 userdata_id) const [pure virtual]

Returns the name of a userdata array.

Note:

Userdata arrays need to use consecutive userdata IDs starting with 0. The number of userdata arrays is limited to mi::neuraylib::ATTR_USER_NUM.

Parameters

userdata_id
The ID of the userdata array.

Returns

The name of this userdata array, or NULL if there is no userdata array with the given ID.

virtual bool mi::​neuraylib::​ISimple_mesh::has_unique_material() const [pure virtual]

Indicates whether all triangles use the same material.

virtual Uint32 mi::​neuraylib::​ISimple_mesh::triangles_size() const [pure virtual]

Returns the number of triangles.