Maxon Developers Maxon Developers
    • Documentation
      • Cinema 4D Python API
      • Cinema 4D C++ API
      • Cineware API
      • ZBrush GoZ API
      • Code Examples on Github
    • Forum
    • Downloads
    • Support
      • Support Procedures
      • Registered Developer Program
      • Plugin IDs
      • Contact Us
    • Categories
      • Overview
      • News & Information
      • Cinema 4D SDK Support
      • Cineware SDK Support
      • ZBrush 4D SDK Support
      • Bugs
      • General Talk
    • Unread
    • Recent
    • Tags
    • Users
    • Login

    Viewport Select Radius

    SDK Help
    0
    20
    1.5k
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • H
      Helper
      last edited by

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

      On 26/07/2011 at 05:06, xxxxxxxx wrote:

      Hi Steve,

      That is pretty much what I do to add to the selection.  The problem I am encountering is that when I do this, ViewportiPixel::i only returns the point that directly closest to the mouse, not all points within the radius.  So to solve that I would iterate through all the points in the object and use BaseSelect to select any points that were a certain distance away from the point selected which works (kinda).  🙂  It get very slow with objects that have many points.

      Also this method is object based and selects points based on distance on the object.  The live select tool selects points based on the radius of the circle guide that is drawn.  You can see that the selections are based on the Screen coordinates.  That is the effect I am looking for.

      Some how, I need to get the location of the pixels on the screen that are within the radius and test GetNearestPoint() against those pixels.

      Any thoughts on how I would iterate through the pixels within the radius of ViewportSelect::ShowHotSpot() ?

      Thanks for the response Steve 🙂

      1 Reply Last reply Reply Quote 0
      • H
        Helper
        last edited by

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

        On 26/07/2011 at 05:58, xxxxxxxx wrote:

        Right, got you. I thought GetNearestPoint would return a list of points within the specified radius, not just one point.

        There must be a way of doing it... I can't see any immediate answer, but I'll have another think.

        Edit - does sculpting.cpp in the SDk example source help? It uses GetPixelInfoPoint rather than GetNearestPoint. I haven't tried to work out how it works, but it might help do what you want to do.

        1 Reply Last reply Reply Quote 0
        • H
          Helper
          last edited by

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

          On 26/07/2011 at 06:26, xxxxxxxx wrote:

          I did look at that source a couple days ago but the only thing I could glean from it was that GetPixelInfoPoint gave me information about the point that was behind the mouse.  Not the pixels within the radius.  HAHA  seems like this is gonna be a tough one to solve..   Must be that screen based is the way to go,  because the live select tool selects points at the radius of that circle no matter how close or far away from the object the camera is,  so it must be using screen coordinates to determine which points to select.  🙂

          Oh how I wish GetNearestPoint returned all the points within the radius  HAHA

          Thanks again.  🙂

          ~Shawn

          1 Reply Last reply Reply Quote 0
          • H
            Helper
            last edited by

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

            On 26/07/2011 at 06:30, xxxxxxxx wrote:

            Unless of course the live select tool uses a raycollider but I can't see how to do that without iterating through all the points.  🙂

            1 Reply Last reply Reply Quote 0
            • H
              Helper
              last edited by

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

              On 26/07/2011 at 10:20, xxxxxxxx wrote:

              Why not just use GetNearestPoint() and then use a Neighbor class to get neighboring points within the radius (do a distance from the hitpoint being used as the center of the radial selection?

              1 Reply Last reply Reply Quote 0
              • H
                Helper
                last edited by

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

                On 26/07/2011 at 10:25, xxxxxxxx wrote:

                hmmm.. you might be on to something there Robert.  😄

                How would I get Neighboring points though?  Get the neighboring polys and then get the points of those polys using

                void GetPointPolys(LONG pnt, LONG** dadr, LONG* dcnt)_<_h4_>_

                Thanks,

                Shawn

                1 Reply Last reply Reply Quote 0
                • H
                  Helper
                  last edited by

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

                  On 26/07/2011 at 10:46, xxxxxxxx wrote:

                  After a bit of research and search here, you might want to stay with the ViewportSelect+ViewportPixel.  Michael Welter says this:

                  Try

                  ViewportPixel* GetPixelInfoPoint(LONG x, LONG y);
                  ViewportPixel* GetPixelInfoPolygon(LONG x, LONG y);
                  ViewportPixel* GetPixelInfoEdge(LONG x, LONG y);

                  You can iterate over all pixels in the selection area and call these. Its quite fast so it shouldn't be the bottleneck, if your are worried about that.

                  Note that you will need to get the pixels within the radius of the hitpoint (the selection area).

                  1 Reply Last reply Reply Quote 0
                  • H
                    Helper
                    last edited by

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

                    On 26/07/2011 at 10:49, xxxxxxxx wrote:

                    Yeah I saw that, and I attempted to iterate through the pixels and it lagged pretty bad,   but maybe I iterated through the pixels wrong.

                    If I remember correctly, I used the current mouse location,   and set up a range from negative radius to positive radius in both x and y and iterated through that to check for points at those pixel locations and that was crazy slow..

                    Do I interpret him meaning incorrectly?

                    1 Reply Last reply Reply Quote 0
                    • H
                      Helper
                      last edited by

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

                      On 26/07/2011 at 10:58, xxxxxxxx wrote:

                      so as a code example of how I had iterated through that..  I would so something like this.  🙂

                        
                      LONG xmin = mx - radius   //mx is the current mouse x position.  :)  
                      LONG xmax = mx + radius  
                      LONG ymin = my - radius   //my is the current mouse y position.  :)  
                      LONG ymax = my + radius  
                        
                      for(int ix = xmin; ix < xmax; ix++)  
                      {  
                        for(int iy = ymin; iy  < ymax; iy++)  
                        {  
                            ViewportPixel *vp = vps->GetPixelInfoPoint(ix, iy);  
                            bsPoint->Select(vp->i);  
                        }  
                      }  
                      

                      Is that completely wrong  HAHA?

                      1 Reply Last reply Reply Quote 0
                      • H
                        Helper
                        last edited by

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

                        On 26/07/2011 at 11:41, xxxxxxxx wrote:

                        Is the radius specified in pixels or in 3D (Real) units?

                        I'd do it more like this (minor changes) :

                        LONG xmin = mx - radius;   //mx is the current mouse x position.  :)  
                        LONG xmax = mx + radius;  
                        LONG ymin = my - radius;  //my is the current mouse y position.  :)  
                        LONG ymax = my + radius;  
                          
                        LONG    iy;  
                        ViewportPixel* vp = NULL;  
                        for(LONG ix = xmin; ix < xmax; ++ix)  
                        {  
                          for(iy = ymin; iy  < ymax; ++iy)  
                          {  
                              vp = vps->GetPixelInfoPoint(ix, iy);  
                              if (vp) bsPoint->Select(vp->i);  
                          }  
                        }
                        

                        Of course, this doesn't do a circular radius but a rectangular area.

                        Dan does something like this:

                        `     LONG x = mx, y = my;  
                             ViewportPixel *vp = vps->GetNearestPolygon(op,x,y,rad);  
                             if(vp)  
                             {  
                                  Vector mpt = Vector(mx,my,0.0);  
                                  Vector pxl = Vector(x,y,0.0);  
                                    
                                  if(Len(pxl - mpt) < rad)  
                                  {  
                                       if(ctrl) bs->Deselect(vp->i);  
                                       else bs->Select(vp->i);  
                                  }  
                             }`
                        

                        Finally, check out the sculpting.cpp example in the plugins/cinema4dsdk folder.  It uses a ViewportSelect and calls GetPixelInfoPoint().

                        1 Reply Last reply Reply Quote 0
                        • H
                          Helper
                          last edited by

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

                          On 26/07/2011 at 11:53, xxxxxxxx wrote:

                          Thanks Robert,  I have talked to Dan via email about this and he ran in to the same problems that I am..  He was unable to get it to perform as efficiently as the live select tool also. 
                          However his code for getting a circular radius is a good place to start with the pixel parsing code.

                          I will play around with parsing the pixels as see if I can optimize that enough to work.  🙂

                          the radius value is a Real value obtained from the AM.  This is that same value that ShowHotSPot() uses to draw the radius guide circle.   I will take a look again at sculpting.cpp and see if I can get more from it.  🙂

                          Thanks for your time.  😄

                          ~Shawn

                          1 Reply Last reply Reply Quote 0
                          • H
                            Helper
                            last edited by

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

                            On 27/07/2011 at 18:33, xxxxxxxx wrote:

                            Just an update!  this method was the answer.. it worked very well.. the problem I was having was I was allocating the

                            GetPixelInfoPoint
                            

                            within the loop.  Thanks Robert!

                            ~Shawn

                            1 Reply Last reply Reply Quote 0
                            • H
                              Helper
                              last edited by

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

                              On 27/07/2011 at 18:48, xxxxxxxx wrote:

                              Final Code

                                
                              LONG xmin = mx - radius;   //mx is the current mouse x position.  :)  
                                                                LONG xmax = mx + radius;  
                                                                LONG ymin = my - radius;  //my is the current mouse y position.  :)  
                                                                LONG ymax = my + radius;  
                                
                                                                LONG    iy;  
                                                                ViewportPixel* vp = NULL;  
                                                                Vector origin = Vector(mx, my, 0);  
                                                                for(LONG ix = xmin; ix < xmax; ++ix)  
                                                                {  
                                                                    for(iy = ymin; iy  < ymax; ++iy)  
                                                                    {  
                                                                        Vector current = Vector(ix, iy, 0);  
                                                                        Vector dist = origin - current;  
                                                                        Real dis = Len(dist);  
                                                                        vp = vps->GetPixelInfoPoint(ix, iy);  
                                
                                                                        if (dis < radius)  
                                                                        {  
                                                                            if (vp) bsPoint->Select(vp->i);  
                                                                        }  
                                                                    }  
                                                                }  
                              

                              If anyone sees any optimization possibilities  I am all ears, eyes, and fingers.. HAHA..

                              ~Shawn

                              1 Reply Last reply Reply Quote 0
                              • H
                                Helper
                                last edited by

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

                                On 27/07/2011 at 21:40, xxxxxxxx wrote:

                                LONG xmin = mx - radius;   //mx is the current mouse x position.  :)  
                                LONG xmax = mx + radius;  
                                LONG ymin = my - radius;  //my is the current mouse y position.  :)  
                                LONG ymax = my + radius;  
                                  
                                LONG    iy;  
                                ViewportPixel* vp = NULL;  
                                Vector origin = Vector(mx, my, 0);  
                                Vector current;  
                                Vector dist;  
                                Real dis;  
                                for(LONG ix = xmin; ix < xmax; ++ix)  
                                {  
                                  for(iy = ymin; iy  < ymax; ++iy)  
                                  {  
                                      current = Vector(ix, iy, 0);  
                                      dist = origin - current;  
                                      dis = Len(dist);  
                                      if (dis < radius)  
                                      {  
                                              vp = vps->GetPixelInfoPoint(ix, iy);  
                                          if (vp) bsPoint->Select(vp->i);  
                                      }  
                                  }  
                                }
                                
                                1 Reply Last reply Reply Quote 0
                                • H
                                  Helper
                                  last edited by

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

                                  On 27/07/2011 at 21:44, xxxxxxxx wrote:

                                  Thanks Robert,  I should know not to declare variables inside of loops..  LOL

                                  ~Shawn

                                  1 Reply Last reply Reply Quote 0
                                  • H
                                    Helper
                                    last edited by

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

                                    On 27/07/2011 at 21:59, xxxxxxxx wrote:

                                    Another thing I was wondering,

                                    Is there a way to keep the radius guide circle that is drawn with ShowHotSpot() in line with teh mouse tip?  I find that if I move my mouse faster, the radius circle ends up lagging behind a bit.  It's as if it can't keep up with the mouse cursor.

                                    Have you run in to this at all?

                                    Thanks,

                                    Shawn

                                    1 Reply Last reply Reply Quote 0
                                    • First post
                                      Last post