First of all, I'm sorry I simply forget your topic, so thanks for bumping it again.
Regarding your question, I'm really not sure about what you want to achieve. So maybe try to explain what you want to achieve with simple step by step.
Anyway, I will try to answers your question about how to retrieve the delta from a non-deformed geometry to a deformed geometry.
Keep in mind that all points position retrieved by GetAllPoints() are local to the current object matrix, so doing a SetRelPos, on the object will most likely not affect the point position returned since it moves the whole object matrix.
So here a quick example that properly retrieves the delta from a deformed object and its normal version.
import c4d
def main():
# Get the current world position
allPtCurrentFrame = op.GetDeformCache().GetAllPoints()
mgCurrentFrame = op.GetDeformCache().GetMg()
# Move the mod +10 in Z in world position
mod = doc.SearchObject('mod_1')
modMat = mod.GetMg()
modMat.off += c4d.Vector(0, 0, 10)
mod.SetMg(modMat)
# change the frame
doc.SetTime(c4d.BaseTime(1, doc.GetFps()))
buildflag = c4d.BUILDFLAGS_NONE if c4d.GetC4DVersion() > 20000 else c4d.BUILDFLAGS_0
doc.ExecutePasses(None, True, True, True, buildflag)
# Get the next world position
allPtNextFrame = op.GetDeformCache().GetAllPoints()
mgNextFrame = op.GetDeformCache().GetMg()
# Calculate the difference in both local space and global space
diffLocalSpace = [allPtNextFrame[ptID] - x for ptID, x in enumerate(allPtCurrentFrame)]
diffGlobalSpace = [(allPtNextFrame[ptID] * mgNextFrame) - (x * mgCurrentFrame) for ptID, x in enumerate(allPtCurrentFrame)]
# For each axes create a Vertex map
componentNames = ["x", "y", "z"]
for componentId, componentName in enumerate(componentNames):
# First find the maximum delta for the current component
maxLocalSpace = 1
maxGlobalSpace = 1
for ptLocal in diffLocalSpace:
maxLocalSpace = max(maxLocalSpace, ptLocal[componentId])
for ptGlobal in diffGlobalSpace:
maxGlobalSpace = max(maxGlobalSpace, ptGlobal[componentId])
# Normalize all of them from 0 to 1
normalizedLocal = [pt[componentId] / float(maxLocalSpace) for pt in diffLocalSpace]
normalizedGlobal = [pt[componentId] / float(maxGlobalSpace) for pt in diffGlobalSpace]
# Create Tag for local
vMapLocal = op.MakeVariableTag(c4d.Tvertexmap, op.GetPointCount())
op.InsertTag(vMapLocal)
vMapLocal.SetName("{0}_local".format(componentName))
vMapLocal.SetAllHighlevelData(normalizedLocal)
# Create Tag for Global
vMapGlobal = op.MakeVariableTag(c4d.Tvertexmap, op.GetPointCount())
op.InsertTag(vMapGlobal)
vMapGlobal.SetName("{0}_global".format(componentName))
vMapGlobal.SetAllHighlevelData(normalizedGlobal)
c4d.EventAdd()
# Execute main()
if __name__=='__main__':
main()
Cheers,
Maxime.