0

I am a newcomer to Blender.

Briefly, I want to generate Points (x,y,z) model from a 3D model using Blender. And use these points to do numerical simulation. These points should be not only on the surface of the model.

I want to divide a 3D model into many small cubes at first, and then place some points inside each cube. Export these points' locations.

I've tried exporting my object as a .ply and chose the "ASCII" format instead of binary. But I find it only exports a few points. I want to control the number and location of points like points cloud.

If there were good solutions, please help me. Thanks.

Blunder
  • 13,925
  • 4
  • 13
  • 36
gd l
  • 3
  • 1
  • 1
    I would try exporting your object as a .ply and choose "ASCII" format instead of binary. You can open the .ply with a text editor and the data will be written as plain text. – Gorgious Dec 06 '22 at 15:18
  • Thanks. I find it only export few points. I want to control the number and location of points like points cloud. – gd l Dec 07 '22 at 08:18
  • You'll have to be a little more specific about your workflow here because there is litterally an infinite number of ways to distribute points on a mesh surface :) – Gorgious Dec 07 '22 at 08:28
  • What I want is to divide a 3d model into many small cubes at first, and then place some points inside of each cube. Export these points' location. – gd l Dec 07 '22 at 08:49
  • Hello and welcome! Please give as many details as you can and add them to your question => Edit because the comments here can be removed, hidden, and change their order when they get upvotes. – Blunder Dec 07 '22 at 09:32
  • "divide a 3D model into many small cubes" sounds like voxelized. This can be done with the Remesh modifier. With the new Geometry Node "Distribute Points in Volume" of the new Blender 3.4 version you should be able to fill the cubes. – Blunder Dec 07 '22 at 09:39
  • Wait, the Remesh modifier only creates cubes for the surface. It does not fill the model if this is what you want. But the GN Mesh To Volumes does this. Should the cubes all be the same size? Why do you want/need these cubes? -- And I am not sure if you can export the GN point cloud in a .ply format. Maybe you need to create vertices from them first. – Blunder Dec 07 '22 at 09:53
  • Thank you for your reply. I am doing a research on Material Point Method(MPM). This method separate the object into many particles to compute in background mesh. I want to look for an easy way to build the model (very similar to point cloud). – gd l Dec 07 '22 at 12:08
  • This sounds like what I'm trying to do (3d occupancy AI training data generation), Anyway if you want it to work like point cloud and export .ply file. Try to use the blender range scanner addon: https://github.com/ln-12/blainder-range-scanner. it simulates the real radar/lidar scanner and gives you point cloud files(.ply), you can also change the scanner resolution to adjust the density of the points. But note that those points are all located on the mesh surface and don't go inside. It doesn't vocalize your scene/model. Anyway, I also wish to have that .ply you described(or any other file th – miaomiao May 19 '23 at 09:51

1 Answers1

0

I'm not sure if this is exactly what you want but let's give it a try.

The latest Blender version 3.4 that got released today has a new Geometry Node called Distribute Points in Volume. With it, you can scatter points inside a mesh.

Add a Geometry Nodes modifier to your mesh and wire the following nodes. Adjust their values according to your needs (Random/Grid, Density, Voxel Amount, etc).

screenshot

When you apply the modifier, you will have these scattered vertices in 3D space. (To apply it, hover the mouse over the modifier and press Ctrl+A or use the dropdown menu right next to its name. The menu entry Object > Convert To > Mesh also works.)

Point Clouds are still under development and access via Python script is limited. But since we can convert them to vertices they can be exported. Unfortunately, the *.ply ASCII exporter doesn't work when there are no faces. So here is a little script that does the export. Just adjust the file path, select the object with the point cloud vertices, and run it.

import bpy

obj = bpy.context.active_object

f = open("c:/tmp/point_cloud_data.csv", "w")
for v in obj.data.vertices: f.write(f"{v.co.x}, {v.co.y}, {v.co.z}\n") f.close()

Blunder
  • 13,925
  • 4
  • 13
  • 36