edge selection -> points [SOLVED]



  • On 11/10/2014 at 09:41, xxxxxxxx wrote:

    ello, I haven't used the example code myself, yet. But I would think, a,b,c and d are the point-vectors. Or are you looking for point indeces?



  • On 11/10/2014 at 09:49, xxxxxxxx wrote:

    if there was a way to get the point indeces i think it would be better, since i would know how to handle things from that point on... i will however try to understand the example



  • On 11/10/2014 at 09:51, xxxxxxxx wrote:

    Can you give me any more details on what you are actually trying to achieve? Because in your original question, you asked for coordinates...



  • On 11/10/2014 at 10:17, xxxxxxxx wrote:

    sure. i want to create some polygons which align to the edges given by the edge selection. something like the matrix extrude but based on the edges. so in the end i need the coordinates of the points belonging to the selected edges



  • On 11/10/2014 at 10:22, xxxxxxxx wrote:

    Then I'd recommend to go with the example. If you fail with that, please give me a short code example, which demonstrates, in which way it's not doing what you want.

    Oh and by the way, I think, you should get the point indeces from the original BaseSelect.



  • On 11/10/2014 at 10:25, xxxxxxxx wrote:

    Originally posted by xxxxxxxx

    Oh and by the way, I think, you should get the point indeces from the original BaseSelect.

    really?? how? as i don't see a member which would give me those.



  • On 11/10/2014 at 10:28, xxxxxxxx wrote:

    It may be a bit cumbersome and there may be better ways to do so, but you can query indeces via IsSelected().



  • On 11/10/2014 at 10:29, xxxxxxxx wrote:

    i'll try things out now... thank you so far



  • On 11/10/2014 at 10:31, xxxxxxxx wrote:

    You are welcome. 🙂



  • On 11/10/2014 at 11:45, xxxxxxxx wrote:

    Got it working using the following code:

    	selection = linkedSelection->GetBaseSelect();
    	
    	LONG pcnt = ToPoly(source)->GetPointCount();
    	LONG fcnt = ToPoly(source)->GetPolygonCount();
    	const CPolygon *fadr = ToPoly(source)->GetPolygonR();
    	LONG p1;
    	LONG p2;
    	
    	Neighbor neighbor;
    	if (!neighbor.Init(pcnt, fadr, fcnt, nullptr)) return NULL;
      
    	LONG edgeCount = neighbor.GetEdgeCount();
    	for (int i=0; i<edgeCount;i++)
    	{
    		fadr->EdgePoints(i,p1,p2);
    		String nfo = "";
    		if (selection->IsSelected(i)) nfo = "Selected";
    		GePrint(LongToString(i)+": "+LongToString(p1)+"->"+LongToString(p2)+" "+nfo);
    	}
    

    Thanks again to everybode helping here :)



  • On 11/10/2014 at 12:44, xxxxxxxx wrote:

    hm, probably a bit to early with my joy...

    for example if i have a cube as a basemesh and use the edge selection shown in the image. the console gives me the proper counting thru the edges and it seems the IsSelected works, too (it reacts twice edge 1 and 9).. but for the EdgePoints i get weird results. the first result makes sense (edge 1: point 1 and 3) but why does it return point 1 and 3 also for edge 9??



  • On 11/10/2014 at 13:01, xxxxxxxx wrote:

    Could it be, EdgePoints() delivers the point index on the polygon?
    I'm not sure and haven't tried it. And it's getting a bit late for today for me to do so.
    Doesn't the CPolygon contain the vertex indeces directly (a, b, c ,d)?



  • On 11/10/2014 at 13:04, xxxxxxxx wrote:

    yes, it does. but i need to get the indices for the points which build the selected edges only. not the whole polygon. i'll keep on trying :)



  • On 11/10/2014 at 13:07, xxxxxxxx wrote:

    Yes, I understood that. Via the index received from GetEdgePoints() you should be able to choose between a, b, c and d (like in the example on PolyInfo struct). I probably should have elaborated a bit further. Sorry.

    Once more I'm sorry, not like in the example. But in a similar way. I'd expect the indeces from GetEdgePoints() to correspond directly to a, b, c and d.



  • On 11/10/2014 at 13:09, xxxxxxxx wrote:

    ah, wait, i guess i understand now. is it that EdgePoints can only return 0 to 3



  • On 11/10/2014 at 13:11, xxxxxxxx wrote:

    I think so. But in order to be sure, I'd either have to try or to look it up in the code. I can't do so before Monday, so I'd recommend, you try yourself.
    If this is the case, I'll add it to my notes for SDK doc improvement...



  • On 11/10/2014 at 13:12, xxxxxxxx wrote:

    ok. thank you so far.



  • On 11/10/2014 at 14:53, xxxxxxxx wrote:

    So, i wen on using the PolyInfo Example. Still some weird results.
    based on the image i posted previously i get points 1->3 which is correct, and for the other edge between points 7->5 i get 6->4. if i choose other edges the thing continues with wrong results.

    why are the results different from the indices i get in cinema when checking the vertices in the structure manager??

    any help is appreciated.

    		for (int i=0; i<fcnt; i++)
    		{
    			PolyInfo *pli = neighbor.GetPolyInfo(i);
      
    			for (int side=0; side<4; side++) 
    			{
    				if (pli->mark[side] || side==2 && padr[i].c==padr[i].d) continue;  
    				switch (side)
    				{
    					case 0: p1=padr[i].a; p2=padr[i].b; edge = pli->edge[0]; break;
    					case 1: p1=padr[i].b; p2=padr[i].c; edge = pli->edge[1]; break;
    					case 2: p1=padr[i].c; p2=padr[i].d; edge = pli->edge[2]; break;
    					case 3: p1=padr[i].d; p2=padr[i].a; edge = pli->edge[3]; break;
    				}
    				
    				if (selection->IsSelected(edge)) 
    				{
    					GePrint("Selected Edge: "+LongToString(edge)+" - Points "+LongToString(p1)+"->"+LongToString(p2));
    				}
    			}
    		}
    


  • On 12/10/2014 at 09:29, xxxxxxxx wrote:

    I was a bit quick with my assumptions yesterday, sorry 😢

    Check the following code (it it's not complete, it assumes you a poly selection pBSPoly) :

      LONG pcnt = g_objPoly->GetPointCount();
      LONG fcnt = g_objPoly->GetPolygonCount();
      const CPolygon *fadr = g_objPoly->GetPolygonR();
      LONG p1, p2;
      
      if (pBSPoly) {  // starting with a polygon selection here
        SelectionChanger * pSC = SelectionChanger::Alloc();
        if (pSC->InitFromSelection(pBSPoly, Mpolygons, g_objPoly)) {
          Neighbor neighbor;
          if (neighbor.Init(pcnt, fadr, fcnt, nullptr)) {
            BaseSelect* pBSEdges = pSC->GetEdgeS();    // convert polygon selection into an edge selection
            // NOTE: edges are multiple times in this pBSEdges (once for each poly, idxPoly*4+idxEdge)
            // NOTE 2: BSEdges is owned by pSC (I think)
            if (pBSEdges) {
              for (int idxPolys = 0; idxPolys < fcnt; idxPolys++) {
                PolyInfo *pPI = neighbor.GetPolyInfo(idxPolys);
                // From example SDK docs PolyInfo struct:
                int idxSide;
                for (idxSide = 0; idxSide < 4; idxSide++) { // test all 4 sides of a polygon
                  // only proceed if edge has not already been processed
                  // and edge really exists (for triangles side 2 from c..d does not exist as c==d)
                  if (pPI->mark[idxSide] || ((idxSide == 2) && (fadr[idxPolys].c == fadr[idxPolys].d))) continue;
      
                  String nfo = "";
                  switch (idxSide) {
                  case 0: p1 = fadr[idxPolys].a; p2 = fadr[idxPolys].b; break;
                  case 1: p1 = fadr[idxPolys].b; p2 = fadr[idxPolys].c; break;
                  case 2: p1 = fadr[idxPolys].c; p2 = fadr[idxPolys].d; break;
                  case 3: p1 = fadr[idxPolys].d; p2 = fadr[idxPolys].a; break;
                  } // switch (idxSide...
                  if (pBSEdges->IsSelected((4 * idxPolys) + idxSide)) {
                    nfo = "selected";
                  } // if (pBSEdges->....
                  GePrint("Edge " + LongToString(p1) + "->" + LongToString(p2) + ": " + nfo);
                } // for (idxSide...
              } // for (idxPolys
            } // if (pBSEdges)...
          } // if (neighbor...
          SelectionChanger::Free(pSC);
        } // if (pSC->...
      } else { // if (pBSPoly
        // Handle error: SELECTION NOT CONVERTED
      }
    

    One more note:
    In your code, you had:

    fadr->EdgePoints(idxEdges, p1, p2);
    

    You were always addressing the first polygon with this.

    I hope this helps.



  • On 12/10/2014 at 11:16, xxxxxxxx wrote:

    I think he's looking for the point index#s Andreas.
    You're code produces edge index#s. Which he needs to be converted into point index#s and their global positions.

    While I'm watching Football on T.V. I've rolled my own EdgesToPoints code to do this. Without using the neighbor class.
    But I'd like to see how it's done using the neighbor class too.

    I can post my no-neighbors class version if you like.
    But I'm also interested in seeing how to do it using the neighbor class.

    -ScottA


Log in to reply