• R/O
  • HTTP
  • SSH
  • HTTPS

Commit

Tags
No Tags

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

packages/wallpapers/Basic


Commit MetaInfo

Revision0ac0b3f704bedde5c3a117ac68e7cd4956cd73ef (tree)
Time2009-09-13 19:40:04
AuthorRomain Guy <romainguy@andr...>
CommiterRomain Guy

Log Message

Tweak the galaxy and add better support for preview mode.

Change-Id: I3339d8066ec0f20ff12adcd9eedf2186d2ea4b01

Change Summary

Incremental Difference

--- a/res/raw/galaxy.rs
+++ b/res/raw/galaxy.rs
@@ -23,8 +23,8 @@ float angle;
2323 float distance;
2424
2525 void init() {
26- angle = 0.0f;
27- distance = 0.0f;
26+ angle = 37.0f;
27+ distance = 0.55f;
2828 }
2929
3030 void drawSpace(float xOffset, int width, int height) {
@@ -61,7 +61,7 @@ void drawParticles(float xOffset, int width, int height) {
6161
6262 float matrix[16];
6363 matrixLoadTranslate(matrix, 0.0f, 0.0f, 10.0f - 6.0f * distance);
64- matrixScale(matrix, 6.15f, 6.0f, 1.0f);
64+ matrixScale(matrix, 6.6f, 6.0f, 1.0f);
6565 matrixRotate(matrix, angle, 1.0f, 0.5f, 0.0f);
6666 vpLoadModelMatrix(matrix);
6767
@@ -103,9 +103,17 @@ int main(int index) {
103103 drawParticles(x, width, height);
104104 drawLights(x, width, height);
105105
106- if (angle < 68.0f) {
107- angle += 0.4f;
108- distance = angle / 68.0f;
106+ if (State->isPreview == 0) {
107+ if (angle > 0.0f) {
108+ angle -= 0.4f;
109+ distance = angle / 68.0f;
110+ }
111+ } else {
112+ // Unfortunately this cannot happen in init()
113+ // since the State structure instance does not
114+ // exist at this point
115+ angle = 0.0f;
116+ distance = 0.0f;
109117 }
110118
111119 return 1;
--- a/src/com/android/wallpaper/RenderScriptScene.java
+++ b/src/com/android/wallpaper/RenderScriptScene.java
@@ -24,6 +24,7 @@ import android.renderscript.ScriptC;
2424 public abstract class RenderScriptScene {
2525 protected int mWidth;
2626 protected int mHeight;
27+ protected boolean mPreview;
2728 protected Resources mResources;
2829 protected RenderScript mRS;
2930 protected ScriptC mScript;
@@ -33,11 +34,16 @@ public abstract class RenderScriptScene {
3334 mHeight = height;
3435 }
3536
36- public void init(RenderScript rs, Resources res) {
37+ public void init(RenderScript rs, Resources res, boolean isPreview) {
3738 mRS = rs;
3839 mResources = res;
40+ mPreview = isPreview;
3941 mScript = createScript();
4042 }
43+
44+ public boolean isPreview() {
45+ return mPreview;
46+ }
4147
4248 public int getWidth() {
4349 return mWidth;
--- a/src/com/android/wallpaper/RenderScriptWallpaper.java
+++ b/src/com/android/wallpaper/RenderScriptWallpaper.java
@@ -72,7 +72,7 @@ public abstract class RenderScriptWallpaper<T extends RenderScriptScene> extends
7272 super.onSurfaceChanged(holder, format, width, height);
7373 if (mRenderer == null) {
7474 mRenderer = createScene(width, height);
75- mRenderer.init(mRs, getResources());
75+ mRenderer.init(mRs, getResources(), isPreview());
7676 mRenderer.start();
7777 } else {
7878 mRenderer.resize(width, height);
--- a/src/com/android/wallpaper/fall/FallView.java
+++ b/src/com/android/wallpaper/fall/FallView.java
@@ -37,7 +37,7 @@ class FallView extends RSSurfaceView {
3737
3838 RenderScript RS = createRenderScript(false);
3939 mRender = new FallRS(w, h);
40- mRender.init(RS, getResources());
40+ mRender.init(RS, getResources(), false);
4141 mRender.start();
4242 }
4343
--- a/src/com/android/wallpaper/galaxy/GalaxyRS.java
+++ b/src/com/android/wallpaper/galaxy/GalaxyRS.java
@@ -173,6 +173,7 @@ class GalaxyRS extends RenderScriptScene {
173173 public int particlesCount;
174174 public int galaxyRadius;
175175 public float xOffset;
176+ public int isPreview;
176177 }
177178
178179 static class GalaxyParticle {
@@ -184,11 +185,17 @@ class GalaxyRS extends RenderScriptScene {
184185 }
185186
186187 private void createState() {
188+ boolean isPreview = isPreview();
189+
187190 mGalaxyState = new GalaxyState();
188191 mGalaxyState.width = mWidth;
189192 mGalaxyState.height = mHeight;
190193 mGalaxyState.particlesCount = PARTICLES_COUNT;
191194 mGalaxyState.galaxyRadius = GALAXY_RADIUS;
195+ mGalaxyState.isPreview = isPreview ? 1 : 0;
196+ if (isPreview) {
197+ mGalaxyState.xOffset = 0.5f;
198+ }
192199
193200 mStateType = Type.createFromClass(mRS, GalaxyState.class, 1, "GalaxyState");
194201 mState = Allocation.createTyped(mRS, mStateType);
@@ -209,23 +216,29 @@ class GalaxyRS extends RenderScriptScene {
209216
210217 @SuppressWarnings({"PointlessArithmeticExpression"})
211218 private void createParticle(GalaxyParticle gp, int index, float scale) {
212- float d = abs(randomGauss()) * GALAXY_RADIUS / 2.0f + random(-4.0f, 4.0f);
213- float z = randomGauss() * 0.5f * 0.8f * ((GALAXY_RADIUS - d) / (float) GALAXY_RADIUS);
219+ float d = abs(randomGauss()) * GALAXY_RADIUS * 0.5f + random(64.0f);
220+ float id = d / (float) GALAXY_RADIUS;
221+ float z = randomGauss() * 0.4f * (1.0f - id);
214222 float p = -d * ELLIPSE_TWIST;
215223
216- final float nd = d / (float) GALAXY_RADIUS;
217-
218224 int red, green, blue, alpha;
219- if (d < GALAXY_RADIUS / 3.0f) {
220- red = (int) (220 + nd * 35);
225+ if (d < GALAXY_RADIUS * 0.33f) {
226+ red = (int) (220 + id * 35);
221227 green = 220;
222228 blue = 220;
223229 } else {
224230 red = 180;
225231 green = 180;
226- blue = (int) constrain(140 + nd * 115, 140, 255);
232+ blue = (int) constrain(140 + id * 115, 140, 255);
227233 }
228- alpha = (int) (40 + nd * 215);
234+
235+ if (d > GALAXY_RADIUS * 0.15f) {
236+ z *= 0.6f * (1.0f - id);
237+ } else {
238+ z *= 0.72f;
239+ }
240+
241+ alpha = (int) (140 + (1.0f - id) * 115);
229242 int color = red | green << 8 | blue << 16 | alpha << 24;
230243
231244 // Map to the projection coordinates (viewport.x = -1.0 -> 1.0)
--- a/src/com/android/wallpaper/galaxy/GalaxyView.java
+++ b/src/com/android/wallpaper/galaxy/GalaxyView.java
@@ -35,7 +35,7 @@ class GalaxyView extends RSSurfaceView {
3535
3636 RenderScript RS = createRenderScript(false);
3737 GalaxyRS render = new GalaxyRS(w, h);
38- render.init(RS, getResources());
38+ render.init(RS, getResources(), false);
3939 render.setOffset(0.5f, 0.0f, 0, 0);
4040 render.start();
4141 }
--- a/src/com/android/wallpaper/grass/GrassView.java
+++ b/src/com/android/wallpaper/grass/GrassView.java
@@ -35,7 +35,7 @@ class GrassView extends RSSurfaceView {
3535
3636 RenderScript RS = createRenderScript(false);
3737 GrassRS render = new GrassRS(w, h);
38- render.init(RS, getResources());
38+ render.init(RS, getResources(), false);
3939 render.setOffset(0.5f, 0.0f, 0, 0);
4040 render.start();
4141 }