""" Lawson Bottle 1 25.04.2020 """ import c4d import math # Variablen und Konstanten dialog_title = 'Lawson Bottle 1' uMin = 0.0 # Bereich u uMax = 2*math.pi # Bereich u vMin = 0 # Bereich v vMax = 2*math.pi # Bereich v Nu = 100 # Anzahl Punkte u Nv = 150 # Anzahl Punkte v Faktor = 100 # Skalierungsfaktor def CreatePolygonObject(): # Polygonobjekt erzeugen obj = c4d.BaseObject(c4d.Opolygon) obj.ResizeObject((Nu+1)*(Nv+1), Nu*Nv) obj.SetName(dialog_title) # Variablen zz=0 # Zaehler # Segmentbreiten berechnen du=(uMax-uMin)/Nu dv=(vMax-vMin)/Nv # Punkte erzeugen for i in xrange(0,Nu+1): for j in xrange(0,Nv+1): # Berechnung der Parameter u=uMin+i*du v=vMin+j*dv # Berechnung der Koordinaten w=(math.sin(u)*math.sin(v) + math.sin(u/2.0)*math.cos(v))/math.sqrt(2) x=(math.sin(u)*math.sin(v) - math.sin(u/2.0)*math.cos(v))*math.sqrt(0.5)/(1+w) y=math.cos(u)*math.sin(v)/(1+w) z=math.cos(u/2.0)*math.cos(v)/(1+w) # Punkt speichern obj.SetPoint(zz, c4d.Vector(x*Faktor,y*Faktor,z*Faktor)) # Zähler erhöhen zz=zz+1 # Polygone erzeugen zz=0 # Zähler zurücksetzen for j in xrange(0,Nv): for i in xrange(0,Nu): # Punkte für ein Quadrat definieren P1=i*(Nv+1)+j P2=i*(Nv+1)+j+1 P3=(i+1)*(Nv+1)+j+1 P4=(i+1)*(Nv+1)+j # Quadrat speichern obj.SetPolygon(zz, c4d.CPolygon(P1,P2,P3,P4)) # Zähler erhöhen zz=zz+1 # obj.Message(c4d.MSG_UPDATE) return obj def main(): plyobj = CreatePolygonObject() doc.InsertObject(plyobj, None, None, True) c4d.EventAdd() if __name__=='__main__': main()