TransWikia.com

Calculating edges and polygon indices in python numerically to build mesh

Blender Asked on November 30, 2021

I can calculate the vertices and faces but how does one calculate edges and polygon indices numerically in python?

import bpy
import math

def parametricfunc(val1):

    # mesh arrays
    verts = []
    faces = []

    # mesh variables
    numX = 50
    numY = 50

    # fill verts array
    for i in range (0, numX):
        for j in range(0,numY):
            # nomalize range
            u = 8*(i/numX-1/2)
            v = 2*math.pi*(j/(numY-1)-1/2)

            x = 2*math.sqrt(1+u*u)*math.cos(v)*(val1/12)
            y = 2*math.sqrt(1+u*u)*math.sin(v)*(val1/12)
            z = 12*u/(val1/12+0.01)

            vert = (x,y,z)
            verts.append(vert)
            
    # fill faces array
    count = 0
    for i in range (0, numY *(numX-1)):
        if count < numY-1:
            A = i
            B = i+1
            C = (i+numY)+1
            D = (i+numY)
            face = (A,B,C,D)
            faces.append(face)
            count = count + 1
        else:
            count = 0
    
    return x, y, z, verts, A, B, C, D, faces
            
x, y, z, verts, A, B, C, D, faces = parametricfunc(val1)            
        

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP