In real life, what we see is a 3-dimensional system. Through the eyes, can see is a rich and colorful world. We use the camera, can take a lot of beautiful pictures. When you shoot each picture, you can adjust the content on the screen according to the distance between the shots.
In a virtual world, you can simulate the real world. To show the virtual world, you need to use a virtual camera, the virtual world to shoot out.
In the JSR-184, the virtual world is constructed by the worlds class. The virtual camera is the camera class. The virtual world is displayed on the mobile screen by changing the camera position or angle of view. Camera default is a negative direction toward the z-axis. In the virtual world, each object is created by the mesh class. Different mesh properties correspond to different objects.
When constructing an object, the skeleton (i.e. the shape) of the object is first constructed, and then a material is used to cover the skeleton. The shape of an object is determined by a set of points and by the normal vector of each point. The material is the picture.
Next, build a cube in a virtual world, in the opposite order. The steps are as follows:
1 Structural cubes
Constructing a cube needs to give each vertex of the cube, then specify the normal vector of each vertex, and finally post the picture to a shelf composed of vertices and the normal vectors of each point.
Each vertex is given in conjunction with the normal vector. Since the cube is made up of 6 rectangles, it is necessary to determine the 6 rectangles. Since a single point and a normal vector are able to determine a plane, then 4 vertices and 4 normal vectors determine 4 faces. If these 4 faces overlap, the 4 vertices form a rectangular region. Use this method to determine 6 rectangles, and then use these 6 to form a cube.
To paste the picture into the cube is to correspond the vertices on the cube to the points on the picture. The two can be in different units.
Build a cube below
Give the vertices of the cube:
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,//a
X,fy,z, Fx,fy,z, X,FY,FZ, FX,FY,FZ}; E
Vertexarray Vertarray = new Vertexarray (VERT.LENGTH/3, 3, 2);
Vertarray.set (0, VERT.LENGTH/3, vert);
gives the normal vectors of the vertices of the cube:
Consciousness rotates the cube 1 degrees in a vector (1,0,0) direction (that is, an X axis).
So far, is to build a virtual world, and put a cube of steps. The code above is intercepted from a complete program and may not be easily understood in some places. The complete code will be attached later.
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.