Exemplo n.º 1
0
            private void shit(Rect rect, int baseidx, IColorOwner co)
            {
                int ridx = baseidx;

                baseidx *= 4;
                vec3 a = rect.pts[rect.a];
                vec3 b = rect.pts[rect.b];
                vec3 c = rect.pts[rect.c];
                vec3 d = rect.pts[rect.d];

                for (int i = 0; i < 8; i++)
                {
                    for (int j = 0; j < 8; j++)
                    {
                        float pi  = (i) / 8f;
                        float pi2 = (i + 1) / 8f;
                        float pj  = j / 8f;
                        float pj2 = (j + 1) / 8f;
                        vec3  ab1 = lerp(a, b, pi);
                        vec3  ab2 = lerp(a, b, pi2);
                        vec3  cd1 = lerp(c, d, pi);
                        vec3  cd2 = lerp(c, d, pi2);
                        int   z   = baseidx;
                        tpoints[baseidx++] = lerp(ab1, cd1, pj);
                        tpoints[baseidx++] = lerp(ab2, cd2, pj);
                        tpoints[baseidx++] = lerp(ab1, cd1, pj2);
                        tpoints[baseidx++] = lerp(ab2, cd2, pj2);
                        Color col = co.getColor(0, 0, 0, 0, 0, v2(pi, pj));
                        trects[ridx++] = new Rect(_tpoints, col, _tpoints, z, z + 1, z + 2, z + 3);
                    }
                }
            }
Exemplo n.º 2
0
 public void draw(SCENE scene)
 {
     for (int i = 0; i < hpixels; i++)
     {
         for (int j = 0; j < vpixels; j++)
         {
             if (!(owner[i, j] is IColorOwner))
             {
                 odot[i, j].update(scene.time, null, null, 0f);
                 continue;
             }
             IColorOwner co  = (IColorOwner)owner[i, j];
             vec4        pos = v4(this.x + i * pixelsize, this.y + j * pixelsize, 1f, 1f);
             vec4        res = col(co.getColor(i, j, (int)pos.x, (int)pos.y, zbuf[i, j], uv[i, j]));
             if (res.x == 0f && res.y == 0f && res.z == 0f)
             {
                 // this somehow fixes things /shrug
                 odot[i, j].update(scene.time, null, null, 0f);
                 continue;
             }
             odot[i, j].update(scene.time, res, pos);
             odot[i, j].draw(scene.g);
         }
     }
 }