Merge change 21750 into eclair
* changes: Tweak the galaxy
This commit is contained in:
Binary file not shown.
|
Before Width: | Height: | Size: 657 B After Width: | Height: | Size: 413 B |
@@ -30,7 +30,7 @@
|
|||||||
|
|
||||||
#define PARTICLES_TEXTURES_COUNT 2
|
#define PARTICLES_TEXTURES_COUNT 2
|
||||||
|
|
||||||
#define ELLIPSE_RATIO 0.86f
|
#define ELLIPSE_RATIO 0.892f
|
||||||
#define ELLIPSE_TWIST 0.02333333333f
|
#define ELLIPSE_TWIST 0.02333333333f
|
||||||
|
|
||||||
void drawSpace(int width, int height) {
|
void drawSpace(int width, int height) {
|
||||||
@@ -47,15 +47,18 @@ void drawSpace(int width, int height) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void drawLights(int width, int height) {
|
void drawLights(int width, int height) {
|
||||||
float x = (width - 512.0f) / 2.0f;
|
float x = (width - 512.0f) * 0.5f;
|
||||||
float y = (height - 512.0f) / 2.0f;
|
float y = (height - 512.0f) * 0.5f;
|
||||||
|
|
||||||
|
// increase the size of the texture by 5% on each side
|
||||||
|
x -= 512.0f * 0.05f;
|
||||||
|
|
||||||
bindProgramFragment(NAMED_PFBackground);
|
bindProgramFragment(NAMED_PFBackground);
|
||||||
bindTexture(NAMED_PFBackground, 0, NAMED_TLight1);
|
bindTexture(NAMED_PFBackground, 0, NAMED_TLight1);
|
||||||
drawQuad(x + 512.0f, y , 0.0f,
|
drawQuad(x + 512.0f * 1.1f, y , 0.0f,
|
||||||
x , y , 0.0f,
|
x , y , 0.0f,
|
||||||
x , y + 512.0f, 0.0f,
|
x , y + 512.0f, 0.0f,
|
||||||
x + 512.0f, y + 512.0f, 0.0f);
|
x + 512.0f * 1.1f, y + 512.0f, 0.0f);
|
||||||
}
|
}
|
||||||
|
|
||||||
void drawParticle(float *particle, int index, float *particleBuffer, int bufferIndex,
|
void drawParticle(float *particle, int index, float *particleBuffer, int bufferIndex,
|
||||||
@@ -67,11 +70,11 @@ void drawParticle(float *particle, int index, float *particleBuffer, int bufferI
|
|||||||
float r = particle[index + PARTICLE_STRUCT_RADIUS];
|
float r = particle[index + PARTICLE_STRUCT_RADIUS];
|
||||||
|
|
||||||
float a = angle + speed;
|
float a = angle + speed;
|
||||||
float x = distance * sinf(a);
|
float x = distance * sinf_fast(a);
|
||||||
float y = distance * cosf(a) * ELLIPSE_RATIO;
|
float y = distance * cosf_fast(a) * ELLIPSE_RATIO;
|
||||||
float z = distance * ELLIPSE_TWIST;
|
float z = distance * ELLIPSE_TWIST;
|
||||||
float s = cosf(z);
|
float s = cosf_fast(z);
|
||||||
float t = sinf(z);
|
float t = sinf_fast(z);
|
||||||
|
|
||||||
float sX = t * x + s * y + w;
|
float sX = t * x + s * y + w;
|
||||||
float sY = s * x - t * y + h;
|
float sY = s * x - t * y + h;
|
||||||
@@ -87,7 +90,7 @@ void drawParticle(float *particle, int index, float *particleBuffer, int bufferI
|
|||||||
|
|
||||||
// upper middle vertex of the particle's triangle
|
// upper middle vertex of the particle's triangle
|
||||||
bufferIndex += PARTICLE_BUFFER_COMPONENTS_COUNT;
|
bufferIndex += PARTICLE_BUFFER_COMPONENTS_COUNT;
|
||||||
particleBuffer[bufferIndex + 1] = sX; // X
|
particleBuffer[bufferIndex + 1] = sX; // X
|
||||||
particleBuffer[bufferIndex + 2] = sY - r; // Y
|
particleBuffer[bufferIndex + 2] = sY - r; // Y
|
||||||
|
|
||||||
particle[index + PARTICLE_STRUCT_ANGLE] = a;
|
particle[index + PARTICLE_STRUCT_ANGLE] = a;
|
||||||
|
|||||||
@@ -49,7 +49,6 @@ class GalaxyRS {
|
|||||||
private static final int RSID_STATE = 0;
|
private static final int RSID_STATE = 0;
|
||||||
|
|
||||||
private static final int TEXTURES_COUNT = 3;
|
private static final int TEXTURES_COUNT = 3;
|
||||||
private static final int PARTICLES_TEXTURES_COUNT = 2;
|
|
||||||
private static final int RSID_TEXTURE_SPACE = 0;
|
private static final int RSID_TEXTURE_SPACE = 0;
|
||||||
private static final int RSID_TEXTURE_LIGHT1 = 1;
|
private static final int RSID_TEXTURE_LIGHT1 = 1;
|
||||||
private static final int RSID_TEXTURE_FLARES = 2;
|
private static final int RSID_TEXTURE_FLARES = 2;
|
||||||
@@ -216,13 +215,15 @@ class GalaxyRS {
|
|||||||
|
|
||||||
@SuppressWarnings({"PointlessArithmeticExpression"})
|
@SuppressWarnings({"PointlessArithmeticExpression"})
|
||||||
private void createParticle(float[] particles, int index, int bufferIndex) {
|
private void createParticle(float[] particles, int index, int bufferIndex) {
|
||||||
float d = abs(randomGauss()) * GALAXY_RADIUS / 2.0f;
|
float d = abs(randomGauss()) * GALAXY_RADIUS / 2.0f + random(-4.0f, 4.0f);
|
||||||
|
float z = randomGauss() * 0.5f * 0.8f * ((GALAXY_RADIUS - d) / (float) GALAXY_RADIUS);
|
||||||
|
z += 1.0f;
|
||||||
|
|
||||||
particles[index + PARTICLE_STRUCT_ANGLE] = random(0.0f, (float) (Math.PI * 2.0));
|
particles[index + PARTICLE_STRUCT_ANGLE] = random(0.0f, (float) (Math.PI * 2.0));
|
||||||
particles[index + PARTICLE_STRUCT_DISTANCE] = d;
|
particles[index + PARTICLE_STRUCT_DISTANCE] = d;
|
||||||
particles[index + PARTICLE_STRUCT_SPEED] = random(0.0015f, 0.0025f) *
|
particles[index + PARTICLE_STRUCT_SPEED] = random(0.0015f, 0.0025f) *
|
||||||
(0.5f + (0.5f * (float) GALAXY_RADIUS / d));
|
(0.5f + (0.5f * (float) GALAXY_RADIUS / d)) * 0.7f;
|
||||||
particles[index + PARTICLE_STRUCT_RADIUS] = random(1.0f, 2.1f);
|
particles[index + PARTICLE_STRUCT_RADIUS] = z * random(1.2f, 2.1f);
|
||||||
|
|
||||||
int red, green, blue;
|
int red, green, blue;
|
||||||
if (d < GALAXY_RADIUS / 3.0f) {
|
if (d < GALAXY_RADIUS / 3.0f) {
|
||||||
@@ -234,27 +235,24 @@ class GalaxyRS {
|
|||||||
green = 180;
|
green = 180;
|
||||||
blue = (int) constrain(140 + (d / (float) GALAXY_RADIUS) * 115, 140, 255);
|
blue = (int) constrain(140 + (d / (float) GALAXY_RADIUS) * 115, 140, 255);
|
||||||
}
|
}
|
||||||
|
|
||||||
final int color = 0xFF000000 | red | green << 8 | blue << 16;
|
final int color = red | green << 8 | blue << 16 | 0xff000000;
|
||||||
final int sprite = random(PARTICLES_TEXTURES_COUNT);
|
|
||||||
final float u1 = sprite / (float) PARTICLES_TEXTURES_COUNT;
|
|
||||||
final float u2 = (sprite + 1) / (float) PARTICLES_TEXTURES_COUNT;
|
|
||||||
|
|
||||||
final float[] floatData = mFloatData5;
|
final float[] floatData = mFloatData5;
|
||||||
final Allocation buffer = mParticlesBuffer;
|
final Allocation buffer = mParticlesBuffer;
|
||||||
|
|
||||||
floatData[0] = Float.intBitsToFloat(color);
|
floatData[0] = Float.intBitsToFloat(color);
|
||||||
floatData[3] = u1;
|
floatData[3] = 0.0f;
|
||||||
floatData[4] = 1.0f;
|
floatData[4] = 1.0f;
|
||||||
buffer.subData1D(bufferIndex, 1, floatData);
|
buffer.subData1D(bufferIndex, 1, floatData);
|
||||||
|
|
||||||
bufferIndex++;
|
bufferIndex++;
|
||||||
floatData[3] = u2;
|
floatData[3] = 1.0f;
|
||||||
floatData[4] = 1.0f;
|
floatData[4] = 1.0f;
|
||||||
buffer.subData1D(bufferIndex, 1, floatData);
|
buffer.subData1D(bufferIndex, 1, floatData);
|
||||||
|
|
||||||
bufferIndex++;
|
bufferIndex++;
|
||||||
floatData[3] = u1 + (u2 - u1) / 2.0f;
|
floatData[3] = 0.5f;
|
||||||
floatData[4] = 0.0f;
|
floatData[4] = 0.0f;
|
||||||
buffer.subData1D(bufferIndex, 1, floatData);
|
buffer.subData1D(bufferIndex, 1, floatData);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -170,6 +170,44 @@ static void SC_storeMatrix(uint32_t bank, uint32_t offset, const rsc_Matrix *m)
|
|||||||
#define DEG_TO_RAD PI / 180.0f
|
#define DEG_TO_RAD PI / 180.0f
|
||||||
#define RAD_TO_DEG 180.0f / PI
|
#define RAD_TO_DEG 180.0f / PI
|
||||||
|
|
||||||
|
static float SC_sinf_fast(float x)
|
||||||
|
{
|
||||||
|
const float A = 1.0f / (2.0f * M_PI);
|
||||||
|
const float B = -16.0f;
|
||||||
|
const float C = 8.0f;
|
||||||
|
|
||||||
|
// scale angle for easy argument reduction
|
||||||
|
x *= A;
|
||||||
|
|
||||||
|
if (fabsf(x) >= 0.5f) {
|
||||||
|
// argument reduction
|
||||||
|
x = x - ceilf(x + 0.5f) + 1.0f;
|
||||||
|
}
|
||||||
|
|
||||||
|
const float y = B * x * fabsf(x) + C * x;
|
||||||
|
return 0.2215f * (y * fabsf(y) - y) + y;
|
||||||
|
}
|
||||||
|
|
||||||
|
static float SC_cosf_fast(float x)
|
||||||
|
{
|
||||||
|
x += float(M_PI / 2);
|
||||||
|
|
||||||
|
const float A = 1.0f / (2.0f * M_PI);
|
||||||
|
const float B = -16.0f;
|
||||||
|
const float C = 8.0f;
|
||||||
|
|
||||||
|
// scale angle for easy argument reduction
|
||||||
|
x *= A;
|
||||||
|
|
||||||
|
if (fabsf(x) >= 0.5f) {
|
||||||
|
// argument reduction
|
||||||
|
x = x - ceilf(x + 0.5f) + 1.0f;
|
||||||
|
}
|
||||||
|
|
||||||
|
const float y = B * x * fabsf(x) + C * x;
|
||||||
|
return 0.2215f * (y * fabsf(y) - y) + y;
|
||||||
|
}
|
||||||
|
|
||||||
static float SC_randf(float max)
|
static float SC_randf(float max)
|
||||||
{
|
{
|
||||||
float r = (float)rand();
|
float r = (float)rand();
|
||||||
@@ -846,6 +884,10 @@ ScriptCState::SymbolTable_t ScriptCState::gSyms[] = {
|
|||||||
"int", "(int)" },
|
"int", "(int)" },
|
||||||
{ "absf", (void *)&fabs,
|
{ "absf", (void *)&fabs,
|
||||||
"float", "(float)" },
|
"float", "(float)" },
|
||||||
|
{ "sinf_fast", (void *)&SC_sinf_fast,
|
||||||
|
"float", "(float)" },
|
||||||
|
{ "cosf_fast", (void *)&SC_cosf_fast,
|
||||||
|
"float", "(float)" },
|
||||||
{ "sinf", (void *)&sinf,
|
{ "sinf", (void *)&sinf,
|
||||||
"float", "(float)" },
|
"float", "(float)" },
|
||||||
{ "cosf", (void *)&cosf,
|
{ "cosf", (void *)&cosf,
|
||||||
|
|||||||
Reference in New Issue
Block a user