Home | History | Annotate | Download | only in raw
      1 // Fountain test script
      2 
      3 #pragma version(1)
      4 #pragma stateVertex(PVBackground)
      5 #pragma stateFragment(PFBackground)
      6 #pragma stateStore(PSBackground)
      7 
      8 #define STATE_TRIANGLE_OFFSET_COUNT 0
      9 #define STATE_LAST_FOCUS 1
     10 
     11 
     12 // The script enviroment has 3 env allocations.
     13 // bank0: (r) The enviroment structure
     14 // bank1: (r) The position information
     15 // bank2: (rw) The temporary texture state
     16 
     17 int lastFocus;
     18 
     19 int main(int index)
     20 {
     21     float mat1[16];
     22 
     23     float trans = Pos->translate;
     24     float rot = Pos->rotate;
     25 
     26     matrixLoadScale(mat1, 2.f, 2.f, 2.f);
     27     matrixTranslate(mat1, 0.f, 0.f, trans);
     28     matrixRotate(mat1, 90.f, 0.f, 0.f, 1.f);
     29     matrixRotate(mat1, rot, 1.f, 0.f, 0.f);
     30     vpLoadModelMatrix(mat1);
     31 
     32     // Draw the lighting effect in the strip and fill the Z buffer.
     33     drawSimpleMesh(NAMED_mesh);
     34 
     35     // Start of images.
     36     bindProgramStore(NAMED_PSImages);
     37     bindProgramFragment(NAMED_PFImages);
     38     bindProgramVertex(NAMED_PVImages);
     39 
     40     float focusPos = Pos->focus;
     41     int focusID = 0;
     42     int lastFocusID = loadI32(2, STATE_LAST_FOCUS);
     43     int imgCount = 13;
     44 
     45     if (trans > (-.3f)) {
     46         focusID = -1.0f - focusPos;
     47         if (focusID >= imgCount) {
     48             focusID = -1;
     49         }
     50     } else {
     51         focusID = -1;
     52     }
     53 
     54     /*
     55     if (focusID != lastFocusID) {
     56         if (lastFocusID >= 0) {
     57             uploadToTexture(con, env->tex[lastFocusID], 1);
     58         }
     59         if (focusID >= 0) {
     60             uploadToTexture(con, env->tex[focusID], 0);
     61         }
     62     }
     63     */
     64     lastFocus = focusID;
     65 
     66     int triangleOffsetsCount = Pos->triangleOffsetCount;
     67 
     68     int imgId = 0;
     69     for (imgId=1; imgId <= imgCount; imgId++) {
     70         float pos = focusPos + imgId + 0.4f;
     71         int offset = (int)floorf(pos * 2.f);
     72         pos = pos - 0.75f;
     73 
     74         offset = offset + triangleOffsetsCount / 2;
     75         if (!((offset < 0) || (offset >= triangleOffsetsCount))) {
     76             int start = offset -2;
     77             int end = offset + 2;
     78 
     79             if (start < 0) {
     80                 start = 0;
     81             }
     82             if (end >= triangleOffsetsCount) {
     83                 end = triangleOffsetsCount-1;
     84             }
     85 
     86             bindTexture(NAMED_PFImages, 0, loadI32(0, imgId - 1));
     87             matrixLoadTranslate(mat1, -pos - loadF(5, triangleOffsetsCount / 2), 0, 0);
     88             vpLoadTextureMatrix(mat1);
     89             drawSimpleMeshRange(NAMED_mesh, loadI32(4, start), (loadI32(4, end) - loadI32(4, start)));
     90         }
     91     }
     92     return 0;
     93 }
     94 
     95