3D programming on mobile phones-simple creation of 3D cubes (1)
Source: Internet
Author: User
Reference: JSR-184
Tool: Eclipse3.0 + Eclipseme
API: Mobile 3D Graphics API
Simulator: Sony Ericsson
Analysis:
In real life, what we see is a three-dimensional system. What you can see through your eyes is a rich and colorful world. The camera we use can take many beautiful pictures. When taking each image, you can adjust the content of the image based on the distance between the shooting distance.
In a virtual world, you can simulate the real world. To show the virtual world, we need to use a virtual camera to take a picture of the virtual world.
In JSR-184, the virtual World is constructed by the World class. A virtual Camera is a Camera class. The virtual world is displayed on the mobile phone screen by changing the Camera position or angle of view. By default, Camera is in the negative direction toward the Z axis. In the virtual world, all objects are created by the Mesh class. Different Mesh attributes correspond to different objects.
When constructing an object, you must first construct the skeleton (shape) of the object and then mask it to the skeleton with a material. The shape of an object is determined by the normal vectors of a group of points and each point. The material is an image.
Next we will build a cube in another virtual world in the opposite order. The procedure is as follows:
1. Construct a cube
To construct a cube, we need to give each vertex of the cube, specify the normal vector of each vertex, and post the image to the shelf composed of the vertex and the method vector of each vertex.
Each vertex is given in combination with a normal vector. Since the cube is composed of six rectangles, we need to determine these six rectangles. Because one vertex and one normal vector can determine a plane, then four vertices and four normal vectors determine four planes. If the four faces overlap, the four vertices constitute the area of a rectangle. Use this method to determine the six rectangles and then hold the six to form a cube.
To post an image to a cube is to match the vertex on the cube with the vertex on the image. The two can use different units.
Construct a cube
Given the cube vertices:
Short x = 20;
Short y = 20;
Short z = 20;
Short fx = (short)-x;
Short fy = (short)-y;
Short fz = (short)-z;
Short [] vert = {x, y, z, fx, y, z, x, fy, z, fx, fy, z, // D
Fx, y, fz, x, y, fz, fx, fy, fz, x, fy, fz, // C
Fx, y, z, fx, y, fz, fx, fy, z, fx, fy, fz, // B
X, y, fz, x, y, z, x, fy, fz, x, fy, z, // F
X, y, fz, fx, y, fz, x, y, z, fx, y, z, //
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.