BaseFile Issues

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

On 16/05/2011 at 18:01, xxxxxxxx wrote:

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

---------
I have written functions that save presets and load presets for my object plugin.  The functions use a BaseFile and loads and saves parameters.

Here is the LoadPresets() function..

  
  
  
//LOAD PRESET  
//====================================================//  
Bool PXGPlanet::LoadPreset(GeListNode* node, Filename file){  
  
  BaseObject *op = (BaseObject* )node;  
  BaseContainer *bc = op->GetDataInstance();  
    
  //Declare the BaseFile  
  AutoAlloc<BaseFile> bf;  
  
  //Open the BaseFile for Reading.  
#ifdef C4D_R12  
  bf->Open(file, FILEOPEN_READ, FILEDIALOG_IGNOREOPEN, BYTEORDER_INTEL, MACTYPE_CINEMA, MACCREATOR_CINEMA);  
#else  
  bf->Open(file, GE_READ, FILE_IGNOREOPEN, GE_INTEL, MACTYPE_CINEMA, MACCREATOR_CINEMA);  
#endif  
  
  //Read PXG Attributes from the File.  
    
  //GENERAL  
  //==========================================================//  
      //Planet Shape  
      LONG pshape;  
      bf->ReadLong(&pshape);  
      bc->SetLong(PLANETX_GENERAL_SHAPE, pshape);  
  
      //Radius  
      LReal genrad;  
      bf->ReadLReal(&genrad);  
      bc->SetReal(PLANETX_GENERAL_RADIUS, genrad);  
  
      //Segments  
      LReal genseg;  
      bf->ReadLReal(&genseg);  
      bc->SetReal(PLANETX_GENERAL_SEGMENTS, genseg);  
    
      //Height  
      LReal genht;  
      bf->ReadLReal(&genht);  
      bc->SetReal(PLANETX_GENERAL_HEIGHT, genht);  
  
      //Enable Rotation  
      Bool enrot;  
      bf->ReadBool(&enrot);  
      bc->SetBool(PLANETX_GENERAL_ENABLE_ROTATION, enrot);  
  
      //Rotation Direction  
      LONG rotdir;  
      bf->ReadLong(&rotdir);  
      bc->SetLong(PLANETX_GENERAL_ROTATION_DIRECTION, rotdir);  
  
      //Rotation Speed  
      LReal rotspeed;  
      bf->ReadLReal(&rotspeed);  
      bc->SetReal(PLANETX_GENERAL_ROTATION_SPEED, rotspeed);  
  
      //Frame Rate FPS  
      LReal framerate;  
      bf->ReadLReal(&framerate);  
      bc->SetReal(PLANETX_GENERAL_SCENEFPS, framerate);  
  
  //SURFACE  
  //==========================================================//  
      //Surface Map  
      Filename smap;  
      bf->ReadFilename(&smap);  
      bc->SetFilename(PLANETX_SURFACE_SURFACE_MAP, smap);  
  
      //Enable Specular  
      Bool enspec;  
      bf->ReadBool(&enspec);  
      bc->SetBool(PLANETX_SURFACE_SPEC_ENABLE, enspec);  
  
      //Specular Mode  
      LONG specmode;  
      bf->ReadLong(&specmode);  
      bc->SetLong(PLANETX_SURFACE_SPEC_MODE, specmode);  
  
      //Specular Width  
      LReal specwidth;  
      bf->ReadLReal(&specwidth);  
      bc->SetReal(PLANETX_SURFACE_SPEC_WIDTH, specwidth);  
  
      //Specular Height  
      LReal specheight;  
      bf->ReadLReal(&specheight);  
      bc->SetReal(PLANETX_SURFACE_SPEC_HEIGHT, specheight);  
  
      //Specular Falloff  
      LReal specfalloff;  
      bf->ReadLReal(&specfalloff);  
      bc->SetReal(PLANETX_SURFACE_SPEC_FALLOFF, specfalloff);  
  
      //Specular Inner Width  
      LReal speciwidth;  
      bf->ReadLReal(&speciwidth);  
      bc->SetReal(PLANETX_SURFACE_SPEC_INNER_WIDTH, speciwidth);  
  
      //Enable Generator  
      Bool engen;  
      bf->ReadBool(&engen);  
      bc->SetBool(PLANETX_SURFACE_ENABLE_GENERATOR, engen);  
  
      //Sea Color  
      LVector seacolor;  
      bf->ReadLVector(&seacolor);  
  
#ifdef C4D_R12  
      bc->SetVector(PLANETX_SURFACE_SEA_COLOR, seacolor);  
#else  
      bc->SetVector(PLANETX_SURFACE_SEA_COLOR, Vector(seacolor.x, seacolor.y, seacolor.z));  
#endif  
  
      //Land Color  
      LVector landcolor;  
      bf->ReadLVector(&landcolor);  
  
#ifdef C4D_R12  
      bc->SetVector(PLANETX_SURFACE_LAND_COLOR, landcolor);  
#else  
      bc->SetVector(PLANETX_SURFACE_LAND_COLOR, Vector(landcolor.x, landcolor.y, landcolor.z));  
#endif  
  
      //Mountain Color  
  
      LVector mtncolor;  
      bf->ReadLVector(&mtncolor);  
  
#ifdef C4D_R12      
      bc->SetVector(PLANETX_SURFACE_MOUNTAIN_COLOR, mtncolor);  
#else  
      bc->SetVector(PLANETX_SURFACE_MOUNTAIN_COLOR, Vector(mtncolor.x, mtncolor.y, mtncolor.z));  
#endif  
  
      //Level  
      LReal level;  
      bf->ReadLReal(&level);  
      bc->SetReal(PLANETX_SURFACE_LEVEL, level);  
  
      //Frequnecy  
      LReal freq;  
      bf->ReadLReal(&freq);  
      bc->SetReal(PLANETX_SURFACE_FREQUENCY, freq);  
  
      //Generator Reflection  
      Bool genref;  
      bf->ReadBool(&genref);  
      bc->SetBool(PLANETX_SURFACE_GENERATOR_USE_REFLECTION, genref);  
  
      //Generator Elevation  
      Bool genelev;  
      bf->ReadBool(&genelev);  
      bc->SetBool(PLANETX_SURFACE_GENERATOR_USE_ELEVATION, genelev);  
  
      //Reflection Strength  
      LReal refstr;  
      bf->ReadLReal(&refstr);  
      bc->SetReal(PLANETX_SURFACE_SURFACE_REFLECTION_GEN, refstr);  
  
      //Elevation Strength  
      LReal elvstr;  
      bf->ReadLReal(&elvstr);  
      bc->SetReal(PLANETX_SURFACE_ELEVATION_STRENGTH_GEN, elvstr);  
  
      //Use Reflection Map  
      Bool usermap;  
      bf->ReadBool(&usermap);  
      bc->SetBool(PLANETX_SURFACE_REFLECTION_USE_MAP, usermap);  
        
      //Reflection Map   
      Filename rmap;  
      bf->ReadFilename(&rmap);  
      bc->SetFilename(PLANETX_SURFACE_REFLECTION_MAP, rmap);  
  
      //Reflection Mix  
      LReal refmix;  
      bf->ReadLReal(&refmix);  
      bc->SetReal(PLANETX_SURFACE_SURFACE_REFLECTION_MMIX, refmix);  
  
      //Surface Reflection  
      LReal surfref;  
      bf->ReadLReal(&surfref);  
      bc->SetReal(PLANETX_SURFACE_SURFACE_REFLECTION,surfref);  
  
      //Elevation Map   
      Filename emap;  
      bf->ReadFilename(&emap);  
      bc->SetFilename(PLANETX_SURFACE_ELEVATION_MAP, emap);  
  
      //Elevation Strength  
      LReal estrength;  
      bf->ReadLReal(&estrength);  
      bc->SetReal(PLANETX_SURFACE_ELEVATION_STRENGTH, estrength);  
  
      //Use Normal Map  
      Bool useemap;  
      bf->ReadBool(&useemap);  
      bc->SetBool(PLANETX_SURFACE_USE_NORMAL_MAP, useemap);  
  
      //Normal Map   
      Filename nmap;  
      bf->ReadFilename(&nmap);  
      bc->SetFilename(PLANETX_SURFACE_NORMAL_MAP,nmap);  
  
      //Normal Strength  
      LReal nstrength;  
      bf->ReadLReal(&nstrength);  
      bc->SetReal(PLANETX_SURFACE_NORMAL_STRENGTH, nstrength);  
  
  
  //CLOUDS  
  //==========================================================//  
      //Enable Clouds  
      Bool enclouds;  
      bf->ReadBool(&enclouds);  
      bc->SetBool(PLANETX_CLOUDS_ENABLE, enclouds);  
  
      //Cloud Map   
      Filename cmap;  
      bf->ReadFilename(&cmap);  
      bc->SetFilename(PLANETX_CLOUD_CLOUD_MAP,cmap);  
  
      //Cloud Color  
  
      LVector ccolor;  
      bf->ReadLVector(&ccolor);  
  
#ifdef C4D_R12  
      bc->SetVector(PLANETX_CLOUD_COLOR, ccolor);  
#else  
      bc->SetVector(PLANETX_CLOUD_COLOR, Vector(ccolor.x, ccolor.y, ccolor.z));  
#endif  
  
      //Brightness  
      LReal cbright;  
      bf->ReadLReal(&cbright);  
      bc->SetReal(PLANETX_CLOUD_BRIGHTNESS, cbright);  
  
      //Thickness  
      LReal cthick;  
      bf->ReadLReal(&cthick);  
      bc->SetReal(PLANETX_CLOUD_THICKNESS, cthick);  
  
      //Elevation  
      LReal celeva;  
      bf->ReadLReal(&celeva);  
      bc->SetReal(PLANETX_CLOUD_ELEVATION, celeva);  
  
      //Enable Shadows  
      Bool enshad;  
      bf->ReadBool(&enshad);  
      bc->SetBool(PLANETX_CLOUD_ENABLE_SHADOWS, enshad);  
  
  
  //ATMOSPHERE  
  //==========================================================//  
      //Enable Atmosphere  
      Bool enatmo;  
      bf->ReadBool(&enatmo);  
      bc->SetBool(PLANETX_ATMOSPHERE_ENABLE, enatmo);  
  
      //Atmosphere Color  
      Gradient *atmColor =(Gradient* )bc->GetCustomDataType(PLANETX_ATMOSPHERE_COLOR,CUSTOMDATATYPE_GRADIENT);  
      Gradient *blank = Gradient::Alloc();  
  
      LONG knotCount;  
      bf->ReadLong(&knotCount);  
  
      bc->SetParameter((DescID)(DescID)PLANETX_ATMOSPHERE_COLOR, GeData(CUSTOMDATATYPE_GRADIENT, *blank));  
         
      for(int i = 0; i < knotCount; i++){  
            
          LVector color;  
          LReal position;  
  
          bf->ReadLVector(&color);  
          bf->ReadLReal(&position);  
  
          GradientKnot knot;  
          Vector tmpcol = Vector(color.x, color.y, color.z);  
          knot.col = tmpcol;  
          knot.pos = position;  
  
          atmColor->InsertKnot(knot);  
      }  
  
      bc->SetParameter((DescID)(DescID)PLANETX_ATMOSPHERE_COLOR, GeData(CUSTOMDATATYPE_GRADIENT, *atmColor));  
  
      //Transparency Color  
      Gradient *atmtColor =(Gradient* )bc->GetCustomDataType(PLANETX_ATMOSPHERE_TRANSPARENCY, CUSTOMDATATYPE_GRADIENT);  
      Gradient *tblank = Gradient::Alloc();  
  
      LONG tknotCount;  
      bf->ReadLong(&tknotCount);  
  
      bc->SetParameter((DescID)(DescID)PLANETX_ATMOSPHERE_TRANSPARENCY, GeData(CUSTOMDATATYPE_GRADIENT, *tblank));  
         
      for(int i = 0; i < tknotCount; i++){  
            
          LVector tcolor;  
          LReal tposition;  
  
  
          bf->ReadLVector(&tcolor);  
          bf->ReadLReal(&tposition);  
  
          GradientKnot tknot;  
          Vector ttmpcol = Vector(tcolor.x, tcolor.y, tcolor.z);  
          tknot.col = ttmpcol;  
          tknot.pos = tposition;  
  
          atmtColor->InsertKnot(tknot);  
      }  
  
      bc->SetParameter((DescID)(DescID)PLANETX_ATMOSPHERE_TRANSPARENCY, GeData(CUSTOMDATATYPE_GRADIENT, *atmtColor));  
  
      //Haze Color  
      LVector ahazecolor;  
      bf->ReadLVector(&ahazecolor);  
  
#ifdef C4D_R12  
      bc->SetVector(PLANETX_ATMOSPHERE_HAZE_COLOR, ahazecolor);  
#else  
      bc->SetVector(PLANETX_ATMOSPHERE_HAZE_COLOR, Vector(ahazecolor.x, ahazecolor.y, ahazecolor.z));  
#endif  
  
      //Atmosphere Thickness  
      LReal athick;  
      bf->ReadLReal(&athick);  
      bc->SetReal(PLANETX_ATMOSPHERE_THICKNESS, athick);  
  
      //Enable Glow  
      Bool eng;  
      bf->ReadBool(&eng);  
      bc->SetBool(PLANETX_ATMOSPHERE_ENABLE_GLOW, eng);  
  
      //Use Material Color  
      Bool emc;  
      bf->ReadBool(&emc);  
      bc->SetBool(PLANETX_ATMOSPHERE_GLOW_USE_COLOR, emc);  
  
      //Glow Color  
      LVector gcolor;  
      bf->ReadLVector(&gcolor);  
  
#ifdef C4D_R12  
      bc->SetVector(PLANETX_ATMOSPHERE_GLOW_COLOR, gcolor);  
#else  
      bc->SetVector(PLANETX_ATMOSPHERE_GLOW_COLOR, Vector(gcolor.x, gcolor.y, gcolor.z));  
#endif  
        
      //Brightness  
      LReal gbrit;  
      bf->ReadLReal(&gbrit);  
      bc->SetReal(PLANETX_ATMOSPHERE_GLOW_BRIGHTNESS, gbrit);  
        
      //Inner Strength  
      LReal gis;  
      bf->ReadLReal(&gis);  
      bc->SetReal(PLANETX_ATMOSPHERE_GLOW_INNERSTRENGTH, gis);  
        
      //Outer Strength  
      LReal gos;  
      bf->ReadLReal(&gos);  
      bc->SetReal(PLANETX_ATMOSPHERE_GLOW_OUTERSTRENGTH, gos);  
        
      //Radius  
      LReal grad;  
      bf->ReadLReal(&grad);  
      bc->SetReal(PLANETX_ATMOSPHERE_GLOW_RADIUS, grad);  
        
      //Random  
      LReal grand;  
      bf->ReadLReal(&grand);  
      bc->SetReal(PLANETX_ATMOSPHERE_GLOW_RANDOM, grand);  
  
      //Frequency  
      LReal gfreq;  
      bf->ReadLReal(&gfreq);  
      bc->SetReal(PLANETX_ATMOSPHERE_GLOW_FREQUENCY, gfreq);  
  
      //LIGHTS  
      //==========================================================//  
      //Enable Lights  
      Bool elts;  
      bf->ReadBool(&elts);  
      bc->SetBool(PLANETX_LIGHTS_ENABLE, elts);  
  
        
      //City Lights Map  
      Filename lmap;  
      bf->ReadFilename(&lmap);  
      bc->SetFilename(PLANETX_CITY_LIGHTS_MAP,lmap);  
  
      //Brightness  
      LReal ltsbrt;  
      bf->ReadLReal(&ltsbrt);  
      bc->SetReal(PLANETX_CITY_LIGHTS_BRIGHTNESS, ltsbrt);  
  
      //Lights Color  
      LVector ltscolor;  
      bf->ReadLVector(&ltscolor);  
  
#ifdef C4D_R12  
      bc->SetVector(PLANETX_CITY_LIGHTS_COLOR, ltscolor);  
#else  
      bc->SetVector(PLANETX_CITY_LIGHTS_COLOR, Vector(ltscolor.x, ltscolor.y, ltscolor.z));  
#endif  
        
  return TRUE;  
}  
  

This works great when I save the file in Windows and open the file in Windows,,  The problem arises when I save the file with a PC and try to open it with a Mac.  My Mac tester tells me that the plugin loads fine but none of the preset files oad properly.  I assume that this is an issue with the ByteOrder but I do not know how to account for the different operating systems with a function like this.  Does anyone know how to allow a file that was saved on a PC via my SavePresets() function, to be opened on a Mac?

Any help you could offer would be awesome.

Thanks,

Shawn

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

On 16/05/2011 at 23:55, xxxxxxxx wrote:

As far as I know, the only area that has byteorder concern is WriteBytes and ReadBytes.  Everything else should be system independent as long as you stick with the same byte order across the board.

I have had issues with Real, SReal, and LReal in transitioning from RXX to R12 though. In this case, it required using WriteSReal/ReadSReal to make things work.

Considering that most contemporary Mac computers are using Intel it seems odd that there would be any issues between PC and Mac.  My suggestion is to do tests with the minimal settings being written and read and expand them until the issue appears so as to see if it is related to a certain type (esp. Reals!).  Remember that it could also be a 32-bit/64-bit issue.  Size of types varies between systems and bit width (unfortunately).  You may need to compensate for that as well.

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

On 17/05/2011 at 07:35, xxxxxxxx wrote:

How do you write the presetfiles ?
If not with functions from C4D, then with C++ standart library methods i think ?

As I know from Python, Windows writes some additional bytes at the start of a document, as far as I remember.
There, you must open the file anogher way. 'wb' instead of 'w', so that no extra bytes are written.
Maybe its the same in C++, and readinh the file on Mac makes problems because of theese additional bytes ?

Cheers,
Niklas

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

On 17/05/2011 at 10:22, xxxxxxxx wrote:

I write the files the same as above but using the C4D Write...() functions instead of read..  and a few subtle differences of course
 
I am not sure why it is happening.  I really need to invest in a Mac in the near future,  I don't like being in the dark on the Mac side of things.  😞
 
~Shawn

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

On 17/05/2011 at 17:20, xxxxxxxx wrote:

OMG this is so annoying..  I changed all the LReals to SReals and it still did not work..  The plugin will not load the preset file..  Here is the SavePreset() :

  
  
  
//SAVE PRESET  
//====================================================//  
Bool PXGPlanet::SavePreset(GeListNode* node){  
  
  BaseObject *op = (BaseObject* )node;  
  BaseContainer *bc = op->GetDataInstance();  
    
  //Declare the BaseFile  
  AutoAlloc<BaseFile> bf;  
  
  //Set the Filename  
  Filename file;  
  Filename dir = GeGetPluginPath() + "presets/planets";  
  file.SetDirectory(dir);  
  
#ifdef C4D_R12  
  file.FileSelect(FILESELECTTYPE_ANYTHING, FILESELECT_SAVE, "Save Your Preset");      
  //Open the BaseFile for writing.  
  bf->Open(file, FILEOPEN_WRITE, FILEDIALOG_IGNOREOPEN, BYTEORDER_INTEL, MACTYPE_CINEMA, MACCREATOR_CINEMA);  
#else  
  file.FileSelect(FSTYPE_ANYTHING, GE_SAVE, "Save Your Preset");  
  //Open the BaseFile for writing.  
  bf->Open(file, GE_WRITE, FILE_IGNOREOPEN, GE_INTEL, MACTYPE_CINEMA, MACCREATOR_CINEMA);  
#endif  
  
  //Write PXG Attributes to the File.  
    
  //GENERAL  
  //==========================================================//  
      //General Shape  
      bf->WriteLong(bc->GetLong(PLANETX_GENERAL_SHAPE));  
      //Radius  
      bf->WriteLReal(bc->GetReal(PLANETX_GENERAL_RADIUS));  
      //Segments  
      bf->WriteLReal(bc->GetReal(PLANETX_GENERAL_SEGMENTS));  
      //Height  
      bf->WriteLReal(bc->GetReal(PLANETX_GENERAL_HEIGHT));  
      //Enable Rotation  
      bf->WriteBool(bc->GetBool(PLANETX_GENERAL_ENABLE_ROTATION));  
      //Rotation Direction  
      bf->WriteLong(bc->GetLong(PLANETX_GENERAL_ROTATION_DIRECTION));  
      //Rotation Speed  
      bf->WriteLReal(bc->GetReal(PLANETX_GENERAL_ROTATION_SPEED));  
      //Frame Rate FPS  
      bf->WriteLReal(bc->GetReal(PLANETX_GENERAL_SCENEFPS));  
  
  //SURFACE  
  //==========================================================//  
      //Surface Map  
      bf->WriteFilename(bc->GetFilename(PLANETX_SURFACE_SURFACE_MAP));  
      //Enable Specular  
      bf->WriteBool(bc->GetBool(PLANETX_SURFACE_SPEC_ENABLE));  
      //Specular Mode  
      bf->WriteLong(bc->GetLong(PLANETX_SURFACE_SPEC_MODE));  
      //Specular Width  
      bf->WriteLReal(bc->GetReal(PLANETX_SURFACE_SPEC_WIDTH));  
      //Specular Height  
      bf->WriteLReal(bc->GetReal(PLANETX_SURFACE_SPEC_HEIGHT));  
      //Specular Falloff  
      bf->WriteLReal(bc->GetReal(PLANETX_SURFACE_SPEC_FALLOFF));  
      //Specular Inner Width  
      bf->WriteLReal(bc->GetReal(PLANETX_SURFACE_SPEC_INNER_WIDTH));  
      //Enable Generator  
      bf->WriteBool(bc->GetBool(PLANETX_SURFACE_ENABLE_GENERATOR));  
        
#ifdef C4D_R12  
      //Sea Color  
      bf->WriteLVector(bc->GetVector(PLANETX_SURFACE_SEA_COLOR));  
      //Land Color  
      bf->WriteLVector(bc->GetVector(PLANETX_SURFACE_LAND_COLOR));  
      //Mountain Color  
      bf->WriteLVector(bc->GetVector(PLANETX_SURFACE_MOUNTAIN_COLOR));  
#else  
      //Helpers  
      Vector sea1 = bc->GetVector(PLANETX_SURFACE_SEA_COLOR);  
      Vector land1 = bc->GetVector(PLANETX_SURFACE_LAND_COLOR);  
      Vector mtn1 = bc->GetVector(PLANETX_SURFACE_MOUNTAIN_COLOR);  
        
      //Sea Color  
      bf->WriteLVector(LVector(sea1.x, sea1.y, sea1.z));  
      //Land Color  
      bf->WriteLVector(LVector(land1.x, land1.y, land1.z));  
      //Mountain Color  
      bf->WriteLVector(LVector(mtn1.x, mtn1.y, mtn1.z));  
#endif  
  
      //Level  
      bf->WriteLReal(bc->GetReal(PLANETX_SURFACE_LEVEL));  
      //Frequnecy  
      bf->WriteLReal(bc->GetReal(PLANETX_SURFACE_FREQUENCY));  
      //Generator Reflection  
      bf->WriteBool(bc->GetBool(PLANETX_SURFACE_GENERATOR_USE_REFLECTION));  
      //Generator Elevation  
      bf->WriteBool(bc->GetBool(PLANETX_SURFACE_GENERATOR_USE_ELEVATION));  
      //Reflection Strength  
      bf->WriteLReal(bc->GetReal(PLANETX_SURFACE_SURFACE_REFLECTION_GEN));  
      //Elevation Strength  
      bf->WriteLReal(bc->GetReal(PLANETX_SURFACE_ELEVATION_STRENGTH_GEN));  
      //Use Reflection Map  
      bf->WriteBool(bc->GetBool(PLANETX_SURFACE_REFLECTION_USE_MAP));  
      //Reflection Map   
      bf->WriteFilename(bc->GetFilename(PLANETX_SURFACE_REFLECTION_MAP));  
      //Reflection Mix  
      bf->WriteLReal(bc->GetReal(PLANETX_SURFACE_SURFACE_REFLECTION_MMIX));  
      //Surface Reflection  
      bf->WriteLReal(bc->GetReal(PLANETX_SURFACE_SURFACE_REFLECTION));  
      //Elevation Map   
      bf->WriteFilename(bc->GetFilename(PLANETX_SURFACE_ELEVATION_MAP));  
      //Elevation Strength  
      bf->WriteLReal(bc->GetReal(PLANETX_SURFACE_ELEVATION_STRENGTH));  
      //Use Normal Map  
      bf->WriteBool(bc->GetBool(PLANETX_SURFACE_USE_NORMAL_MAP));  
      //Normal Map   
      bf->WriteFilename(bc->GetFilename(PLANETX_SURFACE_NORMAL_MAP));  
      //Normal Strength  
      bf->WriteLReal(bc->GetReal(PLANETX_SURFACE_NORMAL_STRENGTH));  
  
  //CLOUDS  
  //==========================================================//  
      //Enable Clouds  
      bf->WriteBool(bc->GetBool(PLANETX_CLOUDS_ENABLE));  
      //Cloud Map   
      bf->WriteFilename(bc->GetFilename(PLANETX_CLOUD_CLOUD_MAP));  
  
#ifdef C4D_R12      
      //Cloud Color  
      bf->WriteLVector(bc->GetVector(PLANETX_CLOUD_COLOR));  
#else  
      //Helper  
      Vector cldclr = bc->GetVector(PLANETX_CLOUD_COLOR);  
      bf->WriteLVector(LVector(cldclr.x, cldclr.y, cldclr.z));  
#endif  
      //Brightness  
      bf->WriteLReal(bc->GetReal(PLANETX_CLOUD_BRIGHTNESS));  
      //Thickness  
      bf->WriteLReal(bc->GetReal(PLANETX_CLOUD_THICKNESS));  
      //Elevation  
      bf->WriteLReal(bc->GetReal(PLANETX_CLOUD_ELEVATION));  
      //Use Particles  
      bf->WriteBool(bc->GetBool(PLANETX_CLOUD_ENABLE_SHADOWS));  
  
  //ATMOSPHERE  
  //==========================================================//  
      //Enable Atmosphere  
      bf->WriteBool(bc->GetBool(PLANETX_ATMOSPHERE_ENABLE));  
        
      //Atmosphere Color  
      Gradient *atmColor =(Gradient* )bc->GetCustomDataType(PLANETX_ATMOSPHERE_COLOR,CUSTOMDATATYPE_GRADIENT);  
  
      LONG knotCount = atmColor->GetKnotCount();  
      bf->WriteLong(knotCount);  
  
      for(int i = 0; i < knotCount; i++){  
          GradientKnot knot = atmColor->GetKnot(i);  
  
#ifdef C4D_R12  
          bf->WriteLVector(knot.col);  
#else  
          //Helper   
          Vector mycol = knot.col;  
          bf->WriteLVector(LVector(mycol.x, mycol.y, mycol.z));  
#endif  
  
          bf->WriteLReal(knot.pos);  
      }  
  
      //Transparency Color  
      Gradient *atmtColor =(Gradient* )bc->GetCustomDataType(PLANETX_ATMOSPHERE_TRANSPARENCY, CUSTOMDATATYPE_GRADIENT);  
  
      LONG tknotCount = atmtColor->GetKnotCount();  
      bf->WriteLong(tknotCount);  
  
      for(int i = 0; i < tknotCount; i++){  
          GradientKnot tknot = atmtColor->GetKnot(i);  
  
#ifdef C4D_R12  
          bf->WriteLVector(tknot.col);  
#else  
          //Helper  
          Vector mytcol = tknot.col;  
          bf->WriteLVector(LVector(mytcol.x, mytcol.y, mytcol.z));  
#endif  
  
          bf->WriteLReal(tknot.pos);  
      }  
  
#ifdef C4D_R12  
      //Haze Color  
      bf->WriteLVector(bc->GetVector(PLANETX_ATMOSPHERE_HAZE_COLOR));  
#else  
      //Helper  
      Vector hzcol = bc->GetVector(PLANETX_ATMOSPHERE_HAZE_COLOR);  
        
      bf->WriteLVector(LVector(hzcol.x, hzcol.y, hzcol.z));  
#endif  
  
      //Atmosphere Thickness  
      bf->WriteLReal(bc->GetReal(PLANETX_ATMOSPHERE_THICKNESS));  
      //Enable Glow  
      bf->WriteBool(bc->GetBool(PLANETX_ATMOSPHERE_ENABLE_GLOW));  
      //Use Material Color  
      bf->WriteBool(bc->GetBool(PLANETX_ATMOSPHERE_GLOW_USE_COLOR));  
      //Glow Color  
#ifdef C4D_R12  
      bf->WriteLVector(bc->GetVector(PLANETX_ATMOSPHERE_GLOW_COLOR));  
#else  
      //Helper  
      Vector glcol = bc->GetVector(PLANETX_ATMOSPHERE_GLOW_COLOR);  
      bf->WriteLVector(LVector(glcol.x, glcol.y, glcol.z));  
#endif  
  
      //Brightness  
      bf->WriteLReal(bc->GetReal(PLANETX_ATMOSPHERE_GLOW_BRIGHTNESS));  
      //Inner Strength  
      bf->WriteLReal(bc->GetReal(PLANETX_ATMOSPHERE_GLOW_INNERSTRENGTH));  
      //Outer Strength  
      bf->WriteLReal(bc->GetReal(PLANETX_ATMOSPHERE_GLOW_OUTERSTRENGTH));  
      //Radius  
      bf->WriteLReal(bc->GetReal(PLANETX_ATMOSPHERE_GLOW_RADIUS));  
      //Random  
      bf->WriteLReal(bc->GetReal(PLANETX_ATMOSPHERE_GLOW_RANDOM));  
      //Frequency  
      bf->WriteLReal(bc->GetReal(PLANETX_ATMOSPHERE_GLOW_FREQUENCY));  
  
  
      //LIGHTS  
      //==========================================================//  
      //Enable Lights  
      bf->WriteBool(bc->GetBool(PLANETX_LIGHTS_ENABLE));  
      //City Lights Map  
      bf->WriteFilename(bc->GetFilename(PLANETX_CITY_LIGHTS_MAP));  
      //Brightness  
      bf->WriteLReal(bc->GetReal(PLANETX_CITY_LIGHTS_BRIGHTNESS));  
      //Lights Color  
#ifdef C4D_R12  
      bf->WriteLVector(bc->GetVector(PLANETX_CITY_LIGHTS_COLOR));  
#else  
      //Helper  
      Vector clcol = bc->GetVector(PLANETX_CITY_LIGHTS_COLOR);  
      bf->WriteLVector(LVector(clcol.x, clcol.y, clcol.z));  
#endif  
  
  
      bc->SetString(PXG_CURRENT_PRESET_TEXT, file.GetFileString());  
  
      bf->Close();  
  
      //READ ONLY  
      if(bc->GetBool(PLANETX_GENERAL_SAVE_READONLY) == TRUE){  
  
#ifdef C4D_R10  
          GePrint("THIS FEATURE IS NOT AVAILABLE IN R10");  
#else  
          GeFSetAttributes(file, GE_FILE_ATTRIBUTE_READONLY, GE_FILE_ATTRIBUTE_READONLY);  
          GePrint("FILE SAVED AS READ ONLY");  
#endif  
      }  
        
  return TRUE;  
}  
  

Does anyone notice anything I botched up that would prevent it from working on a Mac?

Man this is annoying me tonight.
Thanks,

~Shawn

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

On 17/05/2011 at 23:13, xxxxxxxx wrote:

Originally posted by xxxxxxxx

[...] Does anyone notice anything I botched up that would prevent it from working on a Mac?Man this is annoying me tonight.Thanks,~Shawn

Do yourself a favour and implement some basic error checking in the code and add some detailed console error messages for the customer/tester.

Best regards,

Wilfried

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

On 20/05/2011 at 05:48, xxxxxxxx wrote:

okay so after some testing, we have determined that the save preset function is saving Filenames from the attributes manager with full paths.  So for example the plugin uses external textures like test.jpg.  So the filename field gets saved as (doing this on my phone and don't havr backslash)  C:/Program Files/Maxon/Plugins/PXG Planet/Presets/Test.jpg.   So when that prset gets opened on a mac that path doesn't exist which leads to the preset not opening properly.   How can I get the preset to save the file name and location so that it can ne read by both Mac ane Windos folder structures?

Thanks.  Shawn

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

On 20/05/2011 at 09:54, xxxxxxxx wrote:

To save just the file name itself, use this:

Filename fn = bc->GetFilename(xxx);
fn = fn.GetFile();

As for location, that will vary from system to system (Windows, MacOS, drive or volume, etc.).  Best to use GeGetPluginPath() to prepend to the filename after reading and just store the file name (Test.jpg) in the presets file.