如何在 Java 中使用 Blender 模型?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/3532988/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-14 01:36:55  来源:igfitidea点击:

How do I use Blender models in Java?

javagraphicsblender

提问by Garee

Just a general question really?

真的只是一个普遍的问题吗?

Let's say I am making a game and have made a character model in Blender. How would I use this model in Java?

假设我正在制作游戏并在 Blender 中制作了角色模型。我将如何在 Java 中使用这个模型?

Would I import it somehow?

我会以某种方式导入它吗?

Thanks.

谢谢。

回答by dvanaria

There are input/output scripts available for Blender that will help you.

Blender 有一些输入/输出脚本可以帮助你。

Blend2Java, for example, is a set of Python scripts for use with Blender that will export to Java XML, which can be decoded with the standard java.beans.XMLDecoder class.

例如,Blend2Java 是一组与 Blender 一起使用的 Python 脚本,它将导出为 Java XML,可以使用标准 java.beans.XMLDecoder 类对其进行解码。

There's a good overview of how to do this at http://blend2java.sourceforge.net/blend2java-howto.html

http://blend2java.sourceforge.net/blend2java-howto.html 上有一个关于如何做到这一点的很好的概述

回答by dvanaria

Here's a better idea: Use an existing Java 3D library (dzzdI highly recommend) and load in your model using the library's built in functions. Then, instead of just working with the data, you can actually display it. From Blender, it's a simple matter of exporting as 3DS.

这是一个更好的主意:使用现有的 Java 3D 库(我强烈推荐dzzd)并使用库的内置函数加载到您的模型中。然后,您不仅可以处理数据,还可以实际显示它。在 Blender 中,导出为 3DS 是一件简单的事情。

回答by udoprog

Generally when making models in blender you export the model in a format which allows you to later import it in the game engine of your choice, which format you use differ in requirements.

通常,在 Blender 中制作模型时,您以一种格式导出模型,该格式允许您稍后将其导入到您选择的游戏引擎中,您使用的格式因需求而异。

The export-import cycle is often referred to as the "Asset Pipeline", and you generally want to keep it as simple and automated as possible since it is something you or your artists will perform on a regular basis.

导出-导入周期通常被称为“资产管道”,您通常希望使其尽可能简单和自动化,因为您或您的艺术家将定期执行此操作。

So if we look at a few specific graphics engines and platforms;

因此,如果我们查看一些特定的图形引擎和平台;

  • OGRE3D(or Ogre4J) supports it's own plain-text format (.scene, .mesh.xml, .material.xml) in order to load scenes, models and materials. It also has support for armature animations among other things, there is also some support for loading .blend-files directly. See their documentation for blender.
  • JmonkeyEnginehas support for loading both OGRE3D .scene's and .blend's directly. It also has it's own binary j3o format which these can be converted into when you want to package the game. For specific examples, see their tutorials.
  • OGRE3D(或Ogre4J)支持它自己的纯文本格式(.scene、.mesh.xml、.material.xml)以加载场景、模型和材料。它还支持骨架动画等,还支持直接加载 .blend-files。请参阅他们的文档 Blender
  • JmonkeyEngine支持直接加载 OGRE3D .scene 和 .blend。它还具有自己的二进制 j3o 格式,当您要打包游戏时,可以将这些格式转换为这些格式。有关具体示例,请参阅他们的教程

There are multiple formats you can take into consideration when deciding how you want to use your model. When it is imported however, the game engine of choice represents it in an internal structure which usually allows you to be decoupled from the exact format of choice.

在决定如何使用模型时,您可以考虑多种格式。然而,当它被导入时,选择的游戏引擎在一个内部结构中表示它,这通常允许您与选择的确切格式分离。

Picking which to use is and should not be written in stone since requirements might change and if done properly it should not have a considerable effect on the project. This is also something you should take into consideration if you are writing your own engine.

选择使用哪个是不应该一成不变的,因为需求可能会改变,如果做得好,它应该不会对项目产生相当大的影响。如果您正在编写自己的引擎,这也是您应该考虑的事情。

回答by homac

Yet another solution: Java .Blendprovides you with a type-safe Java API to all data in a Blender file. It supports even creating new Blender files from within Java ;)

另一个解决方案:Java .Blend为 Blender 文件中的所有数据提供了类型安全的 Java API。它甚至支持从 Java 中创建新的 Blender 文件;)