在 J2ME M3G 中查找对象

发布于 2024-08-29 01:57:05 字数 260 浏览 5 评论 0原文

我使用 Blender 创建 m3g 文件,然后将它们加载到 java 程序中。
World 中查找对象(Mesh)的最佳方法是什么? (我应该如何“构建”一个世界?)

我应该为每个对象创建单独的类,然后将它们添加到一个 World 对象中,还是应该为 Blender 中的对象分配 ID 并在程序中找到它们通过 ID?
或者将每个对象导出到单独的 M3G 文件?
(或者其他方式?)

I'm using Blender to create m3g files and then I load them in a java program.
Which is the best way to find an object (a Mesh) in the World? (How should I "build" a world?)

Should I create separate classes for every object and then add them to one World object or should I assign IDs to the objects in Blender and find them in the program by ID?
Or export every object to a separate M3G file?
(Or some other way?)

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

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

发布评论

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

评论(1

往日情怀 2024-09-05 01:57:05

Q1.如果您知道网格的ID (MESH_ID),那么:

try {
  Object3D[] roots = Loader.load( "http://www.example.com/scene.m3g" );

  World world = roots[0];
  Mesh mesh = world.find( MESH_ID );
}
catch( Exception e ) {
  // Handle it
}

Q2。加载基本的 World

public class MyCanvas extends Canvas
    Graphics3D g3d;
    World world;
    int currentTime = 0;

    public MyCanvas() {
        g3d = Graphics3D.create();
        Object root[] = Loader.load("world.m3g");
        world = root[0];
    }

    protected void paint(Graphics g) {
        g3d.bindTarget(g);
        world.animate(currentTime);
        currentTime += 50;
        g3d.render(world);
        g3d.releaseTarget();
    }
}

然后使用 API 创建更多对象并将其添加到世界中 API 文档对此进行了深入介绍:

第 3 季度。在 Blender 中分配它们,然后使用 find 方法获取您需要的 Object3D 的确切实例。

Q4。如果您计划重用网格(针对不同的应用程序),请将它们组织到单独的文件中,在应用程序初始化期间单独加载它们,然后将它们插入到世界中。

Q1. If you know the ID of the Mesh (MESH_ID), then:

try {
  Object3D[] roots = Loader.load( "http://www.example.com/scene.m3g" );

  World world = roots[0];
  Mesh mesh = world.find( MESH_ID );
}
catch( Exception e ) {
  // Handle it
}

Q2. Load a basic World:

public class MyCanvas extends Canvas
    Graphics3D g3d;
    World world;
    int currentTime = 0;

    public MyCanvas() {
        g3d = Graphics3D.create();
        Object root[] = Loader.load("world.m3g");
        world = root[0];
    }

    protected void paint(Graphics g) {
        g3d.bindTarget(g);
        world.animate(currentTime);
        currentTime += 50;
        g3d.render(world);
        g3d.releaseTarget();
    }
}

Then use the API to create and add more objects into the world The API documentation covers this in depth:

Q3. Assign them in Blender, then use the find method to get the exact instance of Object3D you need.

Q4. If you plan on reusing meshes (for different applications), organize them into separate files, load them separately during initialization of an application, and then insert them into the world.

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