/*
* Copyright (C) 2007 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.android.globaltime;
import java.io.ByteArrayInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.List;
import java.util.Locale;
import java.util.TimeZone;
import javax.microedition.khronos.egl.*;
import javax.microedition.khronos.opengles.*;
import android.app.Activity;
import android.content.Context;
import android.content.res.AssetManager;
import android.graphics.Canvas;
import android.opengl.Object3D;
import android.os.Bundle;
import android.os.Handler;
import android.os.Looper;
import android.os.Message;
import android.os.MessageQueue;
import android.util.Log;
import android.view.KeyEvent;
import android.view.MotionEvent;
import android.view.SurfaceHolder;
import android.view.SurfaceView;
import android.view.animation.AccelerateDecelerateInterpolator;
import android.view.animation.DecelerateInterpolator;
import android.view.animation.Interpolator;
/**
* The main View of the GlobalTime Activity.
*/
class GTView extends SurfaceView implements SurfaceHolder.Callback {
/**
* A TimeZone object used to compute the current UTC time.
*/
private static final TimeZone UTC_TIME_ZONE = TimeZone.getTimeZone("utc");
/**
* The Sun's color is close to that of a 5780K blackbody.
*/
private static final float[] SUNLIGHT_COLOR = {
1.0f, 0.9375f, 0.91015625f, 1.0f
};
/**
* The inclination of the earth relative to the plane of the ecliptic
* is 23.45 degrees.
*/
private static final float EARTH_INCLINATION = 23.45f * Shape.PI / 180.0f;
/** Seconds in a day */
private static final int SECONDS_PER_DAY = 24 * 60 * 60;
/** Flag for the depth test */
private static final boolean PERFORM_DEPTH_TEST= false;
/** Use raw time zone offsets, disregarding "summer time." If false,
* current offsets will be used, which requires a much longer startup time
* in order to sort the city database.
*/
private static final boolean USE_RAW_OFFSETS = true;
/**
* The earth's atmosphere.
*/
private static final Annulus ATMOSPHERE =
new Annulus(0.0f, 0.0f, 1.75f, 0.9f, 1.08f, 0.4f, 0.4f, 0.8f, 0.0f,
0.0f, 0.0f, 0.0f, 1.0f, 50);
/**
* The tesselation of the earth by latitude.
*/
private static final int SPHERE_LATITUDES = 25;
/**
* The tesselation of the earth by longitude.
*/
private static int SPHERE_LONGITUDES = 25;
/**
* A flattened version of the earth. The normals are computed identically
* to those of the round earth, allowing the day/night lighting to be
* applied to the flattened surface.
*/
private static Sphere worldFlat = new LatLongSphere(0.0f, 0.0f, 0.0f, 1.0f,
SPHERE_LATITUDES, SPHERE_LONGITUDES,
0.0f, 360.0f, true, true, false, true);
/**
* The earth.
*/
private Object3D mWorld;
/**
* Geometry of the city lights
*/
private PointCloud mLights;
/**
* True if the activiy has been initialized.
*/
boolean mInitialized = false;
/**
* True if we're in alphabetic entry mode.
*/
private boolean mAlphaKeySet = false;
private EGLContext mEGLContext;
private EGLSurface mEGLSurface;
private EGLDisplay mEGLDisplay;
private EGLConfig mEGLConfig;
GLView mGLView;
// Rotation and tilt of the Earth
private float mRotAngle = 0.0f;
private float mTiltAngle = 0.0f;
// Rotational velocity of the orbiting viewer
private float mRotVelocity = 1.0f;
// Rotation of the flat view
private float mWrapX = 0.0f;
private float mWrapVelocity = 0.0f;
private float mWrapVelocityFactor = 0.01f;
// Toggle switches
private boolean mDisplayAtmosphere = true;
private boolean mDisplayClock = false;
private boolean mClockShowing = false;
private boolean mDisplayLights = false;
private boolean mDisplayWorld = true;
private boolean mDisplayWorldFlat = false;
private boolean mSmoothShading = true;
// City search string
private String mCityName = "";
// List of all cities
private List<City> mClockCities;
// List of cities matching a user-supplied prefix
private List<City> mCityNameMatches = new ArrayList<City>();
private List<City> mCities;
// Start time for clock fade animation
private long mClockFadeTime;
// Interpolator for clock fade animation
private Interpolator mClockSizeInterpolator =
new DecelerateInterpolator(1.0f);
// Index of current clock
private int mCityIndex;
// Current clock
private Clock mClock;
// City-to-city flight animation parameters
private boolean mFlyToCity = false;
private long mCityFlyStartTime;
private float mCityFlightTime;
private float mRotAngleStart, mRotAngleDest;
private float mTiltAngleStart, mTiltAngleDest;
// Interpolator for flight motion animation
private Interpolator mFlyToCityInterpolator =
new AccelerateDecelerateInterpolator();
private static int sNumLights;
private static int[] sLightCoords;
// static Map<Float,int[]> cityCoords = new HashMap<Float,int[]>();
// Arrays for GL calls
private float[] mClipPlaneEquation = new float[4];
private float[] mLightDir = new float[4];
// Calendar for computing the Sun's position
Calendar mSunCal = Calendar.getInstance(UTC_TIME_ZONE);
// Triangles drawn per frame
private int mNumTriangles;
private long startTime;
private static final int MOTION_NONE = 0;
private static final int MOTION_X = 1;
private static final int MOTION_Y = 2;
private static final int MIN_MANHATTAN_DISTANCE = 20;
private static final float ROTATION_FACTOR = 1.0f / 30.0f;
private static final float TILT_FACTOR = 0.35f;
// Touchscreen support
private float mMotionStartX;
private float mMotionStartY;
private float mMotionStartRotVelocity;
private float mMotionStartTiltAngle;
private int mMotionDirection;
public void surfaceCreated(SurfaceHolder holder) {
EGL10 egl = (EGL10)EGLContext.getEGL();
mEGLSurface = egl.eglCreateWindowSurface(mEGLDisplay, mEGLConfig, this, null);
egl.eglMakeCurrent(mEGLDisplay, mEGLSurface, mEGLSurface, mEGLContext);
}
public void surfaceDestroyed(SurfaceHolder holder) {
// nothing to do
}
public void surfaceChanged(SurfaceHolder holder, int format, int w, int h) {
// nothing to do
}
/**
* Set up the view.
*
* @param context the Context
* @param am an AssetManager to retrieve the city database from
*/
public GTView(Context context) {
super(context);
getHolder().addCallback(this);
getHolder().setType(SurfaceHolder.SURFACE_TYPE_GPU);
AssetManager am = context.getAssets();
startTime = System.currentTimeMillis();
EGL10 egl = (EGL10)EGLContext.getEGL();
EGLDisplay dpy = egl.eglGetDisplay(EGL10.EGL_DEFAULT_DISPLAY);
int[] version = new int[2];
egl.eglInitialize(dpy, version);
int[] configSpec = {
EGL10.EGL_DEPTH_SIZE, 16,
EGL10.EGL_NONE
};
EGLConfig[] configs = new EGLConf
没有合适的资源?快使用搜索试试~ 我知道了~
资源推荐
资源详情
资源评论
收起资源包目录
AndroidGlobalTime_0.9.zip (74个子文件)
AndroidGlobalTime
AndroidManifest.xml 666B
src
com
android
globaltime
City.java 7KB
Annulus.java 4KB
PointCloud.java 2KB
.svn
props
all-wcprops 2KB
entries 2KB
text-base
R.java.svn-base 858B
GLView.java.svn-base 30KB
Shape.java.svn-base 9KB
Clock.java.svn-base 11KB
City.java.svn-base 7KB
GlobalTime.java.svn-base 45KB
LatLongSphere.java.svn-base 4KB
Sphere.java.svn-base 951B
Texture.java.svn-base 1KB
PointCloud.java.svn-base 2KB
Annulus.java.svn-base 4KB
format 2B
tmp
props
text-base
prop-base
prop-base
Clock.java 11KB
R.java 858B
Sphere.java 951B
GLView.java 30KB
Texture.java 1KB
Shape.java 9KB
LatLongSphere.java 4KB
GlobalTime.java 45KB
.svn
props
all-wcprops 97B
entries 252B
text-base
format 2B
tmp
props
text-base
prop-base
prop-base
.svn
props
all-wcprops 89B
entries 241B
text-base
format 2B
tmp
props
text-base
prop-base
prop-base
.svn
props
all-wcprops 85B
entries 233B
text-base
format 2B
tmp
props
text-base
prop-base
prop-base
res
values
styles.xml 972B
.svn
props
all-wcprops 322B
entries 495B
text-base
strings.xml.svn-base 724B
styles.xml.svn-base 972B
format 2B
tmp
props
text-base
prop-base
prop-base
strings.xml 724B
layout
global_time.xml 907B
.svn
props
all-wcprops 216B
entries 367B
text-base
global_time.xml.svn-base 907B
format 2B
tmp
props
text-base
prop-base
prop-base
.svn
props
all-wcprops 85B
entries 264B
text-base
format 2B
tmp
props
text-base
prop-base
prop-base
drawable
.svn
props
all-wcprops 228B
entries 383B
text-base
app_global_time.png.svn-base 4KB
format 2B
tmp
props
text-base
prop-base
prop-base
app_global_time.png.svn-base 53B
app_global_time.png 4KB
assets
world.gles 45KB
.svn
props
all-wcprops 640B
entries 937B
text-base
earth.raw.svn-base 256KB
cities_en.dat.svn-base 39KB
lights.dat.svn-base 8KB
tz512.raw.svn-base 256KB
world.gles.svn-base 45KB
format 2B
tmp
props
text-base
prop-base
prop-base
earth.raw.svn-base 53B
cities_en.dat.svn-base 53B
lights.dat.svn-base 53B
tz512.raw.svn-base 53B
world.gles.svn-base 53B
tz512.raw 256KB
cities_en.dat 39KB
lights.dat 8KB
earth.raw 256KB
共 74 条
- 1
huamuggcctt
- 粉丝: 0
- 资源: 1
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- 写入三菱plcD位寄存器的值
- 确保你的操作系统符合Docker的要求 Docker支持的操作系统包括Ubuntu、Debian、CentOS、Fedora和m
- 确保你的操作系统符合Docker的要求 Docker支持的操作系统包括Ubuntu、Debian、CentOS、Fedora和m
- HDMI 虚拟软件欺骗器
- 确保你的操作系统符合Docker的要求 Docker支持的操作系统包括Ubuntu、Debian、CentOS、Fedora和m
- 读取三菱PLC D位寄存器
- HDMI edid 编辑工具
- 要在你的计算机上安装Docker,你可以按照以下步骤进行:
- 要在你的计算机上安装Docker,你可以按照以下步骤进行:
- html加JavaScript进行表单验证
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功
- 1
- 2
- 3
前往页