波前OBJ:从Objective-C字符串转换为C结构显然不正确

波前OBJ:从Objective-C字符串转换为C结构显然不正确,objective-c,struct,wavefront,Objective C,Struct,Wavefront,我正在为工作编写一个Wavefront对象加载器,因为在专业项目中使用我不懂的代码让我感到不舒服。在第一步之后,我尝试加载和记录顶点。首先,我编写了一个C结构来保存这些值 struct Vertice { float x; float y; float z; }; 接下来,我需要一种方法来有效地记录这一点,所以我写了一个预处理器函数,它的灵感来自于在这个网站上找到的一个函数。天哪,你们什么都有 #define LogVertice(VERTICE) NSLog(@"Ve

我正在为工作编写一个Wavefront对象加载器,因为在专业项目中使用我不懂的代码让我感到不舒服。在第一步之后,我尝试加载和记录顶点。首先,我编写了一个C结构来保存这些值

struct Vertice {
    float x;
    float y;
    float z;
};
接下来,我需要一种方法来有效地记录这一点,所以我写了一个预处理器函数,它的灵感来自于在这个网站上找到的一个函数。天哪,你们什么都有

#define LogVertice(VERTICE) NSLog(@"Vertice - X: %0.00000f, Y: %0.00000f, Z: %0.00000f", VERTICE.x, VERTICE.y, VERTICE.z);
接下来,我实际加载并尝试解析顶点

NSArray *verticeLineParts = [currentLine componentsSeparatedByCharactersInSet:[NSCharacterSet whitespaceCharacterSet]];
struct Vertice v;
v.x = [[verticeLineParts objectAtIndex:1] floatValue];
v.y = [[verticeLineParts objectAtIndex:2] floatValue];
v.z = [[verticeLineParts objectAtIndex:3] floatValue];
NSLog(@"%@", currentLine);
LogVertice(v);
除了说输出是错误的以外,我不确定描述输出的最佳方式,因此我将向您展示。前五行输出:

2010-10-14 13:46:03.587 ObjLoader[1353:207] v -0.035910 1.710543 -0.048286
2010-10-14 13:46:03.594 ObjLoader[1353:207] Vertice - X: -0, Y: 2, Z: -0
2010-10-14 13:46:03.595 ObjLoader[1353:207] v -0.041089 1.710543 -0.048951
2010-10-14 13:46:03.596 ObjLoader[1353:207] Vertice - X: -0, Y: 2, Z: -0
2010-10-14 13:46:03.596 ObjLoader[1353:207] v -0.040913 1.711848 -0.048951
2010-10-14 13:46:03.597 ObjLoader[1353:207] Vertice - X: -0, Y: 2, Z: -0
2010-10-14 13:46:03.598 ObjLoader[1353:207] v -0.040396 1.713069 -0.048951
2010-10-14 13:46:03.599 ObjLoader[1353:207] Vertice - X: -0, Y: 2, Z: -0
2010-10-14 13:46:03.600 ObjLoader[1353:207] v -0.039573 1.714114 -0.048951
2010-10-14 13:46:03.600 ObjLoader[1353:207] Vertice - X: -0, Y: 2, Z: -0
以及文件中的前五个顶点

v -0.035910 1.710543 -0.048286
v -0.041089 1.710543 -0.048951
v -0.040913 1.711848 -0.048951
v -0.040396 1.713069 -0.048951
v -0.039573 1.714114 -0.048951

我会说我是一个像样的Objective-C程序员,但显然我甚至不能正确地使用浮动。有人看到我的明显错误了吗?

更改我的日志函数可以修复它

#define LogVertice(VERTICE) NSLog(@"Vertice - X: %f, Y: %f, Z: %f", VERTICE.x, VERTICE.y, VERTICE.z);

我在实际阵列上做了一个NSLog,它给出了预期值:v,“0.034290”,“1.720835”,“-0.084707”