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
    • Recent
    • Tags
    • Users
    • Login

    'closing' a SplineObject

    Scheduled Pinned Locked Moved SDK Help
    6 Posts 0 Posters 396 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 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

      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 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);

        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 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.

          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 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).

            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 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).

              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 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.

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