-
首页
-
C4D R23.110 C++ SDK
TranslationMaps Class Reference
Library
»
建模
#include <lib_modeling.h>
详细描述
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.
-
注意
-
若
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)
{
...
case
MSG_TRANSLATE_POINTS
:
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;
TransPointInterData
*ipnt;
// Processed any interpolated points
for
(i=0;i<map->
m_mPointCount
;i++)
{
if
(!(map->
m_pPointMap
[i].
lFlags
&
TRANSMAP_PNTFLAG_INTER
))
continue
;
ipnt=&map->
m_pInterpolatedPoints
[map->
m_pPointMap
[i].
mIndex
];
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++)
{
if
(map->
m_pPointMap
[i].
lFlags
& (
TRANSMAP_PNTFLAG_INTER
|
TRANSMAP_FLAG_DELETED
))
continue
;
if
(map->
m_pPointMap
[i].
lFlags
&
TRANSMAP_FLAG_NEW
)
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
];
}
}
}
构造函数 & 析构函数文档编制
◆
TranslationMaps()
Constructor.
成员函数文档编制
◆
FindOriginalPoint()
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
.)
-
参数
-
[in]
|
index
|
The new index.
|
-
返回
-
The old index.
◆
FindOriginalPolygon()
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
.)
-
参数
-
[in]
|
index
|
The new index.
|
-
返回
-
The old index.
◆
FindOriginalPgon()
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
.)
-
参数
-
[in]
|
index
|
The new index.
|
-
返回
-
The old index.
◆
FindOriginalSegment()
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
.)
-
参数
-
[in]
|
index
|
The new index.
|
-
返回
-
The old index.
◆
FindNewPoint()
Searches for the new index based on the original
index
. (A pure helper. The source for this function is available in
lib_modeling.cpp
.)
-
参数
-
[in]
|
index
|
The old index.
|
-
返回
-
The new index.
◆
FindNewPolygon()
Searches for the new index based on the original
index
. (A pure helper. The source for this function is available in
lib_modeling.cpp
.)
-
参数
-
[in]
|
index
|
The old index.
|
-
返回
-
The new index.
◆
FindNewPgon()
Searches for the new index based on the original
index
. (A pure helper. The source for this function is available in
lib_modeling.cpp
.)
-
参数
-
[in]
|
index
|
The old index.
|
-
返回
-
The new index.
◆
FindNewSegment()
Searches for the new index based on the original
index
. (A pure helper. The source for this function is available in
lib_modeling.cpp
.)
-
参数
-
[in]
|
index
|
The old index.
|
-
返回
-
The new index.
◆
FindWeldPoint()
Searches for the new index based on the original
index
. (A pure helper. The source for this function is available in
lib_modeling.cpp
.)
-
参数
-
[in]
|
index
|
The old index.
|
-
返回
-
The new index.
◆
FindMeltPolygon()
Searches for the new index based on the original
index
. (A pure helper. The source for this function is available in
lib_modeling.cpp
.)
-
参数
-
[in]
|
index
|
The old index.
|
-
返回
-
The new index.
Member Data Documentation
◆
m_oPointCount
Original point count.
◆
m_oPolygonCount
Original polygon count.
◆
m_oPgonCount
Original
Pgon
count.
◆
m_oSegmentCount
Original segment count.
◆
m_nPointCount
New point count.
◆
m_nPolygonCount
New polygon count.
◆
m_nPgonCount
New
Pgon
count.
◆
m_nSegmentCount
New segment count.
◆
m_mPointCount
Map point count.
◆
m_mPolygonCount
Map polygon count.
◆
m_mPgonCount
Map
Pgon
count.
◆
m_mSegmentCount
Map segment count.
◆
m_mWeldCount
Map weld count.
◆
m_mMeltCount
Map melt count.
◆
m_pPointMap
Point translation map.
◆
m_pPolygonMap
Polygon translation map.
◆
m_pPgonMap
Pgon
translation map.
◆
m_pSegmentMap
Segment
translation map.
◆
m_pWeldMap
Weld index translation map.
◆
m_pMeltMap
Melt index translation map.
◆
m_pNewPointMap
New point translation map.
◆
m_pNewPolygonMap
New polygon translation map.
◆
m_pNewPgonMap
New
Pgon
translation map.
◆
m_pNewSegmentMap
New segment translation map.
◆
m_pInterpolatedPoints
Interpolation map.
◆
m_pDeltaPoints
Delta map.
#define TRANSMAP_FLAG_NEW
New.
定义:
lib_modeling.h:45
TransMapData * m_pPointMap
Point translation map.
定义:
lib_modeling.h:312
#define MSG_TRANSLATE_POINTS
Sent by the modeling core to let tags etc. update after point changes. The corresponding data is Tran...
定义:
c4d_baselist.h:512
Int32 lFlags
定义:
lib_modeling.h:101
maxon::Float Float
定义:
ge_sys_math.h:64
TransPointInterData * m_pInterpolatedPoints
Interpolation map.
定义:
lib_modeling.h:325
Float t
Interpolation parameter.
定义:
lib_modeling.h:123
Int32 nIndex
New index.
定义:
lib_modeling.h:83
Int32 m_mPointCount
Map point count.
定义:
lib_modeling.h:304
TransIndexMapData * m_pWeldMap
Weld index translation map.
定义:
lib_modeling.h:317
Int32 m_nPointCount
New point count.
定义:
lib_modeling.h:299
maxon::Int32 Int32
定义:
ge_sys_math.h:58
Bool Message(Int32 type, void *data=nullptr)
定义:
c4d_baselist.h:1394
Int32 p1
First point.
定义:
lib_modeling.h:121
Int32 oIndex
Old index.
定义:
lib_modeling.h:82
#define TRANSMAP_PNTFLAG_INTER
Interpolated.
定义:
lib_modeling.h:55
maxon::Bool Bool
定义:
ge_sys_math.h:53
Int32 p2
Second point.
定义:
lib_modeling.h:122
Int32 m_mWeldCount
Map weld count.
定义:
lib_modeling.h:309
Int32 mIndex
Mapped index.
定义:
lib_modeling.h:104
#define TRANSMAP_FLAG_DELETED
Deleted.
定义:
lib_modeling.h:48