5
$\begingroup$

I have a very simple python script to generate planes in the scene. I want to generate 50000 planes in a scene, to compensate for unavailability of POINT primitive, so that i can render a point cloud. It runs at a good pace till 2000 th plane is added , then starts slowing down, and gets very slow. My computer's config is - i7 3.4 GHz, 16GB RAM, GeForce 9800 GTX graphic card.

here is the python script-

import bpy 
from math import *
import random

for i in range(2000):
    x=random.uniform(0,100)
    y=random.uniform(0,100)
    z=random.uniform(0,100)
    bpy.ops.mesh.primitive_plane_add(location=(x,y,z))
    #bpy.context.active_object.scale=(100,100,100)
    print("\n",i)

Any Help on why it is slowing down? How can this be fixed ? Any alternate approach to render point cloud in blender? would be much appreciated...

Thanks for your time and attention

$\endgroup$
1
  • $\begingroup$ It would be better to use Instances, which use less memory (and may run faster too, but I haven't tested this). Probably the best way to do is by using Dupliverts to instance a tri to a point cloud object made up of verts. $\endgroup$
    – gandalf3
    Mar 7, 2014 at 7:30

2 Answers 2

6
$\begingroup$

Dupli objects

Try using Dupliverts (instances):

  1. Create/import the point cloud as a mesh with only vertices:

    enter image description here

  2. Create a single tri by adding a plane (ShiftA> Mesh > Plane) and merging one edge with AltM:

    enter image description here enter image description here

  3. Parent the tri to the point cloud by selecting both objects with the point cloud active (last selected) and pressing CtrlP.

  4. With the point cloud active, enable Verts in Properties > Object > Duplication:

    enter image description here

  5. Add a track to constraint to the tri with the camera object as the target so that all the tris face the camera:

    enter image description here

This has performed fine for me with point/vertex clouds of over 7000 vertices. This will work with both BI and Cycles.

Halos

Another method for rendering point clouds is to use a Halo Material:

  1. Create/Import a point cloud as vertex only mesh (no edges or faces):

    enter image description here

  2. Create a Halo material:

    enter image description here

Note that this only works for BI.

$\endgroup$
2
1
$\begingroup$

The python script that i used earlier used a function call inside the loop

bpy.ops.mesh.primitive_plane_add(location=(x,y,z))

As a result of which the blender was updating the scene by iterating over all the previously existing objects in the scene in each loop iteration. Below link explains the problem and gives the solution.

Python performance with Blender operators

$\endgroup$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .