3d grid/matrix inside a mesh
Hi All,
I'm trying to create a matrix/grid inside a 3D mesh.
I can create grids, i can create random points inside meshes and colliders, I can even slice the grids using a plane... but I'm having trouble combining the 2.
I'm trying to create an environment where I can get any 3D mesh (Any shape/design/3D file format) and then create a series of 3D points inside it at a given distance from each other.
And obviously only have the points that are inside the mesh, removing the others.
I've looked into Octree and just found out about KDtree but really not sure i need to get that complicated.
Does anyone know how I can achieve this, how would you go about doing this?
Not looking for code or anything, just direction.
Answer by Bunny83 · Sep 20, 2020 at 03:16 PM
Sorry but I think I'm not really sure what you're actually asking here. A grid is a rather abstract concept. It could be simply snapping points to the closest grid point, it could be about drawing grid lines. This part:
I'm trying to create an environment where I can get any 3D mesh (Any shape/design/3D file format) and then create a series of 3D points inside it at a given distance from each other.
And obviously only have the points that are inside the mesh, removing the others.
sounds more like you're looking for generating point cloud data and / or working on boolean operations (CSG). To me it sounds like you don't really sure what you actually want or that you have trouble explaining it :) Maybe it's just me not understanding it.
KD-trees and octrees are just a way for space partitioning to speed up searching for things inside the tree.
To me it's still not clear if you actually want to work with 3d meshes or if you're just interested in getting the points inside them (for whatever reasons). Since you talked about arbitrary meshes I'd like to note that a mesh in general does not really represent any volume as a mesh only defines the surface. A mesh does not need to be closed. So if you're thinking about CSG there's not always a reasonable way to construct a logical volume out of surface meshes. While the logic behind CSG is relatively simple, implementing them is much harder. When you want to implement boolean operation between 3d meshes there are many edge cases which can drive you mad, believe me :) Under the hood it's just basic geometry / maths / equations.
Apologies if you didn't understand the issue,
I need to create a matrix of points at a set distance from each other inside a mesh.
These points could be local, world or any other coordinates i just need their location programatically...
I want to use these points/coordinates to place prefabs.
EDIT: Imagine Voxel Art in the shape of something, and man, a teddybear, a car, a tree etc.
Think I just answered my own question...
Kindest regards,
Chris
Your answer
Follow this Question
Related Questions
3D Grid Based Movement 0 Answers
How to check if object is inside another 1 Answer
Destroying an object in a matrix 0 Answers
How do I obtain smooth movement of a 3d object on an int grid? 0 Answers
Point Generator(based on time) 0 Answers