gpt4 book ai didi

opengl - 使用 OPENGL 或 P3D 库在 Processing.org 中显示复杂矢量文件的 SVG 替代方案

转载 作者:行者123 更新时间:2023-12-04 05:43:30 24 4
gpt4 key购买 nike

我正在尝试使用 OPENGL 或 P3D 库通过 Processing.org 以 3D 形式显示 SVG 文件。问题,documented here (和其他地方: 12an undesirable library hack ),是这些渲染器不支持复杂的形状(那些有孔或复杂中断的形状)。

是否有图形的 SVG 替代方案,或我可以使用的其他库?

下面是图像文件和代码示例。第一个图像使用默认渲染器:

with default renderer

此图像使用 OPENGL 3D 库。您可以看到它很难重现 SVG 文件。

with OPENGL 3d renderer

I've posted a zip of this sketch with images和下面的代码。取消注释 OPENGL 行并注释默认行以查看问题。

import processing.opengl.*; 

float wh = 0;

void setup() {
//size(600, 600, OPENGL); // use OPENGL
size(600, 600); // use default library
background(255);
smooth();
}

void draw() {
wh = random(40, 200);
PShape s;
String file = "gear" + ceil(random(0, 12)) + ".svg";
s = loadShape(file);
shape(s, random(-20, width), random(-20, height), wh, wh);
}

最佳答案

您可以使用与 OPENGL 渲染器配合良好的几何库。
你可以在那里找到它:
http://www.ricardmarxer.com/geomerative/

这是您提供的适用于 Geomerative 的示例,适用于 OPENGL:

import geomerative.*;
import processing.opengl.*;

float wh = 0;

void setup() {
size(600, 600, OPENGL);
RG.init( this );

background(255);
smooth();
}

void draw() {
wh = random(40, 200);
RShape s;
String file = "gear" + ceil(random(0, 12)) + ".svg";
s = RG.loadShape(file);

pushMatrix();
translate(random(-20, width), random(-20, height));
s.draw();
popMatrix();
}

关于opengl - 使用 OPENGL 或 P3D 库在 Processing.org 中显示复杂矢量文件的 SVG 替代方案,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10982814/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com