Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Structs versus Vectors



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
References: 
 >Structs versus Vectors (From: Richard Somers <email@hidden>)
 >Re: Structs versus Vectors (From: "Wesley Smith" <email@hidden>)
 >Re: Structs versus Vectors (From: "Keith Bauer" <email@hidden>)
 >Re: Structs versus Vectors (From: Jocelyn Houle <email@hidden>)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.