Reputation: 5616
I am following through an example of how to parse a DAE file to OpenGL ES (http://www.everita.com/lightwave-collada-and-opengles-on-the-iphone).
In this example there is the following code :
const Vertex3D tigerBottomNormals[] = {
{-0.425880, -0.327633, 0.350967},
{-0.480159, -0.592888, 0.042138},
{-0.113803, -0.991356, 0.065283},
};
Here a C struct is used to store 3 arrays each containing three float values.
My question is how would I convert this data structure to objective C objects. I am thinking I would create NSArrays within a larger container NSArray, but am unsure how I should join the three separate float values so that they can be added as one item to the array.
Thanks in advance.
Upvotes: 1
Views: 2951
Reputation: 11174
NSValue is the objective c class which is designed to be a container for c data.
check out this answer
Upvotes: 2
Reputation: 4261
I'd recommend you to reconsider your decision to replace the plain C-structs with Objective-C classes in this case. Objective-C is a subset of the C, so it works with plain C structs without any problems and the code above should compile. I have a bunch of projects with low-level math structs implemented in C/C++ which makes the code simple and readable for this particular task.
However, if you strictly need an Obj-C wrapper, check the CIVector class - you must create something like that (or maybe even use CIVector directly since CoreImage is a part of the iOS 5).
Upvotes: 2
Reputation: 11970
I don't know much openGL ES, but you could declare a class like:
@interface YourClass : NSObject
{
float value1;
float value2;
float value3;
}
@end
To hold your variables. You could store those objects in a NSArray if you want to.
Upvotes: 3