Modeling Command for Set Point Value ?



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

    On 07/10/2009 at 16:37, xxxxxxxx wrote:

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

    ---------
    Hi,

    I want to perform a "Set Point Value" (Menu "Structure -> Set Point Value"; Shortcut M~L) on a polygon object and crumple it.

    I can't find it in the SDK and also not in the PluginCafé, so I ask :)
    IMO there should be a Modeling Command for this, but I couldn't find it.

    Thanks in advance for any help!

    Cheers,
    Jack



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

    On 07/10/2009 at 21:20, xxxxxxxx wrote:

    There is but it doesn't show up until the R10.5 SDK. You could try duplicating the ID_MODELING_SETVALUE_TOOL enum and use the toolsetvalue.res in R10.1 to see if it works despite its omission.



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

    On 08/10/2009 at 05:05, xxxxxxxx wrote:

    Hm, I can't get it to work...

    I tried it like that:

    > BaseContainer md; \> md.SetLong(TEMP_MDATA_SETVALUE_SETALL, MDATA_SETVALUE_CRUMPLE_ALONGNORMALS); \> md.SetReal(TEMP_MDATA_SETVALUE_VAL_X, CrumpleVal); \> ModelingCommandData cd; \> cd.doc = doc; \> cd.bc = &md; \> cd.op = MyPolyObj; \> if (!SendModelingCommand(ID_MODELING_SETVALUE_TOOL, cd)) return NULL;

    Nothing happens. No crash, SendModelingCommand() returns TRUE, but the Polygon Object does not change at all.
    So I thought, maybe I have to get the modified geometry from the ModelingCommandData's result:

    > \> TheFinalObject = static_cast<PolygonObject\*>(cd.result->GetIndex(0));

    GetIndex(0) makes it crash :-(

    What am I doing wrong?
    Thanks in advance!

    Cheers,
    Jack



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

    On 08/10/2009 at 06:35, xxxxxxxx wrote:

    OK, I found it's easier to write my own crumple function than to find my way through undocumented tool functions... I'll share the code here.

    Please note that this code was written very hasty ;-) It works, but it could be cleaner.

    > <code>void CrumpleGeometry(PolygonObject *op, Real Strength, Random &Rnd;)
    > {
    >      if (!op) return;
    >
    >      LONG PointCount = op->GetPointCount();
    >      LONG p = 0;
    >
    >      Vector Norm = Vector();
    >      Vector *parr = op->GetPointW();
    >
    >      Neighbor nb;
    >      if (!nb.Init(PointCount, op->GetPolygonW(), op->GetPolygonCount(), NULL)) return;
    >
    >      for (p = 0; p < PointCount; p++) {
    >           Norm = GetVertexNormal(p, op, &nb;);
    >           parr
    >
    > += Norm * Strength * Rnd.Get11();
    >      }
    > }
    > </code>

    And here's the used GetVertexNormal() function, which I wrote earlier from tipps here in the Café...

    > <code>Vector GetVertexNormal(LONG PointIndex, PolygonObject *op, Neighbor *neighbor)
    > // Gets the normal vector for a vertex of a polygon object.
    > // Needs an initialized Neighbor class
    > {
    >      // Variables
    >      CPolygon *pNeighborPoly;
    >      LONG j, faceCnt, *pFaces = NULL;
    >      Vector v1, v2, vNorm = Vector();
    >      CPolygon *m_pPolys = op->GetPolygonW();
    >      Vector *m_pPoints = op->GetPointW();
    >
    >      // Get polygons attached to point
    >      neighbor->GetPointPolys(PointIndex, &pFaces;, &faceCnt;);
    >      if(!faceCnt) return vNorm;
    >
    >      for(j=0; j<faceCnt; j++)
    >     {
    >         pNeighborPoly = &m;_pPolys[pFaces[j]];
    >
    >         // Compute face normal
    >         v1 = m_pPoints[pNeighborPoly->b] - m_pPoints[pNeighborPoly->a];
    >         v2 = m_pPoints[pNeighborPoly->c] - m_pPoints[pNeighborPoly->a];
    >         vNorm += v1 % v2; // get cross-product
    >     }
    >      vNorm /= faceCnt;
    >
    >      // Return resuling normal vector
    >      return !vNorm;
    > }
    > </code>

    Cheers,
    Jack



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

    On 08/10/2009 at 07:48, xxxxxxxx wrote:

    As I said, you could try it. No guarantee that it would work in R10. :)

    Before you call GetIndex(0) you would need to check that cd.result was not NULL. In commands that return a 'result', SendModelingCommand() will fail before a NULL result is returned. In other cases (where it works directly with the cd.op), it will definitely be NULL. Don't forget that when 'result' is not NULL, you have to free it:

    AtomArray::Free(cd.result);

    Glad that you found a workaround!


Log in to reply