访问搅拌机对象的旋转
我刚刚开始使用 Blender 和 Python,我一直在尝试使用带有 Python 2.5.1 的 Blender 游戏引擎来访问立方体的旋转属性
我将这个 python 脚本附加到场景中的立方体上:
cont = GameLogic.getCurrentController()
own = cont.owner
print own.RotX, own.RotY, own.RotZ
我得到的一切是这个错误吗:
来自控制器“cont#CONTR#1”的 Python 脚本错误: 回溯(最近一次调用最后一次): 文件“starter”,第 4 行,位于 AttributeError:“KX_GameObject”对象没有属性“RotX”
有人能告诉我如何访问旋转属性吗?感觉我要疯了!
谢谢,
将要
I'm just starting out with Blender and Python and I've been trying to access the rotation properties of a cube using the blender game engine with Python 2.5.1
I have this python script attached to a cube in my scene:
cont = GameLogic.getCurrentController()
own = cont.owner
print own.RotX, own.RotY, own.RotZ
All I get is this error:
Python script error from controller "cont#CONTR#1":
Traceback (most recent call last):
File "starter", line 4, in
AttributeError: 'KX_GameObject' object has no attribute 'RotX'
Can anybody tell me how I can access the rotation properties? feel like I'm going crazy!
Thanks,
Will
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可以使用 localOrientation 属性,这似乎是在游戏引擎中访问旋转的唯一方法,而无需使用不允许打印当前旋转的运动执行器。
localOrientation 由列表列表或 3x3 矩阵组成。矩阵的每一行都是相应轴将指向的点。
对于默认多维数据集:
将产生
Matrix((1.0, 0.0, 0.0), (0.0, 1.0, 0.0), (0.0, 0.0, 1.0)) 因为对象的x轴指向点(1, 0, 0),y轴指向( 0, 1, 0),z 到 (0, 0, 1)
希望这有帮助!
编辑:
只是玩弄这个,我想说,如果事情表现得很奇怪,请记住这是本地导向。如果事情不正常,请检查对象的本地位置!我只是感到非常困惑,因为我没有意识到我的对象的本地位置为 (0,0,0),尽管它看起来像是在 (9,-10,0)
You can use the property localOrientation, which seems to be the only way to access rotation in the game engine without using the motion actuator which doesn't allow the printing of the current rotation.
localOrientation consists of a list of lists, or a 3x3 matrix. each row of the matrix is a point that the corresponding axis will point to.
For a default cube:
will yield
Matrix((1.0, 0.0, 0.0), (0.0, 1.0, 0.0), (0.0, 0.0, 1.0)) because the x axis of the object points to the point (1, 0, 0), and y points to (0, 1, 0), the z to (0, 0, 1)
hope this helps!
EDIT:
just played around with this, and I would like to say that if things are acting weird remember that this is LOCAL orientation. Check the local location of the object if things aren't working right! I just got severely confused because I didn't realize my object had a local position of (0,0,0) even though it looked like it was at (9,-10,0)
据我记得,您可以通过 getDRot() 函数访问旋转属性,其中 getDRot()[0] = rotX,getDRot()[1] = rotY,getDRot()[2] = rotZ。但我不确定是否可以在所有者对象上调用它。从我很久以前写的一些片段来看,我在执行器上调用了这个函数。所以你的球必须有一个 Actuator,然后你就可以
As far as I remember you can access the rotation properties by the getDRot() function, where getDRot()[0] = rotX, getDRot()[1] = rotY, getDRot()[2] = rotZ. But I am not sure if you can call it on the owner object. From some snippets that I have written a long time ago I call this function on an Actuator. So your ball must have an Actuator, and then you can