从游戏模型获取图像
所以我不是 100% 确定是否可能,但我想做的是采用某人为游戏创建的模型,例如 Blender 或类似的东西,以各种格式,然后创建一个图像以在网站上显示。
是否有任何 Java 库可以帮助我解决这个问题?也许是Java3D?或者甚至是 Flash 中的东西?理想情况下,您可以在某些嵌入式 Flash 应用程序中旋转模型,但我会选择普通的旧图像。
So I'm not 100% sure if it's possible, but what I'd like to do is take a model that someone has created for a game, say in Blender or something similar, in various formats, and from that create an image to show on a website.
Are there any Java libraries around that could help me with that? Java3D maybe? Or even something in Flash? Ideally you'd be able to rotate the model in some embedded flash app, but I'd settle for a plain old image.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
这取决于您想走多远。大多数模型都采用标准格式,或者可以轻松转换为标准格式,并且大多数 3D API 都能够加载这些格式。
在服务器上执行此操作有点不寻常 - 您甚至可能需要OpenGL 安装在其上 - 但将模型加载到 3D 环境中并轻松拍摄快照或一系列快照应该非常容易。甚至可能使用它们来创建围绕模型完整旋转的短片。如果您使用 Java,请查看 http://www.javagaming 上人们正在做的一些事情.org/ - 我不知道 Java3D 是否仍在使用,但周围还有其他良好的 3D java 环境。上次我探索该领域时,JMonkeyEngine 看起来最有趣。
或者,您可能可以设置一种将模型加载到客户端环境中的方法 - 我不知道 Flash 现在是否可以执行 3D 功能,但 Shockwave 当然可以(尽管使用起来很糟糕),而且我相信 Silverlight 的功能也同样如此。当然,除非您预先生成动画,否则您可能会将模型传递到客户端上的显示逻辑,并且精明的用户可以拦截该模型,但风险可能相当低,从您的问题来看,尚不清楚这是否会是一个给你带来问题。
It depends on how far you want to go. Most models are going to be in a standard format- or can easily be converted to be - and most 3D Apis are able to load these formats in.
It would be a little unusual to do this on a server - you may even need to have OpenGL installed on it - but it should be quite easy to load a model in to a 3D environment and take a snapshot or a series of snapshots quite easily. Possibly even use these to create a short video clip of a complete turn around the model. If you're using Java take a look at some of the things people are working on over at http://www.javagaming.org/ - I don't know that Java3D is in use much still but there are other good 3D java environments around. JMonkeyEngine looked most interesting last time I was exploring that area.
Alternatively you probably can set up a way of loading the model into a clientside environment - I don't know if Flash can do 3D stuff now, but Shockwave certainly can ( although it's horrible to work with ) and I believe the Silverlight stuff likewise. Of course unless you are pregenerating your animations you are likely to be passing the model to your display logic on the client and a savvy user could intercept that, but the risk is probably reasonably low and from your question it's not clear whether that would be a problem to you.
看看这篇文章:
http://techblog.floorplanner.com/2010/01/25/introducing -asblender/
“进入 ASBlender,这是我在几天内拼凑而成的一个库,用于读取 Blender 的 .blend 文件格式并将其解析为 AS3。”
幸运的你! ;)
编辑:添加了该项目的链接:
http://github.com/timknip/asblender
编辑2:使用asblender库,您可以直接解析.blend 文件(这是工作文件,而不是导出的文件格式)。一旦您在 Flash 应用程序中拥有该文件,您就可以使用 Papervision(我相信您对其他 3D 库也做了同样的事情)来渲染模型,这样您就可以制作模型的单个图像,也可以让用户查看模型旋转。请注意,任何此类库都无法提供与 Blender 等 3D 应用程序相同的渲染质量。该库的优点是能够读取场景中的所有信息,因此您可以将相机和灯光匹配为尽可能接近原始 .blend 文件。
另外还有其他解析器,如 Ase、Collada、DAE、KMZ、Max3DS、MD2、Sketchup、SketchupCollada...所有这些都位于 papervision 库中。
Take a look into this post:
http://techblog.floorplanner.com/2010/01/25/introducing-asblender/
"Enter ASBlender, a library I slapped together in a few days to read Blender’s .blend file format and parse it to AS3."
lucky you! ;)
EDIT: added link for the project:
http://github.com/timknip/asblender
EDIT2: With the asblender library you can parse directly the .blend file (this is the working file, not a exported file format). Once you have the file inside the flash application you can use Papervision (I believe you do the same with other 3d libraries) to render the model, this way you can do a single image of the model or you can let user to see the model rotating. Beware that any of this libraries won't give the same render quality that a 3D application like blender is capable of. The good thing about this library is the capability of reading all the info in the scene, so you can match cameras and lights to be as close as possible to the original .blend file.
Alternatively there are also other parsers like Ase, Collada , DAE, KMZ, Max3DS, MD2, Sketchup, SketchupCollada... all of this inside papervision library.