Esempio n. 1
0
            public override void draw(SCENE scene)
            {
                ICommand.round_move_decimals.Push(5);
                for (int i = 0; i < NBARS; i++)
                {
                    pcubes[i].setheight(MAXHEIGHT * smoothen(fft.smoothframe.values[i], scene));
                }
                copy(_points, points);
                vec3[] __points = new vec3[points.Length];
                copy(__points, _points);
                bool[] skiprect = new bool[orects.Length];
                for (int i = 0; i < NBARS; i++)
                {
                    int L = 3;             // see int[] order
                    int R = 1;             // see int[] order
                    if (i < NBARS - 1)
                    {
                        int  ridx  = reorder(i * 6 + R);
                        int  lidx  = reorder((i + 1) * 6 + L);
                        Rect lrect = orects[lidx].rect;
                        Rect rrect = orects[ridx].rect;
                        lrect.tri1.points = lrect.tri2.points = lrect.pts = __points;
                        rrect.tri1.points = rrect.tri2.points = rrect.pts = __points;
                        if (lrect.pts[lrect.a].z < rrect.pts[rrect.a].z)
                        {
                            rrect.pts[rrect.c].z = lrect.pts[lrect.a].z;
                            rrect.pts[rrect.d].z = lrect.pts[lrect.a].z;
                            skiprect[lidx]       = true;
                        }
                        else
                        {
                            lrect.pts[lrect.c].z = rrect.pts[rrect.a].z;
                            lrect.pts[lrect.d].z = rrect.pts[rrect.a].z;
                            skiprect[ridx]       = true;
                        }
                    }
                }
                Zsc.adjust(_points);
                Zsc.adjust(__points);
                int z = -1;

                foreach (Orect r in orects)
                {
                    z++;
                    Cube cube = cubes[reorder(z) / 6];
                    if (shoulddrawcube(cube) && !skiprect[z])
                    {
                        r.update(scene);
                    }
                    else
                    {
                        r.update(scene, -1f, -1f, -1f);
                    }
                }
                ICommand.round_move_decimals.Pop();
            }
Esempio n. 2
0
            public override void draw(SCENE scene)
            {
                ICommand.round_scale_decimals.Push(1);

                vec3[] points = new vec3[AMOUNT];

                vec3 posoffset = v3(0f, 0f, 0f);
                vec3 mid       = v3(Zsc.mid);

                posoffset.xy -= v2(DIMENSION / 2.3f);
                posoffset.x  += 40;
                posoffset.y  -= 10;
                posoffset.xy -= (-30 + udata[0]) / 100f * DIMENSION / 2f;
                posoffset.xy += DIMENSION / 9.5f * scene.progress;
                posoffset.z  += 30f;

                float angle = 10f;

                float rot = scene.reltime / 80f;

                rot = 45;        // + sin(rad(rot)) * 10f;
                //rot = 225;

                for (int a = 0; a < SIZE; a++)
                {
                    for (int b = 0; b < SIZE; b++)
                    {
                        int  i     = a * SIZE + b;
                        vec3 point = v3(this.points[a, b]);
                        point.z   = heightat((float)a / SIZE, (float)b / SIZE, scene.reltime);
                        point.z  += mid.z;
                        point.z  -= 2f;
                        point    -= posoffset;
                        point     = turn(point, mid, quat(0f, 0, rad(rot)));
                        point     = turn(point, mid, quat(0f, rad(angle), 0));
                        points[i] = point;
                    }
                }
                Zsc.adjust(points);

                screen.clear();
                for (int a = 0; a < SIZE; a++)
                {
                    for (int b = 0; b < SIZE; b++)
                    {
                        int         i        = a * SIZE + b;
                        vec4        pos      = project(points[i]);
                        vec4        col      = v4(1f);
                        const float VIEWDIST = 200f;
                        const float FADEDIST = 100f;
                        float       fadedist = (points[i] - Zsc.mid).length();
                        col.w  = 1f - clampx(fadedist, FADEDIST, VIEWDIST) / FADEDIST;
                        col.w *= clamp(scene.reltime, 0f, 1500f) / 1500f;
                        col.w *= 1f - clampx(scene.time, stop - 1000, stop) / 1000f;
                        float size = col.w * 6f;

                        dots[i].update(scene.time, col, pos, size);
                        dots[i].draw(scene.g);

#if FILL
                        if (a == SIZE - 1 || b == SIZE - 1)
                        {
                            continue;
                        }
                        int  aa = a * SIZE + b;
                        int  bb = (a + 1) * SIZE + b;
                        int  cc = a * SIZE + b + 1;
                        int  dd = (a + 1) * SIZE + b + 1;
                        Rect r  = new Rect(this, col.col(), points, bb, aa, dd, cc);
                        if (r.shouldcull())
                        {
                            continue;
                        }
                        col      = v4(.5f, .68f, .98f, 1f);
                        col.xyz *= .5f + .5f * (r.surfacenorm().norm() ^ r.rayvec().norm());
                        r.setColor(col.col());
                        r.draw(screen);
#endif
                    }
                }
                screen.draw(scene);

                Odot d = new Odot(Sprite.SPRITE_DOT_6_12, 0);
                d.update(scene.time, v4(1f, 0f, 1f, 1f), project(Zsc.mid), 3f);
                d.draw(scene.g);
                ICommand.round_scale_decimals.Pop();
            }
Esempio n. 3
0
            public override void draw(SCENE scene)
            {
                ICommand.round_scale_decimals.Push(1);
                float flyInMod = (1f - clamp(scene.reltime, 0f, 900f) / 900f) * 1000f;

                for (int i = 0; i < points.Length; i++)
                {
                    _points[i]    = v3(points[i]);
                    _points[i].y  = pointYPosAt(points[i], scene.time);
                    _points[i].y += flyInMod;
                }

                phantomframedelta = framedelta = 900;
                if (scene.reltime >= 900)
                {
                    phantomframedelta = framedelta = 300;             // this won't end good
                    float _rot = (scene.reltime - 900f) / 50f;
                    _rot -= clamp(progress(sync(B1S), sync(B1E), scene.time), 0f, 1f) * 60f;
                    turn(_points, Zsc.mid, quat(rad(_rot), 0f, 0f));
                }

                for (int i = 0; i < points.Length; i++)
                {
                    vec3 p   = _points[i];
                    vec3 mid = v3(Zsc.mid);
                    mid.y = p.y;
                    int   ft = pointfadetime[i];
                    float x  = clamp(progressx(ft, ft + FADETIME, scene.time), 0f, 1f);
                    _points[i] = p + (p - mid).norm() * 30f * x;
                }

                Zsc.adjust(_points);

                for (int i = 0; i < points.Length; i++)
                {
                    vec4 q   = project(_points[i]);
                    vec4 col = v4(color, 1f);
                    if (!rendering)
                    {
                        // it's done using command overrides (see ctor),
                        // so don't do this when exporting.
                        // this is purely for the preview (why am I even doing this)
                        foreach (int lighttime in lighttimes)
                        {
                            int lightstart = lightStartTime(points[i], scene.time, lighttime);
                            int lightend   = lightstart + LIGHTFALLOFFTIME;
                            if (lightstart < scene.time && scene.time < lightend)
                            {
                                float x = progress(lightstart, lightend, scene.time);
                                col = v4(lerp(v3(1f), col.xyz, x), 1f);
                            }
                        }
                        int ft = pointfadetime[i];
                        col.w *= 1f - clamp(progressx(ft, ft + FADETIME, scene.time), 0f, 1f);
                    }
                    float fadestart = FADESTART + Zsc.moveback;
                    float fadeend   = FADEEND + Zsc.moveback;
                    float distCul   = clamp(progress(fadestart, fadeend, q.w - flyInMod), 0f, 1f);
                    float size      = 8f * (1f - distCul);
                    if (scene.reltime < 900 && _points[i].y < flyInMod)
                    {
                        size = 0f;
                    }
                    if (scene.reltime >= 900)
                    {
                        dots[i].update(scene.time, col, q, size);
                        dots[i].draw(scene.g);
                    }
                    if (scene.reltime <= 900)
                    {
                        dots0[i].update(scene.time, col, q, size);
                        dots0[i].draw(scene.g);
                    }
                }
                ICommand.round_scale_decimals.Pop();
            }
Esempio n. 4
0
            public override void draw(SCENE scene)
            {
                screen.clear();
                copy(_points, points);

                if (scene.reltime < pretime)
                {
                    for (int i = 0; i < cubes.Length; i++)
                    {
                        Rect[] r   = { cubes[i].rects[Cube.F], cubes[i].rects[Cube.B] };
                        vec3   mid = (r[0].mid() + r[1].mid()) / 2f;
                        vec3   dir = (mid - Zsc.mid).norm();
                        float  x   = 1f - clamp(progress(cubeintime[i], cubeintime[i] + intime, scene.reltime), 0f, 1f);
                        dir *= x * INOFFSET;
                        r[0].move(dir);
                        r[1].move(dir);
                    }
                }

                int currentmove = max(0, scene.reltime - pretime) / movetime;

                if (currentmove < this.moves.Count && scene.reltime > pretime)
                {
                    float moveprogress = scene.reltime - pretime - currentmove * movetime;
                    moveprogress /= movetime;
                    Mov mov = this.moves[currentmove];
                    Rot rot = this.rots[mov.axis];
                    foreach (Cube c in rot.cubes)
                    {
                        turn(c, Zsc.mid, quat(rot.angles * moveprogress * 30f * mov.dir * mov.mp));
                    }
                }

                Cube[] originalCubePositions = new Cube[cubes.Length];
                Array.Copy(cubes, originalCubePositions, cubes.Length);
                int[,] originalCubePoints = new int[cubes.Length, 4 * 6];
                int[,] cp = new int[cubes.Length, 8];
                R rots = new R();

                for (int i = 0; i < cubes.Length; i++)
                {
                    for (int j = 0; j < cubes[i].rects.Length; j++)
                    {
                        originalCubePoints[i, j * 4 + 0] = cubes[i].rects[j].a;
                        originalCubePoints[i, j * 4 + 1] = cubes[i].rects[j].b;
                        originalCubePoints[i, j * 4 + 2] = cubes[i].rects[j].c;
                        originalCubePoints[i, j * 4 + 3] = cubes[i].rects[j].d;
                    }
                    for (int j = 0; j < 8; j++)
                    {
                        cp[i, j] = pt(i, j);
                    }
                    rots.Add(cubes[i], new List <int[]>());
                }

                Cube[] nc = new Cube[cubes.Length];
                for (int i = 0; i < currentmove && i < moves.Count; i++)
                {
                    int axis   = moves[i].axis;
                    int amount = (moves[i].mp + (1 - (moves[i].mp - 1)) * (((moves[i].dir >> 1) & 1) * 2 + dirfix[axis])) % 4;
                    while (amount-- > 0)
                    {
                        Array.Copy(cubes, nc, cubes.Length);
                        for (int j = 0; j < 9; j++)
                        {
                            rc(nc, cp, rots, movmat[rmref[axis], j], emovmat[axis], rotmat[rmref[axis]]);
                        }
                        Array.Copy(nc, cubes, cubes.Length);
                    }
                }

                for (int i = 0; i < cubes.Length; i++)
                {
                    rc3(i, rots[cubes[i]]);
                }

                if (scene.time > 43250)
                {
                    int  rt = scene.time - 43250;
                    vec4 q  = quat(0f, 0f, -rt / 1000f);
                    turn(_points, Zsc.mid, q);
                }
                if (scene.time > 45450)
                {
                    int  rt = scene.time - 45450;
                    vec4 q  = quat(0f, -rt / 1400f, 0f);
                    turn(_points, Zsc.mid, q);
                }
                if (scene.time > 47650)
                {
                    int  rt = scene.time - 47650;
                    vec4 q  = quat(rt / 2000f, 0f, 0f);
                    turn(_points, Zsc.mid, q);
                }

                Zsc.adjust(_points);

                foreach (Cube c in this.cubes)
                {
                    c.draw(screen);
                }
#if ASDOTS
                foreach (Odottedrect o in this.dottedrects)
                {
                    o.draw(scene, screen);
                }
#else
                screen.draw(scene);
#endif
#if ASRECTS
                foreach (Orect o in orects)
                {
                    o.update(scene);
                }
#endif

                Array.Copy(originalCubePositions, cubes, cubes.Length);

                for (int i = 0; i < cubes.Length; i++)
                {
                    for (int j = 0; j < cubes[i].rects.Length; j++)
                    {
                        int a = originalCubePoints[i, j * 4 + 0];
                        int b = originalCubePoints[i, j * 4 + 1];
                        int c = originalCubePoints[i, j * 4 + 2];
                        int d = originalCubePoints[i, j * 4 + 3];
                        cubes[i].rects[j].updatepts(a, b, c, d);
                    }
                }
            }