1

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.

GuybrushThreepwood
  • 5,598
  • 9
  • 55
  • 113

3 Answers3

3

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.

Peter Sarnowski
  • 11,900
  • 5
  • 36
  • 33
2

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).

Gobra
  • 4,263
  • 2
  • 15
  • 20
2

NSValue is the objective c class which is designed to be a container for c data.

check out this answer

Community
  • 1
  • 1
wattson12
  • 11,176
  • 2
  • 32
  • 34