Maxon Developers Maxon Developers
    • Documentation
      • Cinema 4D Python API
      • Cinema 4D C++ API
      • Cineware API
      • ZBrush Python API
      • ZBrush GoZ API
      • Code Examples on Github
    • Forum
    • Downloads
    • Support
      • Support Procedures
      • Registered Developer Program
      • Plugin IDs
      • Contact Us
    • Categories
      • Overview
      • News & Information
      • Cinema 4D SDK Support
      • Cineware SDK Support
      • ZBrush 4D SDK Support
      • Bugs
      • General Talk
    • Unread
    • Recent
    • Tags
    • Users
    • Login

    Spline points - local / global

    Scheduled Pinned Locked Moved PYTHON Development
    2 Posts 0 Posters 265 Views
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • H Offline
      Helper
      last edited by

      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 Python

      def main() :
        pass  #put in your code here

      op1 = 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 midpoint

      frame = 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

      1 Reply Last reply Reply Quote 0
      • H Offline
        Helper
        last edited by

        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

        1 Reply Last reply Reply Quote 0
        • First post
          Last post