示例#1
0
 public void CopyFrom(ref Pattern pattern)
 {
     for (int i = 0; i < NUM_TRACKS; i++)
     {
         for (int j = 0; j < STEPS_PER_PATTERN; j++)
         {
             drumEvents[i * STEPS_PER_PATTERN + j].CopyFrom(ref pattern.drumEvents[i * STEPS_PER_PATTERN + j]);
         }
     }
 }
示例#2
0
        // update tile data from the specified pattern
        public void Update(Pattern pattern)
        {
            // TODO
            const float tileSize = 1.0f / 16.0f;
            int vertIndex = 0;
            int texIndex = 0;
            for (int row = 0; row < Pattern.NUM_TRACKS; row++)
            {
                for (int column = 0; column < Pattern.STEPS_PER_PATTERN; column ++)
                {
                    float x = tileSize * column;
                    float y = tileSize * row;

                    vertices[vertIndex + 0] = x;	// x0
                    vertices[vertIndex + 1] = y;	// y0
                    vertices[vertIndex + 2] = 0.0f;	// z0

                    vertices[vertIndex + 3] = x;	// x1
                    vertices[vertIndex + 4] = y + tileSize;	// y1
                    vertices[vertIndex + 5] = 0.0f;	// z1

                    vertices[vertIndex + 6] = x + tileSize;	// x2
                    vertices[vertIndex + 7] = y;	// y2
                    vertices[vertIndex + 8] = 0.0f;	// z2

                    vertices[vertIndex + 9] = x + tileSize;	// x3
                    vertices[vertIndex + 10] = y + tileSize;	// y3
                    vertices[vertIndex + 11] = 0.0f;	// z3

                    vertIndex += 12;

                    // Set up texture coords (sprite) according to drumevent
                    DrumEvent drumEvent = pattern.drumEvents[row * Pattern.STEPS_PER_PATTERN + column];
                    x = 256.0f / 512;
                    y = 256.0f / 512;
                    float w = 48.0f / 512;
                    float h = 48.0f / 512;
                    if (drumEvent.vol > 20)
                        x = 352.0f / 512;

                    texcoords[texIndex] = x;
                    texcoords[texIndex + 1] = y;

                    texcoords[texIndex + 2] = x;
                    texcoords[texIndex + 3] = y + h;

                    texcoords[texIndex + 4] = x + w;
                    texcoords[texIndex + 5] = y;

                    texcoords[texIndex + 6] = x + w;
                    texcoords[texIndex + 7] = y + h;

                    texIndex += 8;

                }

            }

            for (int i = 0; i < 16 * Pattern.STEPS_PER_PATTERN * Pattern.NUM_TRACKS; i++)
            {
                colours[i] = 1.0f;
            }
        }