Jump to content

3d Mesh generated from functions using blender.


Recommended Posts

Hello, My name is Rick and I've beenplaying KSP for a while now. The game is so greatly improved with theuse of mods such as B9 that I felt the need to contribute. So I'madapting an idea I had (originally for designing ship hulls) to makea blender extension for designing KSP parts. The plugin will allowyou to auto generate a mesh from a 3 variable function and create acollision mesh.

This is my plan for development.

First release


  • develop algorithm to generate simple mesh object
  • add material to the mesh
  • auto generate collision mesh
  • create GUI

Second release


  • add peicewise functionality(use different functions for x > or < whatever)

Third release


  • improve vertex spacing to reduce polygon count to smallest possible number

So before I start, while learning touse unity/blender, I have a few questions from the modding community.

Any words of wisdom?

Has anybody tried this?

What features would you like to seefrom this?

What else can be automated in blender?

Would you make use of this plugin?

Where can I find good python in blendertutorials?

Has this given you any ideas? Pleaseshare below.

Thank you.

Link to comment
Share on other sites

Sincerely not intending to rain on your parade, but Unity provides this function in about three clicks (two if the mesh is already selected) for simple meshes like hulls. Something that could generate convex colliders for complex objects would be awesome, however.

Edit: Or I've completely misunderstood and you're talking about the actual model mesh being generated. That too, would be great.

Edited by Randazzo
Link to comment
Share on other sites

Sincerely not intending to rain on your parade, but Unity provides this function in about three clicks (two if the mesh is already selected) for simple meshes like hulls. Something that could generate convex colliders for complex objects would be awesome, however.

Edit: Or I've completely misunderstood and you're talking about the actual model mesh being generated. That too, would be great.

Don't be sorry for parade raining, That's why I added that Q&A at the end so people could let me know if I'm wasting time. That being said yes I am talking about generating the actual model.

Link to comment
Share on other sites

Alright, progress. I have programmed a dirty python class (in IDLE not blender) which takes a function with parameters z,x and returns y. It then adds each new vertex to a list. Currently its just a jumbled list of vertices in the order they where generated.

The blender API looks simple enough so as soon as I find away to assign vertex tuples to faces I should have a working prototype. The function for generating vertices has to be hard coded unfortunately and I'm currently testing with a simple hemisphere.

I'm also starting to think it might be much cleaner to generate meshes radially rather than up from a grid.

Your thoughts would be appreciated.

import math

class f3dmesh:

#class 3d mesh is an object which handles a mesh based on the output of a 3 var function

vertices = []

edges = []

faces = []

def __init__(self):

self.data = []

def make_vector(self,x,y,z):

#return a list object in x,y,z format

vec = (x,y,z)

return vec

def obj_func(self,x,z):

#this function defines the geometric function of the vectors

#will return string "none" if encountering a domain error

try:

#FUNCTION GOES HERE

y = math.sqrt(pow(5, 2) - pow(x, 2) -pow(z, 2))

return y

except:

return "none"

def build_mesh(self ,Xrange, Zrange):

#scan through Z for each val X

for indexX in Xrange:

for indexZ in Zrange:

#get val of Y from obj_func(x,z)

Y = self.obj_func(indexX, indexZ)

if Y != 'none':

#add to vertices if Y is defined at x,z

self.vertices.append(self.make_vector(indexX, Y,indexZ))

def get_verticies():

return vertices

def get_edges():

return edges

def get_faces():

return faces

Link to comment
Share on other sites

This thread is quite old. Please consider starting a new thread rather than reviving this one.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...