public Zcheckerboard(int start, int stop) { this.start = start; this.stop = stop; framedelta = 100; rects = new Orect[SIZE * SIZE / 2 + 1]; points = new vec3[rects.Length * 4]; _points = new vec3[points.Length]; int idx = 0; for (int i = 0; i < SIZE; i++) { for (int j = 0; j < SIZE; j++) { if ((i + j) % 2 == 1) { continue; } int p = idx * 4; points[p + 0] = v3((i + 0) * SPACING, (j + 0) * SPACING, 0f); points[p + 1] = v3((i + 0) * SPACING, (j + 1) * SPACING, 0f); points[p + 2] = v3((i + 1) * SPACING, (j + 0) * SPACING, 0f); points[p + 3] = v3((i + 1) * SPACING, (j + 1) * SPACING, 0f); Rect rect = new Rect(null, Color.White, _points, p, p + 1, p + 2, p + 3); rects[idx] = new Orect(rect, 0); idx++; } } move(points, Zlc.mid); move(points, v3(v2(SIZE / 2f) * -SPACING, 0f)); }
public override void draw(SCENE scene) { turn(_points, points, mid, 800f * scene.progress, 1200f * scene.progress); float ang = scene.progress * 20f; vec3 light1pos = mid + v3(30f * sin(ang), 20f * cos(ang), 20f); vec3 light1col = v3(1f, 0f, 0f); light1.update(scene.time, v4(light1col, 1f), project(light1pos), 12f); light1.draw(scene.g); vec3 light2pos = mid + v3(30f * sin(ang * 1.7f), 0f, 20f * cos(ang * 1.7f)); light2pos = turn(light2pos, mid, quat(rad(45f), rad(0f), 0f)); vec3 light2col = v3(0f, 0f, 1f); light2.update(scene.time, v4(light2col, 1f), project(light2pos), 12f); light2.draw(scene.g); vec3 light3pos = mid + v3(30f * sin(ang * 0.5f), 0f, 20f * cos(ang * 0.5f)); light3pos = turn(light3pos, mid, quat(0f, rad(-45f), 0f)); vec3 light3col = v3(0f, .4f, 0f); light3.update(scene.time, v4(light3col, 1f), project(light3pos), 12f); light3.draw(scene.g); for (int i = 0; i < 6; i++) { Rect r = cube.rects[i]; Orect o = rects[i]; vec3 rectmid = v3(0f); rectmid += r.pts[r.a]; rectmid += r.pts[r.b]; rectmid += r.pts[r.c]; rectmid += r.pts[r.d]; rectmid /= 4f; float aval = 0.3f; float bval = 0.7f; vec3 result = col(r.color).xyz *aval; result += light1col * bval / pow(distance(light1pos, rectmid) / 15, 2); result += light2col * bval / pow(distance(light2pos, rectmid) / 15, 2); result += light3col * bval / pow(distance(light3pos, rectmid) / 15, 2); result.x = min(1f, result.x); result.y = min(1f, result.y); result.z = min(1f, result.z); Color original = r.color; r.setColor(v4(result, 1f).col()); o.update(scene); r.setColor(original); } }
public Ztestcube4(int start, int stop) { this.start = start; this.stop = stop; framedelta = 100; points = new vec3[] { v3(-10f, -10f, 90f), v3(-10f, -10f, 110f), v3(-10f, 10f, 90f), v3(-10f, 10f, 110f), v3(10f, -10f, 90f), v3(10f, -10f, 110f), v3(10f, 10f, 90f), v3(10f, 10f, 110f), }; _points = new vec3[points.Length]; cube = new Cube( Color.Cyan, Color.Lime, Color.Red, Color.Blue, Color.Yellow, Color.Orange, _points, PA, PD, PC, PB, PF, PE, PH, PG ); rects = new Orect[6]; for (int i = 0; i < rects.Length; i++) { rects[i] = new Orect(cube.rects[i], 0); cube.rects[i].setColor(Color.White); } light1 = new Odot(Sprite.SPRITE_DOT_6_12, 0); light2 = new Odot(Sprite.SPRITE_DOT_6_12, 0); light3 = new Odot(Sprite.SPRITE_DOT_6_12, 0); }
public MultiRectChild(vec3[] points, Color col, int depth, float abt1, float abt2, float act1, float act2) { this.depth = depth; this.abt1 = abt1; this.abt2 = abt2; this.act1 = act1; this.act2 = act2; this.parentpoints = new vec3[4]; this.mypoints = new vec3[4]; copy(this.parentpoints, points); this.update_my_points(); this.rect = new Orect(new Rect(this, col /*colors[this.depth]*/, this.mypoints, 0, 1, 2, 3), 0); float acdist = distance(this.mypoints[0], this.mypoints[2]); float abdist = distance(this.mypoints[0], this.mypoints[1]); if (depth < 12 && (acdist > 30f || abdist > 30f)) { depth++; if (abdist >= 1.75 * acdist) { this.children = new MultiRectChild[] { new MultiRectChild(mypoints, col, depth, 0f, .5f, 0f, 1f), new MultiRectChild(mypoints, col, depth, .5f, 1f, 0f, 1f), }; } else if (acdist >= 1.75 * abdist) { this.children = new MultiRectChild[] { new MultiRectChild(mypoints, col, depth, 0f, 1f, 0f, .5f), new MultiRectChild(mypoints, col, depth, 0f, 1f, .5f, 1f), }; } else { this.children = new MultiRectChild[] { new MultiRectChild(mypoints, col, depth, 0f, .5f, 0f, .5f), new MultiRectChild(mypoints, col, depth, .5f, 1f, 0f, .5f), new MultiRectChild(mypoints, col, depth, 0f, .5f, .5f, 1f), new MultiRectChild(mypoints, col, depth, .5f, 1f, .5f, 1f), }; } } else { this.children = new MultiRectChild[0]; } }
public Z0020spect(int start, int stop) { this.start = start; this.stop = stop; framedelta = 100; points = new vec3[8 * NBARS]; _points = new vec3[points.Length]; pcubes = new Pcube[NBARS]; rects = new Rect[6 * NBARS]; orects = new Orect[6 * NBARS]; cubes = new Cube[NBARS]; Color[] colors = new Color[] { Color.Cyan, Color.Lime, Color.Red, Color.White, Color.DeepPink, Color.Blue }; for (int i = 0; i < NBARS; i++) { int bi = 8 * i; vec3 bp = v3(Zsc.mid); bp.z -= MAXHEIGHT / 4f; bp.x += SQSIZE * (i - NBARS / 2f); pcubes[i] = new Pcube(points, bi); pcubes[i].set(bp, SQSIZE, SQSIZE, MAXHEIGHT); cubes[i] = new Cube(colors, _points, bi); } int[] order = { Cube.D, Cube.R, Cube.U, Cube.L, Cube.B, Cube.F }; for (int j = 0; j < NBARS; j++) { for (int i = 0; i < 6; i++) { int idx = j * 6 + i; rects[idx] = cubes[j].rects[order[i]]; var or = new Orect(rects[idx], 0); or.addCommandOverride(new FadeCommand(stop - 300, stop, 1f, 0f)); orects[reorder(idx)] = or; } } }
public Zmc(int start, int stop, int pixelsize) { this.start = start; this.stop = stop; framedelta = 50; this.sides = new IColorOwner[] { GrassSide.instance, GrassSide.instance, GrassSide.instance, GrassTop.instance, GrassSide.instance, GrassSide.instance, }; this.points = new vec3[8]; this._points = new vec3[this.points.Length]; new Pcube(points, 0).set(v3(), 8f, 8f, 8f); copy(_points, points); c = new Cube(hwite, this._points, 0); Rect[] r = c.rects; tpoints = new vec3[4 * 8 * 8 * 6]; _tpoints = new vec3[tpoints.Length]; trects = new Rect[8 * 8 * 6]; shit(c.rects[Cube.U], 0, GrassTop.instance); shit(c.rects[Cube.L], 1 * 8 * 8, GrassSide.instance); shit(c.rects[Cube.R], 2 * 8 * 8, GrassSide.instance); shit(c.rects[Cube.F], 3 * 8 * 8, GrassSide.instance); shit(c.rects[Cube.B], 4 * 8 * 8, GrassSide.instance); shit(c.rects[Cube.D], 5 * 8 * 8, GrassSide.instance); torects = new Orect[trects.Length]; for (int i = 0; i < torects.Length; i++) { torects[i] = new Orect(trects[i], 0); } int pxs = pixelsize; this.pixelscreen = new Pixelscreen(/*widescreen mode*/ 854 / pxs, 480 / pxs, pxs); sizetext = new Odot[8 /*charwidth*/ * 8 /*charheight*/ * 10]; sizetext2 = new Odot[8 /*charwidth*/ * 8 /*charheight*/ * 10]; for (int i = 0; i < sizetext.Length; i++) { sizetext[i] = new Odot(Sprite.SPRITE_SQUARE_2_2, 0); sizetext2[i] = new Odot(Sprite.SPRITE_SQUARE_2_2, 0); } sizetextloc = new vec4[sizetext.Length]; sizetextloc2 = new vec4[sizetext.Length]; for (int i = 0; i < sizetextloc.Length; i++) { sizetextloc[i] = v4(90f, 150f, 1f, 1f); sizetextloc[i].x += (i % 80) * TEXTSPACING; sizetextloc[i].y += (i / 80 - 6) * TEXTSPACING - 2; sizetextloc2[i] = v4(360f, 150f, 1f, 1f); sizetextloc2[i].x += (i % 80) * TEXTSPACING; sizetextloc2[i].y += (i / 80 - 6) * TEXTSPACING - 2; } inittext(); }
public Zheart(int start, int stop) { this.start = start; framedelta = BEATLEN / 4; // should be (540 / 4 =) 135 this.start -= framedelta; this.stop = sync(stop); firstpulsetime = sync(72900); turnstop = sync(86500); transitionone = sync(77900); transitiontwo = sync(80000); transitiontri = sync(82100); Rect[] rects; loadobj("obj1", out points, out rects); dots = new Odot[points.Length]; orects = new Orect[rects.Length]; olines = new Oline[rects.Length * 3]; indata = new INDATA[rects.Length]; _points = new vec3[points.Length]; for (int i = 0; i < points.Length; i++) { _points[i] = points[i] = points[i] * 20f + mid; } for (int i = 0; i < points.Length; i++) { dots[i] = new Odot(Sprite.SPRITE_DOT_6_12, 0); } Color bc = v4(basecolor, 1f).col(); Random rand = new Random("zhearts".GetHashCode()); for (int i = 0; i < rects.Length; i++) { Rect r = rects[i]; r.setColor(bc); orects[i] = new Orect(r, Orect.SETTING_SHADED); r.pts = _points; r.tri1.points = _points; r.tri2.points = _points; olines[i * 3 + 0] = new Oline(r.pts, r.a, r.b); olines[i * 3 + 1] = new Oline(r.pts, r.a, r.d); olines[i * 3 + 2] = new Oline(r.pts, r.c, r.d); //if (!r.tri1.shouldcull() || !r.tri2.shouldcull()) { vec3[] inpts = { v3(points[r.a]), v3(points[r.b]), v3(points[r.c]), v3(points[r.d]) }; INDATA id; id.pts = inpts; id._pts = new vec3[4]; id.rect = new Rect(null, bc, id._pts, 0, 1, 2, 3); id.orect = new Orect(id.rect, Orect.SETTING_SHADED | Orect.SETTING_NO_BCULL); //var fc = new FadeCommand(start, start + 300, 0f, 1f); //id.orect.addCommandOverride(fc); float m = (project(r.mid()).xy - v2(50f)).length(); id.flyinstart = start + (int)m; id.rots = v3(rand.Next(10), rand.Next(10), rand.Next(10)); indata[indatac++] = id; //} } }
public Zltext(int start, int stop, string text) { this.start = start; this.stop = stop; framedelta = 100; int width = font.textWidth(text); List <vec3> pointlist = new List <vec3>(); List <MRECT> rectlist = new List <MRECT>(); List <MRECT> rrectlist = new List <MRECT>(); Color[] cols = { v3(.9f).col(), v3(.6f).col(), v3(.6f).col(), v3(.3f).col(), v3(.3f).col(), v3(.9f).col(), }; for (int i = 0; i < cols.Length; i++) { cols[i] = v3(.6f, .4f, 1f).col(); } points = new vec3[8]; vec3 topleft = Zlc.mid - v3(width / 2f * SIZE, 0f, 0f); int pointidx = 0; for (int i = 0; i < text.Length; i++) { int c = text[i] - 32; vec3 pos = v3(topleft); int cw = font.charwidth[c]; for (int k = 0; k < font.charwidth[c]; k++) { pos.z = topleft.z - SIZE; List <MRECT> newrects = new List <MRECT>(); bool[,] skip = new bool[6, font.charheight]; for (int j = font.charheight - 1; j >= 0; j--) { byte cd = font.chardata[c][j]; pos.z += SIZE; if (((cd >> k) & 1) == 0) { continue; } vec3 basepoint = pos + v3(k * SIZE, 0f, 0f); new Pcube(points, 0 * pointidx).set(basepoint, SIZE, SIZE * 3, SIZE); for (int z = 0; z < 8; z++) { pointlist.Add(points[z]); } Cube cube = new Cube(cols, _points, pointidx); Tri tri = cube.rects[Cube.L].tri1; if (!skip[Cube.F, j]) { add(cube, Cube.F, tri, newrects, skip, j, c, k); } if (!skip[Cube.B, j]) { add(cube, Cube.B, tri, newrects, skip, j, c, k); } if (!skip[Cube.L, j] && (k == 0 || ((cd >> (k - 1)) & 1) != 1)) { add(cube, Cube.L, tri, newrects, skip, j, c, k); } if (!skip[Cube.R, j] && (k == cw - 1 || ((cd >> (k + 1)) & 1) != 1)) { add(cube, Cube.R, tri, newrects, skip, j, c, k); } if (j == 0 || ((font.chardata[c][j - 1] >> k) & 1) != 1) { newrects.Add(new MRECT(cube.rects[Cube.U], tri)); } if (j == font.charheight - 1 || ((font.chardata[c][j + 1] >> k) & 1) != 1) { newrects.Add(new MRECT(cube.rects[Cube.D], tri)); } pointidx += 8; } for (int z = 0; z < newrects.Count; z++) { rectlist.Add(newrects[z]); rrectlist.Add(newrects[newrects.Count - z - 1]); } newrects.Clear(); } topleft.x += (cw + 1) * SIZE; } points = new vec3[pointlist.Count]; _points = new vec3[points.Length]; int pointcount = 0; foreach (vec3 p in pointlist) { points[pointcount++] = p; } rects = new MRECT[rectlist.Count]; rects2 = new MRECT[rectlist.Count]; orects = new Orect[rects.Length]; orects2 = new Orect[rects.Length]; int rectcount = 0; foreach (MRECT r in rectlist) { int i = rectcount++; rects[i] = r; r.left.points = _points; Rect rect = r.rect; rect.pts = _points; rect.tri1.points = _points; rect.tri2.points = _points; orects[i] = new Orect(rect, Orect.SETTING_SHADED); } rectcount = 0; foreach (MRECT r in rrectlist) { int i = rectcount++; rects2[i] = r; orects2[i] = new Orect(r.rect, Orect.SETTING_SHADED); } }
public Ztestfont2(int start, int stop) { this.start = start; this.stop = stop; framedelta = 100; string text1 = "L|ne 1"; string text2 = "l!ne tw@"; string text = text1 + text2; int width = font.textWidth(text); int width1 = font.textWidth(text1); int width2 = font.textWidth(text2); int pointcount = font.calcPointCount(text); points = new vec3[pointcount * 8]; _points = new vec3[points.Length]; const int SIZE = 2; List <Rect> toprects = new List <Rect>(); List <Rect> siderects = new List <Rect>(); List <Rect> otherrects = new List <Rect>(); Color[] cols = { Color.Cyan, Color.Lime, Color.Red, Color.Blue, Color.Yellow, Color.Orange }; vec3 topleft = mid - v3(width1 / 2f * SIZE, 0f, -(font.charheight + 1) * SIZE); int pointidx = 0; for (int i = 0; i < text.Length; i++) { if (i == text1.Length) { topleft = mid - v3(width2 / 2f * SIZE, 0f, 1 * SIZE); } int c = text[i] - 32; vec3 pos = v3(topleft); for (int j = 0; j < font.charheight; j++) { int cw = font.charwidth[c]; for (int k = 0; k < font.charwidth[c]; k++) { byte cd = font.chardata[c][j]; if (((cd >> k) & 1) == 1) { vec3 basepoint = pos + v3(k * SIZE, 0f, 0f); new Pcube(points, pointidx).set(basepoint, SIZE, SIZE, SIZE); Cube cube = new Cube(cols, _points, pointidx); otherrects.Add(cube.rects[Cube.F]); otherrects.Add(cube.rects[Cube.B]); if (k == 0 || ((cd >> (k - 1)) & 1) != 1) { siderects.Add(cube.rects[Cube.L]); } if (k == cw - 1 || ((cd >> (k + 1)) & 1) != 1) { siderects.Add(cube.rects[Cube.R]); } if (j == 0 || ((font.chardata[c][j - 1] >> k) & 1) != 1) { toprects.Add(cube.rects[Cube.U]); } if (j == font.charheight - 1 || ((font.chardata[c][j + 1] >> k) & 1) != 1) { siderects.Add(cube.rects[Cube.D]); } pointidx += 8; } } pos.z -= SIZE; } topleft.x += (font.charwidth[c] + 1) * SIZE; } int rectcount = 0; rects = new Rect[toprects.Count + siderects.Count + otherrects.Count]; foreach (Rect r in toprects) { rects[rectcount++] = r; } foreach (Rect r in siderects) { rects[rectcount++] = r; } foreach (Rect r in otherrects) { rects[rectcount++] = r; } orects = new Orect[rects.Length]; for (int i = 0; i < orects.Length; i++) { rects[i].pts = _points; rects[i].tri1.points = _points; rects[i].tri2.points = _points; orects[i] = new Orect(rects[i], 0); } }
public Zrub(int start, int stop) { this.start = start; this.stop = stop; framedelta = 100; phantomframedelta = 5; this.moves = new List <Mov>(); this.points = new vec3[27 * 8]; this._points = new vec3[27 * 8]; this.cubes = new Cube[27]; this.dottedrects = new Odottedrect[27 * 6]; this.cubeintime = new int[27]; this.rots = new Rot[6 + 3]; this.rots[Cube.L] = new Rot(v3(0f, +1f, 0f)); this.rots[Cube.R] = new Rot(v3(0f, -1f, 0f)); this.rots[Cube.F] = new Rot(v3(+1f, 0f, 0f)); this.rots[Cube.B] = new Rot(v3(-1f, 0f, 0f)); this.rots[Cube.D] = new Rot(v3(0f, 0f, +1f)); this.rots[Cube.U] = new Rot(v3(0f, 0f, -1f)); this.rots[FM] = new Rot(v3(0f, 0f, -1f)); this.rots[TMH] = new Rot(v3(-1f, 0f, 0f)); this.rots[TMV] = new Rot(v3(0f, +1f, 0f)); pretime = sync(2600); intime = sync(500); Random rnd = new Random(12071607); for (int a = 0; a < 3; a++) { for (int b = 0; b < 3; b++) { for (int c = 0; c < 3; c++) { gen(a, b, c); int time = sync(pretime - rnd.Next(pretime - intime) - intime); cubeintime[a * 9 + b * 3 + c] = time; } } } using (StreamReader r = new StreamReader("rub.txt")) { Dictionary <string, int> mapping = new Dictionary <string, int>(); for (int i = 0; i < SIDES.Length; i++) { mapping.Add(SIDES[i], i); } int[] dir = { 1, 1, 1, 1, 1, 1, 1, 1, 1 }; foreach (string m in r.ReadToEnd().Split(' ')) { if (m == "<") { remap(mapping, Cube.R, Cube.F, Cube.B, Cube.U, Cube.D, Cube.L, FM, TMV, TMH); dir[TMH] *= -1; continue; } if (m == ">") { remap(mapping, Cube.L, Cube.B, Cube.F, Cube.U, Cube.D, Cube.R, FM, TMH, TMV); dir[TMV] *= -1; continue; } if (m == "^") { remap(mapping, Cube.D, Cube.L, Cube.R, Cube.F, Cube.B, Cube.U, TMH, FM, TMV); dir[TMH] *= -1; continue; } Mov mov = new Mov(); moves.Add(mov); int l = m.Length - 1; if (m[l] == '2') { mov.mp = 2; l--; } if (m[l] == '\'') { mov.dir = -1; l--; } mov.axis = mapping[m.Substring(0, l + 1)]; mov.dir *= dir[mov.axis]; } } movetime = ((stop - start) - pretime) / moves.Count; movetime = sync(max(framedelta, movetime)); #if ASRECTS List <Rect> coloredrects = new List <Rect>(); int idx = 0; foreach (Cube c in cubes) { for (int i = 0; i < 6; i++) { Rect r = c.rects[i]; if (r.color == defcol) { orects[idx++] = new Orect(r, 0); continue; } coloredrects.Add(c.rects[i]); } } foreach (Rect r in coloredrects) { orects[idx++] = new Orect(r, 0); } #endif }