I've been working for 2 days to figure out which side of a box i'm hitting when using picking. I get a SimpleVector from the picking and I have tried numerous things to figure it out but all to no avail.
I have tried:
a) adding the SimpleVector and the center of the box together, and finding which side it's closest too, unfortunately it's always closest to the character, even if the top is clicked it will put it on the side that's facing the camera.
b) pulling out my hair
c) crying
I need a fresh mind to help me with this
Thanks
EDIT:
This is my picking code:
SimpleVector dir=Interact2D.reproject2D3DWS(g.camera, g.fb, (int) me.getX(), (int) me.getY()).normalize();
Object[] res=g.world.calcMinDistanceAndObject3D(g.camera.getPosition(), dir, 18 /*or whatever*/);
Object3D result = (Object3D) res[res.length-1];
some pseudo code of what I have tried:
dir.scalarMul(-1f);
dir.add(result.getTransformedCenter());
Object3D temp = result.cloneObject();
temp.translate(0,-2,0); // up
float dist1 = dir.distance(temp.getTransformedCenter());
I use 6 distances (one for each side) and it still doesn't work!
Again, thanks