Visualize Ngons



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

    On 21/04/2009 at 08:06, xxxxxxxx wrote:

    User Information:
    Cinema 4D Version:   R11.026 
    Platform:   Windows  ;   Mac OSX  ; 
    Language(s) :     C++  ;

    ---------
    Hello,

    i want to visualize ngons with the GetVirtualObject-Method in my generatorobject after i already visualized normal polygons. In principle my "datatype" has the same information as the code from the documentation below.

    > \> BaseObject \*ret = BaseObject::Alloc(Onull); \> \> AutoAlloc<PolygonObject> obj(0,0); //begin of example \> if (!obj) return FALSE; \> \> AutoAlloc<Modeling> mod; \> if (!mod || !mod->InitObject(obj)) return FALSE; \> \> LONG a = mod->AddPoint(obj, Vector(0,0,0)); \> LONG b = mod->AddPoint(obj, Vector(100,0,0)); \> LONG c = mod->AddPoint(obj, Vector(150,50,0)); \> LONG d = mod->AddPoint(obj, Vector(100,100,0)); \> LONG e = mod->AddPoint(obj, Vector(0,100,0)); \> if (!a || !b || !c || !d || !e) return FALSE; \> \> LONG padr[] = {a,b,c,d,e}; \> LONG cnt = sizeof(padr)/sizeof(padr[0]); \> \> LONG i = mod->CreateNgon(obj, padr, cnt); \> if (!i) return FALSE; \> \> if (!mod->Commit()) return FALSE; //end of example \> \>    obj->InsertUnderLast(ret); \>

    Did i forget something or did i overlook a fault?

    Thanks for help



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

    On 22/04/2009 at 09:09, xxxxxxxx wrote:

    Did i missed a step between
    > mod->CreateNgon(obj, padr, cnt);
    and
    > obj->InsertUnderLast(ret)
    to "connect" the ngon-information with the PolygonObject so that thePolygonObject internally generates polygons out of the ngons or something like that?
    I don't find the missing link. I need a food for thought.

    cheers

    Oli



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

    On 22/04/2009 at 09:25, xxxxxxxx wrote:

    This line looks wrong.

    > AutoAlloc<PolygonObject> obj(0,0)

    With AutoAlloc allocated objects have only a scope-based lifetime. The polygon object will not be avaible anymore after GetVirtualObjects() has been processed. Use PolygonObject::Alloc(0,0) instead in this case.

    cheers,
    Matthias



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

    On 23/04/2009 at 01:22, xxxxxxxx wrote:

    It works :-).
    What a stupid fault...oh my god.

    Thanks a lot Matthias!

    cheers,

    Oli



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

    On 29/04/2009 at 04:47, xxxxxxxx wrote:

    Same Topic, other problem.

    Now i want to visualize more than one ngon.

    So i use a loop to allocate/free the memory of the PolygonObject and to insert them into the BaseObject.
    In principle it looks like this.

    > <code>BaseObject *ret = BaseObject::Alloc(Onull);
    >
    > AutoAlloc<Modeling> mod;
    >
    > for(LONG ngonCount = 0; ngonCount < ngons; ngonCount++){
    >
    > PolygonObject* obj = PolygonObject::Alloc(0,0);
    >
    > if (!obj) return FALSE;
    >
    > if (!mod || !mod->InitObject(obj)) return FALSE;
    >
    > LONG a = mod->AddPoint(obj, Vector(0,0,0));
    >
    > LONG b = mod->AddPoint(obj, Vector((ngonCount+1)*100,0,0));
    >
    > LONG c = mod->AddPoint(obj, Vector((ngonCount+1)*150,(ngonCount+1)*50,0));
    >
    > LONG d = mod->AddPoint(obj, Vector((ngonCount+1)*100,(ngonCount+1)*100,0));
    >
    > LONG e = mod->AddPoint(obj, Vector(0,(ngonCount+1)*100,0));
    >
    > if (!a || !b || !c || !d || !e) return FALSE;
    >
    > LONG padr[] = {a,b,c,d,e};
    >
    > LONG cnt = sizeof(padr)/sizeof(padr[0]);
    >
    > LONG i = mod->CreateNgon(obj, padr, cnt);
    >
    > if (!i) return FALSE;
    >
    > if (nognCount == ngons-1 && !mod->Commit()) return FALSE;
    >
    >    obj->InsertUnderLast(ret);
    > }
    > </code>

    I know the values of the points not reallymake sense :-).

    My problem is, that this solution worked yesterday and today every time i get a Modeling Kernel Error: internal Error.
    I know i should not use Commit without arguments in a loop (->documentation), but i "commit" not before the last run.

    And how i said, yesterday it worked.

    If there was a magic dragon in my pc yesterday :-), has anybody an other idea to insert more than one ngon into the BaseObject or an idea why it works and than not.

    cheers,

    Oli



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

    On 29/04/2009 at 05:29, xxxxxxxx wrote:

    This seems to work fine here. Maybe just exchange the call to Commit() with mod- >Commit(obj, MODELING_COMMIT_NONE, NULL).

    cheers,
    Matthias



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

    On 29/04/2009 at 07:05, xxxxxxxx wrote:

    Thanks for the fast reply Matthias.
    I have two things.
    1.) If i exchange the call, i only see the last ngon i inserted, but it works :-).

    2.) With your solution i was aible to isolate the fault. In the concrete case i wanted to create a cube with three ngons. So i copied the Cinema-Cube (position of points and the polygonpoints). Ngon 2 and 3 create the ground or rather the top. Ngon 1 should create the four sides of the cube.
    So i get these three arrays for the polygonpoints:
    Ngon 1: 0,1,3,2,2,3,5,4,4,5,7,6,6,7, 1 ,0
    Ngon 2: 1,7,5,3
    Ngon 3: 6,0,2,4

    The marked "1" is the reason for the Modeling Kernel Error.

    If i change the number to "3" for example it works. And if i change the call to Commit() again, i see all ngons :-).

    So any idea why i get the error if there is a "1".

    Thanks,

    Oli



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

    On 05/05/2009 at 07:41, xxxxxxxx wrote:

    I solved the problem.
    The process flow direction of the polygon was wrong at this point :-).


Log in to reply