Maxon Developers Maxon Developers
    • Documentation
      • Cinema 4D Python API
      • Cinema 4D C++ API
      • Cineware 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

    Drawing a spline

    SDK Help
    0
    26
    15.2k
    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
      Helper
      last edited by

      THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

      On 07/02/2011 at 13:59, xxxxxxxx wrote:

      Oh, thanks, couldn't imagine it's different in C++, but now i know better. 😉

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

        THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

        On 07/02/2011 at 14:05, xxxxxxxx wrote:

        Howdy,

        Yeah, coffee is very similar to c++, but from what I remember about coffee, there were more functions you had to call to perform an operation, where in c++ you simply performed the operation.

        Adios,
        Cactus Dan

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

          THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

          On 07/02/2011 at 16:04, xxxxxxxx wrote:

          hey scott would you mind sharing with me the final working code you got.  The4 code above keeps making my c4d crash out.

          Thanks,

          Shawn

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

            THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

            On 07/02/2011 at 21:11, xxxxxxxx wrote:

            Sure. Here's the code again:

            SplineObject *sp = SplineObject::Alloc(3, SPLINETYPE_LINEAR); // create a linear spline with 3 verts
              if(!sp) return NULL;
              doc->InsertObject(sp, NULL, NULL, 0); // Add it to the OM

            Vector *gp = sp->GetPointW();// The point array of the spline
              gp[0] = Vector(10,0,-100);// Place the first point here
              gp[1] = Vector(0,0,0);// Place the first point here
              gp[2] = Vector(-10,0,100);// Place the first point here
              EventAdd();//Update all the changes
              sp->Message(MSG_UPDATE);

            I'm a little surprised that there's no code block formatting option for this forum. To make posting code snippets easier to read.

            -ScottA

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

              THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

              On 07/02/2011 at 21:30, xxxxxxxx wrote:

              why not use [*code] [/*code](without * ) ?

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

                THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

                On 08/02/2011 at 01:08, xxxxxxxx wrote:

                Originally posted by xxxxxxxx

                I'm a little surprised that there's no code block formatting option for this forum. To make posting code snippets easier to read.

                There is, please check the BBCodes avaible for the forum:
                <[URL-REMOVED]>

                cheers,
                Matthias


                [URL-REMOVED] @maxon: This section contained a non-resolving link which has been removed.

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

                  THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

                  On 08/02/2011 at 01:16, xxxxxxxx wrote:

                  Originally posted by xxxxxxxx

                  I looked at the Circle.cpp example. But It's dealing with creating a spline primitive. Not a new spline from scratch. So I'm still not sure how to properly create a spline from scratch

                  I was refering to this part of the circle.cpp example. It shows how to set up a Bezier spline.

                    
                  SplineObject *GenerateCircle(Real rad)  
                  {  
                    #define TANG 0.415  
                    
                    Real    sn,cs;  
                    LONG    i,sub=4;  
                    
                    SplineObject *op = SplineObject::Alloc(sub*2,SPLINETYPE_BEZIER);  
                    if (!op || !op->MakeVariableTag(Tsegment,2)) { blDelete(op); return NULL; }  
                    op->GetDataInstance()->SetBool(SPLINEOBJECT_CLOSED,TRUE);  
                    
                    Vector  *padr = op->GetPointW();  
                    Tangent *hadr = op->GetTangentW();  
                    Segment *sadr = op->GetSegmentW();  
                    
                    if (sadr)  
                    {  
                        sadr[0].closed = TRUE;  
                        sadr[0].cnt    = sub;  
                        sadr[1].closed = TRUE;  
                        sadr[1].cnt    = sub;  
                    }  
                    
                    if (hadr && padr)  
                    {  
                        for (i=0; i<sub; i++)  
                        {  
                            SinCos(2.0*pi*i/Real(sub),sn,cs);  
                              
                            padr[i]    = Vector(cs*rad,sn*rad,0.0);  
                            hadr[i].vl = Vector(sn*rad*TANG,-cs*rad*TANG,0.0);  
                            hadr[i].vr = -hadr[i].vl;  
                    
                            padr[i+sub]    = Vector(cs*rad,sn*rad,0.0)*0.5;  
                            hadr[i+sub].vl = Vector(sn*rad*TANG,-cs*rad*TANG,0.0)*0.5;  
                            hadr[i+sub].vr = -hadr[i+sub].vl;  
                        }  
                    }  
                    
                    op->Message(MSG_UPDATE);  
                    
                    return op;  
                  }  
                  

                  op- >Message(MSG_UPDATE) is needed to update the object.

                  EventAdd() is used to update managers like the Object manager. So only have to call it when you add new objects to the scene for example.

                  cheers,
                  Matthias

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

                    THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

                    On 08/02/2011 at 03:25, xxxxxxxx wrote:

                    Thanks Matthias.. That helped a ton.   I've got it figured out now.  🙂

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

                      THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

                      On 08/02/2011 at 08:13, xxxxxxxx wrote:

                      Thanks Matthias.

                      If it's something that you can easily do. Could you possibly add the code block icon to the top of the message creation window with the other icons?

                      If it's a hassle to enable it. Don't sweat it.

                      -ScottA

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

                        THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

                        On 08/02/2011 at 09:41, xxxxxxxx wrote:

                        When I type in code examples I usually just type [*code] My Code [*/code] without the * as mentioned above.   🙂

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