definition of spline segments



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

    On 28/05/2004 at 06:38, xxxxxxxx wrote:

    User Information:
    Cinema 4D Version:   8.5 
    Platform:   Windows  ;   
    Language(s) :   C.O.F.F.E.E  ;

    ---------
    Hi,

    I'm currently working on a little C.O.F.F.E.E. plugin, that merges spline segments having end-points that lie very near. Everything runs fine, except the setting of segments. Befor setting the segments I send an appropriate message (MSG_SEGMENTS_CHANGED) with VariableChanged. That seems to work fine. But the call SetSegments() doesn't work and returns FALSE. Am I doing something wrong? The following code shows the current state of the according function- trgPoints, trgTangents and trgSegments are objects of a stack class. Stack::Array() returns an array. And yes I have checked them. They have the correct values and size. (I left BackupTag out, because trgSpline is a newly created object and won't be added to the document, if an error occurs)

    So if you find an error or could give me an example that shows how you change spline segments in C.O.F.F.E.E., you would make me very very very happy. Here I found several threads about that problem, but there was never an answer.

    Thanks a lot in advance. Cheers,
    Marcus

    -------------8<----------------

      
    MergeSegments::SetAttributes(srcSpline, trgSpline, trgPoints, trgTangents, trgSegments)  
    {  
    // copy spline attributes  
    var srcAttr = srcSpline->GetContainer();  
    var trgAttr = trgSpline->GetContainer();  
    if (!instanceof(srcAttr, BaseContainer) || !instanceof(trgAttr, BaseContainer)) {  
        PrintError("Invalid spline attribut container returned."); return FALSE;  
    }  
    trgAttr->SetData(SPLINEOBJECT_TYPE,          srcAttr->GetData(SPLINEOBJECT_TYPE));  
    trgAttr->SetData(SPLINEOBJECT_INTERPOLATION, srcAttr->GetData(SPLINEOBJECT_INTERPOLATION));  
    trgAttr->SetData(SPLINEOBJECT_CLOSED,        srcAttr->GetData(SPLINEOBJECT_CLOSED));  
    trgAttr->SetData(SPLINEOBJECT_SUB,           srcAttr->GetData(SPLINEOBJECT_SUB));  
    trgAttr->SetData(SPLINEOBJECT_ANGLE,        srcAttr->GetData(SPLINEOBJECT_ANGLE));  
    if (!trgSpline->SetContainer(trgAttr)) {  
        PrintError("Could not set new spline attributes."); return FALSE;  
    }  
    trgSpline->SetMl(srcSpline->GetMl());  
    trgSpline->Message(MSG_UPDATE);  
      
    // add points, tangents (if necessary) and segments  
    if (trgPoints) {  
      
        // backup tags and initialize new point count  
        var vc = new(VariableChanged);  
        if (!vc) {  
          PrintError("Could not allocate VariableChanged object."); return FALSE;  
        }  
        if (!vc->Init(0, trgPoints->Size())) {  
          PrintError("Could not prepare point count change."); return FALSE;  
        }  
        if (!trgSpline->Message(MSG_POINTS_CHANGED, vc)) {  
          PrintError("Could not set point count of new spline object."); return FALSE;  
        }  
      
        // set new points and tangents  
        if (!trgSpline->SetPoints(trgPoints->Array())) {  
          PrintError("Could not set points in new spline object."); return FALSE;  
        }  
        if (trgTangents) {  
          if (!trgSpline->SetTangents(trgTangents->Array())) {  
            PrintError("Could not set tangents in new spline objects."); return FALSE;  
          }  
        }  
      
        // set new segments  
        if (trgSegments) {  
          if (!vc->Init(0, trgSegments->Size())) {  
            PrintError("Could not prepare segment change."); return FALSE;  
          }  
          if (!trgSpline->Message(MSG_SEGMENTS_CHANGED, vc2)) {  
            PrintError("Could not set segment count of new spline object."); return FALSE;  
          }  
          if (!trgSpline->SetSegments(trgSegments->Array())) {  
            PrintError("Could not set segments"); return FALSE;  
          }  
        }  
    }  
    trgSpline->Message(MSG_UPDATE);  
    return TRUE;  
    }  
    

    ---------------->8----------------



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

    On 30/05/2004 at 17:15, xxxxxxxx wrote:

    You're using a variable called "vc2" in the MSG_SEGMENTS_CHANGED line, that isn't mentioned before. Could this be the cause of the error?



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

    On 31/05/2004 at 04:39, xxxxxxxx wrote:

    Hi Mikael,

    well that is an error I introduced myself while trying to get segment setting running :) Thanks for mentioning it. But a correction doesn't fix the problem.

    Ok, I put together a very simple example. This command plugin does nothing else than adding a new sline object to the document. This spline object shall be made of two segments.

    You can download the test plugin here:
    http://home.arcor.de/marcus.spranger/tmp/TestSegments.cof

    Perhaps you or somebody else could change it, so that it creates two segments.

    Thanks a lot in advance. Cheers,
    Marcus

    or here is the source code:

      
    const var cMyID = 1016119;  
      
      
    class TestSegments : MenuPlugin  
    {  
    public:  
      
        TestSegments();  
        GetID();  
        GetName();  
        GetHelp();  
        GetState();  
        Execute(document);  
    }  
      
      
    TestSegments::TestSegments() { super(); }  
    TestSegments::GetID()        { return cMyID; }  
    TestSegments::GetName()       { return "TestSegments"; }  
    TestSegments::GetHelp()       { return "A spline segment test."; }  
      
      
    TestSegments::GetState()  
    {  
    return instanceof(GetActiveDocument(), BaseDocument) ? CMD_ENABLED : 0;  
    }  
      
      
    TestSegments::Execute(document)  
    {  
    // check current document and create new spline object  
    if (!instanceof(document, BaseDocument)) return;  
    var spline = new(SplineObject);  
      
    // add vertices  
    var vertices = new(array, 4);  
    vertices[0] = vector(0.0, 0.0, 0.0);  
    vertices[1] = vector(0.0, 100.0, 0.0);  
    vertices[2] = vector(100.0, 0.0, 0.0);  
    vertices[3] = vector(100.0, 100.0, 0.0);  
    var vc = new(VariableChanged);  
    if (!vc) {  
        println("Could not allocate VariableChanged object."); return;  
    }  
    if (!vc->Init(0, sizeof(vertices))) {  
        println("Could not prepare point count change."); return;  
    }  
    if (!spline->Message(MSG_POINTS_CHANGED, vc)) {  
        println("Could not set point count of new spline object."); return;  
    }  
    if (!spline->SetPoints(vertices)) {  
        println("Could not set points in new spline object."); return;  
    }  
      
    // set segments  
    var segments = new(array, 2);  
    segments[0] = 2;  
    segments[1] = 2;  
    if (!vc->Init(0, sizeof(segments))) {  
        println("Could not prepare segment change."); return;  
    }  
    if (!spline->Message(MSG_SEGMENTS_CHANGED, vc)) {  
        println("Could not set segment count of new spline object."); return;  
    }  
    if (!spline->SetSegments(segments)) {  
        println("Could not set segments"); // return;  
    }  
      
    // add spline oject to document  
    if (!document->InsertObject(spline, NULL, NULL)) {  
        println("Could not insert new spline object."); return;  
    }  
    GeEventAdd(DOCUMENT_CHANGED);  
    return;  
    }  
      
      
    main()  
    {  
    Register(TestSegments);  
    }  
    


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

    On 08/06/2004 at 03:08, xxxxxxxx wrote:

    This does seem to be a bug in C4D. I can't get it to work. I'll submit it as a bug to the developers. Thanks for reporting!


Log in to reply