adding points



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

    On 26/09/2009 at 17:10, xxxxxxxx wrote:

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

    ---------
    Hello,

    I am trying to add points to an existing object.
    This is the code that I am currently using.

    However, the points are not showing up on my object.

    Does anyone see anything wrong with this code?

    Thanks,

    ~Shawn

    > `

      
    \>  // Add new points  
    \>       LONG newPointCount;  
    \>       newPointCount = objPoly->GetPointCount();  
    \>       vc.old_cnt=newPointCount;  
    \>       vc.new_cnt=newPointCount + lngCrossSymCount;  
    \>    
    \>       LONG addedPointCount = vc.new_cnt - vc.old_cnt;  
    \>       GePrint("The Number of New points is: " + LongToString(addedPointCount));  
    \>    
    \>       for (lngI=0;lngI<addedPointCount;lngI++)       
    \>       {  
    \>            if (objPoly->Message(MSG_POINTS_CHANGED,&vc;))  
    \>            {   
    \>            arrPoints=objPoly->GetPointW();  
    \>            // update the first point  
    \>            arrPoints[newPointCount]=(0,0,0);  
    \>            // Increment newPointCount so it points to the seccond new point  
    \>            newPointCount++;  
    \>            objPoly->Message(MSG_UPDATE);  
    \>            }  
    \>       }  
    \>    
    \>  
    

    `



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

    On 26/09/2009 at 17:53, xxxxxxxx wrote:

    You only need to send the message once. Dispose of that loop around the code! The points are automatically set to (0,0,0) when created. It really should be Vector(0,0,0) to do the initialization. You can do that in a loop:

    if (objPoly->Message(MSG_POINTS_CHANGED,&vc;))
    {
         arrPoints =     objPoly->GetPointW();
         for (lngI = 0L; lngI < addedPointCount; ++lngI)
         {
              arrPoints[newPointCount] = Vector(0.0f);
              ++newPointCount;
         }
         objPoly->Message(MSG_UPDATE);
    }
    // You might need to send this to get everything updated properly
    EventAdd();

    Other than that, the code looks correct.



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

    On 26/09/2009 at 20:05, xxxxxxxx wrote:

    Thanks Robert.

    I tried your version of the code and still no points show up in the center of my object.

    Here it is as you wrote it.

    > `

      
    \>       // Add new points  
    \>       LONG newPointCount;  
    \>       newPointCount = objPoly->GetPointCount();  
    \>       vc.old_cnt=newPointCount;  
    \>       vc.new_cnt=newPointCount + lngCrossSymCount;  
    \>    
    \>       LONG addedPointCount = vc.new_cnt - vc.old_cnt;  
    \>       GePrint("The Number of New points is: " + LongToString(addedPointCount));  
    \>    
    \>       if (objPoly->Message(MSG_POINTS_CHANGED,&vc;))  
    \>       {  
    \>            arrPoints = objPoly->GetPointW();  
    \>            for (lngI = 0L; lngI < addedPointCount; ++lngI)  
    \>            {  
    \>          arrPoints[newPointCount] = Vector(0.0f);  
    \>          ++newPointCount;  
    \>            }  
    \>                 objPoly->Message(MSG_UPDATE);  
    \>       }  
    \>       EventAdd();  
    \>    
    \>  
    

    `

    If I create a cube, and give it 3 segments in x y and z.   and then enable the symmetry, it the then invokes the CreateSymmetry() in my plugin. This code is found within the CreateSymmetry ()...   the idea is that it will create points on the symmetry plane, or the center of the object, if there are none there.

    Does it look like that is what this code is doing? And if not, what would you recommend.

    Thanks,

    ~Shawn



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

    On 26/09/2009 at 20:30, xxxxxxxx wrote:

    okay.. correction,   the new points are being added.   but they are being placed at absolute 0.   so all of the new points are at 0,0,0 I want the points to show up between each point of the center polygons so that it cuts the object in half at the center. .

    Any thoughts?

    ~Shawn



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

    On 26/09/2009 at 20:46, xxxxxxxx wrote:

    The values of an object's vectors are considered global coordinates so, yes, (0,0,0) is the world center. You need to find the line segment between the two points at which the splitting occured and then find the point along the line segment at 0.0 with respect to the plane of symmetry - assuming that the plane coincides with a global axial plane. Again, the clipping routines that I mentioned previously would furnish you with the coordinates of the new point without much more work.



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

    On 26/09/2009 at 20:59, xxxxxxxx wrote:

    how do I find a line segment?

    ~Shawn



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

    On 26/09/2009 at 21:17, xxxxxxxx wrote:

    I'd concentrate on "3D clipping polygon against plane" (as in Google).

    Here are a few site references:

    Polygon Clipping

    Sutherland-Hodgeman clipping

    You'll usually see these algorithms in relation to View Frustrum Clipping but the general principle is the same for any polygon clipping against a plane. Of course, the result of a plane cutting a (convex) polygon is a line segment with two new points on the polygon's edges (one or both may be coincident with existing points requiring less work). Unless you are dealing with concave polygons which would incur more new points and possibly multiple line segments, I wouldn't worry about it. Cinema 4D normally only presents you with quadrangles and triangles. Triangles can never be concave. Quadrangles might be but that is a rare situation. While concavity in polygons is a remote possibility, code exists to handle that situation as well (old, but cornerstone, "High-resolution Computer Graphics Using C" by Ian O. Angell).



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

    On 27/09/2009 at 15:53, xxxxxxxx wrote:

    okay the new points are being placed in the right spot now.. How would I connect specific points with a line segment to make two polygons instead of 1?



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

    On 27/09/2009 at 16:39, xxxxxxxx wrote:

    You're going to need to increase the number of polygons on the object. Instead of VariableChanged, I'd use PolygonObject::ResizeObject() instead as you can do both at once. Then you'll need to change the new and affected polygon indices.

    As you can see, the original and new polygons will share two indices into the point array (C'=B'' and D'=A''). The other two original indices (C and D) will now be used by the new polygon.



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

    On 29/09/2009 at 01:41, xxxxxxxx wrote:

    If you need to consider ngons you should also take a look at the Modeling library. I think the SplitEdge/SplitPolygon functions are related to your plugin.

    cheers,
    Matthias


Log in to reply