将3D模型离散化为矩阵的最佳方法

RNs_Ghost

我想要一个3D模型,可以在Blender,Sketchup等模型中制作出来,然后离散化为3D矩阵。

您可能会说我想“我的世界”任意对象。(除了用于模拟)

一个例子:这是一个具有半球形末端的离散圆柱体:

在此处输入图片说明

我当前的想法是获取描述对象的顶点列表,并查看它们将占据矩阵中的哪些单元,然后将其标记为被对象占据。

1)这是一个好方法吗?

2)如果是,最简单的模型格式可以用来完成此任务,那么是否有一些标准的高质量库?

谢谢

光谱
  1. create render engine for your model directly to 3D matrix not on screen (Volume rendering)

    either use own soft render or OpenGL + GLSL or whatever...

  2. clear matrix

    with empty color

  3. render your model to matrix

    no CULL_FACE removal, no Z buffer and no PERSPECTIVE projection !!!

  4. fill inside of mesh

    cast ray for each row of the matrix and set as filled all those there are inside. At start of ray voxels are outside and when you hit any filled voxel then it is inside from that point. When you hit any filled voxel again then it is outside from that point and so on ...

In software render the write pixel is like this:

DWORD scr[ys][xs],DWORD zed[ys][xs]; // screen and Z buffers xs,ys is resolution

void setpixel(DWORD x,DWORD y,DWORD z,DWORD color) // x,y,z, are already projected
 {
 if ((x>=0)&&(x<xs)) // cut off out of screen pixels
  if ((y>=0)&&(y<ys))
   if (z<=zed[y][x]) // test Z buffer
    scr[y][x]=color; // write color to pixel
 }

So just change it to this:

DWORD vox[zs][ys][xs]; // voxel buffer (your 3D matrix)

void setpixel(DWORD x,DWORD y,DWORD z,DWORD color) // x,y,z, are already projected
 {
 if ((x>=0)&&(x<xs)) // cut off out of volume pixels
  if ((y>=0)&&(y<ys))
   if ((z>=0)&&(z<zs))
    vox[z][y][x]=color; // write color to voxel
 }

OpenGL中,您可以绘制纹理阵列或使用3D纹理...我不使用DirectX,但我认为也可以在其中实现。这是我的GLSL示例:

本文收集自互联网,转载请注明来源。

如有侵权,请联系[email protected] 删除。

编辑于
0

我来说两句

0条评论
登录后参与评论

相关文章

来自分类Dev

将3D模型离散化为矩阵的最佳方法

来自分类Dev

将3D世界向量转换为模型视图矩阵

来自分类Dev

将3D矩阵与2D矩阵相乘

来自分类Dev

将矩阵转换为3D矩阵

来自分类Dev

ARKit 3D 模型的最佳设置是什么

来自分类Dev

NumPy:将每对2d矩阵乘以两个3d矩阵的有效方法吗?

来自分类Dev

将3D矩阵与2D矩阵相乘得到2D矩阵

来自分类Dev

在Django 1.6中将多个模型序列化为json的最佳方法是什么?

来自分类Dev

将contenteditable字段序列化为JSON对象以保存到模型的最佳方法是什么?

来自分类Dev

将3D矩阵与1D相乘

来自分类Dev

将2D矩阵的Numpy矩阵相乘得到3D矩阵

来自分类Dev

Matlab-将矩阵与3d矩阵的每个矩阵相乘

来自分类Dev

3D模型运动,寻找移动3D模型的更好方法

来自分类Dev

保存和加载3D矩阵的方法

来自分类Dev

在R中保存3D数组的最佳方法

来自分类Dev

C#访问3D结构数组的最佳方法

来自分类Dev

将3D矩阵列表转换为4D矩阵

来自分类Dev

将2d矩阵转换为3d一个热矩阵numpy

来自分类Dev

使用张量流将3D矩阵重塑为2D矩阵

来自分类Dev

如何使用OpenCV C ++将3D矩阵划分为2D矩阵束

来自分类Dev

将3D矩阵转换/重塑为2D矩阵

来自分类Dev

将3D矩阵拆分为多个2D矩阵

来自分类Dev

将2D矩阵的1广播到1-hot 3D矩阵

来自分类Dev

将2个2d矩阵相乘得到3d矩阵

来自分类Dev

将2D稀疏矩阵转换为3D矩阵

来自分类Dev

将4d矩阵转换为3d矩阵R

来自分类Dev

使用张量流将3D矩阵重塑为2D矩阵

来自分类Dev

Matlab将2D矩阵转换为3D矩阵

来自分类Dev

MATLAB:将 2D 矩阵与元胞数组内的 3D 矩阵相乘