TranslationMaps Class Reference

#include <lib_modeling.h>

Detailed Description

With previous versions of Cinema 4D it was a hard to update plugin tags after modeling operations. They all had to be done manually per tool (at least in theory, not many plugins bothered!).

A solution to this problem are the tag translation messages. During Modeling::Commit() there are two points at which translations of tags can be done:

  • PRETRANSLATE: This is done before any changes to the object happen. It can be useful to use the old tag/polygon data to translate or to store this info for the translate;
    e.g. edge selections and UVs both need to store old tag data and polygon data ready for the translation after the object is changed.
  • TRANSLATE: This is done after the object is changed.
Note
If Modeling::Commit() fails then TRANSLATE is called with nullptr so that any data stored from PRETRANSLATE can be released.

The TranslationMaps pointer is passed for the translation message data.
A simple example is the vertex map tag. Points are the easiest to translate. Polygons are pretty much the same too. Edges are much harder since they do not have any representation.
In the modeling library they are handled by storing (in PRETRANSLATE) information about the points/polygons that form the edges and use this in TRANSLATE to match up any edge changes.

Bool VertexMapTag::Message(Int32 type, void *data)
{
switch (type)
{
...
RemapVertexMap((Float*)t_data,(TranslationMaps*)data);
break;
}
return SUPER::Message(type,data);
}
static void RemapVertexMap(Float *vmap, TranslationMaps *map)
{
if (map && map->m_pPointMap && map->m_nPointCount && vmap)
{
Int32 i,l,s;
// Processed any interpolated points
for (i=0;i<map->m_mPointCount;i++)
{
if (!(map->m_pPointMap[i].lFlags & TRANSMAP_PNTFLAG_INTER)) continue;
vmap[map->m_pPointMap[i].nIndex]=Mix(vmap[ipnt->p1],vmap[ipnt->p2],ipnt->t);
}
// Merge any welds
for (i=0;i<map->m_mWeldCount;)
{
l=map->m_pWeldMap[i].nIndex; s=0;
Float sum=0.0;
while (i<map->m_mWeldCount && map->m_pWeldMap[i].nIndex==l)
{
if (map->m_pWeldMap[i].oIndex>=0)
{
sum+=vmap[map->m_pWeldMap[i].oIndex];
s++;
}
i++;
}
if (s>0) sum=sum/Float(s);
vmap[l]=sum;
}
// Remap any changes
for (i=0;i<map->m_mPointCount;i++)
{
vmap[map->m_pPointMap[i].nIndex]=0.0;
else if (map->m_pPointMap[i].nIndex!=map->m_pPointMap[i].oIndex)
vmap[map->m_pPointMap[i].nIndex]=vmap[map->m_pPointMap[i].oIndex];
}
}
}

Public Member Functions

 TranslationMaps ()
 
Int32 FindOriginalPoint (Int32 index)
 
Int32 FindOriginalPolygon (Int32 index)
 
Int32 FindOriginalPgon (Int32 index)
 
Int32 FindOriginalSegment (Int32 index)
 
Int32 FindNewPoint (Int32 index)
 
Int32 FindNewPolygon (Int32 index)
 
Int32 FindNewPgon (Int32 index)
 
Int32 FindNewSegment (Int32 index)
 
Int32 FindWeldPoint (Int32 index)
 
Int32 FindMeltPolygon (Int32 index)
 

Public Attributes

Int32 m_oPointCount
 
Int32 m_oPolygonCount
 
Int32 m_oPgonCount
 
Int32 m_oSegmentCount
 
Int32 m_nPointCount
 
Int32 m_nPolygonCount
 
Int32 m_nPgonCount
 
Int32 m_nSegmentCount
 
Int32 m_mPointCount
 
Int32 m_mPolygonCount
 
Int32 m_mPgonCount
 
Int32 m_mSegmentCount
 
Int32 m_mWeldCount
 
Int32 m_mMeltCount
 
TransMapDatam_pPointMap
 
TransMapDatam_pPolygonMap
 
TransMapDatam_pPgonMap
 
TransMapDatam_pSegmentMap
 
TransIndexMapDatam_pWeldMap
 
TransIndexMapDatam_pMeltMap
 
TransMapNewDatam_pNewPointMap
 
TransMapNewDatam_pNewPolygonMap
 
TransMapNewDatam_pNewPgonMap
 
TransMapNewDatam_pNewSegmentMap
 
TransPointInterDatam_pInterpolatedPoints
 
TransPointDeltaDatam_pDeltaPoints
 

Constructor & Destructor Documentation

◆ TranslationMaps()

Constructor.

Member Function Documentation

◆ FindOriginalPoint()

Int32 FindOriginalPoint ( Int32  index)

Searches for the original (i.e old) index based on the new index. (A pure helper. The source for this function is available in lib_modeling.cpp.)

Parameters
[in]indexThe new index.
Returns
The old index.

◆ FindOriginalPolygon()

Int32 FindOriginalPolygon ( Int32  index)

Searches for the original (i.e old) index based on the new index. (A pure helper. The source for this function is available in lib_modeling.cpp.)

Parameters
[in]indexThe new index.
Returns
The old index.

◆ FindOriginalPgon()

Int32 FindOriginalPgon ( Int32  index)

Searches for the original (i.e old) index based on the new index. (A pure helper. The source for this function is available in lib_modeling.cpp.)

Parameters
[in]indexThe new index.
Returns
The old index.

◆ FindOriginalSegment()

Int32 FindOriginalSegment ( Int32  index)

Searches for the original (i.e old) index based on the new index. (A pure helper. The source for this function is available in lib_modeling.cpp.)

Parameters
[in]indexThe new index.
Returns
The old index.

◆ FindNewPoint()

Int32 FindNewPoint ( Int32  index)

Searches for the new index based on the original index. (A pure helper. The source for this function is available in lib_modeling.cpp.)

Parameters
[in]indexThe old index.
Returns
The new index.

◆ FindNewPolygon()

Int32 FindNewPolygon ( Int32  index)

Searches for the new index based on the original index. (A pure helper. The source for this function is available in lib_modeling.cpp.)

Parameters
[in]indexThe old index.
Returns
The new index.

◆ FindNewPgon()

Int32 FindNewPgon ( Int32  index)

Searches for the new index based on the original index. (A pure helper. The source for this function is available in lib_modeling.cpp.)

Parameters
[in]indexThe old index.
Returns
The new index.

◆ FindNewSegment()

Int32 FindNewSegment ( Int32  index)

Searches for the new index based on the original index. (A pure helper. The source for this function is available in lib_modeling.cpp.)

Parameters
[in]indexThe old index.
Returns
The new index.

◆ FindWeldPoint()

Int32 FindWeldPoint ( Int32  index)

Searches for the new index based on the original index. (A pure helper. The source for this function is available in lib_modeling.cpp.)

Parameters
[in]indexThe old index.
Returns
The new index.

◆ FindMeltPolygon()

Int32 FindMeltPolygon ( Int32  index)

Searches for the new index based on the original index. (A pure helper. The source for this function is available in lib_modeling.cpp.)

Parameters
[in]indexThe old index.
Returns
The new index.

Member Data Documentation

◆ m_oPointCount

Int32 m_oPointCount

Original point count.

◆ m_oPolygonCount

Int32 m_oPolygonCount

Original polygon count.

◆ m_oPgonCount

Int32 m_oPgonCount

Original Pgon count.

◆ m_oSegmentCount

Int32 m_oSegmentCount

Original segment count.

◆ m_nPointCount

Int32 m_nPointCount

New point count.

◆ m_nPolygonCount

Int32 m_nPolygonCount

New polygon count.

◆ m_nPgonCount

Int32 m_nPgonCount

New Pgon count.

◆ m_nSegmentCount

Int32 m_nSegmentCount

New segment count.

◆ m_mPointCount

Int32 m_mPointCount

Map point count.

◆ m_mPolygonCount

Int32 m_mPolygonCount

Map polygon count.

◆ m_mPgonCount

Int32 m_mPgonCount

Map Pgon count.

◆ m_mSegmentCount

Int32 m_mSegmentCount

Map segment count.

◆ m_mWeldCount

Int32 m_mWeldCount

Map weld count.

◆ m_mMeltCount

Int32 m_mMeltCount

Map melt count.

◆ m_pPointMap

TransMapData* m_pPointMap

Point translation map.

◆ m_pPolygonMap

TransMapData* m_pPolygonMap

Polygon translation map.

◆ m_pPgonMap

TransMapData* m_pPgonMap

Pgon translation map.

◆ m_pSegmentMap

TransMapData* m_pSegmentMap

Segment translation map.

◆ m_pWeldMap

TransIndexMapData* m_pWeldMap

Weld index translation map.

◆ m_pMeltMap

TransIndexMapData* m_pMeltMap

Melt index translation map.

◆ m_pNewPointMap

TransMapNewData* m_pNewPointMap

New point translation map.

◆ m_pNewPolygonMap

TransMapNewData* m_pNewPolygonMap

New polygon translation map.

◆ m_pNewPgonMap

TransMapNewData* m_pNewPgonMap

New Pgon translation map.

◆ m_pNewSegmentMap

TransMapNewData* m_pNewSegmentMap

New segment translation map.

◆ m_pInterpolatedPoints

TransPointInterData* m_pInterpolatedPoints

Interpolation map.

◆ m_pDeltaPoints

TransPointDeltaData* m_pDeltaPoints

Delta map.

TRANSMAP_FLAG_NEW
#define TRANSMAP_FLAG_NEW
New.
Definition: lib_modeling.h:41
TranslationMaps::m_pPointMap
TransMapData * m_pPointMap
Point translation map.
Definition: lib_modeling.h:308
MSG_TRANSLATE_POINTS
#define MSG_TRANSLATE_POINTS
Sent by the modeling core to let tags etc. update after point changes. The corresponding data is Tran...
Definition: c4d_baselist.h:507
TransMapData::lFlags
Int32 lFlags
Definition: lib_modeling.h:97
Float
maxon::Float Float
Definition: ge_sys_math.h:51
TranslationMaps::m_pInterpolatedPoints
TransPointInterData * m_pInterpolatedPoints
Interpolation map.
Definition: lib_modeling.h:321
TranslationMaps
Definition: lib_modeling.h:209
TransPointInterData::t
Float t
Interpolation parameter.
Definition: lib_modeling.h:119
TransIndexMapData::nIndex
Int32 nIndex
New index.
Definition: lib_modeling.h:79
TransPointInterData
Definition: lib_modeling.h:115
TranslationMaps::m_mPointCount
Int32 m_mPointCount
Map point count.
Definition: lib_modeling.h:300
TranslationMaps::m_pWeldMap
TransIndexMapData * m_pWeldMap
Weld index translation map.
Definition: lib_modeling.h:313
TranslationMaps::m_nPointCount
Int32 m_nPointCount
New point count.
Definition: lib_modeling.h:295
Int32
maxon::Int32 Int32
Definition: ge_sys_math.h:45
C4DAtom::Message
Bool Message(Int32 type, void *data=nullptr)
Definition: c4d_baselist.h:1388
TransPointInterData::p1
Int32 p1
First point.
Definition: lib_modeling.h:117
TransIndexMapData::oIndex
Int32 oIndex
Old index.
Definition: lib_modeling.h:78
TRANSMAP_PNTFLAG_INTER
#define TRANSMAP_PNTFLAG_INTER
Interpolated.
Definition: lib_modeling.h:51
Bool
maxon::Bool Bool
Definition: ge_sys_math.h:40
TransPointInterData::p2
Int32 p2
Second point.
Definition: lib_modeling.h:118
TranslationMaps::m_mWeldCount
Int32 m_mWeldCount
Map weld count.
Definition: lib_modeling.h:305
TransMapData::mIndex
Int32 mIndex
Mapped index.
Definition: lib_modeling.h:100
TRANSMAP_FLAG_DELETED
#define TRANSMAP_FLAG_DELETED
Deleted.
Definition: lib_modeling.h:44