// AlbumArtWaveSpectum.vtx // Author : MrC float[] vl(256); int x; float[] cubeRot(3); float[] cubePos(3); void Init() { for (int i=0; i<9;i++) { cubePos[i] = 0.0f; cubeRot[i] = 0.0f; } } void Render() { gfxSetTexture(TEXTURE_ALBUMART); for (int i=0; i<3;i++) { cubePos[i] = cubePos[i] + cubeRot[i]; cubeRot[i] = cubeRot[i] * 0.95; if (cubeRot[i] > 1) cubeRot[i] = 1; if (cubeRot[i] < -1) cubeRot[i] = -1; } cubeRot[0] += BASS; cubeRot[1] += MIDDLE; cubeRot[2] += TREBLE; gfxPushMatrix(); gfxTranslate(-0.8, 0.25, 2); gfxRotate(cubePos[0],1,0,0); gfxRotate(cubePos[1],0,0,1); gfxRotate(cubePos[2],0,1,0); gfxCube(-0.25f, -0.25f, -0.25f, 0.25f, 0.25f, 0.25f); gfxPopMatrix(); gfxSetTexture(NULL); gfxSetAspect(0); gfxTranslate(0, 0, 2.414); gfxColour(1, 1, 1, 1); gfxBegin(PRIM_LINESTRIP); for (int x=0; x<256; x=x+1) { float r = WaveLeft(x); gfxVertex((x-128) / 256.0f + 0.3, r * 0.2f + 0.5f, 0); } gfxEnd(); gfxBegin(PRIM_LINESTRIP); for (int x=0; x<256; x=x+1) { float r = WaveRight(x); gfxVertex((x-128) / 256.0f + 0.3, r * 0.2f + 0.1f, 0); } gfxEnd(); // calculate spectrum for (x=0;x<256;x=x+1) vl[x] = 0; for (x=0;x<512;x=x+1) vl[x/2] = vl[x/2] + GetSpecLeft(x)+GetSpecRight(x); // now draw spectrum gfxTranslate(-1,-0.9,0); gfxBegin(PRIM_QUADLIST); gfxSetTexture(NULL); for (x = 0; x < 256; x++) { vl[x] = vl[x]/8; if (vl[x]>1.0) vl[x]=1.0; float xPos = x / 128.0f; gfxColour(1,0,0,1); gfxVertex(xPos+(1/128.0f),0,0); gfxVertex(xPos,0,0); gfxColour(1,vl[x],0, 1); gfxVertex(xPos,vl[x]*0.4,0); gfxVertex(xPos+(1/128.0f),vl[x]*0.4,0); } gfxEnd(); }