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

    Jiggle modifier not cached

    Cinema 4D SDK
    c++ r20 r19
    2
    3
    450
    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.
    • rsodreR
      rsodre
      last edited by

      Hi!

      When I need the polygons of some object, I usually use the JOIN command to build a fresh cache, apply all the modifiers and include all the children. Works really good.

      But I have a setup now, of a Plane with a Bend and a Jiggle to give some physics to the animation.
      When I apply the Join command to this plane, I get the Bend deformation but never the Jiggle.
      Is there anything different with the Jiggle to force it's deformation into the cache?
      I see there's an Enable Cache in it, but from the docs I think it's not what I'm looking for, and of course I tried it and made no difference for me.

      This is how I join the object...

      	bool MakePolygon( BaseDocument* doc, BaseObject* src, PolygonObject* dst )
      	{
      		auto clonedSource = static_cast<BaseObject*>( src->GetClone( COPYFLAGS_0, nullptr ) );
      		CHECK_RETURN_FALSE( clonedSource != nullptr );
      		
      		// ignore object transform
      		clonedSource->SetMg( Matrix() );
      		
      		// The JOIN command will make editable, appy all modifiers, and join into a single polygon
      		ModelingCommandData joinCommand;
      		joinCommand.op = clonedSource;
      		joinCommand.doc = doc;			// cannot be null, wil not create object
      		joinCommand.mode = MODELINGCOMMANDMODE_ALL;
      		joinCommand.flags = MODELINGCOMMANDFLAGS_0;
      		auto success = SendModelingCommand( MCOMMAND_CURRENTSTATETOOBJECT, joinCommand );
      		if( !success || joinCommand.result == nullptr )
      		{
      			BaseObject::Free( clonedSource );
      			return false;
      		}
      		
      		auto result = false;
      		PolygonObject* joinedPolygon = static_cast<PolygonObject*>( joinCommand.result->GetIndex(0) );
      		if( joinedPolygon->IsInstanceOf( Opolygon ) )
      		{
      			joinedPolygon->CopyTo( dst, COPYFLAGS_0, nullptr );
      			result = true;
      		}
      		
      		BaseObject::Free( clonedSource );
      		PolygonObject::Free( joinedPolygon );
      		
      		return result;
      	}
      
      rsodreR 1 Reply Last reply Reply Quote 0
      • rsodreR
        rsodre @rsodre
        last edited by rsodre

        @rsodre Passing the deform cache to the command bakewd the Jiggle deformation to my polygon.

        if( src->GetDeformCache() != nullptr )
        {
        	src = src->GetDeformCache();
        }
        

        Does this sounds ok?

        Using MCOMMAND_CURRENTSTATETOOBJECT instead of MCOMMAND_JOIN seems to have the same effect. What's the difference of using each one?

        1 Reply Last reply Reply Quote 0
        • ManuelM
          Manuel
          last edited by s_bach

          Hello,

          Regarding the question yes, using GetDeformCache is the way to go.

          Using one object, there's not too much difference between MCOMMAND_CURRENTSTATETOOBJECT and MCOMMAND_JOIN as the MCOMMAND_JOIN is calling a MCOMMAND_CURRENTSTATETOOBJECT for each object.

          The obvious part is that the Join command will create one object while the other will return a hierarchy. (if there are children)

          Cheers,
          Manuel

          MAXON SDK Specialist

          MAXON Registered Developer

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