• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2007 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 package com.android.globaltime;
18 
19 import javax.microedition.khronos.opengles.GL10;
20 
21 /**
22  * A class representing a set of GL_POINT objects.  GlobalTime uses this class
23  * to draw city lights on the night side of the earth.
24  */
25 public class PointCloud extends Shape {
26 
27     /**
28      * Constructs a PointCloud with a point at each of the given vertex
29      * (x, y, z) positions.
30      * @param vertices an array of (x, y, z) positions given in fixed-point.
31      */
PointCloud(int[] vertices)32     public PointCloud(int[] vertices) {
33         this(vertices, 0, vertices.length);
34     }
35 
36     /**
37      * Constructs a PointCloud with a point at each of the given vertex
38      * (x, y, z) positions.
39      * @param vertices an array of (x, y, z) positions given in fixed-point.
40      * @param off the starting offset of the vertices array
41      * @param len the number of elements of the vertices array to use
42      */
PointCloud(int[] vertices, int off, int len)43     public PointCloud(int[] vertices, int off, int len) {
44         super(GL10.GL_POINTS, GL10.GL_UNSIGNED_SHORT,
45               false, false, false);
46 
47         int numPoints = len / 3;
48         short[] indices = new short[numPoints];
49         for (int i = 0; i < numPoints; i++) {
50             indices[i] = (short)i;
51         }
52 
53         allocateBuffers(vertices, null, null, null, indices);
54         this.mNumIndices = mIndexBuffer.capacity();
55     }
56 
getNumTriangles()57     @Override public int getNumTriangles() {
58         return mNumIndices * 2;
59     }
60 }
61