Developing the retention mode of mobile 3D games for J2ME

Source: Internet
Author: User

Today, 3D Graphics are almost a key part of any game, and even some applications have succeeded by describing information in 3D form. As mentioned earlier, it is slow and complex to build all 3D objects in both immediate and manual encoding. All corner points of a polygon in an application must be encoded independently in the array. In JSR 184, this is called immediate mode.

Another, more advanced pattern is called retention mode, which allows designers to design scene diagrams using a three-dimensional modeling software such as 3D Max Studio, and then apply them to programs.

One, 3D editor

Today, the most popular commercial animation software should be 3D Studio Max, which supports the output model or scene map to the m3g format (the file format specified in JSR 184). The file format is specifically designed to apply to the specific needs of mobile devices. However, 3D Studio Max is very expensive, and even if it is a good tool, it may not be suitable for anyone.

Superscape Company has its own swerve product family (Swerve Studio,swerve client,swerve Content) to help software developers develop 3D Java and native applications. Unfortunately, swerve Studio is only suitable for a limited number of developers who are very familiar with Superscape.

There is also a free tool to choose from: Blender. Blender is an open source 3D modeling tool, but it's quite powerful. You can use blender for any 3D design-from simple styling to full animation. Although there is no output tool to output the blender model to the m3g file, there may soon be some tools available (because blender is open source).

Third, modeling

How do I use m3g files in a MIDP application? First, you need a m3g file that already has some kind of 3D model. You can use Google engine to quickly find out, or you can use the Wirelesstoolkit 2.2 (under the Demo3d folder) development package with the release of ready-made files. In this article, we will make deep modifications to Sun's Pogoroo routines (simplified). We don't let it move or do anything fancy, but just show the objects on the screen.

Iv. Loading World

First, you want to load the world from the M3d file. In the pogoroo.m3g file, you will see a kangaroo jumping on a single spring stilt pole with a green side. The following list 1 invokes method load () for the loader class.

Listing 1. Load the World

try {
//从M3D文件中加载World
myWorld = (World)Loader.load("/pogoroo.m3g")[0];
getObjects();
setupAspectRatio();
}
catch(Exception e) {
e.printStackTrace();
}

V. Acquiring objects from the 3D world

The 3D world has already been loaded, and now you have to get each object from it (see Listing 2). Here, there are four objects in the 3D world, one of which is information about animations (kangaroos jumping on one foot). You can use the world's Find () method to get these objects.

Listing 2. Getting objects from 3D world

try {
tRoo = (Group) myWorld.find(POGOROO);
tCams = (Group) myWorld.find(CAMERA);
acRoo = (Group) myWorld.find(TRANSFORM);
animRoo = (AnimationController) myWorld.find(ROO);
//取得动画的长度
AnimationTrack track = acRoo.getAnimationTrack(0);
animLength = 1000; // 缺省长度为1秒
if (track != null) {
  KeyframeSequence ks = track.getKeyframeSequence();
  if (ks != null) animLength = ks.getDuration();
}
}
catch(Exception e) {
e.printStackTrace();
}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.