Spline points - local / global
-
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 10/07/2012 at 02:43, xxxxxxxx wrote:
I'm trying to crate a spline, however, I seem to mess up local / global positions.
Here is what I do.
I have three Null objects and their global positions.
Now the spline should start at p1 and end at the middle between p2 en p3 (=(p2+p3)/2).
I create a spline, calculate the step per frame (midstep = midpoint* (frame/20.0) + p1).
Everything is ok, when p1 is at 0,0,0. If not, it fails.Any ideas?
Here is the source.import c4d
#Welcome to the world of Pythondef main() :
pass #put in your code hereop1 = doc.SearchObject("p1")
p1 = op1.GetMg().off
op2 = doc.SearchObject("p2")
p2 = op2.GetMg().off
op3 = doc.SearchObject("p3")
p3 = op3.GetMg().off
midpoint = (p3 + p2) / 2
#print midpointframe = doc.GetTime().GetFrame(doc.GetFps())
if ((frame == 1) and (doc.SearchObject("EigenSpline") == None)) :
print "Create Spline."
splineobj = c4d.BaseObject(c4d.Ospline) # Create new spline
splineobj[c4d.ID_BASELIST_NAME] = "EigenSpline"
doc.InsertObject(splineobj)
c4d.EventAdd()current = splineobj.GetPointCount()
splineobj.ResizeObject(1)
splineobj.SetPoint(0, p1)splineobj.Message (c4d.MSG_UPDATE) #update spline in viewport
else:
if (frame > 1) :
splineobj = doc.SearchObject("EigenSpline")splineobj.ResizeObject(frame) #add point
midstep = midpoint* (frame/20.0) + p1
splineobj.SetPoint(frame-1, midstep)
splineobj.Message (c4d.MSG_UPDATE) #update spline in viewport -
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 10/07/2012 at 03:58, xxxxxxxx wrote:
Solved. The algorithm was wrong, also to difficult.
It should be: midstep = (midpoint - p1) * (frame/20.0) + p1