some problem with polygon and modellig



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

    On 30/04/2009 at 01:35, xxxxxxxx wrote:

    User Information:
    Cinema 4D Version:   10.5 /11 
    Platform:   Windows  ;   Mac OSX  ; 
    Language(s) :     C++  ;

    ---------
    Hello all,
    i am serching a way to cerate a polygon (ngon) from some existing point.
    in particular i create with modelling Lib this point in a loop and then in next loop i need to cerate an Ngon.

    Another problem:
    here some code  in may Descriptiontooldata::MouseInput
    case SM_TYPE_CONTOUR:
    {
    if (i==0)
    {
    mymod= Modeling::Alloc();
    mymod->InitObject((PolygonObject* )obj,0);
    }
    if ( i != 0)
    {
    if ( newpos == trackarr[0] )
    {
    mymod->CreateNgon((PolygonObject* )obj,index,i);
    if (!mymod->Commit()) return FALSE;
    EventAdd();
    trackarr.Free();
    longarr.Free();
    Modeling::Free(mymod);
    i=0;
    break;
    }
    }
    trackarr.Push(newpos);
    index[i] = mymod->AddPoint(obj,newpos);
    if (!mymod->Commit()) return FALSE;
    i=i++;
    break;
    }
    the main problem is this in the first loop (i=0) i alloc modelling and this is ok
    then on each i increment i ad a point with  mymod->AddPoint(obj,newpos);
    but in the second loop this operation return 0 and not point virtual index, cinema4d trace tell me Modelling Kernel error.
    any idea ?
    Thanks
    Franz



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

    On 30/04/2009 at 02:04, xxxxxxxx wrote:

    Hi Franz,

    If you use Commit() inside of a loop the Commit-function returns FALSE from the second run. You have to call Commit() after all your Ngons were created.
    In your case you should add first all points and then call the Commit-function.

    I hope this solves your problem.

    cheers,

    Oli



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

    On 30/04/2009 at 03:58, xxxxxxxx wrote:

    Hello Oli,
    you are right, thanks..... But if don't commit after addpoint, my new point are not displayed in editor and i need it.
    any sugestion ?
    thanks in advance
    franz



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

    On 30/04/2009 at 07:22, xxxxxxxx wrote:

    The topic "Visualize Ngons" could helps you. There is the problem discribed which i had with this stuff and how it was solved.
    I think it's not the same, but a similar problem.

    cheers,

    Oli



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

    On 03/05/2009 at 09:48, xxxxxxxx wrote:

    Hello all, 
    any help for me ?
    curently i am tring to draw point by point my polygon but i can't view and snap drawed point i already done in my draw loop.
    i need to create somthing like create polygon tool in Cinema, where all point are availabe for snapping before each click in the editor.
    i meaby work without modeling lib ?

    thanks
    Franz



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

    On 04/05/2009 at 02:36, xxxxxxxx wrote:

    You have to pass the MODELING_COMMIT_UPDATE flag to Commit(). Also make sure to call Init() outside of your loop.

    Here is a little example tool drawing points:

    > \> Bool LiquidToolData::MouseInput(BaseDocument \*doc, BaseContainer &data;, BaseDraw \*bd,EditorWindow \*win, const BaseContainer &msg;) \> { \>      Real mx = msg.GetReal(BFM_INPUT_X); \>      Real my = msg.GetReal(BFM_INPUT_Y); \>      LONG button; \> \>      switch (msg.GetLong(BFM_INPUT_CHANNEL)) \>      { \>           case BFM_INPUT_MOUSELEFT : button=KEY_MLEFT; break; \>           case BFM_INPUT_MOUSERIGHT: button=KEY_MRIGHT; break; \>           default: return TRUE; \>      } \> \>      BaseObject \*obj = NULL; \>      obj = doc->GetActiveObject(); \>      if (!obj || obj->GetType() != Opolygon) return TRUE; \> \>      AutoAlloc<Modeling> mod; \>      if (!mod || !mod->InitObject(obj)) return FALSE; \> \>      Real dx,dy; \> \>      BaseContainer device; \>      win->MouseDragStart(button,mx,my,MOUSEDRAG_DONTHIDEMOUSE|MOUSEDRAG_NOMOVE); \>      while (win->MouseDrag(&dx;,&dy;,&device;)==MOUSEDRAG_CONTINUE) \>      { \>           if (dx==0.0 && dy==0.0) continue; \> \>           mx+=dx; \>           my+=dy; \> \>           Vector ray = !(bd->SW(Vector(mx,my,500.0)) - bd->GetMg().off); // calculate the camera ray \> \>           Real alpha = VectorAngle(ray,Vector(0,-1,0)); // calculate angle between camera ray and the normal of the y-plane \>           Real camlevel = bd->GetMg().off.y; // y-position of the camera \>           Real camdist = camlevel/Cos(alpha); // calculate the distance from the camera to be on the y-plane \> \>           Matrix m = HPBToMatrix(VectorToHPB(ray),ROT_HPB); // create a global matrix for the camera ray \>           m.off = bd->GetMg().off; \> \>           Vector pos = m\*Vector(0,0,camdist); // bring position into global space \> \>           if (mod->AddPoint(obj, pos) == 0) \>           { \>                GePrint("modeling error"); \>                return FALSE; \>           } \> \>           if (!mod->Commit(obj, MODELING_COMMIT_UPDATE, NULL)) \>           { \>                GePrint("commit error"); \>                return FALSE; \>           } \> \>           DrawViews(DA_ONLY_ACTIVE_VIEW|DA_NO_THREAD|DA_NO_ANIMATION); \>      } \>      EventAdd(); \> \>      return TRUE; \> } \>

    cheers,
    Matthias



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

    On 05/05/2009 at 00:44, xxxxxxxx wrote:

    Hello Matthias,
    Thanks for reply is useful for my job, and sorry for my late reply.
    Best
    Franz


Log in to reply