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.

3 Answers 3

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.

Sign up to request clarification or add additional context in comments.

Comments

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

1 Comment

Objective-C is not a subset of the C, it is a "strict superset" of C.
2

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

check out this answer

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.