well I don't know how to get a particular sphere polygon below the camera, maybe there is a way to get it seeing I constructed it. I build the sphere just by iterating through the spherical coordinates at a given r and creating verticies/triangles by converting the coords back to cartesian:
for (float alt=-(float)Math.PI; alt < Math.PI; alt = alt+span) {
for (float az=-(float)Math.PI; az < Math.PI; az = az+span) {
surface.addTriangle(p2c(alt,az,varHt(alt,az,r)),
p2c(alt+span,az,r),
p2c(alt,az+span,r);
surface.addTriangle(p2c(alt,az+span,r),
p2c(alt+span,az,r),
p2c(alt+span,az+span,r));
}
}
protected SimpleVector p2c (float a, float z, float r) {
SimpleVector v = new SimpleVector();
v.x = (float) (r * Math.cos(a) * Math.sin(z));
v.y = (float) (r * Math.sin(a) * Math.sin(z));
v.z = (float) (r * Math.cos(z));
return v;
}
There is probably a way to access the triangles in the mesh later but I'm pretty new to JPct/OpenGL programming, so I am not sure how.
The tangent on the sphere below the camera should in theory be easier to get. The tangent plane to the point on the sphere should be orthogonal (normal?) to the camera's current position vector, then to select a particular tangent vector on that plane you would somehow take the camera's current direction into account? Some sort of vector addition/subtraction/math there but it's where I am fuzzy.
I assume though that the sphere itself doesn't enter into the calculations for the camera orientation, it can be derived solely based on the camera's position and current orientation. I was thinking that maybe what I want is to set the camera's XZ plane to something orthogonal to it's position, and then somehow modify the x and y orientation of the camera based on the mouse-look deltas, but leave the z orientation as-is. No idea how to do that though...
so the summary of what I have/what I need is:
have:
camera current position (== a vector that is normal to the polygon on the sphere below the current position I think)
camera current direction
need:
way to set camera Z orientation based on the above, leaving camera x and y orientation as-is.
Thanks for replying Egon, appreciate the help. This board seems pretty active and well run!
Ed