VertexController question

Started by janineh, December 27, 2007, 01:12:36 PM

Previous topic - Next topic

janineh


I've been playing around with the PolygonManager and GenericVertexController to try and determine adjacent polygons in the same plane to a 'selected' polygon.

Looking at the JavaDoc, it seems that the GenericVertexController.getPolygonIDs function should
'Returns the polygon IDs of the polygons that are using the vertex "number".'

However, I don't understand where I would get the 'vertex number' from - just plugging in 0,1,2, random number gets me an array of length 1 with the value of 0 in the array (i.e. a[0]=0).

This doesn't make much sense as my object is a cube, so each polygon vertex should have at least 3 polygons attached to it.

Am I missing something here?

Many thanks,
Janine

EgonOlsen

The method has 2 parameters, one for indicating the vertex number (you have to "guess" that number from the number of vertices in the object starting with 0) and the max-id-number, which may be 1 in your case. Try to increase that value and see if the returned array contains more information.

janineh

#2
I initially used 4 for the max-id-number as I thought there would be only 2 or 3 polygons with the same vertex.
I've upped it to 20 and I still get the same result.

Here's my code in case it helps:


int[] polyIDs;
   
SimpleVector[] srcMesh=this.getSourceMesh();
int size=this.getMeshSize();
               
for (int i=0; i<size; i++)
{
     // Get all polygons that share that vertex
     polyIDs = this.getPolygonIDs(0, 20);
   
     for (int j=0; j<polyIDs.length; j++)
     {
          System.out.println("polyID:" + polyIDs[j]);
     }
}



This is what I get printed out:
polyID:0
polyID:0
polyID:0
polyID:0
polyID:0
polyID:0
polyID:0
polyID:0

EgonOlsen

Your code has a little flaw, it doesn't use the i, it always uses 0 as the vertex number. However, you are right: That method gives strange results. They are correct in some (more internal) way, but i don't think that this is, what i had in mind when adding it. But i'm not sure and i can't check all my sources ATM to see, if the current way IS the way it was meant to be or not. However, i don't think so and working with the limited resources that i have (i'm not at home and won't be some a few weeks), i've created a "fixed" version, that can be found here: http://www.jpct.net/download/beta/jpctapi116pre4.zip
Please give it a try to see, if the method in this version does what you expect from it and let me know.

janineh

That produced better results, thanks.
I'm now getting (from first iteration of the outside loop):
polyID:0
polyID:1
polyID:6
polyID:7
polyID:8

I know about the 0 instead of i, it was a debug measure to try and get it to work!  ;)

Thank you for making the change, especially at this time of year!
Seasons Greetings, and I hope you have a Happy New Year.

Janine