在 Java 游戏上轻松从 2D 移植到 3D

发布于 2024-07-11 15:17:30 字数 328 浏览 6 评论 0原文

由于缺乏资金和时间,我们不得不以 2D 方式制作游戏,尽管我(开发者)更喜欢以 3D 方式制作游戏。 我不希望用户加入游戏后,只是觉得图形看起来很糟糕,然后就离开了。 尽管我想我们只需要尽力而为。

话虽这么说,我希望以这样的方式开发游戏,如果时机成熟,我们可以尽可能轻松地移植到 3D。 我知道有些游戏必须从头开始重写整个内容。 我不想这样做,所以我想要一些在游戏编程时使用的技巧/指南,这样,当我们转向 3D 时,它就像更改 1-5 个图形渲染类的代码一样简单(或关闭)并且 3D 图形将运行。

PS 这是一款多人角色扮演游戏(不是 MMORPG,目前范围要小得多)

Due to lack of capital and time we are having to do our game in 2D even though me (the developer) would prefer if it was done in 3D. I would hate for users to join the game, only to think the graphics look bad and leave. Though I suppose we just have to try and do our best.

That being said, I would like to develop the game in such a way that, should the time come, we can port to 3D as easily as possible. I know of games that had to rewrite the entire thing from scratch. I'd hate to do that, so I'd like some tips / guidelines to use when programming the game so that, when we move to 3D, it will be as simple as changing the code of 1-5 graphics rendering classes (or close) and the 3D graphics would run.

P.S It is a multiplayer roleplaying game (Not an MMORPG, much smaller in scope for now)

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

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

发布评论

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

评论(4

伴梦长久 2024-07-18 15:17:30

实现此目的的最简单方法是以 3D 形式编写游戏,并使用 3D 到 2D 投影(例如平面图或立面图)渲染视图。 如果游戏的内部机制是 2D,并且您尝试转向真正的 3D 框架,那么重写可能会更好。 它还在一定程度上取决于 3D 的含义,以及您是否有有效的映射选项。 例如,微软的《帝国时代》以 3D 形式呈现,但作为 2D 计划也能完美运行。 另一方面,《半条命》或《雷神之锤》等第一人称射击游戏则不会。

The simplest way to achieve this is to write the game in 3D, and render the views using a 3d to 2d projection, e.g. in plan or elevation. If the games internal mechanics are 2D and you try to move to a true 3d frame, you would probably better off with a rewrite. It also depends to an extent on what you mean by 3D, and whether you have an effective mapping option. For example, Microsofts Age of Empires is rendered in 3D, but would work perfectly well as a 2D plan. A first person shooter such as Half Life or Quake on the other hand would not.

魄砕の薆 2024-07-18 15:17:30

由于缺乏资金和时间,我们
甚至必须以 2D 方式进行游戏
虽然我(开发者)更喜欢
如果它是用 3D 完成的。 我会讨厌
用户加入游戏,只为思考
图形看起来很糟糕并离开。
虽然我想我们只需要尝试
并尽力而为。

我不认为所有东西都必须是 3D 才好看。 做得好的 2D 看起来比一些标准 3D 图形好很多倍。 要获得出色的 3D 图形,您必须投入大量精力。 如果你的预算不允许这样做,我宁愿尝试在游戏开发上投入大量精力。

想想(有点过时的)《暗黑破坏神 II》,它不是 3D,但仍然有一些漂亮的图形。

当然可以构建一个可以更轻松地更改图形表示的架构,但我认为它几乎永远不会像您描述的那么简单。 当然,如果您只是为了 3D 而想要 3D,那么也可以实现(您现在渲染 3D 模型而不是位图),但这有点毫无意义。 如果你想使用 3D,玩家应该能够利用它(例如通过移动相机,拥有更多的自由度,...),但这必须在游戏的整个设计中考虑,因此必须认真对待影响游戏玩法。

Due to lack of capital and time we are
having to do our game in 2D even
though me (the developer) would prefer
if it was done in 3D. I would hate for
users to join the game, only to think
the graphics look bad and leave.
Though I suppose we just have to try
and do our best.

I don't think everything has to be 3D to look good. Well done 2D can look many times better than some standard 3D graphics. To have great 3D graphics you have to invest some serious effort. If your budget doesn't allow for this, I would rather try to put a lot effort into gameplay development.

Just think of (somewhat dated) Diablo II which is not 3D but still has some nice and good looking graphics.

It is certainly possible to build an architecture which could make it easier to change the graphical representation, but I think it will almost never be as simple as you described. Of course, if you just want 3D for the sake of 3D it could be done (instead of bitmaps you now render 3D models) but this is somewhat pointless. If you want to use 3D the player should be able to make use of it (e.g. by moving the camera, having more degrees of freedom, ...) but this would have to be considered in the whole design of the game and thus seriously affects gameplay.

策马西风 2024-07-18 15:17:30

您可以使用 GL 正交视图。 这将允许您仅使用 2D 坐标在屏幕上绘图,如果稍后需要 3D,请从正交视图切换到透视视图,并且您拥有 3D,但是我认为这不会帮助您重用代码,因为 2D 正交视图通常是通过纹理完成的,并且您无法将纹理转换为 3D 网格。

也许更好的方法是在 3D 中完成所有操作,并将相机设置为从上方观看,如果稍后这样做,您可以通过重新定位相机并制作更好的模型和纹理来切换到 3D。 此选项听起来更好,但可以让您在 2D 到 3D 可移植性之间进行更多工作,而无需更改代码。

You can use the GL ortho view. This will allow you to draw on screen using only 2D coordinates, if you want 3D later on, switch from Ortho to Perspective view and you have 3D, however i don't think it will help you reuse the code, since the 2D ortho view is usually done with textures, and you cannot transform a texture to a 3D mesh.

Maybe a better approach is to do everything in 3D, and setup your camera to look from above, if you do that later you can switch to 3D just by relocating the camera and making better models and textures. This options sounds nicer but gives you more work with the trade-off 2D to 3D portability without code changes.

世态炎凉 2024-07-18 15:17:30

MVC 模式应该会有所帮助。

我想您已经知道了,但是您看过 Java3D ? 也许拥有一个基于此的可替换的 3D 渲染视图(但不一定是经过打磨和生产准备的)会让你保持诚实,这样你就不会以某种可怕的方式与 2D 联系在一起。 它可以像渲染 2D 内容一样简单,并添加一些 Z 定位。

An MVC pattern should help.

And I guess you're aware already, but have you looked at Java3D? Perhaps having a plug replaceable 3D rendering view based on that (but which is not necessarily polished and production ready) will keep you honest so that you don't wind up tied to 2D in some horrible way. It could be as simple as rendering your 2D stuff with some Z positioning added.

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