简体   繁体   English

Java 3D对象管理设计

[英]Java 3D object management design

LS LS

For a small project I am creating a mincraft like 3D environment with a little more details. 对于一个小项目,我正在创建一个类似3D环境的迷你技术,并提供更多细节。 But one thing I noticed is that dynamic object creation has a heavy impact on the performance. 但有一点我注意到,动态对象创建对性能有很大影响。 So I was wondering, how does other games of 3D apps do this? 所以我想知道,3D应用程序的其他游戏如何做到这一点?

I was thinking about create all the objects before the app starts, but I soon discovered that this has a huge memory impact. 我在考虑在应用程序启动之前创建所有对象,但我很快就发现这会对内存造成巨大影响。 Are there other technics, like deep cloning or should I build an object warehouse to reuse? 是否有其他技术,如深度克隆或我应该构建一个对象仓库来重用? Or are the other ways I did think about? 还是我想到的其他方式?

I'm curious how this is done. 我很好奇这是怎么做到的。

Re-use the objects as much as possible. 尽可能重复使用对象。 Render only the parts that are necessary and don't store any objects that you think might be used for future rendering. 仅渲染必要的零件,不存储您认为可能用于将来渲染的任何对象。

Use images where ever you can to replace custom shape objects/models. 尽可能使用图像来替换自定义形状对象/模型。 Images and axes transformations are your best buddies. 图像和轴转换是您最好的伙伴。 Serialize the objects if you think is necessary but it will affect the performance. 如果您认为有必要,则序列化对象但会影响性能。 Scene Graph branches must be reused if the relative position remains unchanged. 如果相对位置保持不变,则必须重复使用场景图分支。 You can always trade off load time for a good game play performance. 您可以随时交换加载时间以获得良好的游戏性能。

For reference see, performance guide on Java 3D . 有关参考,请参阅Java 3D性能指南。 Some tips from there you can apply in general and are not just specific to Java 3D. 从那里你可以应用一些技巧,而不仅仅是Java 3D。

I followed the advice. 我听从了建议。 And build a kind of object storage to reuse graphical objects. 并构建一种对象存储来重用图形对象。 That seems to give it a better performance. 这似乎给它带来了更好的表现。 To increase the perfomance I build some logic to limit the collision objects to objects nearby. 为了提高性能,我构建了一些逻辑来将碰撞对象限制在附近的对象上。 Using images however is stil a little difficult in a minecraft like world. 然而,在像世界这样的世界中,使用图像仍然有点困难。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM