2013-02-24 85 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值。

從數組元素中創建適當的參數。

相關問題