Geometry usage

This commit is contained in:
Lubos Lenco 2016-01-11 21:10:33 +01:00
parent 42369a0cd8
commit 07ff2f8c6e
10 changed files with 34 additions and 20 deletions

View file

@ -5,7 +5,6 @@
"render_targets": [],
"stages": [
{
"command": "set_target",
"params": [""]
@ -14,6 +13,10 @@
"command": "clear_target",
"params": ["depth", "color"]
},
{
"command": "draw_quad",
"params": ["material_resource", "material1", "env_map"]
},
{
"command": "draw_geometry",
"params": ["forward"]

View file

@ -1769,9 +1769,14 @@ class ArmoryExporter(bpy.types.Operator, ExportHelper):
if is_instanced == True:
om.instance_offsets = instance_offsets
# Export usage
if node.static_usage == False:
om.static_usage = False
# Delete the new mesh that we made earlier.
bpy.data.meshes.remove(exportMesh)
o.mesh = om
# One geometry data per file

View file

@ -4,11 +4,11 @@ from bpy.props import *
# Implementation of custom nodes from Python
# Derived from the NodeTree base type, similar to Menu, Operator, Panel, etc.
class MyCustomTree(NodeTree):
class CGTree(NodeTree):
# Description string
'''Logic nodes'''
# Optional identifier string. If not explicitly defined, the python class name is used.
bl_idname = 'CustomTreeType'
bl_idname = 'CGTreeType'
# Label for nice name display
bl_label = 'CG Node Tree'
# Icon identifier
@ -22,14 +22,14 @@ class MyCustomTree(NodeTree):
# Mix-in class for all custom nodes in this tree type.
# Defines a poll function to enable instantiation.
class MyCustomTreeNode:
class CGTreeNode:
@classmethod
def poll(cls, ntree):
return ntree.bl_idname == 'CustomTreeType'
return ntree.bl_idname == 'CGTreeType'
# Derived from the Node base type.
class TransformNode(Node, MyCustomTreeNode):
class TransformNode(Node, CGTreeNode):
# Description string
'''A custom node'''
# Optional identifier string. If not explicitly defined, the python class name is used.
@ -70,7 +70,7 @@ class TransformNode(Node, MyCustomTreeNode):
#layout.prop_search(self, "objname", context.scene, "objects", text = "")
# Derived from the Node base type.
class TimeNode(Node, MyCustomTreeNode):
class TimeNode(Node, CGTreeNode):
# Description string
'''Time node'''
@ -102,7 +102,7 @@ class TimeNode(Node, MyCustomTreeNode):
def free(self):
print("Removing node ", self, ", Goodbye!")
class VectorNode(Node, MyCustomTreeNode):
class VectorNode(Node, CGTreeNode):
bl_idname = 'VectorNodeType'
# Label for nice name display
bl_label = 'Vector'
@ -127,7 +127,7 @@ class VectorNode(Node, MyCustomTreeNode):
render()
class ScaleValueNode(Node, MyCustomTreeNode):
class ScaleValueNode(Node, CGTreeNode):
bl_idname = 'ScaleValueNodeType'
# Label for nice name display
bl_label = 'ScaleValue'
@ -153,7 +153,7 @@ class ScaleValueNode(Node, MyCustomTreeNode):
render()
class SineNode(Node, MyCustomTreeNode):
class SineNode(Node, CGTreeNode):
bl_idname = 'SineNodeType'
# Label for nice name display
bl_label = 'Sine'
@ -190,7 +190,7 @@ from nodeitems_utils import NodeCategory, NodeItem
class MyNodeCategory(NodeCategory):
@classmethod
def poll(cls, context):
return context.space_data.tree_type == 'CustomTreeType'
return context.space_data.tree_type == 'CGTreeType'
# all categories in a list
node_categories = [
@ -208,10 +208,10 @@ node_categories = [
def register():
bpy.utils.register_module(__name__)
try:
nodeitems_utils.register_node_categories("CUSTOM_NODES", node_categories)
nodeitems_utils.register_node_categories("CG_NODES", node_categories)
except:
pass
def unregister():
nodeitems_utils.unregister_node_categories("CUSTOM_NODES")
nodeitems_utils.unregister_node_categories("CG_NODES")
bpy.utils.unregister_module(__name__)

View file

@ -284,7 +284,8 @@ def buildNodeTrees():
# Export node scripts
for node_group in bpy.data.node_groups:
buildNodeTree(node_group)
if type(node_group) == 'nodes.CGTree': # Build only cycles game trees
buildNodeTree(node_group)
def buildNodeTree(node_group):
rn = getRootNode(node_group)

View file

@ -10,12 +10,14 @@ def cb_scene_update(context):
if edit_obj is not None and edit_obj.is_updated_data is True:
edit_obj.geometry_cached = False
def initObjectProperties():
# For geometry
bpy.types.Object.geometry_cached = bpy.props.BoolProperty(name="Geometry cached", default=False)
def initProperties():
# For object
bpy.types.Object.geometry_cached = bpy.props.BoolProperty(name="Geometry cached", default=False) # TODO: move to mesh type
bpy.types.Object.instanced_children = bpy.props.BoolProperty(name="Instanced children", default=False)
bpy.types.Object.custom_material = bpy.props.BoolProperty(name="Custom material", default=False)
bpy.types.Object.custom_material_name = bpy.props.StringProperty(name="Name", default="")
# For geometry
bpy.types.Mesh.static_usage = bpy.props.BoolProperty(name="Static usage", default=True)
# For camera
bpy.types.Camera.frustum_culling = bpy.props.BoolProperty(name="Frustum Culling", default=False)
bpy.types.Camera.pipeline_path = bpy.props.StringProperty(name="Pipeline Path", default="pipeline_resource/forward_pipeline")
@ -44,7 +46,7 @@ class ObjectPropsPanel(bpy.types.Panel):
if obj.custom_material:
layout.prop(obj, 'custom_material_name')
# Menu in camera region
# Menu in data region
class DataPropsPanel(bpy.types.Panel):
bl_label = "Cycles Props"
bl_space_type = "PROPERTIES"
@ -59,6 +61,8 @@ class DataPropsPanel(bpy.types.Panel):
layout.prop(obj.data, 'frustum_culling')
layout.prop(obj.data, 'pipeline_path')
layout.prop(obj.data, 'pipeline_pass')
elif obj.type == 'MESH':
layout.prop(obj.data, 'static_usage')
# Menu in materials region
class MatsPropsPanel(bpy.types.Panel):
@ -80,7 +84,7 @@ class MatsPropsPanel(bpy.types.Panel):
# Registration
def register():
bpy.utils.register_module(__name__)
initObjectProperties()
initProperties()
bpy.app.handlers.scene_update_post.append(cb_scene_update)
def unregister():

View file

@ -34,7 +34,8 @@ def write_main():
"""// Auto-generated
package ;
class Main {
static inline var projectName = '""" + bpy.data.worlds[0]['CGProjectName'] + """';
public static inline var projectName = '""" + bpy.data.worlds[0]['CGProjectName'] + """';
public static inline var projectPackage = '""" + bpy.data.worlds[0]['CGProjectPackage'] + """';
static inline var projectWidth = """ + str(bpy.data.worlds[0]['CGProjectWidth']) + """;
static inline var projectHeight = """ + str(bpy.data.worlds[0]['CGProjectHeight']) + """;
public static function main() {