New STK property Browser

Re: New STK property Browser

Postby Auria » 18 Mar 2011, 16:10

OK I investigated a bit more : it seems like the property browser is all OK, and the exporter is messing things up; it looks like the numbers are being multiplied by 255 by the exporter, so looks like the exporter thinks they are floating point colors, but they are not.

I will open a ticket for Joerg
Image
User avatar
Auria
STK Moderator
 
Posts: 2976
Joined: 07 Dec 2009, 03:52

Re: New STK property Browser

Postby STKRudy85 » 23 Mar 2011, 22:47

Thank you for this indispensable and well adapted tool

;)

I notice nevertheless that the precision arena could be added
STK fan
User avatar
STKRudy85
 
Posts: 532
Joined: 23 Dec 2010, 03:00
Location: France

Re: New STK property Browser

Postby STKRudy85 » 23 Mar 2011, 23:02

transparency too :|

when I click on menu "all" and I select empty or mesh I obtain Python script error : check console

{l Code}: {l Select All Code}
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'
STK fan
User avatar
STKRudy85
 
Posts: 532
Joined: 23 Dec 2010, 03:00
Location: France

Re: New STK property Browser

Postby asciimonster » 23 Mar 2011, 23:35

You're welcome. What exactly do you mean by a precision area? And transparency of what (mesh, texture, object)?

"KeyError: 'Empty'" -> I didn't add the key Empty => Fixed now.
asciimonster
 
Posts: 375
Joined: 03 Dec 2009, 18:24

Re: New STK property Browser

Postby STKRudy85 » 23 Mar 2011, 23:56

asciimonster {l Wrote}: What exactly do you mean by a precision area?


just add a button in "all" menu : arena : yes or no

asciimonster {l Wrote}:And transparency of what (mesh, texture, object)


Texture

Maybe it already exist :oops: ?
STK fan
User avatar
STKRudy85
 
Posts: 532
Joined: 23 Dec 2010, 03:00
Location: France

Re: New STK property Browser

Postby Auria » 24 Mar 2011, 03:01

Transparency of texture is "compositing" set to "blend", "test" or "additive", depending on the effect you want (blend is the most common)
Image
User avatar
Auria
STK Moderator
 
Posts: 2976
Joined: 07 Dec 2009, 03:52

Re: New STK property Browser

Postby asciimonster » 24 Mar 2011, 12:18

STKRudy85 {l Wrote}:Maybe it already exist :oops: ?

I believe Rudy is still developing for STK 0.7. Due to the tweaks we have made in STK many options in the browser have also evolved. Several options were added, others changed, a few removed.

I'm sorry, but I think you will need to use the standard ID Property Browser for now to edit these "legacy" items.

STKRudy85 {l Wrote}:just add a button in "all" menu : arena : yes or no

"the All menu" isn't a menu (option), but a filter. You will need to open your Track object (often called "Scene") to see the arena option.
asciimonster
 
Posts: 375
Joined: 03 Dec 2009, 18:24

Re: New STK property Browser

Postby Auria » 24 Mar 2011, 16:53

Hi asciimonster :)
Now we need to talk seriously about the direction the property browser has to take :D

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. Of course the property browser will need to be ported

The good news is that Blender 2.5 has much better built-in support for property browsers. Below I quickly hacked together a quick and dirty property browser sample for track properties :

{l Code}: {l Select All Code}
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)


The result is :

prop browser 2.5.png


Now i think we need to seriously need to consider leaving Blender 2.4 in its current state, since any time spent on the 2.4 property browser will soon become useless work. What about we start porting the property browser to blender 2.5 right now? I'd like to know your opinion on this :)
Image
User avatar
Auria
STK Moderator
 
Posts: 2976
Joined: 07 Dec 2009, 03:52

Re: New STK property Browser

Postby Auria » 24 Mar 2011, 17:42

The blender 2.5 API is wonderful :) I found an even cleaner way :

{l Code}: {l Select All Code}
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()


EDIT: I adapted this code for the python API in blender SVN, which should be pretty much identical to the blender 2.5 final API
Image
User avatar
Auria
STK Moderator
 
Posts: 2976
Joined: 07 Dec 2009, 03:52

Re: New STK property Browser

Postby Kinsu » 24 Mar 2011, 18:28

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 ?
User avatar
Kinsu
 
Posts: 476
Joined: 15 Mar 2011, 14:28

Re: New STK property Browser

Postby Auria » 24 Mar 2011, 18:55

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 ?


At this time, it is for tracks only, but the kart exporter has its own GUI
Image
User avatar
Auria
STK Moderator
 
Posts: 2976
Joined: 07 Dec 2009, 03:52

Re: New STK property Browser

Postby asciimonster » 25 Mar 2011, 19:22

Auria {l Wrote}:Hi asciimonster :)
Now we need to talk seriously about the direction the property browser has to take :D

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 :)

Let's go for it...
asciimonster
 
Posts: 375
Joined: 03 Dec 2009, 18:24

Re: New STK property Browser

Postby 3dwarehouse » 31 Mar 2011, 13:31

when will you guys update the python script for blender 2.5?

2.57 rc came out today!
STK Rocks!!!
Also anything I make is under the any licence you want : CC_by_sa GPL public_domain
User avatar
3dwarehouse
 
Posts: 99
Joined: 19 Jan 2010, 15:05
Location: USA

Re: New STK property Browser

Postby Auria » 31 Mar 2011, 18:01

3dwarehouse {l Wrote}:when will you guys update the python script for blender 2.5?

2.57 rc came out today!


Nice to know it's out.

We are currently updating the scripts, but this is a long process, so please give us some time
Image
User avatar
Auria
STK Moderator
 
Posts: 2976
Joined: 07 Dec 2009, 03:52

Re: New STK property Browser

Postby Auria » 01 Apr 2011, 17:11

Hi asciimonster,

I see you started work on 2.5 scripts, nice! I see you have included support for per-object properties in your scsript, 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.

One thing though, I think it may be a good idea to move the scripts to the media repository where I store other Blender 2.5 scripts (maybe move them all into a folder named 'blender 2.5')? This way we'd have them all in the same place, and users looking for stable scripts would not accidentally use your WIP scripts
Image
User avatar
Auria
STK Moderator
 
Posts: 2976
Joined: 07 Dec 2009, 03:52

Re: New STK property Browser

Postby asciimonster » 01 Apr 2011, 19:46

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.

I'm still trying to figure out what the new API is all about. I have tried several things, but most of them don't seem feasible. I'm currently seeing how to do grouping of properties by using the built-in icons.

I see you are already quite active on this. Are you sure you don't want to take it from here?
asciimonster
 
Posts: 375
Joined: 03 Dec 2009, 18:24

Re: New STK property Browser

Postby Auria » 01 Apr 2011, 22:00

Well my time is limited so I would gladly welcome help :)

Regarding grouping, I would recommend using layout.box()

stk_panel.py, the panel I had started, does this so you could get inspiration from there
Image
User avatar
Auria
STK Moderator
 
Posts: 2976
Joined: 07 Dec 2009, 03:52

Re: New STK property Browser

Postby asciimonster » 15 Apr 2011, 23:39

Blender 2.57 (final) has been released
asciimonster
 
Posts: 375
Joined: 03 Dec 2009, 18:24

Re: New STK property Browser

Postby Auria » 16 Apr 2011, 02:15

Yes it has :)
I've been busy porting the track export script; it's now almost done. The b3D exporter has made some good progress, too
Image
User avatar
Auria
STK Moderator
 
Posts: 2976
Joined: 07 Dec 2009, 03:52

Re: New STK property Browser

Postby asciimonster » 17 Apr 2011, 14:59

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... :( )
asciimonster
 
Posts: 375
Joined: 03 Dec 2009, 18:24

Re: New STK property Browser

Postby Auria » 17 Apr 2011, 17:03

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... :( )


You can find those in the media repo ("B3DExport_2.5.py" and "stk_track_2.5.py"). And indeed my Track export script creates a panel that can most likely be merged with yours :)

And I don't really agree that the new API is difficult, what do you have problems with? :)
(I hope you have discovered the 'python console' pane, it is very helpful to get things done. But for the panels I have really relied on the online documentation which, albeit a little unorganized, seemed sufficient to me)

And yes I've seen your latest commit, nice work, thanks :)

(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)
Image
User avatar
Auria
STK Moderator
 
Posts: 2976
Joined: 07 Dec 2009, 03:52

Re: New STK property Browser

Postby asciimonster » 17 Apr 2011, 17:46

Auria {l Wrote}:And I don't really agree that the new API is difficult, what do you have problems with? :)

It is perfect is you want a static simple, out-of-the box script, I agree. But you really don't want a static script because it will grow out of proportions and will take large amounts of time to maintain. When I completed the previous browser I only needed 10 sec tweaking of some parameters to make the changes... wonderful.
However since everything in the API is made to be used staticly it's giving me a lot of grief.

There are three things that are completely stomping me:
- The register() function is not working, some example's have it, some don't and I'm not sure it even works in Blender 2.57. (Which directory do I need to use anyway? Can't find it anywhere in de documentation)
- Getting a color picker needs requires a property created from an ID Property which has to be set to {subtype='COLOR'}. I've tried every computation... None work. No documentation found. P.S. If colours, integers and floats are set by a RNA option, why is a boolean value not set that way? (or am I missing something?)
- Properties for camera's, lamps, textures all have a nice panel. However, for the is no property screen for textures! That means I need to make my own... Not simple.

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)

Well, on the blender forums nobody is replying to my questions, so I guess you were lucky.
asciimonster
 
Posts: 375
Joined: 03 Dec 2009, 18:24

Re: New STK property Browser

Postby Auria » 17 Apr 2011, 18:01

Hi,

Indeed I've never tried to get color pickers working. Maybe we can just make a custom picker, I have some experience with them, we could create a small frame displaying three sliders (R, G and B) and all left to find is to display a preview

And yeah not sure what to do with texture ID properties :( Looks like we'll need to make a custom panel there and stage it somewhere (maybe just in the Scene panel, with a combo to select the current texture)

Regarding SVN, in the scripts directory I see "Import_driveline.py" and "strip_texture_path_from_models.py". Are those really needed??? For the first, we just don't support importing tracks at all, we don't even have a B3D importer. IMO it makes no sense to support importing drivelines but supporting exporting nothing else
Regarding "strip_texture_path_from_models.py", what does this do? File > External Data > Make Paths Relative seems to do all we need with texture paths
Image
User avatar
Auria
STK Moderator
 
Posts: 2976
Joined: 07 Dec 2009, 03:52

Re: New STK property Browser

Postby Auria » 17 Apr 2011, 21:42

Rehi Asciimonster,

after quite a bit of fiddling around I think I found a reasonable way of providing a color picker

{l Code}: {l Select All Code}
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()


The only thing that's left is to find a way to give a color preview instead of just showing the RGB value text
Image
User avatar
Auria
STK Moderator
 
Posts: 2976
Joined: 07 Dec 2009, 03:52

Re: New STK property Browser

Postby Auria » 17 Apr 2011, 22:17

Err, oops, apparently we can do much easier than that :S

{l Code}: {l Select All Code}
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()


We'll need to modify the track exporter to handle color ID-properties but that's OK
Image
User avatar
Auria
STK Moderator
 
Posts: 2976
Joined: 07 Dec 2009, 03:52

Who is online

Users browsing this forum: Bing [Bot] and 1 guest