-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #73 from joewashear007/pbody
Pbody
- Loading branch information
Showing
10 changed files
with
44 additions
and
46 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,11 @@ | ||
import bge | ||
import time | ||
if "Server" in bge.logic.globalDict: | ||
|
||
cont = bge.logic.getCurrentController() | ||
trueSensors = False | ||
for s in cont.sensors: | ||
trueSensors = trueSensors or s.positive | ||
|
||
if "Server" in bge.logic.globalDict and trueSensors: | ||
bge.logic.globalDict["Server"].stop() | ||
time.sleep(1) | ||
cont = bge.logic.getCurrentController() | ||
bge.logic.globalDict["Server"] = None | ||
cont.activate(cont.actuators["QuitGame"]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,30 +1,21 @@ | ||
#! /usr/bin/env python3 | ||
|
||
# Copyright (C) <2014> <Joseph Liveccchi, [email protected]> | ||
# Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: | ||
# The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. | ||
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | ||
|
||
|
||
|
||
import server | ||
import bge | ||
import json | ||
from time import sleep | ||
|
||
class BlenderHandler(server.WebSocketHandler): | ||
def on_message(self, msg): | ||
cont = bge.logic.getCurrentController() | ||
msg_info = msg | ||
if "Actuator" in msg_info: | ||
direction = msg_info["Actuator"] | ||
print("Moving:", direction) | ||
print("Acting: ", msg_info["Actuator"]) | ||
action = msg_info["Actuator"] | ||
if "Speed" in msg_info: | ||
speed = msg_info["Speed"] | ||
print("Speed: ", speed) | ||
print(" - Speed: ", speed) | ||
#get the curretn speed | ||
rot = cont.actuators[direction].dRot | ||
loc = cont.actuators[direction].dLoc | ||
rot = cont.actuators[action].dRot | ||
loc = cont.actuators[action].dLoc | ||
#Normalize the speed back to 1 | ||
#print(sum(rot)) | ||
if sum(rot) != 0: | ||
|
@@ -33,21 +24,23 @@ def on_message(self, msg): | |
if sum(loc) != 0: | ||
loc = [x/abs(sum(loc)) for x in loc] | ||
#set teh new speed | ||
cont.actuators[direction].dLoc = [x*speed for x in loc] | ||
cont.actuators[direction].dRot = [x*speed for x in rot] | ||
cont.activate(cont.actuators[direction]) | ||
# sleep(cont.owner.get("MoveTime")) | ||
cont.actuators[action].dLoc = [x*speed for x in loc] | ||
cont.actuators[action].dRot = [x*speed for x in rot] | ||
cont.activate(cont.actuators[action]) | ||
if "Stop" in msg_info: | ||
for act in cont.actuators: | ||
cont.deactivate(act) | ||
if "Reset" in msg_info: | ||
print("Resetting the scene!") | ||
try: | ||
cont.owner.worldOrientation = [[1.0, 0.0, 0.0], [ 0.0, 1.0, 0.0], [0.0, 0.0, 1.0]] | ||
print("Ornt: ", bge.logic.globalDict['Ctrl-Ornt']) | ||
print("Pos: ", bge.logic.globalDict["CtrlView-Pos"]) | ||
cont.owner.worldOrientation = bge.logic.globalDict['Ctrl-Ornt'] | ||
scene = bge.logic.getCurrentScene() | ||
scene.objects["ControllerView"].localPosition = (0.0, -2.5, 0.0) | ||
scene.objects["ControllerView"].localPosition = bge.logic.globalDict["CtrlView-Pos"] | ||
except e: | ||
print("Error: "+ e) | ||
|
||
def send_message(self, msg): | ||
pass | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters