Thanks to everyone for their comments. I have learned a lot. Perhaps I
should describe the exact issue I am struggling with.
I have an axis-aligned bounding box which is transformed by the
modelview matrix. I need to find a second bounding box which encloses
the first but which is unaffected by the modelview matrix or in other
words is in another coordinate system.
My axis-aligned bounding box data structure looks like this.
typedef struct _recVec3 {
double x,y,z;
} recVec3;
typedef struct _recExtent3 {
recVec3 min;
recVec3 max;
} recExtent3;
First I get the modelViewMatrix like this.
GLfloat m[16];
glGetFloatv(GL_MODELVIEW_MATRIX, m);
Then I multiply the first bounding box by the modelview matrix. I then
check the x, y, and z coordinates of all eight points of the transformed
box to see which ones will determine the extents of the second enclosing
box.
My first attempt at the code, after correcting the errors, actually
worked but was incredibly ugly. That is when I thought if I could just
use some looping it would make life easier and that my current bounding
box or extent data type is not very friendly to looping. (Some of the
prior comments suggest ways as to how to loop through a struct and I
will be thinking about that.) I am currently coding in C and
Objective-C. My project will eventually have some C++ code but I am not
there yet.
Best Regards,
Richard
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Mac-opengl mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/mac-opengl/email@hidden
This email sent to email@hidden