J2_3d programming-the first 3D Program

Source: Internet
Author: User

J2_3d programming-the first 3D Program (with source code)
For more articles visit: http://blog.csdn.net/mailbomb
Refer to the demo provided by WTK2.2 and complete the first 3D program. Although it is very simple and some problems are not very clear, we still need to share the Code with our friends who are willing to learn the 3D programming of j2s.
For more information about 3D programming, see my blog.
Code compilation and running are described as follows:
1. the following code is compiled under j2-wtk2.2.
2. The code is divided into two files: First3DCanvas. java and First3DMIDlet. java.
3. Use j2-wtk2.2 to create a new project. The main MIDlet class is first3d. First3DMIDlet.
4. Save the code to the first3d directory under your project directory.
5. Install
Copy the swerve. m3g file in the includemo3descomsuperscapem3gwtksamplesetainedmodecontent directory to the res directory under your project directory.
6. After your project is created, set the project and open the setting window through the "Settings" button on the WTK interface. In "API selection", set "Target Platform" to "Custom; "Profile" is "MIDP2.0", "configuration" is "CLDC1.1", and "Mobile 3D Graphics for j2r184" is selected )".
7. You can compile and run the following code.
The source code is as follows:
// First3DMIDlet. java
Package first3d;
Import javax. microedition. midlet .*;
Import javax. microedition. lcdui .*;
Public class First3DMIDlet extends MIDlet {
Private First3DCanvas displayable = new First3DCanvas ();
Public void startApp (){
Display. getDisplay (this). setCurrent (displayable );
}
Public void pauseApp (){}
Public void destroyApp (boolean unconditional ){}
}
// First3Dcanvas. java
Package first3d;
Import javax. microedition. lcdui .*;
Import javax. microedition. m3g .*;
Import java. util .*;
/**
* The first 3D Program
*/
Public class First3DCanvas
Extends Canvas
Implements Runnable {
/** World object */
Private World myWorld = null;
/** Graphics3D object */
Private Graphics3D g3d = Graphics3D. getInstance ();
/** Camera object */
Private Camera cam = null;
Private int viewport_x;
Private int viewport_y;

Related Article

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.