diff --git a/mysql/mysql_general.py b/mysql/mysql_general.py index b4b6898..baf08ee 100644 --- a/mysql/mysql_general.py +++ b/mysql/mysql_general.py @@ -1,8 +1,8 @@ import bpy import sys -sys.path.append('C:\Python35\Lib\site-packages') -sys.path.append('C:\Python35\DLLs') -import pymysql +#sys.path.append('C:\Python35\Lib\site-packages') +#sys.path.append('C:\Python35\DLLs') +#import pymysql def dbConnect(databaseName, databaseHost, databaseUsername, databasePassword): try: diff --git a/simulation/ground.py b/simulation/ground.py new file mode 100644 index 0000000..e7ade2f --- /dev/null +++ b/simulation/ground.py @@ -0,0 +1,4 @@ +import bpy +from bpy.props import * + +bpy.types.Scene.groundObject = StringProperty(name="Ground Object", description="The object that will be used as a ground in the simulation.") diff --git a/simulation/main.py b/simulation/main.py index 00e1d49..e99afeb 100644 --- a/simulation/main.py +++ b/simulation/main.py @@ -1,9 +1,11 @@ import bpy import sys +from mathutils import Vector #from ..nodes import main from .. icon_load import cicon from . import agents from . import position +from . import ground class ShowPositionGraphics(bpy.types.Operator): """Show the positional graphics""" @@ -24,6 +26,31 @@ class RunSimulation(bpy.types.Operator): def execute(self, context): scene = context.scene + groupObjs = bpy.data.groups[scene.agentGroup].objects + halfAgents = scene.agentNumber // 2 + + for object in groupObjs: + if scene.groundObject == object.name: + self.report({'ERROR'}, "The ground object must not be in the same group as the agent!") + + bpy.context.scene.objects.active.select = False + + if scene.positionType == "formation": + if scene.formationPositionType == "array": + for a in range(halfAgents): + obj1 = bpy.data.objects[groupObjs[1].name] + ground = bpy.data.objects[scene.groundObject] + offset_x = (obj1.dimensions.x + scene.formationArrayX) + obj1.select = True + obj1 = obj1.copy() + if scene.positionMode == "vector": + location = Vector((scene.positionVector[0], scene.positionVector[1], ground.location.z)) + elif scene.positionMode == "object": + objStart = bpy.data.objects[scene.positionObject] + location = Vector((objStart.location.x, objStart.location.y, ground.location.z)) + obj1.location = location + scene.objects.link(obj1) + location.x -= offset_x return {'FINISHED'} @@ -41,12 +68,15 @@ def draw(self, context): row = layout.row() row.prop_search(scene, "agentGroup", bpy.data, "groups") + row = layout.row() + row.prop_search(scene, "groundObject", scene, "objects") + row = layout.row() row.prop(scene, "agentNumber") row = layout.row() row.scale_y = 1.2 - if scene.agentGroup == "": + if (scene.agentGroup == "") or (scene.groundObject == ""): row.enabled = False row.operator("scene.cm_run_simulation", icon_value=cicon('run_sim')) diff --git a/simulation/position.py b/simulation/position.py index ac2aa97..a5ab0d7 100644 --- a/simulation/position.py +++ b/simulation/position.py @@ -23,7 +23,7 @@ # Formation positioning bpy.types.Scene.formationPositionType = bpy.props.EnumProperty( - items = [('array', 'Array', 'The agents are aligned in an array starting at the .'), + items = [('array', 'Array', 'The agents are aligned in an array starting at the point specified.'), ('shape', 'Shape', 'The span location is specified as the location of an object.')], name = "Formation Type", description = "Where the spawn location is pulled from.",