UI and interface
[convexer.git] / config.py
diff --git a/config.py b/config.py
new file mode 100644 (file)
index 0000000..b886758
--- /dev/null
+++ b/config.py
@@ -0,0 +1,254 @@
+# Convexer default configuration .py
+#  
+# config dict           purpose
+# ------------------------------------------------------------------------------
+# cxr_shaders           Defines shader names
+# cxr_graph_mapping     Contains a graph to traverse Blender shader nodes
+# cxr_shader_params     Material shader properties and groups
+# cxr_entities          Entity info
+
+# Shader names
+# 
+cxr_shaders = \
+{
+   "LightMappedGeneric": { "name": "Light Mapped" },
+   "VertexLitGeneric": { "name": "Vertex Lit" },
+   "UnlitGeneric": { "name": "Unlit" },
+   "Builtin": { "name": "Builtin" }
+}
+
+# Shader graph mapping
+# ------------------------------------------------------------------------------
+
+def material_tex_image(v):
+   return {
+      "ShaderNodeTexImage":
+      {
+         "image": F"${v}"
+      }
+   }
+
+cxr_graph_mapping = \
+{
+   "ShaderNodeBsdfPrincipled":
+   {
+      "Base Color":
+      {
+         "ShaderNodeMixRGB":
+         {
+            "Color1": material_tex_image("basetexture"),
+            "Color2": material_tex_image("decaltexture")
+         },
+         "ShaderNodeTexImage":
+         {
+            "image":"$basetexture"
+         },
+         "default":
+            [("VertexLitGeneric","$color2"),\
+             ("UnlitGeneric","$color2"),\
+             ("LightMappedGeneric","$color")]
+      },
+      "Normal":
+      {
+         "ShaderNodeNormalMap":
+         {
+            "Color": material_tex_image("bumpmap")
+         }
+      }
+   }
+}
+
+# Shader keyvalues / material properties
+# ------------------------------------------------------------------------------
+
+cxr_shader_params = \
+{
+   "Textures":
+   {
+      "type": "ui",
+      "shaders": ("UnlitGeneric","VertexLitGeneric","LightMappedGeneric"),
+
+      "$basetexture":
+      {
+         "name": "Base Texture",
+         "type": "intrinsic",
+         "default": None
+      },
+      "$decaltexture":
+      {
+         "name": "Decal Texture",
+         "type": "intrinsic",
+         "default": None,
+
+         "$decalblendmode":
+         {
+            "name": "Blend Mode",
+            "type": "enum",
+            "items": [
+               ('0',"AlphaOver","Default",'',0),
+               ('1',"Multiply","",'',1),
+               ('2',"Modulate","",'',2),
+               ('3',"Additive","",'',3)
+            ],
+            "default": 0,
+            "always": True
+         }
+      },
+      "$bumpmap":
+      {
+         "name": "Normal Map",
+         "type": "intrinsic",
+         "flags": NBVTF_TEXTUREFLAGS_NORMAL, # OpenGL (correct) normal maps.
+         "default": None
+      }
+   },
+   "$color":
+   {
+      "name": "Color",
+      "type": "intrinsic",
+      "default": None,
+      "exponent": 2.2
+   },
+   "$color2":
+   {
+      "name": "Color2",
+      "type": "intrinsic",
+      "default": None,
+      "exponent": 2.2
+   },
+   "Lighting":
+   {
+      "type": "ui",
+      "shaders": ("VertexLitGeneric", "LightMappedGeneric"),
+
+      "$phong":
+      {
+         "name": "Phong",
+         "type": "bool",
+         "default": False,
+
+         "$phongexponent":
+         {
+            "name": "Exponent",
+            "type": "float",
+            "default": 5.0
+         },
+         "$phongboost":
+         {
+            "name": "Boost",
+            "type": "float",
+            "default": 1.0
+         },
+         "$phongfresnelranges":
+         {
+            "name": "Fresnel Ranges",
+            "type": "vector",
+            "default":(1.0,1.0,1.0)
+         }
+      },
+      "$envmap":
+      {
+         "name": "Cubemap",
+         "type": "string",
+         "default": "",
+
+         "$envmaptint":
+         {
+            "name": "Tint",
+            "type": "vector",
+            "subtype": 'COLOR',
+            "default": (1.0,1.0,1.0)
+         },
+         "$envmaplightscale":
+         {
+            "name": "Light Scale",
+            "type": "float",
+            "default": 0.0
+         },
+         "$envmaplightscaleminmax":
+         {
+            "name": "Min/Max",
+            "type": "vector",
+            "default": (0.0,1.0)
+         }
+      }
+   },
+   "Transparency":
+   {
+      "type": "ui",
+      "shaders": ("UnlitGeneric","VertexLitGeneric","LightMappedGeneric"),
+
+      "$translucent":
+      {
+         "name": "Translucent",
+         "type": "bool",
+         "default": False
+      },
+      "$alphatest":
+      {
+         "name": "Alpha Test",
+         "type": "bool",
+         "default": False,
+
+         "$alphatestreference":
+         {
+            "name": "Step",
+            "type": "float",
+            "default": 0.5
+         }
+      },
+      "$nocull":
+      {
+         "name": "No Cull",
+         "type": "bool",
+         "default": False
+      }
+   }
+}
+
+# Entity KV definitions
+#  Note: currently blender doesnt support enum or bool types for IDProperties,
+#        so unfortunately the panel UI is a little bit bad to work with.
+# ------------------------------------------------------------------------------
+
+cxr_entities = \
+{
+   # Builtin/intrinsic entities, you probably dont want to modify these
+   "light": { "keyvalues": ent_lights },
+   "light_spot": { "keyvalues": ent_lights },
+   "env_cubemap": { "keyvalues": ent_cubemap },
+   
+   # CSGO.fgd
+   # --------
+   "info_player_counterterrorist":
+   {
+      "gizmo": [],
+      "allow": ('EMPTY',),
+      "keyvalues": cxr_baseclass([ent_transform],\
+      {
+         "priority": {"type": "int", "default": 0 },
+         "enabled": {"type": "int", "default": 1 },
+      })
+   },
+   "info_player_terrorist":
+   {
+      "gizmo": [],
+      "allow": ('EMPTY',),
+      "keyvalues": cxr_baseclass([ent_transform],\
+      {
+         "priority": {"type": "int", "default": 0 },
+         "enabled": {"type": "int", "default": 1 },
+      })
+   },
+
+   # Brush entites
+   # -------------
+   "func_buyzone": 
+   {
+      "allow": ('MESH',),
+      "keyvalues": 
+      {
+         "TeamNum": {"type": "int", "default": 0 }
+      }
+   }
+}