当前位置: 首页>>代码示例>>Python>>正文


Python GameLogic.addActiveActuator方法代码示例

本文整理汇总了Python中GameLogic.addActiveActuator方法的典型用法代码示例。如果您正苦于以下问题:Python GameLogic.addActiveActuator方法的具体用法?Python GameLogic.addActiveActuator怎么用?Python GameLogic.addActiveActuator使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在GameLogic的用法示例。


在下文中一共展示了GameLogic.addActiveActuator方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: max

# 需要导入模块: import GameLogic [as 别名]
# 或者: from GameLogic import addActiveActuator [as 别名]
    GL.Globals["phi_x_p"] = max(GL.Globals["phi_x_p"], 0)

if GL.Globals["phi_y"] == GL.Globals["Upper_Limit_phi_y"]:
    GL.Globals["phi_y_p"] = min(GL.Globals["phi_y_p"], 0)
elif GL.Globals["phi_y"] == GL.Globals["Lower_Limit_phi_y"]:
    GL.Globals["phi_y_p"] = max(GL.Globals["phi_y_p"], 0)

# Set speed and rotation for the body
GL.Globals["Motion_Actuator_Body_Point"].setDLoc(
    Blender_Factor * GL.Globals["x_p"], Blender_Factor * GL.Globals["y_p"], Blender_Factor * GL.Globals["z_p"], 1
)
GL.Globals["Motion_Actuator_Body_Point"].setDRot(0, 0, -Blender_Factor * GL.Globals["phi_z_p"], 0)
GL.Globals["Motion_Actuator_Body"].setDRot(
    -Blender_Factor * GL.Globals["phi_x_p"], -Blender_Factor * GL.Globals["phi_y_p"], 0, 1
)
GL.addActiveActuator(GL.Globals["Motion_Actuator_Body_Point"], 1)
GL.addActiveActuator(GL.Globals["Motion_Actuator_Body"], 1)

# Set rotation for the wheels
GL.Globals["Rotation_Actuator_Wheel_1"].setDRot(0, -Blender_Factor * GL.Globals["omega_1"], 0, 1)
GL.addActiveActuator(GL.Globals["Rotation_Actuator_Wheel_1"], 1)
GL.Globals["Rotation_Actuator_Wheel_2"].setDRot(0, -Blender_Factor * GL.Globals["omega_2"], 0, 1)
GL.addActiveActuator(GL.Globals["Rotation_Actuator_Wheel_2"], 1)
GL.Globals["Rotation_Actuator_Wheel_3"].setDRot(0, -Blender_Factor * GL.Globals["omega_3"], 0, 1)
GL.addActiveActuator(GL.Globals["Rotation_Actuator_Wheel_3"], 1)
GL.Globals["Rotation_Actuator_Wheel_4"].setDRot(0, -Blender_Factor * GL.Globals["omega_4"], 0, 1)
GL.addActiveActuator(GL.Globals["Rotation_Actuator_Wheel_4"], 1)

# Get inputs
Cont = GL.getCurrentController()
Left = Cont.getSensor("Left")
开发者ID:reversemind,项目名称:jAER,代码行数:33,代码来源:Dynamics.py

示例2:

# 需要导入模块: import GameLogic [as 别名]
# 或者: from GameLogic import addActiveActuator [as 别名]
		phi_z_Body_Point = M.pi - M.asin(Orientation_Body_Point[0][1])
	elif Orientation_Body_Point[0][0] >= 0.0 and Orientation_Body_Point[0][1] <= 0.0:
		phi_z_Body_Point = 2*M.pi + M.asin(Orientation_Body_Point[0][1])
	else:
		phi_z_Body_Point = 0.0
		
	# -> get phi_z_Body <-
	if Orientation_Body[0][0] >= 0.0 and  Orientation_Body[0][1] >= 0.0:
		phi_z_Body = M.asin(Orientation_Body[0][1])
	elif Orientation_Body[0][0] <= 0.0 and Orientation_Body[0][1] >= 0.0:
		phi_z_Body = M.pi - M.asin(Orientation_Body[0][1])
	elif Orientation_Body[0][0] <= 0.0 and Orientation_Body[0][1] <= 0.0:
		phi_z_Body = M.pi - M.asin(Orientation_Body[0][1])
	elif Orientation_Body[0][0] >= 0.0 and Orientation_Body[0][1] <= 0.0:
		phi_z_Body = 2*M.pi + M.asin(Orientation_Body[0][1])
	else:
		phi_z_Body = 0.0

	# -> calculate corrections <-
	Correction_phi_x = 0.0
	Correction_phi_y = 0.0
	Correction_phi_z = - (phi_z_Body - phi_z_Body_Point) * 0.1
	
	if Correction_phi_z > 0.01:
		Correction_phi_z = 0.0

	# -> correct drift <-
	Rotation_Speed_Body = GL.Globals['Motion_Actuator_Body'].getDRot()
	GL.Globals['Motion_Actuator_Body'].setDRot(Rotation_Speed_Body[0] + Correction_phi_x,Rotation_Speed_Body[1] + Correction_phi_y,Rotation_Speed_Body[2] + Correction_phi_z,Rotation_Speed_Body[3])
	GL.addActiveActuator(GL.Globals['Motion_Actuator_Body'],1)
开发者ID:AndreaCensi,项目名称:jAER,代码行数:32,代码来源:Corrections.py


注:本文中的GameLogic.addActiveActuator方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。