class RED::ILineShape
This interface gives access to the line's properties. More...
#include <REDILineShape.h>
Inherits: IREDObject.
Public functions:
virtual RED_RC | AddSegments ( const int * iSegmentIndex, int iSegmentCount, const RED::State & iState ) = 0 |
virtual RED_RC | AddSegmentsAdjacency ( const int * iSegmentIndex, int iSegmentCount, const RED::State & iState ) = 0 |
virtual RED_RC | AddStrips ( const int * iStripIndex, const int * iStripCount, int iStripEntriesCount, const RED::State & iState ) = 0 |
virtual RED_RC | BuildSegmentsAdjacency ( const RED::State & iState ) = 0 |
virtual RED_RC | Collapse ( double iTolerance, const RED::State & iState ) = 0 |
virtual RED_RC | CopyFrom ( const RED::Object & iLine, const RED::State & iState, int iSrcStateNumber = -1 ) = 0 |
virtual RED_RC | DeleteAllArrays ( const RED::State & iState ) = 0 |
virtual RED_RC | DeleteArray ( RED::MESH_CHANNEL iChannelId, const RED::State & iState ) = 0 |
virtual RED_RC | DeleteSegments ( const RED::State & iState ) = 0 |
virtual RED_RC | GetArray ( const void *& oArray, int & oSize, RED::MESH_FORMAT & oFormat, RED::MESH_CHANNEL iChannelId, int iStateNumber = -1 ) const = 0 |
virtual RED_RC | GetArray ( void *& oArray, int & oSize, RED::MESH_FORMAT & oFormat, RED::MESH_CHANNEL iChannelId, const RED::State & iState ) = 0 |
virtual RED_RC | GetArray ( const void *& oData, RED::MESH_CHANNEL iChannelId, int iStateNumber = -1 ) const = 0 |
virtual RED_RC | GetArray ( void *& oData, RED::MESH_CHANNEL iChannelId, const RED::State & iState ) = 0 |
virtual RED_RC | GetSegments ( const int *& oSegmentIndex, int & oSegmentCount, int iStateNumber = -1 ) const = 0 |
virtual RED_RC | GetSegments ( int *& oSegmentIndex, int & oSegmentCount, const RED::State & iState ) = 0 |
virtual RED_RC | GetSegmentsCount ( int & oCount, int iStateNumber = -1 ) const = 0 |
virtual RED_RC | GetStrip ( int *& oStripIndex, int & oStripSize, const RED::State & iState ) = 0 |
virtual RED_RC | GetStrip ( const int *& oStripIndex, int & oStripSize, int iStateNumber = -1 ) const = 0 |
virtual RED_RC | GetStripSize ( int & oSize, int iStateNumber = -1 ) const = 0 |
virtual RED_RC | GetVertexArray ( const void *& oArray, int & oSize, RED::MESH_FORMAT & oFormat, int iStateNumber = -1 ) const = 0 |
virtual RED_RC | GetVertexArray ( void *& oArray, int & oSize, RED::MESH_FORMAT & oFormat, const RED::State & iState ) = 0 |
virtual RED_RC | GetVerticesCount ( int & oCount, int iStateNumber = -1 ) const = 0 |
virtual RED_RC | IsSegmentsAdjacency ( bool & oAdjacency, int iStateNumber = -1 ) const = 0 |
virtual RED_RC | IsSharedArray ( bool & oShared, RED::MESH_CHANNEL iChannelId, int iStateNumber = -1 ) const = 0 |
virtual RED_RC | IsSharedSegments ( bool & oShared, int iStateNumber = -1 ) const = 0 |
virtual RED_RC | IsSharedStrip ( bool & oShared, int iStateNumber = -1 ) const = 0 |
virtual RED_RC | Parametrize ( RED::MESH_CHANNEL iParamChannel, const RED::State & iState ) = 0 |
virtual RED_RC | RemoveSegmentsAdjacency ( const RED::State & iState ) = 0 |
virtual RED_RC | SetArray ( RED::MESH_CHANNEL iChannelId, const void * iData, int iVerticesCount, int iSize, RED::MESH_FORMAT iFormat, const RED::State & iState ) = 0 |
virtual RED_RC | SetSegment ( int iNumSegment, int iP0, int iP1, const RED::State & iState ) = 0 |
virtual RED_RC | SetSegmentAdjacency ( int iNumSegment, int iV0, int iV1, int iV2, int iV3, const RED::State & iState ) = 0 |
virtual RED_RC | SetSharedArray ( RED::MESH_CHANNEL iChannelId, const void * iData, int iVerticesCount, int iSize, RED::MESH_FORMAT iFormat, const RED::State & iState ) = 0 |
virtual RED_RC | SetSharedSegments ( const int * iSegmentIndex, int iSegmentCount, const RED::State & iState ) = 0 |
virtual RED_RC | SetSharedSegmentsAdjacency ( const int * iSegmentIndex, int iSegmentCount, const RED::State & iState ) = 0 |
virtual RED_RC | SetSharedStrip ( const int * iStripIndex, int iStripSize, const RED::State & iState ) = 0 |
virtual RED_RC | SetStrip ( const int * iStripIndex, int iStripSize, const RED::State & iState ) = 0 |
Public static functions:
static RED::CID | GetClassID ( ) |
Detailed description:
This interface gives access to the line's properties.
Lines are built using indexed segments lists or are built using a single line strip. The primitive provides a helper that breaks multiple line strips into isolated segments as this provides better rendering performances in minimizing the number of rendering calls.
Multiple line strips that are intended to be rendered as real strips for quality reasons compared to segments have to be stored on separate shapes. Note that line strips can't be batched in the same way as we do it for segments, and therefore take longer to render.
A line that has a valid strip contents in will ignore its segments for the rendering and only consider the strip.
Lines are similar to meshes (see RED::IMeshShape) in the sense that they also feature 16 data channels that can store each line's vertex attributes.
Functions documentation
public static RED::CID RED::ILineShape::GetClassID | ( | ) |
public virtual RED_RC RED::ILineShape::AddSegments | ( | const int * | iSegmentIndex, |
int | iSegmentCount, | ||
const RED::State & | iState | ||
) | = 0 |
Adds segments to the object's list.
This method adds segments to the list of segments in the object. The input information is being copied and appended at the end of the existing information already set.
It's possible to provide no segments index array at all. In this case, the size of the segments list is increased by iNbSegments, and all indices in the added list are set to zero. Then the quick segment edition method RED::ILineshape::SetSegment can be used to change the list on the fly, without memory allocations penalties that would occur with a 1 by 1 addition of all segments.
If the object had a shared segment list or a shared strip, this list is replaced by the data supplied to this method.
See also Building basic primitives.
Parameters:
iSegmentIndex: | Index array for the added segments. Contains two (int) values per segment. Each index points to the number of the vertex to reference in the line data channels. When NULL, the method creates an index array set to zero by default, sized to the number of requested segments. |
iSegmentCount: | Number of segments to add (must be >=0) |
iState: | Current transaction. |
Returns:
RED_BAD_PARAM if the method has received an invalid parameter,
RED_ALLOC_FAILURE if an internal memory allocation has failed,
RED_FAIL otherwise.
public virtual RED_RC RED::ILineShape::AddSegmentsAdjacency | ( | const int * | iSegmentIndex, |
int | iSegmentCount, | ||
const RED::State & | iState | ||
) | = 0 |
Adds segments to the object's list, with adjacency informations.
This method adds segments to the list of segments in the object. The input information is being copied and appended at the end of the existing information already set.
It's possible to provide no segments index array at all. In this case, the size of the segments list is increased by iNbSegments, and all indices in the added list are set to zero. Then the quick segment edition method RED::ILineshape::SetSegmentAdjacency can be used to change the list on the fly, without memory allocations penalties that would occur with a 1 by 1 addition of all segments.
If the object had a shared segment list or a shared strip, this list is replaced by the data supplied to this method.
Segments with adjacency are defined as indicated below:

Description of a segment with its adjacency vertices.
Each shape segment must be defined with two adjacent vertices. The segment is [ P0, P1 ] and the set of 4 vertices 0, 1, 2, 3 are supplied to the method for each triangle, 0 being P0 and 2 being P1.
See also Building basic primitives.
Parameters:
iSegmentIndex: | Index array for the added segments. Contains four (int) values per segment. Each index points to the number of the vertex to reference in the line data channels. When NULL, the method creates an index array set to zero by default, sized to the number of requested segments. |
iSegmentCount: | Number of segments to add (must be >=0) |
iState: | Current transaction. |
Returns:
RED_BAD_PARAM if the method has received an invalid parameter,
RED_ALLOC_FAILURE if an internal memory allocation has failed,
RED_FAIL otherwise.
public virtual RED_RC RED::ILineShape::AddStrips | ( | const int * | iStripIndex, |
const int * | iStripCount, | ||
int | iStripEntriesCount, | ||
const RED::State & | iState | ||
) | = 0 |
Adds line strips converted to segments to the object contents.
This method adds line strips to the list of segments in the object. The input information is being turned into segments, then copied and appended at the end of the existing information set.
Calling this method replaces any shared segment list or strip that was stored in the object.
Parameters:
iStripIndex: | Indices of all strips in sequence. If for example, there are two strips added of length 4 and 5, then iStripIndex should contain 9 floats referencing vertices numbers in the data channels of the object. For example, (0,1,2,3,8,9,10,11,12) is a valid content defining two strips of length 4 and 5. |
iStripCount: | Contains the list of number of vertices of each strip. Using the previous example, iStripCount contains only two values set to 4 and 5. |
iStripEntriesCount: | Number of added strips. Still in our example, 2. |
iState: | Current transaction. |
Returns:
RED_BAD_PARAM if the method has received an invalid parameter,
RED_ALLOC_FAILURE if an internal memory allocation has failed,
RED_FAIL otherwise.
public virtual RED_RC RED::ILineShape::BuildSegmentsAdjacency | ( | const RED::State & | iState | ) = 0 |
Constructs segment adjacency for the current object.
This method takes the current list of segments in this and replaces it with a list of segments that contain adjacency informations, as a call to RED::ILineShape::AddSegmentsAdjacency would do.
If the object already has adjacency informations, the method does nothing.
The method does not work on shared lists of segments.
The method does not work on manifold topologies (e.g. each vertex is connected to at most two segments).
The opposite operation is performed by RED::ILineShape::RemoveSegmentsAdjacency.
Parameters:
iState: | Current transaction. |
Returns:
RED_WORKFLOW_ERROR if the shape has a shared list of segments,
RED_ALLOC_FAILURE if an internal allocation has failed,
RED_FAIL if the source mesh is a manifold topology,
RED_FAIL if an unexpected error has occurred.
public virtual RED_RC RED::ILineShape::Collapse | ( | double | iTolerance, |
const RED::State & | iState | ||
) | = 0 |
Removes duplicate vertices.
This method removes all duplicates vertices in the mesh and changes all triangles indices accordingly. Two vertices are considered identical if:
- Their position are identical at iTolerance,
- All their other geometrical attributes are identical at iTolerance.
All duplicate segments resulting of collapsed geometries are removed.
Note that the method can't operate on line shapes with shared arrays as it needs to reallocate the vertex memory to eliminate redundancies.
See Generating vector graphics for a practical example of line collapse operation.
Parameters:
iTolerance: | Numerical tolerancy used for matching tests. |
iState: | Current transaction. |
Returns:
RED_BAD_PARAM if the method has received an invalid parameter,
RED_ALLOC_FAILURE if an internal allocation has failed,
RED_FAIL if an unexpected error has occurred,
RED_FAIL if the mesh has shared arrays.
public virtual RED_RC RED::ILineShape::CopyFrom | ( | const RED::Object & | iLine, |
const RED::State & | iState, | ||
int | iSrcStateNumber = -1 | ||
) | = 0 |
Copies the content of a line instance to the current object.
This method will work for only two instances of the same concrete class.
Parameters:
iLine: | Reference to the object to copy from. |
iState: | Current transaction. |
iSrcStateNumber: | State from which the source line must be copied. |
Returns:
RED_BAD_PARAM if iLine and this are from different classes, or if iSrcStateNumber is invalid,
RED_ALLOC_FAILURE if an internal allocation has failed,
RED_FAIL for any other error.
public virtual RED_RC RED::ILineShape::DeleteAllArrays | ( | const RED::State & | iState | ) = 0 |
Deletes the contents of all data channels.
Works as RED::ILineShape::DeleteArray, for all channels in the object.
Parameters:
iState: | Current transaction. |
Returns:
RED_BAD_PARAM if the method has received an invalid parameter,
RED_ALLOC_FAILURE if an internal allocation has failed,
RED_FAIL otherwise.
public virtual RED_RC RED::ILineShape::DeleteArray | ( | RED::MESH_CHANNEL | iChannelId, |
const RED::State & | iState | ||
) | = 0 |
Deletes the contents of a data channel.
This method deletes the contents of a data channel identified by its number in the object. The corresponding array - if found - is freed from memory.
Parameters:
iChannelId: | Id of the channel to release. |
iState: | Current transaction. |
Returns:
RED_BAD_PARAM if the method has received an invalid parameter,
RED_ALLOC_FAILURE if an internal allocation has failed,
RED_FAIL otherwise.
public virtual RED_RC RED::ILineShape::DeleteSegments | ( | const RED::State & | iState | ) = 0 |
Deletes all segments in the line list.
This method removes all segments from the list within the line. The memory formerly used is released.
Parameters:
iState: | Current transaction. |
Returns:
RED_BAD_PARAM if the method has received an invalid parameter,
RED_ALLOC_FAILURE if an internal memory allocation has failed,
RED_FAIL otherwise.
public virtual RED_RC RED::ILineShape::GetArray | ( | const void *& | oArray, |
int & | oSize, | ||
RED::MESH_FORMAT & | oFormat, | ||
RED::MESH_CHANNEL | iChannelId, | ||
int | iStateNumber = -1 | ||
) | const = 0 |
Read-only access to an array through its channel identifier.
Returns the array whose channel identifier is iChannelId.
See also Building basic primitives.
Parameters:
oArray: | The address of the array in the line. Returns NULL if the line has no data in that array. The returned data is for read access only. |
oSize: | Number of coordinates per vertex (1,2,3, or 4). |
oFormat: | Format of the returned data. |
iChannelId: | Requested channel id. |
iStateNumber: | Queried state number. |
Returns:
RED_BAD_PARAM if the method has received an invalid parameter.
public virtual RED_RC RED::ILineShape::GetArray | ( | void *& | oArray, |
int & | oSize, | ||
RED::MESH_FORMAT & | oFormat, | ||
RED::MESH_CHANNEL | iChannelId, | ||
const RED::State & | iState | ||
) | = 0 |
Read-write access to an array through its channel identifier.
Returns the array whose channel identifier is iChannelId.
See also Building basic primitives.
Parameters:
oArray: | The address of the array in the line. Returns NULL if the line has no data in that array. The returned data is for read / write access. |
oSize: | Number of coordinates per vertex (1,2,3, or 4). |
oFormat: | Format of the returned data. |
iChannelId: | Requested channel id. |
iState: | Current transaction. |
Returns:
RED_BAD_PARAM if the method has received an invalid parameter.
public virtual RED_RC RED::ILineShape::GetArray | ( | const void *& | oData, |
RED::MESH_CHANNEL | iChannelId, | ||
int | iStateNumber = -1 | ||
) | const = 0 |
Read-only access to an array data through its channel identifier.
Returns the data in the array whose channel id is iChannelId.
Parameters:
oData | Address of the array in the line. Returns NULL if the line has no data in that array. The returned data is for read access only. |
iChannelId: | Requested channel id. |
iStateNumber: | Queried state number. |
Returns:
RED_BAD_PARAM if the method has received an invalid parameter.
public virtual RED_RC RED::ILineShape::GetArray | ( | void *& | oData, |
RED::MESH_CHANNEL | iChannelId, | ||
const RED::State & | iState | ||
) | = 0 |
Read-write access to an array data through its channel identifier.
Returns the data in the array whose channel id is iChannelId.
See also Building basic primitives.
Parameters:
oData | Address of the array in the line. Returns NULL if the line has no data in that array. The returned data is for read / write access. |
iChannelId: | Requested channel id. |
iState: | Current transaction. |
Returns:
RED_BAD_PARAM if the method has received an invalid parameter.
public virtual RED_RC RED::ILineShape::GetSegments | ( | const int *& | oSegmentIndex, |
int & | oSegmentCount, | ||
int | iStateNumber = -1 | ||
) | const = 0 |
Read-only access to the list of segments in the line.
Returns the list of segments in the line (isolated lines). Each segment is made of two consecutive entries in oSegmentIndex, for a total of 2 (or 4) * oSegmentCount entries. The number of entries for a segment is 2, unless adjacency informations have been supplied, in which case, the number is 4. See RED::ILineShape::IsSegmentsAdjacency for the query over the line data format.
An index value indicates the number of the vertex to access in the line arrays.
See also Building basic primitives.
Parameters:
oSegmentIndex: | Segment index list. |
oSegmentCount: | Number of segments. |
iStateNumber: | Queried state number. |
Returns:
RED_BAD_PARAM if the method has received an invalid parameter.
public virtual RED_RC RED::ILineShape::GetSegments | ( | int *& | oSegmentIndex, |
int & | oSegmentCount, | ||
const RED::State & | iState | ||
) | = 0 |
Read-write access to the list of segments in the line.
Returns the list of segments in the line (isolated lines). Each segment is made of two consecutive entries in oSegmentIndex, for a total of 2 (or 4) * oSegmentCount entries. The number of entries for a segment is 2, unless adjacency informations have been supplied, in which case, the number is 4. See RED::ILineShape::IsSegmentsAdjacency for the query over the line data format.
An index value indicates the number of the vertex to access in the line arrays.
See also Building basic primitives.
Parameters:
oSegmentIndex: | Segment index list. |
oSegmentCount: | Number of segments. |
iState: | Current transaction. |
Returns:
RED_BAD_PARAM if the method has received an invalid parameter.
public virtual RED_RC RED::ILineShape::GetSegmentsCount | ( | int & | oCount, |
int | iStateNumber = -1 | ||
) | const = 0 |
Returns the number of segments in the line.
Parameters:
oCount: | The number of segments in the line. |
iStateNumber: | Queried state number. |
Returns:
RED_BAD_PARAM if the method has received an invalid parameter.
public virtual RED_RC RED::ILineShape::GetStrip | ( | int *& | oStripIndex, |
int & | oStripSize, | ||
const RED::State & | iState | ||
) | = 0 |
Gets the strip contents, read-write.
Parameters:
oStripIndex: | Current list of strip indices. |
oStripSize: | Size of the strip. |
iState: | Current transaction. |
Returns:
RED_BAD_PARAM if the method has received an invalid parameter,
RED_ALLOC_FAILURE if an internal memory allocation has failed,
RED_FAIL otherwise.
public virtual RED_RC RED::ILineShape::GetStrip | ( | const int *& | oStripIndex, |
int & | oStripSize, | ||
int | iStateNumber = -1 | ||
) | const = 0 |
Gets the strip contents, read-only.
Parameters:
oStripIndex: | List of strip indices. |
oStripSize: | Size of the strip. |
iStateNumber: | Queried state number. |
Returns:
RED_BAD_PARAM if the method has received an invalid parameter.
public virtual RED_RC RED::ILineShape::GetStripSize | ( | int & | oSize, |
int | iStateNumber = -1 | ||
) | const = 0 |
Gets the size of the strip stored in the line shape.
Parameters:
oSize: | Size of the strip. |
iStateNumber: | Queried state number. |
Returns:
RED_BAD_PARAM if the method has received an invalid parameter.
public virtual RED_RC RED::ILineShape::GetVertexArray | ( | const void *& | oArray, |
int & | oSize, | ||
RED::MESH_FORMAT & | oFormat, | ||
int | iStateNumber = -1 | ||
) | const = 0 |
Read-only access to the vertex array of the line.
Returns the vertex array of the line, and its size and type of data per vertex. If this line is intended for use with the ray-tracer, it expects three MFT_FLOAT coordinates.
See also Building basic primitives.
Parameters:
oArray: | Address of the vertex array of the line. Returns NULL if the line has no bound vertex array yet. The returned data is for read access only. |
oSize: | Number of coordinates per vertex (1,2,3, or 4). |
oFormat: | Format of the returned data. |
iStateNumber: | Queried state number. |
Returns:
RED_BAD_PARAM if the method has received an invalid parameter.
public virtual RED_RC RED::ILineShape::GetVertexArray | ( | void *& | oArray, |
int & | oSize, | ||
RED::MESH_FORMAT & | oFormat, | ||
const RED::State & | iState | ||
) | = 0 |
Read-write access to the vertex array of the line.
Returns the current vertex array of the line, its size and type of data per vertex. If this line is intended for use with the ray-tracer, it expects three MFT_FLOAT coordinates. The data array can be modified, but the format and size of the array can't be changed.
See also Building basic primitives.
Parameters:
oArray: | Address of the vertex array of the line. Returns NULL if the line has no bound vertex array yet. The returned data is for read access only. |
oSize: | Number of coordinates per vertex (1,2,3, or 4). |
oFormat: | Format of the returned data. |
iState: | Current transaction. |
Returns:
RED_BAD_PARAM if the method has received an invalid parameter.
public virtual RED_RC RED::ILineShape::GetVerticesCount | ( | int & | oCount, |
int | iStateNumber = -1 | ||
) | const = 0 |
Gets the number of vertices in the line.
Returns the number of vertices in the line. Each used data channel is sized to contain information for the same number of vertices.
Parameters:
oCount: | The number of vertices in the line. |
iStateNumber: | Queried state number. |
Returns:
RED_BAD_PARAM if the method has received an invalid parameter.
public virtual RED_RC RED::ILineShape::IsSegmentsAdjacency | ( | bool & | oAdjacency, |
int | iStateNumber = -1 | ||
) | const = 0 |
Are shape segments using adjacency?
Adjacency can be specified for the shape using RED::ILineShape::AddSegmentsAdjacency.
Parameters:
oAdjacency: | true if the shape stores segments with adjacency. |
iStateNumber: | Queried state number. |
Returns:
RED_BAD_PARAM if the method has received an invalid parameter.
public virtual RED_RC RED::ILineShape::IsSharedArray | ( | bool & | oShared, |
RED::MESH_CHANNEL | iChannelId, | ||
int | iStateNumber = -1 | ||
) | const = 0 |
Is the specified channel being shared?
Parameters:
oShared: | true if the data in iChannelId is shared. false otherwise (not shared or no data). |
iChannelId: | Identifier of the channel to check. |
iStateNumber: | Queried state number. |
Returns:
RED_BAD_PARAM if the method has received an invalid parameter.
public virtual RED_RC RED::ILineShape::IsSharedSegments | ( | bool & | oShared, |
int | iStateNumber = -1 | ||
) | const = 0 |
Is the shape's segment array being shared?
Parameters:
oShared: | true if the object segment list is shared. false otherwise (not shared or no data). |
iStateNumber: | Queried state number. |
Returns:
RED_BAD_PARAM if the method has received an invalid parameter.
public virtual RED_RC RED::ILineShape::IsSharedStrip | ( | bool & | oShared, |
int | iStateNumber = -1 | ||
) | const = 0 |
Is the mesh's strip array being shared?
Parameters:
oShared: | true if the object strip is shared. false otherwise (not shared or no data). |
iStateNumber: | Queried state number. |
Returns:
RED_BAD_PARAM if the method has received an invalid parameter.
public virtual RED_RC RED::ILineShape::Parametrize | ( | RED::MESH_CHANNEL | iParamChannel, |
const RED::State & | iState | ||
) | = 0 |
Creates a contiguous strip with parametric length over the entire shape.
This method adds a 'parametric length' channel information to all segments in the shape and turn the entire set of segments into one single strip. All contiguous segments are grouped together and the added data channel is set to contain the parametric length of the vertex along the global segment made of all contiguous unitary segments:

Example of a mesh segments parametrization.
The parametric value added at each vertex in the mesh is equal to the cumulated length since the start of the segment group up to the considered vertex, divided by the total length of the segment group.
As illustrated above, the method creates segment groups based on unitary segments that are found in the shape. All segments that are connected and that are not connected to any other segment (e.g. that have a number of connected segments <= 2) are part of the same segment group. All vertices that have a connection count greater than 2 (>2) are exploded for the storage of the parametric length of each segment group they belong to.
Then, all segments in the shape are removed and one big strip is set to replace them. The segment groups are linked together to ensure the continuity of the data in one strip. A special shader need to be used to get rid of the 'extra' strip lines created this way:

Unwanted strip parts and the way to get rid of them.
Unwanted strip parts can be discarded using shaders. Assuming that the parametrization is received in a pixel shader through 'fragment.texcoord[0]':
psh.Temp( "R0" );
psh.Add( "SGE R0.x, fragment.texcoord[0].x, { 0.99999 }.x;\n" );
psh.Add( "SLT R0.y, fragment.texcoord[0].x, { 0.00001 }.x;\n" );
psh.Add( "ADD R0.x, R0.x, R0.y;\n" );
psh.Add( "KIL -R0.x;\n" );
Unwanted strip lines added by the method have a constant parametrization: it's either 0.0 or 1.0. This can be used to discard all fragments they would cover if not killed.
If the material used for the display of a parametrization result has to be used by more than one single shape, it should have its batching capabilities disabled (see RED::IMaterial::SetBatchMode).
A full helper for the creation of the material exists here: RED::IResourceManager::CreateParametrizationMaterial.
See Hidden lines removal: A real-time example for a practical application of the parametrization method.
The method neither works if shared arrays are used nor if the shape has segments with adjacency.
Parameters:
iParamChannel: | Data channel that receives the parametrization. 1 single RED::MFT_FLOAT is stored per vertex. |
iState: | Current transaction. |
Returns:
RED_BAD_PARAM if the method has received an invalid parameter,
RED_BAD_PARAM if iParamChannel is already used in the shape,
RED_ALLOC_FAILURE if an internal allocation has failed,
RED_FAIL if an unexpected error has occurred,
RED_FAIL if the shape has shared arrays,
RED_FAIL if the shape contains strips. The method works on segments,
RED_FAIL if the shape has adjacency. The method works only on segments with no adjacency data.
public virtual RED_RC RED::ILineShape::RemoveSegmentsAdjacency | ( | const RED::State & | iState | ) = 0 |
Removes segments adjacency from the current object.
This method does the opposite of RED::ILineShape::BuildSegmentsAdjacency: it removes all adjacency information from the shape and replaces its list of segments with adjacency by a list of segments with no adjacency informations.
If the shape has no adjacency informations, the method does nothing. The method does not work on shared lists of segments.
Parameters:
iState: | Current transaction. |
Returns:
RED_WORKFLOW_ERROR if the shape has a shared list of segments,
RED_ALLOC_FAILURE if an internal allocation has failed,
RED_FAIL if an unexpected error has occurred.
public virtual RED_RC RED::ILineShape::SetArray | ( | RED::MESH_CHANNEL | iChannelId, |
const void * | iData, | ||
int | iVerticesCount, | ||
int | iSize, | ||
RED::MESH_FORMAT | iFormat, | ||
const RED::State & | iState | ||
) | = 0 |
Defines the contents of a data channel.
This method defines the contents of the targeted channel. We have two possible memory behaviors here:
- Copy the provided input data in the class. We try to be memory conservative in this case and to reuse existing memory that could have been allocated earlier on for the same data channel.
- Provide no iData at all. In this case, we allocate an array using the dimension parameters provided. This array is not initialized by the call, and can be accessed to be filled.
Note that we define the number of vertices as a parameter of the method, to be able to figure out the total size of our data channel. All channels must be configured with the same number of vertices. The method fails if the provided number of vertices don't match the current size of other channels.
See also Building basic primitives.
Parameters:
iChannelId: | Targeted channel that'll receive the contents of iData. |
iData: | Data array. NULL to let the method allocate an array itself. |
iVerticesCount: | Number of vertices (the same for all channels). |
iSize: | Number of coordinates per vertex in [1-4]. |
iFormat: | Format of each coordinate. |
iState: | Current transaction. |
Returns:
RED_BAD_PARAM if the method has received an invalid parameter,
RED_ALLOC_FAILURE if an internal allocation has failed,
RED_FAIL if the number of vertices does not match the current size of other channels.
public virtual RED_RC RED::ILineShape::SetSegment | ( | int | iNumSegment, |
int | iP0, | ||
int | iP1, | ||
const RED::State & | iState | ||
) | = 0 |
Modifies indices defining a segment.
This method can be used to quickly change the indices defining a segment. The target segment is iNumSegment, and the new indices to use for it are [ iP0, iP1 ].
Parameters:
iNumSegment: | Segment to modify. |
iP0: | First segment vertex number. |
iP1: | Second segment vertex number. |
iState: | Current transaction. |
Returns:
RED_BAD_PARAM if the method has received an invalid parameter,
RED_ALLOC_FAILURE if an internal memory allocation has failed,
RED_FAIL otherwise.
public virtual RED_RC RED::ILineShape::SetSegmentAdjacency | ( | int | iNumSegment, |
int | iV0, | ||
int | iV1, | ||
int | iV2, | ||
int | iV3, | ||
const RED::State & | iState | ||
) | = 0 |
Modifies indices defining a segment, with adjacency.
This method can be used to quickly change the indices defining a segment. The target segment is iNumSegment, and the new indices to use for it are [ iV0, iV1, iV2, iV3 ].
Parameters:
iNumSegment: | Segment to modify. |
iV0: | First vertex number (is the first segment vertex). |
iV1: | Second vertex number. |
iV2: | Third vertex number (is the second segment vertex). |
iV3: | Fourth vertex number. |
iState: | Current transaction. |
Returns:
RED_BAD_PARAM if the method has received an invalid parameter,
RED_ALLOC_FAILURE if an internal memory allocation has failed,
RED_FAIL otherwise.
public virtual RED_RC RED::ILineShape::SetSharedArray | ( | RED::MESH_CHANNEL | iChannelId, |
const void * | iData, | ||
int | iVerticesCount, | ||
int | iSize, | ||
RED::MESH_FORMAT | iFormat, | ||
const RED::State & | iState | ||
) | = 0 |
Defines the contents of a data channel.
This method is similar to RED::ILineShape::SetArray, except that the memory control of the provided array is let to the caller's responsibility. Shared arrays differ in their behaviors from regular arrays in several ways:
- The address of a shared array do not change with new transactions. A regular array is copied to a new version when modified so that it can be modified without stalling a multi-threaded rendering that may occur on the last closed transaction version of the data. A shared array is not duplicated and therefore the returned address can't be overwritten if multi-threaded rendering is used.
- RED::ILineShape::DeleteArray and RED::ILineShape::DeleteAllArrays don't release the shared memory but behave normally for all other aspects of the method.
Sharing with a RED::IMeshShape array must be done carefully. If the mesh is edited after the sharing has occurred, then the mesh's arrays base addresses will change due to the multi-threading security of REDsdk's transaction model. Then the sharing may become invalid, and should be done again to ensure that we share the appropriate address.
Parameters:
iChannelId: | Targeted channel. |
iData: | Shared data array. |
iVerticesCount: | Number of vertices for all channels. |
iSize: | Number of coordinates per vertex in [1-4]. |
iFormat: | Format of each coordinate. |
iState: | Current transaction. |
Returns:
RED_BAD_PARAM if the method has received an invalid parameter,
RED_ALLOC_FAILURE if an internal allocation has failed,
RED_FAIL if the number of vertices does not match the current size of other channels.
public virtual RED_RC RED::ILineShape::SetSharedSegments | ( | const int * | iSegmentIndex, |
int | iSegmentCount, | ||
const RED::State & | iState | ||
) | = 0 |
Uses a shared segment list for the object.
If the object was owning a list of segments, this list is deleted and replaced by the shared list provided to the method.
Parameters:
iSegmentIndex: | Index array for the added segments. Must point on a valid array of two (int)s for each segment. |
iSegmentCount: | Number of segments in iSegmentIndex. |
iState: | Current transaction. |
Returns:
RED_BAD_PARAM if the method has received an invalid parameter,
RED_ALLOC_FAILURE if an internal memory allocation has failed,
RED_FAIL otherwise.
public virtual RED_RC RED::ILineShape::SetSharedSegmentsAdjacency | ( | const int * | iSegmentIndex, |
int | iSegmentCount, | ||
const RED::State & | iState | ||
) | = 0 |
Uses a shared segment list for the object, with adjacency.
If the object was owning a list of segments, this list is deleted and replaced by the shared list provided to the method.
Parameters:
iSegmentIndex: | Index array for the added segments. Must point on a valid array of four (int)s for each segment. |
iSegmentCount: | Number of segments in iSegmentIndex. |
iState: | Current transaction. |
Returns:
RED_BAD_PARAM if the method has received an invalid parameter,
RED_ALLOC_FAILURE if an internal memory allocation has failed,
RED_FAIL otherwise.
public virtual RED_RC RED::ILineShape::SetSharedStrip | ( | const int * | iStripIndex, |
int | iStripSize, | ||
const RED::State & | iState | ||
) | = 0 |
Uses a shared strip list for the object.
If the object was owning a strip, that strip is deleted and replaced by the shared strip provided to the method.
Parameters:
iStripIndex: | Index array for the added strip. Must point on a valid array with one (int) for each strip point. |
iStripSize: | Number of vertices composiing the strip. |
iState: | Current transaction. |
Returns:
RED_BAD_PARAM if the method has received an invalid parameter,
RED_ALLOC_FAILURE if an internal memory allocation has failed,
RED_FAIL otherwise.
public virtual RED_RC RED::ILineShape::SetStrip | ( | const int * | iStripIndex, |
int | iStripSize, | ||
const RED::State & | iState | ||
) | = 0 |
Sets the object contents to a single line strip.
This method sets the object contents to a single line strip. If the provided iStripSize is zero, the objects contents are erased.
If the object had a shared segment list or a shared strip, this list is replaced by the data supplied to this method.
Parameters:
iStripIndex: | List of indices composing the strip. If set to NULL, the method allocates an array of iStripSize values that are filled with zeros, ready to receive values. |
iStripSize: | Number of vertices composing the strip. |
iState: | Current transaction. |
Returns:
RED_BAD_PARAM if the method has received an invalid parameter,
RED_ALLOC_FAILURE if an internal memory allocation has failed,
RED_FAIL otherwise.