3d 如何从水平线网格中形成形状?处理?

3d 如何从水平线网格中形成形状?处理?,3d,processing,3d,Processing,我想知道如何实现类似的效果,如字母“a”的形状出来的水平线网格(见附图)。 有人知道如何找到教程吗?这种技术叫什么?你能处理吗?或者你需要一个3D程序 欢迎任何提示 想象一下在黑色背景上挤出一个模糊的白色形状,如果你愿意的话 在处理过程中,您将循环图像中的每个像素,并将每个像素的坐标映射到z轴(因为您已经有了x,y坐标) 简言之: 加载或创建黑色背景形状的图像,并在将亮度映射到高程时平滑/模糊图像以获得平滑曲线 循环遍历像素并将每个像素的亮度映射到z位置 下面是一个注释过的草图来说明这个想法:

我想知道如何实现类似的效果,如字母“a”的形状出来的水平线网格(见附图)。 有人知道如何找到教程吗?这种技术叫什么?你能处理吗?或者你需要一个3D程序

欢迎任何提示


想象一下在黑色背景上挤出一个模糊的白色形状,如果你愿意的话

在处理过程中,您将循环图像中的每个像素,并将每个像素的坐标映射到z轴(因为您已经有了x,y坐标)

简言之:

  • 加载或创建黑色背景形状的图像,并在将亮度映射到高程时平滑/模糊图像以获得平滑曲线
  • 循环遍历像素并将每个像素的亮度映射到z位置
  • 下面是一个注释过的草图来说明这个想法:

    PGraphics buffer;
    PShape lines;
    
    void setup(){
      size(400,400,P3D);
      smooth(8);
    
      //create a PGraphics buffer to draw an "A" into and then blur it -> could use a loaded PImage
      buffer = createGraphics(400,400);
      buffer.beginDraw();
      buffer.background(0);
      buffer.textSize(270);
      buffer.text("A",110,270);
      buffer.endDraw();
      //add blur (smooth edges = smooth elevation when moving to 3D)
      buffer.filter(BLUR,8);
    
      //setup PShape
      int hSpacing = 1;                //horizontal spacing
      int vSpacing = 9;                //vertical spacing
      float maxHeight = 30;            //maximum height (when brightness is mapped to elevation)             
      int lineStroke = color(255);
    
      float hw = buffer.width * 0.5;   //half width
      float hh = buffer.height * 0.5;  //half height
    
    
      lines = createShape(GROUP);
      //scan image on Y axis (skipping based on vertical spacing)
      for(int y = 0 ; y < buffer.height; y += vSpacing){
        //create a a shape made of lines
        PShape line = createShape();
        line.beginShape(LINES);
        line.stroke(lineStroke);
        line.strokeWeight(3);
        //scan image on X axis
        for(int x = 0; x < buffer.width; x += hSpacing){
          //if we're not at the last pixel
          if(x < buffer.width - 1){
            //calculate the next x position
            int nextX = x+1;
            //calculate the brightness for the current and next pixel
            float currentPixelBrightness = brightness(buffer.get(x,y));
            float nextPixelBrightness    = brightness(buffer.get(nextX,y));
            //map brightness levels to elevation
            float currentZ = map(currentPixelBrightness,0.0,255.0,0,maxHeight);
            float nextZ    = map(nextPixelBrightness,0.0,255.0,0,maxHeight);
            //add a line between the current and next pixel using the calculated elevations, but offseting by half the image's with so the PShape pivot is at the centre
            line.vertex(x - hw,y - hh,currentZ);
            line.vertex(nextX - hw,y - hh,nextZ);
    
          }
        }
        //finish the lines shape and add it to the main PShape
        line.endShape();
        lines.addChild(line);
      } 
    
    }
    void draw(){
      background(0);
      //debug mode - if mouse is pressed just render the 2D image
      if(mousePressed){
        image(buffer,0,0);
        return;
      }
      //otherwise render the 3D image, rotating on X axis based on mouse X position
      translate(width * 0.5,height * 0.5,0);
      rotateX(map(mouseX,0,width,-PI,PI));
      shape(lines,0,0);
    }
    
    PGraphics缓冲区;
    形态线;
    无效设置(){
    尺寸(400400,P3D);
    光滑(8);
    //创建一个PGraphics缓冲区,在其中绘制一个“a”,然后将其模糊->可以使用加载的图像
    缓冲区=createGraphics(400400);
    buffer.beginDraw();
    缓冲区背景(0);
    buffer.textSize(270);
    缓冲区文本(“A”,110270);
    endDraw();
    //添加模糊(平滑边=移动到三维时的平滑高程)
    滤波器(模糊,8);
    //设置形状
    int hSpacing=1;//水平间距
    int vSpacing=9;//垂直间距
    float maxHeight=30;//最大高度(当亮度映射到高程时)
    int lineStroke=color(255);
    float hw=buffer.width*0.5;//半宽
    float hh=buffer.height*0.5;//半高
    lines=createShape(组);
    //在Y轴上扫描图像(根据垂直间距跳过)
    对于(int y=0;y
    有多种方法可以实现这一点。 这只是一种选择。请记住,该代码并没有针对速度进行优化,而是更加冗长,因此更易于理解和调整

    可以自由使用可用的变量和值(如文本大小、模糊量、最大高度、水平和垂直间距等),练习使用(如展开水平线等)……总之,玩得开心

    这证明了你不需要使用3D程序,除非你真的想使用


    如果您想使用,Photoshop Extended有一个3D深度贴图选项,大多数3D编辑器允许您从高度贴图创建网格,您可以将剥离纹理应用到其中。

    想象一下在黑色背景上挤出模糊的白色形状,如果您愿意的话

    在处理过程中,您将循环图像中的每个像素,并将每个像素的坐标映射到z轴(因为您已经有了x,y坐标)

    简言之:

  • 加载或创建黑色背景形状的图像,并在将亮度映射到高程时平滑/模糊图像以获得平滑曲线
  • 循环遍历像素并将每个像素的亮度映射到z位置
  • 下面是一个注释过的草图来说明这个想法:

    PGraphics buffer;
    PShape lines;
    
    void setup(){
      size(400,400,P3D);
      smooth(8);
    
      //create a PGraphics buffer to draw an "A" into and then blur it -> could use a loaded PImage
      buffer = createGraphics(400,400);
      buffer.beginDraw();
      buffer.background(0);
      buffer.textSize(270);
      buffer.text("A",110,270);
      buffer.endDraw();
      //add blur (smooth edges = smooth elevation when moving to 3D)
      buffer.filter(BLUR,8);
    
      //setup PShape
      int hSpacing = 1;                //horizontal spacing
      int vSpacing = 9;                //vertical spacing
      float maxHeight = 30;            //maximum height (when brightness is mapped to elevation)             
      int lineStroke = color(255);
    
      float hw = buffer.width * 0.5;   //half width
      float hh = buffer.height * 0.5;  //half height
    
    
      lines = createShape(GROUP);
      //scan image on Y axis (skipping based on vertical spacing)
      for(int y = 0 ; y < buffer.height; y += vSpacing){
        //create a a shape made of lines
        PShape line = createShape();
        line.beginShape(LINES);
        line.stroke(lineStroke);
        line.strokeWeight(3);
        //scan image on X axis
        for(int x = 0; x < buffer.width; x += hSpacing){
          //if we're not at the last pixel
          if(x < buffer.width - 1){
            //calculate the next x position
            int nextX = x+1;
            //calculate the brightness for the current and next pixel
            float currentPixelBrightness = brightness(buffer.get(x,y));
            float nextPixelBrightness    = brightness(buffer.get(nextX,y));
            //map brightness levels to elevation
            float currentZ = map(currentPixelBrightness,0.0,255.0,0,maxHeight);
            float nextZ    = map(nextPixelBrightness,0.0,255.0,0,maxHeight);
            //add a line between the current and next pixel using the calculated elevations, but offseting by half the image's with so the PShape pivot is at the centre
            line.vertex(x - hw,y - hh,currentZ);
            line.vertex(nextX - hw,y - hh,nextZ);
    
          }
        }
        //finish the lines shape and add it to the main PShape
        line.endShape();
        lines.addChild(line);
      } 
    
    }
    void draw(){
      background(0);
      //debug mode - if mouse is pressed just render the 2D image
      if(mousePressed){
        image(buffer,0,0);
        return;
      }
      //otherwise render the 3D image, rotating on X axis based on mouse X position
      translate(width * 0.5,height * 0.5,0);
      rotateX(map(mouseX,0,width,-PI,PI));
      shape(lines,0,0);
    }
    
    PGraphics缓冲区;
    形态线;
    无效设置(){
    尺寸(400400,P3D);
    光滑(8);
    //创建一个PGraphics缓冲区,在其中绘制一个“a”,然后将其模糊->可以使用加载的图像
    缓冲区=createGraphics(400400);
    buffer.beginDraw();
    缓冲区背景(0);
    buffer.textSize(270);
    缓冲区文本(“A”,110270);
    endDraw();
    //添加模糊(平滑边=移动到三维时的平滑高程)
    滤波器(模糊,8);
    //设置形状
    int hSpacing=1;//水平间距
    int vSpacing=9;//垂直间距
    float maxHeight=30;//最大高度(当亮度映射到高程时)
    int lineStroke=color(255);
    float hw=buffer.width*0.5;//半宽
    float hh=buffer.height*0.5;//半高
    lines=createShape(组);
    //在Y轴上扫描图像(根据垂直间距跳过)
    对于(int y=0;y