使用 VB6 的 3D 软件渲染器

发布于 2024-08-11 04:29:51 字数 257 浏览 2 评论 0原文

我是 IT 学生,我必须用 VB6 制作一个项目,我想制作一个 3D 软件渲染器,但我真的不知道从哪里开始,我找到了一些教程,但我想要一些深入数学的东西和算法,我会喜欢一些能够展示如何进行 3D 变换、相机、灯光、阴影...

使用的编程语言并不重要,我只需要一些资源来准确地展示如何进行此操作。

所以我只是想知道在哪里可以找到一些资源,或者你可以向我展示一些源代码并告诉我从哪里开始。

或者如果你们对 VB6 项目有更好的想法。

谢谢。

I am IT student and I have to make a project in VB6, I was thinking to make a 3D Software Renderer but I don't really know where to start, I found a few tutorials but I want something that goes in depth with the maths and algorithms, I will like something that shows how to make 3D transformations, Camera, lights, shading ...

It does not matter the programing language used, I just need some resources that shows me exactly how to make this.

So I just want to know where to find some resources, or you can show me some source code and tell me where to start from.

Or if any of you have a better idea for a VB6 project.

Thanks.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(8

执笔绘流年 2024-08-18 04:29:51

我不同意之前的帖子,3D 渲染器实际上非常简单。然而,高质量的 3D 渲染器很难。

  1. 获取一堆3D数据,三角形最简单。
  2. 了解齐次坐标和用于变换的出色 4x4 矩阵。
  3. 通过位置和旋转(以 4x4 矩阵表示)定义相机。
  4. 通过此相机变换您的 3D 几何形状。
  5. 对窗口执行透视划分和缩放。这会将您的 3D 数据转换为 2D。
  6. 将数据渲染为 2D。

现在您将失去深度缓冲区,因此一开始就坚持使用线框。 :-)

不要听这些反对者的话,出去玩吧!

I disagree with the previous posts, a 3D renderer is actually pretty simple. A high-quality 3D renderer is hard however.

  1. Get a bunch of 3D data, triangles are simplest.
  2. Learn about homogenous coordinates and the great 4x4 matrix for transforms.
  3. Define a camera by a position and a rotation (expressed in the 4x4 matrix).
  4. Transform your 3D geometry by this camera.
  5. Perform the perspective divide and scale to your window. This converts your 3D data to 2D.
  6. Render the data as 2D.

Now you're going to lose out on a depth buffer, so stick to wireframes in the beginning. :-)

Don't listen to these nay-sayers, go out and have some fun!

二智少女猫性小仙女 2024-08-18 04:29:51

许多年前,我制作了一个阴影三角形渲染器,它使用库调用来绘制三角形。这是一种相当幼稚的方法,但使用 VB6 也可以达到相同的结果。我得到了所有的数学和数学知识。 Foley 等人的《计算机图形原理与实践》中的技术。有些零件现在已经过时了,但我认为您会发现它对这个项目非常有帮助,并且可以例如从亚马逊以合理的价格购买二手的。

一种简单的方法可能是:

  1. 将模型文件作为三角形读取
  2. 使用矩阵变换每个三角形以考虑相机位置
  3. 将三角形点投影到 2D 上
  4. 绘制 2D 三角形(可能是 使用 GDI

这涵盖了线框查看。要将其扩展到隐藏表面去除,您需要计算出哪些三角形在前面。两种可能的方法:

  1. 按 Z 顺序对三角形进行排序并首先绘制距离相机最远的三角形。如果有很多三角形,这很简单,但效率很低,并且当顺序不太正确时可能会产生重叠的三角形效果。您还必须决定如何对三角形进行排序 - 例如按质心、按范围...
  2. 使用软件深度缓冲区。这将带来更好的结果,但实施起来需要更多工作。您必须编写自己的三角形绘制代码,因此不能依赖 GDI。请参阅 bresenham 直线算法 以及用于填充三角形的相关算法,了解如何执行此操作。

之后,您还需要某种基于光照的阴影。计算机图形学原理和实践中涵盖了计算。对于简单的着色,您可以坚持使用 gdi 绘制三角形,但如果您想要进行 gouraud 或 phong 着色,则整个三角形的颜色值会有所不同。解决这个问题的一种方法是将三角形细分为更小的三角形,但这种方法效率低下,并且不会给出非常漂亮的结果。更好的方法是按照上面软件深度缓冲区的要求自己绘制三角形。

一个好的扩展是支持三角形以外的图元。基本方法是在阅读基元时将它们分割成三角形。

祝你好运——可能是一个有趣的项目。

Many years ago I made a shaded triangle renderer that used library calls to draw the triangles. It's a rather naive approach but you would be able to achieve the same result using VB6. I got all the maths & techniques from "Computer Graphics principles and practice" by Foley et al. Some parts are out of date now but I think you'd find it very helpful for this project and it can be bought 2nd hand at reasonable prices from Amazon for example.

One simple approach could be:

  1. Read model file as triangles
  2. Transform each triangle using matrices to account for camera position
  3. Project triangle points onto 2D
  4. Draw 2D triangle (probably using GDI)

This covers wireframe viewing. To extend this to hidden surface removal you need to work out which triangles are in front. Two possible ways:

  1. Z-order sorting the triangles and drawing the ones furthest from the camera first. This is simple but inefficient if there are a lot of triangles and can give overlapping triangle effects when the order is not quite correct. You also have to decide how to sort the triangles - e..g by centroid, by extents...
  2. Using a software depth buffer. This will give better results but is more work to implement. You will have to write your own triangle drawing code so cannot rely on GDI. See bresenham's line algorithm and related algorithms for doing filled triangles for how to do this.

After this you'd also need some kind of shading based on lighting. The calculations are covered in Computer Graphics principles and practice. For simple shading you can stick with drawing triangles using gdi , but if you want to do gouraud or phong shading the colour values vary across a triangle. One way around this is to sub-divide the triangle into smaller triangles, but this is inefficient and won't give very nice looking results. Better would be to draw the triangles yourself as required above for the software depth buffer.

A good extension would be to support primitives other than triangles. Basic approach would be to split primitives into triangles as you read them.

Good luck - could be an interesting project.

灵芸 2024-08-18 04:29:51

VB6 并不是最适合做数学和 3D 图形的语言,并且考虑到您之前也没有关于该主题的知识,我建议您选择不同的(并且更简单的)语言。

因为它是 Visual Basic,所以你可以尝试一些更面向形式的东西,这就是该语言的初衷。

VB6 is not the best suited language to do maths and 3D graphics, and given that you have no previous knowledge about the subject either, I would recommend you to choose something different (and easier).

As it's Visual Basic, you could try something more form-oriented, that is the original intent of the language.

披肩女神 2024-08-18 04:29:51

3D 引擎列表,其中列出了三个纯基本引擎(矛盾修饰法)+源代码及其其中一种是 Visual Basic (Dex3D)

DeX3D是一个开源3D引擎
完全用 Visual Basic 编码
Jerry Chen([电子邮件受保护])。

  • Gouraud 阴影
  • 透明度
  • 起雾
  • 泛光灯和聚光灯
  • 分层网格
  • 支持 3D Studio 文件
  • 粒子系统
  • 贝塞尔曲线段
  • 2.5D 文本
  • Visual Basic 源代码

更多信息、屏幕截图和
源码可以在Dex3D上找到
主页。 (<= 无效链接)

There is the 3D engine list which lists three engine in pure basic (an oxymoron) + Source code and of them one is in Visual Basic (Dex3D)

DeX3D is an open source 3D engine
coded entirely in Visual Basic from
Jerry Chen ( [email protected] ).

  • Gouraud shading
  • Transparency
  • Fogging
  • Omni and spot lights
  • Hierarchical meshes
  • Support for 3D Studio files
  • Particle systems
  • Bezier curve segments
  • 2.5 D text
  • Visual Basic source

More information, screenshots and the
source can be found on the Dex3D
Homepage. (<= Dead Link)

森末i 2024-08-18 04:29:51

EGL25 作者:Erkan Sanli是一个快速开源 VB 6 渲染器,可以渲染、旋转、动画等由数千个多边形组成的复杂实体形状。只是 Windows API 调用 – 没有 DirectX,没有 OpenGL。

替代文本

VBMigration.com 选择 EGL25 作为高质量的开放式源VB6项目来演示他们的VB6到VB.Net的升级工具。

EGL25 by Erkan Sanli is a fast open source VB 6 renderer that can render, rotate, animate, etc. complex solid shapes made of thousands of polygons. Just Windows API calls – no DirectX, no OpenGL.

alt text

VBMigration.com chose EGL25 as a high-quality open-source VB6 project to demonstrate their VB6 to VB.Net upgrade tool.

倾听心声的旋律 2024-08-18 04:29:51

如果您以前从未使用过,那么 3D 软件渲染器作为整个项目是相当复杂的。我建议做一些更小的事情——比如只做 3D 部分并使用线条进行渲染,或者只编写一个阴影三角形渲染器(无论如何,这是 3D 渲染器的基础)。

比一开始就尝试编写成熟的 3D 软件渲染器更简单一些 - 尤其是在 VB 中。

A 3D software renderer as a whole project is fairly complex if you've never done it before. I would suggest something smaller - like just doing the 3D portion and using lines to do the rendering OR just write a shaded triangle renderer (which is the underpinnings of 3D renderers anyway).

Something a little simpler rather than trying to write a full-blown 3D software renderer on the first go - especially in VB.

旧时浪漫 2024-08-18 04:29:51

软件渲染器是一个非常困难的项目,并且根本没有指出 VB6 语言(对于像这样的任务,c++ 就是这样。),无论如何,我可以向您推荐一些我使用过的好书:

  1. Shaders:http://wiki.gamedev.net/index.php/D3DBook:Introduction_%28Volume%29< /a>
  2. 数学:图形和游戏开发的 3D 数学入门

还有其他2本书。即使它们适用于 VB.NET,您也可以找到一些有用的代码:

  1. .NET 游戏编程DirectX 9.0
  2. 开始在 VB .NET 中进行 .NET 游戏编程

A software renderer is a very difficult project and the language VB6 is not indicated at all ( for a task like this c++ is the way.. ), anyway I can suggest you some great books I used:

  1. Shaders: http://wiki.gamedev.net/index.php/D3DBook:Introduction_%28Volume%29
  2. Math: 3D Math Primer for Graphics and Game Development

There are other 2 books. Even if they are for VB.NET you can find some useful code:

  1. .NET Game Programming with DirectX 9.0
  2. Beginning .NET Game Programming in VB .NET
゛清羽墨安 2024-08-18 04:29:51

我认为您可以采取两种方法,要么采用 Direct X 方式,要么使用支持 VB 5-6 的 DirectX 8。我找到了一个页面 http://www.gamedev.net/reference/articles/article1308。 asp

你总是可以编写一个引擎组,但是这样做你将需要一些基本的线性代数,就像 Frank Krueger 所建议的那样。

I think you can take two ways either go the Direct X way and use DirectX 8 that has VB 5-6 support. I found a page http://www.gamedev.net/reference/articles/article1308.asp

You can always write a engine group up but by doing so you will need some basic linear algebra like Frank Krueger suggests.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文