'closing' a SplineObject

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

On 06/06/2008 at 12:00, xxxxxxxx wrote:

User Information:
Cinema 4D Version:   10.1+ 
Platform:   Windows  ;   
Language(s) :     C++  ;

---------
I have questions about the following code-snippet...

    
    
      
    //----------------------------------------------------------------------------------------------------  
    //******************************************************************************************************  
    // ObjLoader::MakeSplineObject()  
    //******************************************************************************************************  
    //------------------------------------------------------------------------------------------------------
    
    
    
    
    BaseObject *ObjLoader::MakeSplineObject(DWORD numSegments, DWORD *pSegIndices, String splineName)  
    {  
        SplineObject *op;  
        Vector *padr;  
        Segment *sadr;  
        objSegment *pSeg;  
        DWORD *pSegNdx;  
        DWORD i, j, numVerts;
    
    
    
    
        if( !numSegments ) return NULL;
    
    
    
    
        // first figure out how many vertices are used...  
        numVerts = 0;  
        pSegNdx = pSegIndices;  
        for( i=0; i<numSegments; i++)  
        {  
            pSeg = &m_pSegs[*pSegNdx];  
            numVerts += pSeg->vCount;  
            pSegNdx++;  
        }
    
    
    
    
        op = SplineObject::Alloc(numVerts,Tlinear); // allocate spline object large enough for all points  
        if( !op || !op->MakeVariableTag(Tsegment,numSegments) )  
        {  
            MessageDialog(String("Spline Object Allocation Failed"));  
            return NULL;  
        }
    
    
    
    
        op->SetName(splineName);
    
    
    
    
    #ifdef _R10p1_SDK_  
        padr = op->GetPointW();  
        sadr = op->GetSegmentW();  
    #else  
        padr = op->GetPoint();  
        sadr = op->GetSegment();  
    #endif
    
    
    
    
        // set up the points...  
        numVerts = 0;  
        if( padr )  
        {  
            pSegNdx = pSegIndices;  
            for( i=0; i<numSegments; i++)  
            {  
                pSeg = &m_pSegs[*pSegNdx];  
                for(j=0; j<pSeg->vCount; j++)  
                    padr[numVerts++] = m_pVerts[pSeg->v[j]];  
                pSegNdx++;  
            }  
        }
    
    
    
    
        // set up the segments...  
        if (sadr)  
        {  
            pSegNdx = pSegIndices;  
            for( i=0; i<numSegments; i++)  
            {  
                pSeg = &m_pSegs[*pSegNdx];  
                sadr[i].cnt = pSeg->vCount;  
                sadr[i].closed = m_MpOpts.MpCloseSplines() ? true : false; // <-- this is failing  
                pSegNdx++;  
            }  
        }
    
    
    
    
        return op;  
    }
    
    
    

...assuming that 'm_MpOpts.MpCloseSplines()' returns true (which it does), the splines are still not being 'closed'.
In the SDK, I see a SplineObject::IsClosed(void) method, but no other way to Set it to closed.   Am I missing something?
Thanks,
Keith

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

On 06/06/2008 at 13:06, xxxxxxxx wrote:

You have to:

Segment* sadr = op->GetSegmentW();

and set each segment in the spline to be closed, set:

sadr[n].closed = TRUE;

which is what you're already doing. I don't know what the m_MpOpts.MpCloseSplines() is but maybe it is the problem. Try just doing:

sadr[n].closed = m_MpOpts.MpCloseSpline();

and see what results. Don't forget to update the SplineObject after changing it:

op->Message(MSG_UPDATE);

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

On 06/06/2008 at 13:14, xxxxxxxx wrote:

Hey Robert,
I have it coded that way because 'm_MpOpts.MpCloseSpline()' call returns a masked value or zero (not really a boolean), but I've also just hard-coded a 'true' there with no better luck.
Your 'MSG_UPDATE' suggestion may lead somewhere though.. lemme look into the code again - thanks.

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

On 06/06/2008 at 13:18, xxxxxxxx wrote:

...hmm - nope - I was already doing a op->Message(MSG_UPDATE); everywhere, after adding the spline to the scene/document (I also just tried doing it before, but neither works).

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

On 06/06/2008 at 13:30, xxxxxxxx wrote:

I'm surprised since this is almost identical in places to my code which exists in several forms throughout my plugin code.

There is one difference though. I insert the SplineObject into the document before doing any setup. Could this be the culprit?

Oh, I just noticed this tidbit in my code as well (eh hem) :

splineObj->GetDataInstance()->SetBool(SPLINEOBJECT_CLOSED,FALSE);

So, you may want to add this (with TRUE of course).

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

On 06/06/2008 at 13:51, xxxxxxxx wrote:

D'oh!  or, maybe "Eureka" is more appropriate :).  Thanks Robert, I'm sure that will fix it... and - yep! it did.  Thanks again.