Compiled with Python version 2.6.5.
Checking for installed Python... got it!
Traceback (most recent call last):
File "stk_browser.py.002", line 766, in Draw
KeyError: 'Empty'
asciimonster {l Wrote}: What exactly do you mean by a precision area?
asciimonster {l Wrote}:And transparency of what (mesh, texture, object)
STKRudy85 {l Wrote}:Maybe it already exist ?
STKRudy85 {l Wrote}:just add a button in "all" menu : arena : yes or no
import bpy
# ==== OPERATORS FOR MULTI-CHOICE FIELDS ====
COMBOS = { "sky-type" : ["simple", "dome", "box"], "arena" : ["yes", "no"] }
for curr in COMBOS:
for value in COMBOS[curr]:
class STK_SetItem(bpy.types.Operator):
bl_idname = ("screen.STK_set_" + curr + "=" + value)
bl_label = ("STK Object :: set " + curr + " to " + value)
bl_stk_prop = curr
bl_stk_value = value
def execute(self, context):
scene = context.scene
scene[self.bl_stk_prop] = self.bl_stk_value
return {'FINISHED'}
# ==== OPERATORS ====
class STK_CreateProperties(bpy.types.Operator):
bl_idname = ("screen.STK_create_props")
bl_label = ("STK Track : create properties")
def execute(self, context):
scene = context.scene
if not "name" in scene:
scene["name"] = "Untitled"
if not "groups" in scene:
scene["groups"] = "standard"
if not "designer" in scene:
scene["designer"] = "Your name here"
if not "music" in scene:
scene["music"] = ""
if not "screenshot" in scene:
scene["screenshot"] = ""
if not "arena" in scene:
scene["arena"] = "no"
if not "sky-type" in scene:
scene["sky-type"] = "simple"
if not "camera-far" in scene:
scene["camera-far"] = 200
scene["_RNA_UI"] = {"camera-far": {"min":50, "max":500}}
return {'FINISHED'}
# ==== PANEL ====
class OBJECT_PT_hello(bpy.types.Panel):
bl_label = "SuperTuxKart Track Properties"
bl_space_type = "PROPERTIES"
bl_region_type = "WINDOW"
bl_context = "scene"
def draw(self, context):
layout = self.layout
scene = context.scene
# ==== Create properties button ====
row = layout.row()
row.operator("screen.STK_create_props", "Create SuperTuxKart Attributes")
# ==== Track attributes ====
row = layout.row()
row.prop(scene, '["name"]', text="Track name")
row = layout.row()
row.prop(scene, '["groups"]', text="Groups")
row = layout.row()
row.prop(scene, '["designer"]', text="Designer")
row = layout.row()
row.prop(scene, '["music"]', text="Music")
row = layout.row()
row.prop(scene, '["screenshot"]', text="Screenshot")
# ---- Arena
row = layout.row()
row.label("Arena")
if scene["arena"] == "yes":
yes_icon = 'RADIOBUT_ON'
no_icon = 'RADIOBUT_OFF'
else:
yes_icon = 'RADIOBUT_OFF'
no_icon = 'RADIOBUT_ON'
row.operator("screen.STK_set_arena=yes", text="Yes", icon=yes_icon)
row.operator("screen.STK_set_arena=no", text="No", icon=no_icon)
#row.prop(scene, '["arena"]', text="Arena")
# ---- Camera-far
row = layout.row()
row.prop(scene, '["camera-far"]', slider=True, text="Camera far distance")
# ---- Sky-type
row = layout.row()
row.label("Sky Type")
simple_icon = 'RADIOBUT_OFF'
dome_icon = 'RADIOBUT_OFF'
box_icon = 'RADIOBUT_OFF'
if scene["sky-type"] == "simple":
simple_icon = 'RADIOBUT_ON'
elif scene["sky-type"] == "dome":
dome_icon = 'RADIOBUT_ON'
elif scene["sky-type"] == "box":
box_icon = 'RADIOBUT_ON'
row.operator("screen.STK_set_sky-type=simple", text="Simple", icon=simple_icon)
row.operator("screen.STK_set_sky-type=box", text="Box", icon=box_icon)
row.operator("screen.STK_set_sky-type=dome", text="Dome", icon=dome_icon)
import bpy
# ==== OPERATORS FOR MULTI-CHOICE FIELDS ====
COMBOS = { "sky_type" : [("simple", "simple", "Plain-color sky"), ("dome", "dome", "Skydome"), ("box", "box", "Skybox / Skycube")],
"arena" : [("yes", "yes", "This is a battle arena"), ("no", "no", "This is regular track")] }
for curr in COMBOS:
class STK_SetItem(bpy.types.Operator):
value = bpy.props.EnumProperty(attr="values", name="values", default=COMBOS[curr][0][0],
items=COMBOS[curr])
bl_idname = ("screen.stk_set_" + curr)
bl_label = ("STK Object :: set " + curr)
bl_stk_prop = curr
#bl_stk_value = value
def execute(self, context):
scene = context.scene
scene[self.bl_stk_prop] = self.value #self.bl_stk_value
return {'FINISHED'}
# ==== OPERATORS ====
class STK_CreateProperties(bpy.types.Operator):
bl_idname = ("screen.stk_create_props")
bl_label = ("STK Track : create properties")
def execute(self, context):
scene = context.scene
if not "name" in scene:
scene["name"] = "Untitled"
if not "groups" in scene:
scene["groups"] = "standard"
if not "designer" in scene:
scene["designer"] = "Your name here"
if not "music" in scene:
scene["music"] = ""
if not "screenshot" in scene:
scene["screenshot"] = ""
if not "arena" in scene:
scene["arena"] = "no"
if not "sky_type" in scene:
scene["sky_type"] = "simple"
if not "camera_far" in scene:
scene["camera_far"] = 200
scene["_RNA_UI"] = {"camera_far": {"min":50, "max":500}}
return {'FINISHED'}
# ==== PANEL ====
class OBJECT_PT_hello(bpy.types.Panel):
bl_label = "SuperTuxKart Track Properties"
bl_space_type = "PROPERTIES"
bl_region_type = "WINDOW"
bl_context = "scene"
def draw(self, context):
layout = self.layout
scene = context.scene
# ==== Create properties button ====
row = layout.row()
row.operator("screen.stk_create_props", "Create SuperTuxKart Attributes")
# ==== Track attributes ====
try:
row = layout.row()
row.prop(scene, '["name"]', text="Track name")
except:
pass
try:
row = layout.row()
row.prop(scene, '["groups"]', text="Groups")
except:
pass
try:
row = layout.row()
row.prop(scene, '["designer"]', text="Designer")
except:
pass
try:
row = layout.row()
row.prop(scene, '["music"]', text="Music")
except:
pass
try:
row = layout.row()
row.prop(scene, '["screenshot"]', text="Screenshot")
except:
pass
# ---- Arena
row = layout.row()
row.label("Arena")
try:
row.operator_menu_enum("screen.stk_set_arena", property="value", text=scene["arena"])
except:
pass
# ---- Camera-far
row = layout.row()
try:
row.prop(scene, '["camera_far"]', slider=True, text="Camera far distance")
except:
pass
# ---- Sky-type
row = layout.row()
row.label("Sky Type")
try:
row.operator_menu_enum("screen.stk_set_sky_type", property="value", text=scene["sky_type"])
except:
pass
def register():
bpy.utils.register_module(__name__)
register()
Kinsu {l Wrote}:If I understand it the right way, the property browser does enable tracks creators to set automatically some metadata that STK uses to create races on it ?
This must be a very useful tool, which enable graphists to finalize their track without leaving Blender !
The Python code also looks simple (I've never coded in python)... this feature of Blender reminds me Maya's embedded scripting language, which is used create custom GUIs and tools. I think this is a must have for Blender, to compete a little with the big Autodesk's softs...
Back to STK, does the property browser enables to set karts' properties too ?
Auria {l Wrote}:Hi asciimonster
Now we need to talk seriously about the direction the property browser has to take
I have recently been reading on the Blender home page that the release of Blender 2.5 stable is imminent. Therefore I have started looking in the Blender 2.5 API and started porting our various scripts.
(...)
What about we start porting the property browser to blender 2.5 right now? I'd like to know your opinion on this
3dwarehouse {l Wrote}:when will you guys update the python script for blender 2.5?
2.57 rc came out today!
Auria {l Wrote}:I see you started work on 2.5 scripts, nice! I see you have included support for per-object properties in your script, that was a little unexpected, I had already been working on such a script But if you feel like going on with this, please do, it will be more uniform.
Auria {l Wrote}:I've been busy porting the track export script; it's now almost done. The b3D exporter has made some good progress, too
asciimonster {l Wrote}:Auria {l Wrote}:I've been busy porting the track export script; it's now almost done. The b3D exporter has made some good progress, too
Where is it? I want to test/connect to it.
Have you seen the slow but steady progress I'm starting to make?
That new API is hard (especially when it lacks proper documentation... )
Auria {l Wrote}:And I don't really agree that the new API is difficult, what do you have problems with?
Auria {l Wrote}:(if you have issues with the API you can ask me in case I know; otherwise ask on blendernation forums, people there are quite helpful i found)
import bpy
class Apply_Color_Operator(bpy.types.Operator):
bl_idname = ("screen.apply_color")
bl_label = ("Apply Color")
temp_color = bpy.props.FloatVectorProperty(
name= "temp_color",
description= "Temp Color.",
subtype= 'COLOR',
min= 0.0,
max= 1.0,
soft_min= 0.0,
soft_max= 1.0,
default= (1.0,1.0,1.0)
)
def invoke(self, context, event):
currcol = [1.0, 1.0, 1.0]
try:
currcol = list(map(eval, context.object["color"].split()))
except:
pass
print("currcol = ",currcol)
self.temp_color = currcol
context.window_manager.invoke_props_dialog(self)
return {'RUNNING_MODAL'}
def draw(self, context):
layout = self.layout
# ==== Types group ====
box = layout.box()
row = box.row()
try:
row.template_color_wheel(self, "temp_color", value_slider=True)
except Exception as ex:
import sys
print("Except :(", type(ex), ex, "{",ex.args,"}")
pass
row = layout.row()
row.prop(self, "temp_color", text="Selected Color")
def execute(self, context):
context.object["color"] = "%.3f %.3f %.3f" % (self.temp_color[0], self.temp_color[1], self.temp_color[2])
return {'FINISHED'}
# ==== PANEL ====
class OBJECT_PT_hello(bpy.types.Panel):
bl_label = "Hello Panel"
bl_space_type = "PROPERTIES"
bl_region_type = "WINDOW"
bl_context = "object"
def draw(self, context):
layout = self.layout
# ==== Types group ====
row = layout.row()
row.prop(context.object, '["color"]', text="Selected Color")
row.operator("screen.apply_color", "", icon='COLOR')
def register():
bpy.utils.register_module(__name__)
register()
import bpy
# ==== PANEL ====
class OBJECT_PT_hello(bpy.types.Panel):
bl_label = "Hello Panel"
bl_space_type = "PROPERTIES"
bl_region_type = "WINDOW"
bl_context = "object"
def draw(self, context):
layout = self.layout
# ==== Types group ====
row = layout.row()
row.prop(context.object, "colorpreview")
def register():
bpy.types.Object.colorpreview = bpy.props.FloatVectorProperty(
name= "colorpreview",
description= "Ambient color.",
subtype= 'COLOR',
min= 0.0,
max= 1.0,
soft_min= 0.0,
soft_max= 1.0,
default= (1.0,1.0,1.0)
)
bpy.utils.register_module(__name__)
register()
Users browsing this forum: No registered users and 1 guest