예제 #1
0
class Point(GeometryNode):
    __identifier__ = 'OpenGL'
    NODE_NAME = 'Point'

    def __init__(self):
        super(Point, self).__init__()
        self.create_property("Color", (1.0, 1.0, 1.0),
                             widget_type=NODE_PROP_COLORPICKER)
        self.create_property("Size", 0.1, widget_type=NODE_PROP_FLOAT)
        self.create_property("Pos", [0.0, 0.0, 0.0],
                             widget_type=NODE_PROP_VECTOR3)
        self.cook()

    def run(self):
        self.geo = Mesh()
        self.geo.addVertex(self.get_property("Pos"))
        self.geo.createAttribute('vertex',
                                 'color',
                                 'vector3', [1, 1, 1],
                                 applyValue=True)
        self.geo.setVertexAttrib("color", 0, list(self.get_property("Color")))
        self.geo.createAttribute('vertex',
                                 'pscale',
                                 'float',
                                 1.0,
                                 applyValue=True)
        self.geo.setVertexAttrib("pscale", 0, self.get_property("Size"))
예제 #2
0
class Box(GeometryNode):
    __identifier__ = 'Primitives'
    NODE_NAME = 'Box'

    def __init__(self):
        super(Box, self).__init__()
        self.create_property("Size", value=[1, 1, 1], widget_type=NODE_PROP_VECTOR3)
        self.cook()

    def run(self):
        size = self.get_property("Size")
        x = size[0] * 0.5
        y = size[1] * 0.5
        z = size[2] * 0.5
        self.geo = Mesh()
        v1 = self.geo.addVertex([x, -y, -z])
        v2 = self.geo.addVertex([x, -y, z])
        v3 = self.geo.addVertex([x, y, z])
        v4 = self.geo.addVertex([x, y, -z])
        v5 = self.geo.addVertex([-x, -y, -z])
        v6 = self.geo.addVertex([-x, -y, z])
        v7 = self.geo.addVertex([-x, y, z])
        v8 = self.geo.addVertex([-x, y, -z])

        self.geo.addFace([v1, v2, v3, v4])
        self.geo.addFace([v2, v6, v7, v3])
        self.geo.addFace([v6, v5, v8, v7])
        self.geo.addFace([v5, v1, v4, v8])
        self.geo.addFace([v4, v3, v7, v8])
        self.geo.addFace([v5, v6, v2, v1])
        self.geo.mesh.update_normals()