I made a hack with temporary object
pPos = [c4d.Vector(-100, 0, -100), c4d.Vector(100, 0, -100), c4d.Vector(-100, 0, 100), c4d.Vector(100, 0, 100)]
pCount = len(pPos)
tmpPoly = c4d.BaseObject(c4d.Opolygon)
tmpPoly.ResizeObject(pCount , 0)
tmpPoly.SetAllPoints(pPos)
fieldInput = c4d.modules.mograph.FieldInput(pPos, pCount)
fieldInfo = c4d.modules.mograph.FieldInfo.Create(c4d.FIELDSAMPLE_FLAG_VALUE, None, doc, 0, 1, fieldInput, tmpPoly)
fieldOutput = c4d.modules.mograph.FieldOutput.Create(pCount, c4d.FIELDSAMPLE_FLAG_VALUE)
fields.DirectInitSampling(fieldInfo)
samplingSuccess = fields.DirectSample(fieldInput, fieldOutput, fieldInfo)
fields.DirectFreeSampling(fieldInfo)
print samplingSuccess, fieldOutput._value
Seems it works fine - prints True and list of values
Now I'm facing issue with sampling uvw as well:
pPos = [c4d.Vector(-100, 0, -100), c4d.Vector(100, 0, -100), c4d.Vector(-100, 0, 100), c4d.Vector(100, 0, 100)]
pCount = len(pPos)
uvw = [c4d.Vector(0, 0, 0), c4d.Vector(1, 0, 0), c4d.Vector(0, 1, 0), c4d.Vector(1, 1, 0)]
tmpPoly = c4d.BaseObject(c4d.Opolygon)
tmpPoly.ResizeObject(pCount , 0)
tmpPoly.SetAllPoints(pPos)
fieldInput = c4d.modules.mograph.FieldInput(position=pPos, allocatedCount=pCount, transform=op.GetMg(), uvw=uvw)
fieldInfo = c4d.modules.mograph.FieldInfo.Create(c4d.FIELDSAMPLE_FLAG_VALUE, None, doc, 0, 1, fieldInput, tmpPoly)
fieldOutput = c4d.modules.mograph.FieldOutput.Create(pCount, c4d.FIELDSAMPLE_FLAG_VALUE)
fields.DirectInitSampling(fieldInfo)
samplingSuccess = fields.DirectSample(fieldInput, fieldOutput, fieldInfo)
fields.DirectFreeSampling(fieldInfo)
print samplingSuccess, fieldOutput._value
prints False [0.0, 0.0, 0.0, 0.0]
Alternative code:
fieldInput = c4d.modules.mograph.FieldInput(pPos, pCount, op.GetMg(), pCount, None, uvw)
returns error:
StandardError: The arguments don't match any supplied constructors
Would appreciate your help