def setup_properties(self): #scale scaleProp = Props.VectorNodeProperty(self, "Scale of the object", "Scale") self.Properties.Add("scale", scaleProp, Geo.Vector2(1, 1)) #uniformScale uniScaleProp = Props.FloatNodeProperty(self, "Scale of the object", "Uniform scale") self.Properties.Add("uniScale", uniScaleProp, 1) #center centerProp = Props.VectorNodeProperty(self, "Scale from this point", "Center") self.Properties.Add("center", centerProp, Geo.Vector2(0, 0))
def setup_properties(self): print "Creating properties" #position point 1 posFromProp = Props.VectorNodeProperty(self, "Start point position", "Start position") self.Properties.Add("posFrom", posFromProp, Geo.Vector2(0, 2)) #position point 2 posToProp = Props.VectorNodeProperty(self, "End point position", "End position") self.Properties.Add("posTo", posToProp, Geo.Vector2(0, -2)) #thickness thicknessProp = Props.FloatNodeProperty(self, "Thickness of the line", "Thickness") self.Properties.Add("thickness", thicknessProp, 0.2) #action actionProp = Props.DropdownNodeProperty( self, "Choose what to do with existing shapes", "Action", ["Replace", "Merge"]) self.Properties.Add("action", actionProp, "Replace")
def evaluate_frame(self, frame, dataFeed): if dataFeed.ChannelExists(Node.PROPERTY_OUT_CHANNEL): previousVal = dataFeed.GetChannelData(Node.PROPERTY_OUT_CHANNEL) self.Properties["xProp"].StaticValue = previousVal.X self.Properties["yProp"].StaticValue = previousVal.Y xProp = self.Properties.GetValue("xProp", frame) yProp = self.Properties.GetValue("yProp", frame) newVal = Geo.Vector2(xProp, yProp) dataFeed.SetChannelData(Node.PROPERTY_OUT_CHANNEL, newVal)
def evaluate_frame(self, frame, dataFeed): size = self.Properties.GetValue("size", frame) pos = self.Properties.GetValue("pos", frame) action = self.Properties.GetValue("action", frame) points = [ Geo.Vector2(size / 2, size / 2) + pos, Geo.Vector2(-size / 2, size / 2) + pos, Geo.Vector2(-size / 2, -size / 2) + pos, Geo.Vector2(size / 2, -size / 2) + pos, ] triangles = [0, 1, 2, 0, 2, 3] mesh = Meshing.Mesh() mesh.triangles = triangles mesh.points = points meshGroupInput = dataFeed.GetChannelData(Node.MESH_CHANNEL) if action == "Merge": meshGroupInput.Add(mesh) meshGroup = meshGroupInput else: meshGroup = Meshing.MeshGroup(mesh) dataFeed.SetChannelData(Node.MESH_CHANNEL, meshGroup)
def setup_properties(self): print "Creating properties" #position posProp = Props.VectorNodeProperty(self, "Position of the square", "Position") self.Properties.Add("pos", posProp, Geo.Vector2(0, 0)) #size sizeProp = Props.FloatNodeProperty(self, "Size of the square", "Size") self.Properties.Add("size", sizeProp, 2) #action actionProp = Props.DropdownNodeProperty( self, "Choose what to do with existing shapes", "Action", ["Replace", "Merge"]) self.Properties.Add("action", actionProp, "Replace")
def setup_properties(self): print "Creating properties" #position point 1 pos1Prop = Props.VectorNodeProperty(self, "First center position", "Position 1") self.Properties.Add("pos1", pos1Prop, Geo.Vector2(0, 2)) #position point 2 pos2Prop = Props.VectorNodeProperty(self, "Second center position", "Position 2") self.Properties.Add("pos2", pos2Prop, Geo.Vector2(0, -2)) #thickness thicknessProp = Props.FloatNodeProperty(self, "Thickness of the capsule", "Thickness") self.Properties.Add("thickness", thicknessProp, 2) #detail detailProp = Props.FloatNodeProperty( self, "Definition of the rounded edges", "Detail") self.Properties.Add("detail", detailProp, 6) #action actionProp = Props.DropdownNodeProperty( self, "Choose what to do with existing shapes", "Action", ["Replace", "Merge"]) self.Properties.Add("action", actionProp, "Replace")
def evaluate_frame(self, frame, dataFeed): scaleNonUniform = self.Properties.GetValue("scale", frame) scaleUniform = self.Properties.GetValue("uniScale", frame) globalScale = scaleNonUniform * Geo.Vector2(scaleUniform, scaleUniform) center = self.Properties.GetValue("center", frame) meshInput = dataFeed.GetChannelData(Node.MESH_CHANNEL) meshGroup = Meshing.MeshGroup() for mesh in meshInput: newPoints = [] for point in mesh.points: newPoints.append((point - center) * globalScale + center) mesh.points = newPoints meshGroup.Add(mesh) dataFeed.SetChannelData(Node.MESH_CHANNEL, meshGroup)
def setup_properties(self): print "Creating properties" #position posProp = Props.VectorNodeProperty(self, "Position of the circle's center", "Position") self.Properties.Add("pos", posProp, Geo.Vector2(0, 0)) #radius radiusProp = Props.FloatNodeProperty(self, "Circle's radius", "Radius") self.Properties.Add("radius", radiusProp, 5) #detail detailProp = Props.FloatNodeProperty(self, "Smoothness of the circle", "Detail") self.Properties.Add("detail", detailProp, 12) #action actionProp = Props.DropdownNodeProperty( self, "Choose what to do with existing shapes", "Action", ["Replace", "Merge"]) self.Properties.Add("action", actionProp, "Replace")
def evaluate_frame(self, frame, dataFeed): pos1 = self.Properties.GetValue("pos1", frame) pos2 = self.Properties.GetValue("pos2", frame) thickness = self.Properties.GetValue("thickness", frame) detail = self.Properties.GetValue("detail", frame) action = self.Properties.GetValue("action", frame) #normalize data detail = 1 if detail < 1 else int(detail) #calculate normal vector in both ways normal1 = Geo.Vector2.Normalize( Geo.Vector2(pos2.Y - pos1.Y, pos1.X - pos2.X)) * Geo.Vector2( thickness / 2) normal2 = Geo.Vector2.Normalize( Geo.Vector2(pos1.Y - pos2.Y, pos2.X - pos1.X)) * Geo.Vector2( thickness / 2) #angle between circle division divisionAngle = math.pi / detail #main rectangle points points = [ pos1, pos2, pos1 + normal1, pos1 + normal2, pos2 + normal1, pos2 + normal2 ] #circle points for i in range(detail - 1): positionOnCircle1 = Geo.Vector2( thickness / 2 * math.cos(divisionAngle * (i + 1) + math.atan2(normal1.Y, normal1.X) + math.pi), thickness / 2 * math.sin(divisionAngle * (i + 1) + math.atan2(normal1.Y, normal1.X) + math.pi)) points.append(positionOnCircle1 + pos1) positionOnCircle2 = Geo.Vector2( thickness / 2 * math.cos(divisionAngle * (i + 1) + math.atan2(normal1.Y, normal1.X)), thickness / 2 * math.sin(divisionAngle * (i + 1) + math.atan2(normal1.Y, normal1.X))) points.append(positionOnCircle2 + pos2) #main rectangle triangles triangles = [0, 2, 4, 4, 1, 0, 0, 1, 3, 3, 1, 5] #circle triangles border triangles.extend( [0, 3, 6, 1, 4, 7, 0, detail * 2 + 2, 2, 1, detail * 2 + 3, 5]) #circle triangles center for i in range(detail - 2): triangles.extend([0, 6 + (2 * i), 8 + (2 * i)]) triangles.extend([1, 7 + (2 * i), 9 + (2 * i)]) mesh = Meshing.Mesh() mesh.triangles = triangles mesh.points = points meshGroupInput = dataFeed.GetChannelData(Node.MESH_CHANNEL) if action == "Merge": meshGroupInput.Add(mesh) meshGroup = meshGroupInput else: meshGroup = Meshing.MeshGroup(mesh) dataFeed.SetChannelData(Node.MESH_CHANNEL, meshGroup)