从 iOS 内部调用 ShiVa 代码
我对 ShiVa3d 还很陌生,对 iOS 也相当陌生。
我想开发一个在 iPad 上运行的应用程序。我将在 Objective-C 中编写大量将在 iOS 上运行的逻辑,并在 ShiVa 中编写一些简单的 lua 代码。
这是我想要做的一个非常简单的示例:
1)我的应用程序将有一个模型,它将加载并被查看。
2) 在我的 lua ShiVa 代码中,作为 MainAI 的一部分,我将创建一个接受 x,y,z 等参数的方法,让我们将此方法称为“ShiVaCameraToPostition(objX,objY,objZ)”
3) 在我的 iOS 目标中 - c代码我想调用这个“ShiVaCameraToPostition”方法,带参数
这可能吗?
我该怎么做呢?我应该在文档中寻找什么?人们可以举出一些例子吗?
非常感谢。如果以上内容有歧义,请告诉我。
I'm still very new to ShiVa3d and fairly new to iOS.
I'd like to develop an app that runs on an iPad. I will write quite a lot of logic in objective-c that will run on the iOS and some simple lua code in ShiVa.
Here is a very simple example of what I'd like to do:
1) My app will have a single model, which will load and be viewed.
2) Inside my lua ShiVa code, as part of the MainAI, I will create a method that accepts parameters such as x,y,z let's call this method "ShiVaCameraToPostition(objX,objY,objZ)"
3) Inside my iOS objective-c code I want to call this "ShiVaCameraToPostition" method, with parameters
Is this possible?
How would I go about doing this? What should I look for in the documentation? Are there any examples people can point to?
Many thanks in advance. Please let me know if the above is ambiguous.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
好吧,算是成功了。请不要因为最佳实践而责怪我,我只是想让这件事继续下去。
所以,我创建了一个类来完成我的肮脏工作,我们称之为 ShivaInterface。
标题如下:
并实现为:
然后在我的纯 Obj-c 方法中:
可行,我意识到它并不美观,而且我对 C/C++ 缺乏更深入的了解可能无济于事。
(完整线程在这里:http://www.stonetrip.com/开发者/论坛/viewtopic.php?p=29073#p29073)
Ok, success of sorts. Please don't beat me over the head over best practice, I just wanted to get this going.
So, I created a class to do my dirty work in, let's call it ShivaInterface.
The header was as follows:
And implemented as:
Then in my pure Obj-c method:
That works, I realise it's not beautiful, and my lack of a deeper understanding of C/C++ probably doesn't help.
(Full thread here: http://www.stonetrip.com/developer/forum/viewtopic.php?p=29073#p29073)
您似乎无法调用 ShiVa 方法,必须使用以下方式调用处理程序:
S3DClient_SendEventToCurrentUser("MainAI","onMyHandler",0);
第三个和第四个参数是参数数量,数组中的参数(需要单独研究)。
You can't call a ShiVa method it would seem, you must call a handler using:
S3DClient_SendEventToCurrentUser("MainAI","onMyHandler",0);
The 3rd and 4th parameters are number of arguments and the arguments in an array (need to look into that separately).