Objects can't access point info from my generator

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

On 12/10/2010 at 13:42, xxxxxxxx wrote:

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

---------
hi guys,

I was wondering if anyone's experienced this problem before. I've got a generator object that creates a polygon mesh for a gear. It reacts to deformers and everything else normally and can be made editable without issue. The thing is, before it's converted to an editable poly, there are certain objects that ignore it:

Boolean, Connect, Atom Array, HyperNURBS, and Mograph's Fracture Object set to Explode Segments & Connect.

Also, object primitives are visible while they're in point/edge/polygon mode, albeit they can't be modified. The thing is, my object just disappears from the viewport when it's selected in the Object Manager.

It's like other objects can't access its point/polygon  information. I used the roundedTube object from the included SDK examples as a reference when I did my code. I've scanned through it several times but I still couldn't find anything different. Maybe it's a flag that I forgot to include? Maybe I accidentally protected something?

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

On 12/10/2010 at 20:26, xxxxxxxx wrote:

I don't have much experience with that, but I have had objects disappear on me before.
This was due to not cloning an object before I made it editable, or due to allocating an object, inserting it into the document,
and then deleting it (by mistake), rather than letting Cinema4D take control of it.

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

On 13/10/2010 at 02:11, xxxxxxxx wrote:

Please post some reduced code that still shows the problem otherwise it's hard to tell what's going on.

cheers,
Matthias

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

On 13/10/2010 at 03:08, xxxxxxxx wrote:

Here's the stripped version of my plugin.

  
#define ID_TOOTHEDWHEEL 1025798  
  
#include "c4d.h"  
#include "c4d_symbols.h"  
#include "Otoothedwheel.h"  
///////////////////////////////////////////////////////////////////////////////  
class ToothedWheel : public ObjectData{    // TOOTHED WHEEL OBJECT  
  
public:  
  String test;  
  
  virtual Bool Read            (GeListNode *node, HyperFile *hf, LONG level);  
  virtual Bool Write            (GeListNode *node, HyperFile *hf);  
  
  virtual void GetDimension    (PluginObject *op, Vector *mp, Vector *rad);  
  
  virtual BaseObject* GetVirtualObjects(PluginObject*op, HierarchyHelp *hh);  
  virtual Bool Message(GeListNode *node, LONG type, void *t_data);  
  
  static NodeData *Alloc(void) { return gNew ToothedWheel; }  
  
};  
///////////////////////////////////////////////////////////////////////////////  
// read from hyperfile  
Bool ToothedWheel::Read(GeListNode *node, HyperFile *hf, LONG level){  
  if (level>=0){  
      hf->ReadString(&test);  
      }  
  return TRUE;  
}  
///////////////////////////////////////////////////////////////////////////////  
// Write to hyperfile  
Bool ToothedWheel::Write(GeListNode *node, HyperFile *hf){  
  hf->WriteString(test);  
  return TRUE;  
}  
  
///////////////////////////////////////////////////////////////////////////////  
// respond to messages  
Bool ToothedWheel::Message(GeListNode *node, LONG type, void *t_data){  
  if(type == MSG_DESCRIPTION_VALIDATE){//check if values are valid  
  
      }  
  else if(type==MSG_MENUPREPARE){  
      ((BaseObject* )node)->SetPhong(TRUE,TRUE, pi/6);  
      }  
  return TRUE;  
}  
///////////////////////////////////////////////////////////////////////////////  
// for object's bounding box  
void ToothedWheel::GetDimension(PluginObject *op, Vector *mp, Vector *rad){  
  BaseContainer *data = op->GetDataInstance();  
  Real r, h, th;  
  r = data->GetReal(TOOTHEDWHEELOBJECT_R);  
  h = data->GetReal(TOOTHEDWHEELOBJECT_H);  
  th = data->GetReal(TOOTHEDWHEELOBJECT_TOOTHHEIGHT);  
  *mp = 0.0;  
  *rad = Vector(r+th, h*.5, r+th);  
}  
///////////////////////////////////////////////////////////////////////////////  
// create geometry  
static BaseObject *GenerateLathe(Vector *cpadr, LONG loopCount, Real segmentAngle, LONG toothCount, BaseThread *bt){  
  
  PolygonObject *op = NULL;  
  Vector *vadr = NULL;  
  CPolygon *padr = NULL;  
  LONG i,j,segmentNumber,vcnt,pcnt,a,b,c,d;  
  Real len = 0.0, sn, cs, v1, v2, *uvadr = NULL;//sn = sine component, cs = cosine component  
  segmentNumber = toothCount*3;  
  
  vcnt = loopCount*segmentNumber;//vertex count  
  pcnt = loopCount*segmentNumber;//polygon count  
  
  op = PolygonObject::Alloc(vcnt, pcnt);  
  if (!op) goto Error;  
  
  vadr = op->GetPointW();//writable point array  
  padr = op->GetPolygonW();//writable polygon array  
  pcnt = 0;  
  
  for(i = 0; i<segmentNumber; i++){//loop for point locations + polygon assignments aound circle  
      v1=Real(i  )/Real(segmentNumber);  
      v2=Real(i+1)/Real(segmentNumber);  
  
      if (bt && bt->TestBreak()) goto Error;  
  
      for(j = 0; j<loopCount; j++){//0-7  
          a = loopCount*i    \+ j;  
          SinCos(segmentAngle*(Real(i)+0.5), sn, cs);  
          a = loopCount*i    \+ j;  
          vadr[a] = Vector(cpadr[j].x*cs, cpadr[j].y, cpadr[j].x*sn);  
  
          if(i<segmentNumber){  
              b = loopCount*i                            \+ (j+1)%loopCount;  
              c = loopCount*( (i+1)%segmentNumber)    \+ (j+1)%loopCount;  
              d = loopCount*( (i+1)%segmentNumber)    \+ j;  
              }  
  
          if(j<loopCount-1) padr[pcnt++] = CPolygon(a,b,c,d);  
          }  
      }  
  
  op->Message(MSG_UPDATE);  
  op->SetPhong(TRUE, TRUE, Rad(80.0));  
  return op;  
Error:  
  blDelete(op);  
  return NULL;  
}  
///////////////////////////////////////////////////////////////////////////////  
// virtual objects  
BaseObject *ToothedWheel::GetVirtualObjects(PluginObject *op, HierarchyHelp *hh){  
  LineObject *lop = NULL;  
  BaseObject *ret = NULL;      
  ///////////////////////////////////////  
  Bool dirty = op->CheckCache(hh) || op->IsDirty(DIRTY_DATA);//check chache data  
  if (!dirty) return op->GetCache(hh);  
  
  BaseContainer *data = op->GetDataInstance();//get ToothedWheel object data  
  
  Real r = data->GetReal(TOOTHEDWHEELOBJECT_R);  
  Real h = data->GetReal(TOOTHEDWHEELOBJECT_H);  
  Real br = data->GetReal(TOOTHEDWHEELOBJECT_BR);  
  Real bd = data->GetReal(TOOTHEDWHEELOBJECT_BD);  
  Real holer = data->GetReal(TOOTHEDWHEELOBJECT_HOLER);  
  Real holebr = data->GetReal(TOOTHEDWHEELOBJECT_HOLEBR);  
  Real holebd = data->GetReal(TOOTHEDWHEELOBJECT_HOLEBD);  
  LONG tc = data->GetLong(TOOTHEDWHEELOBJECT_TOOTHCOUNT);  
  Real tr = data->GetReal(TOOTHEDWHEELOBJECT_TOOTHHEIGHT);  
  
  LONG segmentNumber = tc*3;  
  Real sectorAngle = pi2/tc;  
  Real segmentAngle = pi2/tc/3;  
    
  ///////////////////////////////////////  
  LONG loopCount = 8;//eight reference circles: (bevel radius, hole bevel radius, hole bevel depth)*(upper and lower)  
  Vector *cpadr = (Vector* )GeAlloc(loopCount*sizeof(Vector));//allocate memory for ring array  
  if(!cpadr) return NULL;  
  /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////  
  // cylindrical distance array for rings. [radial distance, height, 0.0]  
  if(tr > br){  
      cpadr[0] = Vector(r, h*.5, 0.0);  
      cpadr[7] = Vector(r, -h*.5, 0.0);  
      }  
  else{  
      cpadr[0] = Vector(r, tr*bd/br+(h*0.5-bd), 0.0);  
      cpadr[7] = Vector(r, -tr*bd/br-(h*0.5-bd), 0.0);  
      }  
  
  if(tr > br){  
      cpadr[1] = Vector(r, h*.5, 0.0);  
      cpadr[6] = Vector(r, -h*.5, 0.0);  
      }  
  else{  
      cpadr[1] = Vector(r+tr-br, h*.5, 0.0);  
      cpadr[6] = Vector(r+tr-br, -h*.5, 0.0);  
      }  
  cpadr[2] = Vector(holer+holebr,    h*.5, 0.0);  
  cpadr[5] = Vector(holer+holebr,    -h*.5, 0.0);  
  cpadr[3] = Vector(holer, h*.5-holebd, 0.0);  
  cpadr[4] = Vector(holer, -h*.5+holebd, 0.0);  
  
  if(hh->GetVFlags()&VFLAG_POLYGONAL){  
      ret = GenerateLathe(cpadr, loopCount, segmentAngle, tc, hh->GetThread());//third item is point count, toothcount*3  
      if (!ret) goto Error;  
      ret->KillTag(Tphong);  
      if(!op->CopyTagsTo(ret, TRUE, FALSE, FALSE, NULL) ) goto Error;  
      }  
  else{  
      ret = PolygonObject::Alloc(0,0);  
      if (!ret) goto Error;  
      }  
  
  ret->SetName(op->GetName());  
  
  GeFree(cpadr);  
  return ret;  
  
  Error:  
      GeFree(cpadr);  
      blDelete(ret);  
      return NULL;  
}  
///////////////////////////////////////////////////////////////////////////////  
//register plugin  
Bool PluginStart(void){// the main function C4D calls to begin your plugin (think of it as main)  
  
  const Filename pluginPath = GeGetPluginPath();  
  if (!resource.Init(pluginPath)) return FALSE;  
  
  return RegisterObjectPlugin(ID_TOOTHEDWHEEL,"Toothed Wheel",  
                              OBJECT_GENERATOR,  
                              ToothedWheel::Alloc,"Otoothedwheel",  
                              "toothed-wheel-icon.png", 0);  
                              // registers a object plugin with C4D  
}  
///////////////////////////////////////////////////////////////////////////////  
void PluginEnd(void){// called when the plugin is unloaded from C4D  
}  
///////////////////////////////////////////////////////////////////////////////  
Bool PluginMessage(LONG id, void *data){  // allows you to receive plugin messages from C4D or other plugins   
  return TRUE;  
}  

Still trying to figure out what I missed. I'll just work on optimizing my code for now.

Thanks for the help,

-gene

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

On 13/10/2010 at 12:05, xxxxxxxx wrote:

I found the issue. I tried using a different pluginID to see if a fresh build of the plugin would work. Now everything works fine.

I did several Edit>Set As Default... commands a while back to maintain the scene/object  for debugging. I think there was a parameter from an older build that was kept that brought about the glitch.

I guess this means I'll have to clear my Prefs  folder now... O__o

Thanks guys,

-gene