2013-02-24 47 views
-2

我正在尝试使用方法GLKVector3MakeWithArray创建一个向量。将'float'传递给'float *'的不兼容类型

我收到以下错误,我有点不解,为什么,“传递‘浮动’不兼容类型‘浮动*’的”

这里是我的代码:

[self.offsetArray addObject:[jsnmphset valueForKey:@"offset"]]; 

    // Create a Vector3f from the array offset stored in the nsdictionary 
    GLKVector3 offset = GLKVector3MakeWithArray([[self.offsetArray objectAtIndex:0] floatValue]); 

谢谢

+1

您认为这个错误可能意味着什么?你试图做什么来纠正这个问题?您在搜索解决方案时迄今收集了哪些信息?总之,[你有什么尝试](http://mattgemmell.com/2008/12/08/what-have-you-tried/)? GLKVector3偏移= GLKVector3Make( [[self.offsetArray objectAtIndex:0]的floatValue], [[self.offsetArray objectAtIndex:1]的floatValue], [[self.offsetArray – 2013-02-24 20:54:54

+0

我已经通过执行以下操作中创建围绕工作objectAtIndex:2] floatValue] ); – samb90 2013-02-24 20:55:43

回答

3

GLKVector3MakeWithArray的定义如下:

GLKVector3 GLKVector3MakeWithArray(float values[3]); 

它以三个浮点值的阵列。你叫它就好像它是这样定义的:

GLKVector3 GLKVector3MakeWithArray(float value); 

你传入一个浮点值。

你需要做这样的事情:

float values[3]; 

values[0] = [[self.offsetArray objectAtIndex:0] floatValue]; 
values[1] = [[self.offsetArray objectAtIndex:1] floatValue]; 
values[2] = [[self.offsetArray objectAtIndex:2] floatValue]; 

GLKVector3 offset = GLKVector3MakeWithArray(values); 

现在,“”已被设置是否正确,取决于你的具体情况。

2

GLKVector3MakeWithArray函数期望参数的类型为float[3]。但是你试图通过一个单一的float值。

从数组元素中创建适当的参数。

相关问题