I came up with some data catching system for objects that should update over the server:
def objListServer(sceneObjs):
updateObjList = []
for obj in sceneObjs:
if "update_object" in obj:
updateObjList.append(obj)
return updateObjList
def positionVector(obj):
if "position" in obj["update_object"]:
posi = obj.worldPosition
return posi
else:
return None
def orientationMatrix(obj):
if "orientation" in obj["update_object"]:
ori = obj.worldOrientation
return ori
else:
return None
def propertiesList(obj):
propDict = {}
if "update_properties" in obj:
if "properties" in obj["update_object"]:
props = obj.getPropertyNames()
for name in props:
propDict[name] = obj[name]
return propDict
else:
return None
else:
return None
def animationList(obj):
#owner.isPlayingAction(layer=0), owner.getActionName(layer=0), owner.getActionFrame(layer=0)
updateAnimationList = []
if "animation" in obj["update_object"]:
return updateAnimationList
else:
return None
def singleObjDict(updateObjList):
singleObjDict = {}
objUpdateDict = {}
for obj in updateObjList:
position = positionVector(obj)
orientation = orientationMatrix(obj)
properties = propertiesList(obj)
animations = animationList(obj)
singleObjDict = {"position": position,
"orientation": orientation,
"properties": properties,
"animations": animations}
objUpdateDict[obj] = singleObjDict
return objUpdateDict
def upDateServerObjects(cont):
sceneObjs = cont.owner.scene.objects
updateObjsDict = {}
updateObjList = objListServer(sceneObjs)
objDict = singleObjDict(updateObjList)
updateObjsDict.update(objDict)
print(updateObjsDict)
the output looks like
Blender Game Engine Started
{Ground: {'position': Vector((0.0, -28.547155380249023, -17.314699172973633)), '
orientation': Matrix(((1.0, 0.0, 0.0),
(0.0, 1.0, 0.0),
(-0.0, 0.0, 1.0))), 'animations': None, 'properties': {'ground': 0.09999
999403953552, 'block_camera_object': -0.09999999403953552, 'update_properties':
True, 'update_object': True}}, Car: {'position': Vector((-2.2785580711115472e-07
, 0.0, 2.6721572875976562)), 'orientation': Matrix(((1.0, 0.0, 0.0),
(0.0, 1.0, 0.0),
(-0.0, 0.0, 1.0))), 'animations': None, 'properties': {'update_animation
': False, 'update_properties': True, 'update_object': True}}}
{Ground: {'position': Vector((0.0, -28.547155380249023, -17.314699172973633)), '
orientation': Matrix(((1.0, 0.0, 0.0),
(0.0, 1.0, 0.0),
(-0.0, 0.0, 1.0))), 'animations': None, 'properties': {'ground': 0.09999
999403953552, 'block_camera_object': -0.09999999403953552, 'update_properties':
True, 'update_object': True}}, Car: {'position': Vector((-0.009760634042322636,
0.004111429676413536, 2.6693928241729736)), 'orientation': Matrix(((0.9171085953
712463, -0.3985776901245117, -0.006901925429701805),
(0.3986039161682129, 0.9171185493469238, 0.002907336689531803),
(0.005171084776520729, -0.005417478270828724, 0.9999719262123108))), 'an
imations': None, 'properties': {'update_animation': False, 'update_properties':
True, 'update_object': True}}}
Blender Game Engine Finished
is that to much information flow over udp?
meaning that this just two objects without animations and only basic props (just to test it)