Basic Objects



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

    On 14/05/2008 at 09:43, xxxxxxxx wrote:

    Hey Robert

    In fact, that would be great. I've thought about it some time ago. But at the moment I need to simplify it on a specific type of object (writing my Diplomathesis) and want to keep it with less user interaction. Thiswhy I am trying to create either a primitive and transfer it into polygonal state or setting up a polyobject by obtaining its vertex vectors from a primitive (seen above). And to be honest - I am a worse coder (as you might have seen ;P).

    If this thesis is complete and working so far (and satisfiying my prof), I won't hesitate continuing the development in generalizing this method for all input objects using a tag.



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

    On 14/05/2008 at 15:06, xxxxxxxx wrote:

    Hmm, it seems I figured out, what is causing the crash after the MCOMMAND_CURRENTSTATETOOBJECT. The static_cast<_ANYTYPE*_>(cd.result->GetIndex(0)); leads to apllication crash, when inserting a filled object into the scene (doc->InsertObject(poly,NULL,NULL)). If I use the "old" cd.result_ex it works fine, and the current state to object creates a polygonal object of my BaseObject *sphere=BaseObject::Alloc(Osphere). I don't know what is made behind the scenes and there must be a reason why it is noted with "don't use"... So what is crap with result->GetIndex(0) that this one crashes and the "don't use" runs fine?

    Cheers
    Sascha



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

    On 14/05/2008 at 17:16, xxxxxxxx wrote:

    Where are you doing this - in GetVirtualObjects() or in a tag (Execute())?

    Since this feature was added, I've not had trouble with this:

    // +++ CurrentStateToObject
    ModelingCommandData      mcd;
    mcd.doc =               doc;
    BaseContainer          mbc;
    mbc.SetBool(MDATA_CURRENTSTATETOOBJECT_INHERITANCE,          TRUE);
    mbc.SetBool(MDATA_CURRENTSTATETOOBJECT_KEEPANIMATION,     FALSE);
    mbc.SetBool(MDATA_CURRENTSTATETOOBJECT_NOGENERATE,          FALSE);
    mcd.bc =                         &mbc;
    mcd.mode =                         MODIFY_ALL;
    mcd.flags =                         0L;
    mcd.op =                         orig;
    if (!SendModelingCommand(MCOMMAND_CURRENTSTATETOOBJECT, mcd))     return NULL;
    BaseObject*               proxy =     static_cast<BaseObject*>(mcd.result->GetIndex(0L));
    if (!proxy)                         return NULL;
    // If the converted object is under a Null object:
    //          insert result
    //          remove converted object
    //          insert converted object under Figure
    //          remove and free result (Null)
    BaseObject*               op =     proxy->GetDown();
    if (proxy->IsInstanceOf(Onull) && op)
    {
         doc->InsertObject(proxy, NULL, NULL, FALSE);
         op->Remove();
         doc->InsertObject(op, orig, orig->GetDownLast(), FALSE);
         proxy->Remove();
         BaseObject::Free(proxy);
         proxy =     op;
    }
    // else, insert result under Figure
    else     doc->InsertObject(proxy, orig, orig->GetDownLast(), FALSE);
    doc->AddUndo(UNDO_NEW, proxy);

    Note that the converted object in the AtomArray result may be under a Null object.



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

    On 14/05/2008 at 17:21, xxxxxxxx wrote:

    I should note that if you are converting an Osphere object into a PolygonObject, you might want to use MCOMMAND_MAKEEDITABLE instead. This doesn't require any of the mbc settings.



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

    On 15/05/2008 at 03:35, xxxxxxxx wrote:

    Hi Rob,

    at the moment I am running it in ::Execute, I havent tried this in ::GetVirtualObject yet.
    Debugging "result_ex" output in VC and C4D Console did not result in a memoryleak or sth else.

    I've used your codesample within ::Execute, which results in that nice exception
    > <code>Object.cdl!CLODDY4D::Execute(BaseDocument * doc=0x05486a0c) Line 28 + 0x1f bytes     C++</code>

    while executing

    > <code>BaseObject* proxy = static_cast<BaseObject*>(mcd.result->GetIndex(0));</code>

    You set mcd.flag = OL - what is this flag OL? And why you are using the "flag" in mcd.reslut->GetIndex(OL)? I replaced the flag with : MODELINGCOMMANDFLAG_CREATEUNDO;
    and the Indexvalue with zero - getting the result above. this regular result says "Children cannot be evaluated".

    Cheers
    Sascha



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

    On 15/05/2008 at 13:50, xxxxxxxx wrote:

    0L is 'zero - long value'. This just guarantees that the (LONG) flags variable is cleared.

    Don't know about your crashing situation - would need to see the code or it may be that you can't do this in Execute() (?).



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

    On 15/05/2008 at 16:13, xxxxxxxx wrote:

    Using your code above does not work for me either in Execute() nor GetVirtualObjects() nor any self defined method.
    I just have no idea where it comes from, perhaps because I create an object by code... but that make no sense...

    An further question, is it possible mcd.result_ex does not return a "real" polyobject ? I get crashes getting the Array start from the resulting poly...
    I even don't get it using some terms from "roundedTube.cpp"
    like
    > \> BaseObject \*obj = BaseObject::Alloc(Osphere); // or any (\*obj) assigned by method call... \> PointObject \*pointObject = ToPoint(obj); \> const Vector \*pt = pointObject->GetPointR(); \>

    Roundet tube is setting

    > Vector \*vector = obj->GetPointW();

    But that should make no difference (for me)...

    Of this usage is incorrect -> how is it used correctly with a
    > PolygonObject \*obj = static_cast<PolygonObject\*>(mcd.result->GetIndex(0L))

    or

    > PolygonObject \*obj = static_cast<PolygonObject\*>(mcd.result_ex)

    Cheers
    Sascha



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

    On 15/05/2008 at 16:51, xxxxxxxx wrote:

    'roundedTube.cpp' doesn't have that at all.

    It has:

    PolygonObject* op = NULL;
    ...
    op = PolygonObject::Alloc(pcnt,vcnt);

    You have to consider class derivation here:

    BaseObject
    --PointObject
    ----PolygonObject

    An Osphere is a BaseObject (and a procedural primitive) where as a PolygonObject is a BaseObject class extended with points and polygons support. These are not the same which is why you need to make the procedural primitive (Osphere) editable - which turns it into an Opolygon. Again, doing ToPoint(obj) or ToPoly(obj) just casts the pointer to another type - it doesn't actually change the BaseObject into a PolygonObject.

    I have no idea why mcd.result->GetIndex(0) crashes on you. You should verify the actual crash location by commenting out code until the crash disappears and uncommenting until it reappears. It may not be what you think it is.



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

    On 15/05/2008 at 17:00, xxxxxxxx wrote:

    Jepp thats right. It justs casts the type of pointer. Somehow it runs in this example...

    We are two, I also have no idea. I did that commenting out the code... either it crashes on casting the result from sendModelingCommand or when inserting into doc.

    Cheers



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

    On 15/05/2008 at 17:05, xxxxxxxx wrote:

    You might want to check that mcd.result is not NULL (the AtomArray was allocated) as well as checking the retrieved object similarly.



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

    On 15/05/2008 at 17:08, xxxxxxxx wrote:

    Thats a good idea to check...



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

    On 16/05/2008 at 03:36, xxxxxxxx wrote:

    I recently tried the following code, with three methods of object generation. Everyone crashes at the static_cast, no matter to what type the result is casted...

    > BaseObject \*CLODDY4D::GetVirtualObjects(BaseObject \*op, HierarchyHelp \*hh){ \> \>      BaseContainer bc; \>      ModelingCommandData mcd; \>      bc.SetReal(PRIM_SPHERE_RAD,100.0); \>      bc.SetLong(PRIM_SPHERE_SUB,4); \> \>      //BaseObject \*sphere = GeneratePrimitive(NULL,Osphere,bc,1.0,FALSE,hh->GetThread()); \>      //BaseObject \*sphere = BaseObject::Alloc(Osphere); \>      AutoAlloc<BaseObject>sphere(Osphere); \>      if(!sphere) return NULL; \>       \>      mcd.doc = GetActiveDocument(); \>      mcd.bc = &bc; \>      mcd.flags = 0L; \>      mcd.op = sphere; \>      if(!SendModelingCommand(MCOMMAND_CURRENTSTATETOOBJECT, mcd)) return NULL; \>      PolygonObject\* poly = static_cast<PolygonObject\*>(mcd.result->GetIndex(0L)); \>      //if(mcd.result->GetIndex(0L)->GetType()!=Opolygon) return NULL; \>      if(!poly) return NULL; \>      return poly; \> }

    Perhaps I am really running into a dead end, with my vision of the need of a polygonal object (I am much more a c4d user ;) ) to access its points and polygons.
    At the end, all I need is access to the point array of my octa to perfom cutting operations on the edges by mid-point and merging vertex points.

    Cheers
    Sascha



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

    On 20/05/2008 at 03:45, xxxxxxxx wrote:

    Hello again,

    I just can't get rid of this converting. I cannot get it run properly when using code like this:

    > \> static PolygonObject \*PolyObject(BaseObject \*sphere) \> { \>      PolygonObject \*polyOb = NULL; \>      ModelingCommandData mcd; \>      mcd.doc = GetActiveDocument(); \>      mcd.bc = sphere->GetDataInstance(); \>      mcd.op = sphere; \>      if(!SendModelingCommand(MCOMMAND_CURRENTSTATETOOBJECT,mcd)) return NULL; \>      polyOb = static_cast<PolygonObject\*>(mcd.result->GetIndex(0)); \>      if(polyOb->GetType()!=Opolygon) return NULL; \>       \>      return polyOb; \> } \> \> PolygonObject \*CLODDY4D::GetVirtualObjects(PluginObject \*op, HierarchyHelp \*hh) \> { \>      BaseObject \*sphere = BaseObject::Alloc(Osphere); \>      if(!sphere) return NULL; \> \>      BaseContainer \*bc = sphere->GetDataInstance(); \>      bc->SetReal(PRIM_SPHERE_RAD,100); \>      bc->SetLong(PRIM_SPHERE_SUB,4); \>       \>      return PolyObject(sphere); \> } \>

    The debugger stops at polyOb = static_cast<..>;
    If modelingcommand fails, it should return NULL, so there should be some result, but this cast does not work as it should! (According to documentation). I am running out of clues and time...

    *sigh*
    Sascha



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

    On 20/05/2008 at 05:22, xxxxxxxx wrote:

    You can not use GetActiveDocument() in this case. Here some working code.

    > \> static PolygonObject \*PolyObject(BaseDocument \*doc, BaseObject \*sphere) \> { \>      PolygonObject \*polyOb = NULL; \>      ModelingCommandData mcd; \>       mcd.doc = doc; \>      mcd.op = sphere; \>      if(!SendModelingCommand(MCOMMAND_CURRENTSTATETOOBJECT, mcd)) return NULL; \>      polyOb = static_cast<PolygonObject\*>(mcd.result->GetIndex(0)); \>      if(polyOb->GetType()!=Opolygon) return NULL; \>       \>      return polyOb; \> } \> \> // main routine: build virtual atom objects \> BaseObject \*AtomObject::GetVirtualObjects(PluginObject \*op, HierarchyHelp \*hh) \> { \>      BaseObject \*sphere = NULL; \>      sphere = BaseObject::Alloc(Osphere); \>      if(!sphere) goto Error; \> \>      BaseContainer \*bc = sphere->GetDataInstance(); \>      bc->SetReal(PRIM_SPHERE_RAD,100); \>      bc->SetLong(PRIM_SPHERE_SUB,4); \> \>      PolygonObject \*polysphere = NULL; \>      polysphere = PolyObject(op->GetDocument(), sphere); \> \>      if(sphere) \>      { \>           BaseObject::Free(sphere); \>           sphere = NULL; \>      } \> \>      return polysphere; \> \> Error: \>      blDelete(sphere); \>      return NULL; \> } \>

    cheers,
    Matthias



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

    On 20/05/2008 at 07:45, xxxxxxxx wrote:

    Hello Matthias,

    thanks for this clearing.
    I had no idea, that GetDocument(); retrieves the current opened document. Thought it was GetActiveDocument();... Think thats for more than one open doc's ?!

    Right now the function call "polysphere=polyObject(op->GetDocument(),sphere)" causes this exception:

    > \> Unhandled exception at 0x00bbc1ea in CINEMA 4D Demo.exe: 0xC0000005: Access violation reading location 0x00000000

    I have no experience with this type of exception, what went wrong ?!

    P.s.: I am developing under demo of r10.5, cause it starts up much faster than my full installation with lots of Plug-Ins installed...

    Edit:
    It seems the document is not retrived correctly...
    I set up an ::Init()-Function, i hope that is correct for an ObjectData-Plugin... :

    > \> Bool CLODDY4D::Init(GeListNode \*node) \> { \>      BaseObject \*op = (BaseObject\* )node; \>      BaseContainer \*data = op->GetDataInstance(); \>      return TRUE; \> } \>

    So op has to be "anything", where document can be retrieved from.

    Wave
    Sascha op



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

    On 26/05/2008 at 03:43, xxxxxxxx wrote:

    Nobody an idea ? *sigh*

    Cheers



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

    On 27/05/2008 at 00:57, xxxxxxxx wrote:

    Does it work if you change the call to PolyObject() to something like this (use hh instead of op) :

    polysphere = PolyObject(hh->GetDocument(), sphere);

    Either way I don't get this exception here.

    cheers,
    Matthias



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

    On 27/05/2008 at 02:04, xxxxxxxx wrote:

    Hi

    Yes, I already changed it to hh->GetDocument(); earlier, getting the same result.

    If I use BaseDocument *doc = op->GetDocument() or hh->GetDocument(); as very first statement (which is equivalent to the direct call) cinema4D crashes directly there.

    Hmm, what could cause this exception ? IDE ? IDE-config ? Operating System ? I am running VS C++ 2008 EE on Vista x64. Perhaps this does not work with the express edition ?

    Cheers
    Sascha



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

    On 27/05/2008 at 03:32, xxxxxxxx wrote:

    Hey ahm right now, I revisited the documentation. It seems I have missed setting up /vmg /vms.

    Thanks so far, now everything works and i can start manipulating vertexpoints and polygons :)

    Just for safeness:
    Shouln't be the sphere set NULL at first before freeing it ? Setting it NULL first before freeing it does not result a crash at
    c4d_baseObject.cpp, line 841
    void BaseObject::Free(BaseObject *&bl;)
    {
         C4DOS.Bl->Free(bl);
         bl=NULL;
    }



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

    On 27/05/2008 at 03:53, xxxxxxxx wrote:

    No, how should Cnema know what to free if the pointer is set to NULL.

    cheers,
    Matthias


Log in to reply