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

    saving Volume loader object

    Cineware SDK
    5
    12
    3.5k
    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.
    • C
      camille chigot
      last edited by

      hello, I am trying to export animated vdb clouds (from VUE).
      I have a few issue with the Volume loader.
      Context: when loading a multi-grid vdb file in c4d (R23 for instance), a Volume loader is created with a list of the internal grids.
      So, for my export I tried to do the same thing ( if I split the grids on one per file and create volume objects, it works perfectly).
      First issue: the cineware Sdk does not contains the define/param for Ovolumeloader ( #define Ovolumeloader 1039866 is findable on the internet and mentionned in the documentation ).
      ( that is not really an issue but seems to be a forgotten file)

      Second issue : when I save my files with a relative path: the loading of the lit of internal grid seems to be broken.
      As an exemple: I read the file with the commandline tool after the export from VUE and after saving it in C4d:

      
      absolute / generated: 
      Parsing "Small Cumulonimbus [RefObj]" of type (1039866):
      
              found Param id (6000)
                      type(131), values : "D:\Users\C4d\animmetacloud_Small Cumulonimbus [RefObj]_00.vdb"
              found Param id (6001)
                      type(15), values : 1
              found Param id (6003)
                      type(15), values : 0
              found Param id (6004)
                      type(15), values : 56
              found Param id (6008)
                      type(1018397), values : listview with 2 items and selected : -1
                              item 0 with id 0 and name density
                                      type(15), values : 1
                              item 1 with id 1 and name color
                                      type(15), values : 1
      								
      absolute / saved: 						
      Parsing "Small Cumulonimbus [RefObj]" of type (1039866):
      
              found Param id (6000)
                      type(131), values : "D:\Users\C4d\animmetacloud_Small Cumulonimbus [RefObj]_00.vdb"
              found Param id (6001)
                      type(15), values : 1
              found Param id (6002)
                      type(15), values : 0
              found Param id (6003)
                      type(15), values : 0
              found Param id (6004)
                      type(15), values : 64
              found Param id (6005)
                      type(15), values : 0
              found Param id (6006)
                      type(19), values : 1.000000
              found Param id (6007)
                      type(15), values : 0
              found Param id (6008)
                      type(1018397), values : listview with 2 items and selected : -1
                              item 0 with id 0 and name color
                                      type(15), values : 1
                              item 1 with id 1 and name density
                                      type(15), values : 1
              found Param id (6010)
                      type(200000275), values : Unitscale: 1.000000 / 3
              found Param id (6011)
                      type(130), values : "Voxel Amount: 1.182.298   Size: ~3 mb "
              found Param id (6012)
                      type(26), values : -1
      
      relative / generated: 		
      Parsing "Small Cumulonimbus [RefObj]" of type (1039866):
      
              found Param id (6000)
                      type(131), values : "animmetacloud_Small Cumulonimbus [RefObj]_00.vdb"
              found Param id (6001)
                      type(15), values : 1
              found Param id (6003)
                      type(15), values : 0
              found Param id (6004)
                      type(15), values : 56
              found Param id (6008)
                      type(1018397), values : listview with 2 items and selected : -1
                              item 0 with id 0 and name density
                                      type(15), values : 1
                              item 1 with id 1 and name color
                                      type(15), values : 1
      								
      								
      relative / saved: 							
      Parsing "Small Cumulonimbus [RefObj]" of type (1039866):
      
              found Param id (6000)
                      type(131), values : "animmetacloud_Small Cumulonimbus [RefObj]_00.vdb"
              found Param id (6001)
                      type(15), values : 1
              found Param id (6002)
                      type(15), values : 0
              found Param id (6003)
                      type(15), values : 0
              found Param id (6004)
                      type(15), values : 56
              found Param id (6005)
                      type(15), values : 0
              found Param id (6006)
                      type(19), values : 1.000000
              found Param id (6007)
                      type(15), values : 0
              found Param id (6008)
                      type(1018397), values : listview with 1 items and selected : -1
                              item 0 with id 0 and name Small Cumulonimbus [RefObj]
                                      type(15), values : 1
              found Param id (6010)
                      type(200000275), values : Unitscale: 1.000000 / 3
              found Param id (6011)
                      type(130), values : "Voxel Amount: 591.149   Size: ~2 mb "
              found Param id (6012)
                      type(26), values : -1					
      

      As we can see, the param 6008 ( the listview) is modified at the load of the relative path file.

      here find attached screenshots of what happens when I load the files in C4d and the save file ( with the _00.vdb file ( assume that the _XX.vdb are identical from _00.vdb fileAbsolute.PNG )[0_1631807093381_animmetacloud_Small Cumulonimbus [RefObj]_00.vdb](Uploading 100%)

      animmetacloud - absolute.c4d relative.PNG animmetacloud - Relative.c4d

      1 Reply Last reply Reply Quote 0
      • C
        camille chigot
        last edited by

        It seems I can't upload a vdb file 😭

        1 Reply Last reply Reply Quote 0
        • M
          m_adam
          last edited by

          Hi @camille-chigot, your question will be looked tomorrow morning in our daily SDK checks, however try again, it should work now, but we do have a file limit of 4096KiB (around 4.19mo) so if the file is larger either send us the file via mail at [email protected] or upload it within your preferred cloud hosting provider.

          Cheers,
          Maxime.

          MAXON SDK Specialist

          Development Blog, MAXON Registered Developer

          1 Reply Last reply Reply Quote 0
          • C
            camille chigot
            last edited by

            vdb file uploaded animmetacloud_Small Cumulonimbus [RefObj]_00.vdb

            1 Reply Last reply Reply Quote 0
            • C
              camille chigot
              last edited by

              also a bug on C4d on Ovolume object ( not sure when to post this).
              The reload button modify the postion/scale of the object without taking into account if the object is in a group ( in my case, it is in a group with a 100 scale, that means my cloud is magically transported far away).
              The stranger thing, is that the reload seems to be called when I load the scene. But if the object is animated, the reload is applied before the move to the position defined in the position Curve. The result is, the animated cloud is correctly placed whereas the non-animated one is not ( in fact, the position stored in the c4d file is completely ignored)

              1 Reply Last reply Reply Quote 0
              • M
                m_adam
                last edited by m_adam

                Hi Camille one of the things that is a bit unclear to us, are you really using the cineware engine, or do you actually uses the sdk.zip provided in each Cinema 4D?
                Cineware is an external dll that you can link to read/write c4d file without the need to install c4d. Since you mention that you want to create an exporter this is more suited for the usual sdk.

                Would it be possible for you to share your actual code?

                Thanks in advance,
                Cheers,
                Maxime.

                MAXON SDK Specialist

                Development Blog, MAXON Registered Developer

                C 1 Reply Last reply Reply Quote 0
                • C
                  camille chigot @m_adam
                  last edited by camille chigot

                  we are using the cineware SDK from developers maxon net , I can't say for sure what version it is ( it was updated in june 2020, is there a header file where the exact version is stated?). I downloaded the latest version and builded it to use the command line sample that parses a save file ( to check the difference between what I save and what is saved after loading in C4d ( R23).
                  I won't be able to give you the whole code ( at least my legal department is likely to fire me ), but I can give you a sample of what we do for the clouds.

                  			
                  			
                  //create cloud object
                  
                  cineware::BaseObject* c4Cloud;
                  if (gridNames_.size()>0)
                  {
                  	c4Cloud = cineware::BaseObject::Alloc(Ovolumeloader);
                  	if (startFrame_ != endFrame_)
                  	{
                  		cineware::GeData udata;
                  		udata.SetInt32(1);
                  		c4Cloud->SetParameter(6001, udata);  //animation
                  		udata.SetInt32(startFrame_);
                  		c4Cloud->SetParameter(6003, udata);  //frame range start
                  		udata.SetInt32(endFrame_);
                  		c4Cloud->SetParameter(6004, udata); //frame range stop
                  		cineware::ListViewData* lv = cineware::ListViewData::Alloc();
                  		for (size_t i = 0; i < gridNames_.size(); ++i)
                  		{
                  			cineware::GeData vdata;
                  			vdata.SetInt32(1);
                  			lv->AddItem((int)i, ToCinewareString(gridNames_[i]), vdata);
                  		}
                  		udata.SetCustomDataType(CUSTOMDATA_LISTVIEW, *lv);
                  		c4Cloud->SetParameter(6008, udata); //list of activated grids
                  	}
                  	else
                  	{
                  		cineware::GeData udata;
                  		udata.SetInt32(0);
                  		c4Cloud->SetParameter(6001, udata);  //animation
                  		udata.SetInt32(startFrame_);
                  		c4Cloud->SetParameter(6002, udata); //frame
                  	}
                  
                  }
                  else
                  {
                  	c4Cloud = cineware::BaseObject::Alloc(Ovolume);
                  }
                  
                  c4dDoc_->InsertObject(c4Cloud, parentObj);
                  c4Cloud->SetName(ToC4dStr(name).c_str());
                  
                  // set vdb file path
                  cineware::GeData udata;
                  auto newPath = EONPath(file_);
                  if (startFrame_ != endFrame_)
                  {
                  
                  	cineware::CTrack* xTrack(
                  		cineware::CTrack::Alloc(c4Cloud,
                  				cineware::DescLevel(cineware::ID_VOLUME_PATH, cineware::DTYPE_FILENAME, 0),
                  			"path"));
                  	c4Cloud->AppendCTrack(xTrack);
                  	xTrack->t_pseudo = cineware::PSEUDO_DATA; //hack to be able to create pseudo data track
                  	auto curve = xTrack->GetCurve();
                  	for (auto time = startFrame_; time <= endFrame_; ++time)
                  	{
                  		auto path = newPath;
                  		// build file name of frame XX
                  		path.insert_suffix_before_ext_inplace(
                  			StringFormat(EONString(L"_%0") + boost::lexical_cast<std::wstring>(floor(log(endFrame_ - startFrame_) / log(10) + 1)) + L"d", time));	
                  		auto mapPath = MakeRelPath(path, GetSettings().localTexturePath_, Filename()); // relative or absolute path
                  		cineware::GeData data;
                  		data.SetFilename(cineware::Filename(ToCinewareString(mapPath.local_string())));
                  		curve->AddKey(cineware::BaseTime(time ,GetSettings().animationFramerate_ ))->SetGeData(curve, data);
                  	}
                      // build file name of frame 0
                  	newPath.insert_suffix_before_ext_inplace(
                  		StringFormat(EONString(L"_%0") + boost::lexical_cast<std::wstring>(floor(log(endFrame_ - startFrame_) / log(10) + 1)) + L"d", 0));
                  
                  }
                  EONPath mapPath = MakeRelPath(newPath, GetSettings().localTexturePath_, Filename());// relative or absolute path
                  udata.SetFilename(cineware::Filename(ToCinewareString(mapPath.local_string())));
                  c4Cloud->SetParameter(cineware::ID_VOLUME_PATH, udata);
                  
                  
                  // set transformation of object in absolute or relative to parent
                  if (transfo_.hasParent_)
                  {
                  	InitNodeTransform(c4Cloud, transfo_.localPosition_, transfo_.localTransfo_, false);
                  }
                  else
                  {
                  	InitNodeTransform(c4Cloud, transfo_.vPosition_, transfo_.transfo_, true);
                  }
                  
                  
                  
                  
                  1 Reply Last reply Reply Quote 0
                  • ManuelM
                    Manuel
                    last edited by

                    Hi,

                    to answer some of your question:

                    • the last cineware version is 22.004. There's a build.txt at the root. (Should be defined with API_VERSION, but that's not the case for Cineware.
                    • Ovolumeloader isn't defined: cineware is not updated on each release, that probably why. I will check with the devs.

                    So, if i got you correctly, you export a vdb file from VUE. Using Cineware, you create a new document, insert a volume object, define the file path and animation parameter. When you check the .c4d you have an issue if the file is set as a relative reference?

                    I tried with the last cineware version and i couldn't reproduce the issue:

                    I did used the commandline example and redefined the main function as follow, where cloud.vdb is the file you provided in the same path of commandline.exe ([] in the name isn't an issue)

                    When i'm loading the created c4d, i find the two grids.

                    
                    int main(int argc, Char* argv[])
                    {
                    
                    	
                    #define Ovolumeloader 1039866
                    
                    	const char* fnLoad = "cloud.vdb";
                    	const char* fnc4dSave = "c4d_cloud.c4d";
                    
                    
                    	// create new C4D base document (for export we don't need a alien document)
                    	BaseDocument* newC4DDoc = BaseDocument::Alloc();
                    	if (!newC4DDoc)
                    	{
                    		return 1;
                    	}
                    
                    	// create new file for export
                    	HyperFile* newC4Dfile = NewObj(HyperFile);
                    	if (!newC4Dfile)
                    	{
                    		DeleteObj(newC4DDoc);
                    		return false;
                    	}
                    
                    	// open file for write
                    	if (!newC4Dfile->Open(DOC_IDENT, fnc4dSave, FILEOPEN_WRITE))
                    	{
                    		DeleteObj(newC4DDoc);
                    		DeleteObj(newC4Dfile);
                    		return false;
                    	}
                    
                    
                    	cineware::BaseObject* c4Cloud = cineware::BaseObject::Alloc(Ovolumeloader);
                    
                    	cineware::GeData udata;
                    	
                    	udata.SetFilename(cineware::Filename("cloud.vdb"));
                    	c4Cloud->SetParameter(cineware::ID_VOLUME_PATH, udata);
                    
                    
                    
                    	newC4DDoc->InsertObject(c4Cloud, nullptr);
                    	c4Cloud->SetName("my could");
                    	
                    
                    	newC4DDoc->CreateSceneToC4D(true);
                    	newC4DDoc->Write(newC4Dfile);
                    
                    	// close the C4D file
                    	newC4Dfile->Close();
                    
                    	BaseDocument::Free(newC4DDoc);
                    	DeleteObj(newC4DDoc);
                    
                    	// free the new C4D file
                    	DeleteObj(newC4Dfile);
                    
                    
                    	// to keep the console window open wait here for input
                    	char value;
                    	printf("\n <press return to exit>");
                    	scanf("%c", &value);
                    
                    
                    
                    }
                    

                    Cheers,
                    Manuel

                    MAXON SDK Specialist

                    MAXON Registered Developer

                    1 Reply Last reply Reply Quote 1
                    • C
                      camille chigot
                      last edited by

                      ok, I did the same with puting "cloud_00.vdb" in the Filename and having in my folder "cloud_00.vdb" to "cloud_64.vdb". It works fine. but somehow it does not work with filename "animmetacloud_Small Cumulonimbus [RefObj]_00.vdb". I tried other filenames, it works fine. I don't know why the particular filename does not work.

                      1 Reply Last reply Reply Quote 0
                      • C
                        camille chigot
                        last edited by

                        This post is deleted!
                        1 Reply Last reply Reply Quote 0
                        • ferdinandF
                          ferdinand
                          last edited by

                          Hello @camille-chigot,

                          without any further questions, we will consider this topic as solved by Monday, the 25th and flag it accordingly.

                          Thank you for your understanding,
                          Ferdinand

                          MAXON SDK Specialist
                          developers.maxon.net

                          1 Reply Last reply Reply Quote 0
                          • C
                            camille chigot
                            last edited by

                            Hello, Some news about this topic,
                            it seems that the length of the folder where I save the c4d file have an incidence on whether the volumeloader work correctly or not ( C4d R23).
                            if I save the file to E:\data\tests\export\USD, the volume loader does not work, If I save the same thing to E:\USD, it works.
                            here are the files ( I renamed the files afterwards, tell me if you find a difference )
                            Untitled2_longfolder.c4d
                            Untitled2_shortfolder.c4d Untitled2_Dense Stratus.vdb Untitled2_Cumulus.vdb
                            the files' reference are relative so they should load fine. ( at least in a short folder)

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