Reputation: 361
I'm attempting to create a 3d model from a list of xyz coordinate data. I've created a Python script to create a small sphere and then copy it for each data point. Unfortunately, the program takes an unreasonably long time. I've calculated that it would take up to 8 days to finish creating the model. I even tried running the script with Google Compute Engine, but it still would take way too long. Is there anyway to create a model this large in a reasonable time frame? I'm open to trying other programs besides Blender. How do animation companies create huge models? There has to be some way, right?
Here is the Python script for creating the model:
import bpy
import os
radius = 0.0005
scale = 0.001
bpy.ops.object.select_all(action='DESELECT')
bpy.ops.mesh.primitive_uv_sphere_add(size=radius)
sphere = bpy.context.object
filename = 'points.xyz'
directory = 'C:\\Users\\User1\\Desktop'
fullpath = os.path.join(os.getcwd(), filename)
print("Creating OBJ file")
sphereCount = 1
def makeSphere(x,y,z):
global sphereCount
print("Creating Sphere #" + str(sphereCount))
ob = sphere.copy()
ob.location.x = x
ob.location.y = y
ob.location.z = z
bpy.context.scene.objects.link(ob)
sphereCount += 1
with open(fullpath,"r") as f:
for line in f:
values = line.split()
x = values[0]
y = values[1]
z = values[2]
makeSphere(scale*float(x),scale*float(y),scale*float(z))
bpy.context.scene.update()
#Export as OBJ file
filename = 'finalObject.obj'
directory = '/home/user1'
fullpath = os.path.join(os.getcwd(), filename)
print("Exporting OBJ");
bpy.ops.export_scene.obj(filepath=fullpath)
I found this question online and tried this approach, but it ran slower than copying each sphere.
Upvotes: 0
Views: 911
Reputation: 61379
No one creates this many spheres because no human mind can sufficiently process the information contained in the resulting cloud. A simplified display suffices.
To build one:
This gives you O(N) time in moving from your physics to your display representation. It will not be perfect since, upon close examination, spheres may appear to pop in and out of existence. But it's a start.
Upvotes: 2
Reputation: 719229
How do animation companies create huge models? There has to be some way, right?
They probably don't create models with that many objects. (50 million spheres? Seriously?)
And when they do, they probably use proprietary software and techniques developed by in-house specialist software engineers ... and really powerful compute resources ... and it probably still takes a long time.
Having said that, I would suggest investigating the following:
Is the problem occurring while building the model or while exporting it? (I assume that you are exporting the model because you want to import it later. So knowing where the problem lies will also help you when you come to use the model.)
Do you have enough (physical) memory to create the model in memory? If you don't, your problem may be interactions between the garbage collector and virtual memory.
Could you reduce the number of objects to something more tractable?
Could you tweak the parameters on the UV sphere you are copying? A primitive UV sphere is a mesh with a 32 segments and 16 rings by default. (32 x 16 x 50 million will be a truly huge number of mesh elements.)
Upvotes: 2