diff --git a/src/projectM-engine/CMakeLists.txt b/src/projectM-engine/CMakeLists.txt index 76517822d..2d13a895f 100644 --- a/src/projectM-engine/CMakeLists.txt +++ b/src/projectM-engine/CMakeLists.txt @@ -27,7 +27,7 @@ SET(projectM_SOURCES projectM.cpp FBO.cpp InitCond.cpp Func.cpp Eval.cpp PerFrameEqn.cpp PerPointEqn.cpp fftsg.cpp KeyHandler.cpp timer.cpp wipemalloc.cpp BuiltinFuncs.cpp BuiltinParams.cpp Renderer.cpp PresetLoader.cpp PresetChooser.cpp PresetFrameIO.cpp PresetMerge.cpp -ConfigFile.cpp IdlePreset.cpp TextureManager.cpp TimeKeeper.cpp Transformation.cpp Filters.cpp Renderable.cpp Pipeline.cpp PerPixelMesh.cpp ${GLEW_SOURCES}) +ConfigFile.cpp IdlePreset.cpp TextureManager.cpp TimeKeeper.cpp Filters.cpp Renderable.cpp Pipeline.cpp PerPixelMesh.cpp ${GLEW_SOURCES}) if (USE_DEVIL) SET (projectM_SOURCES ${projectM_SOURCES}) diff --git a/src/projectM-engine/PerPixelMesh.cpp b/src/projectM-engine/PerPixelMesh.cpp index 0498c5a48..d122d76ba 100644 --- a/src/projectM-engine/PerPixelMesh.cpp +++ b/src/projectM-engine/PerPixelMesh.cpp @@ -1,44 +1,47 @@ #include +#include #include "PerPixelMesh.hpp" -PerPixelMesh::PerPixelMesh(int width, int height) : width(width), height(height), - x(width, std::vector(height)), - y(width, std::vector(height)), - x_tex(width, std::vector(height)), - y_tex(width, std::vector(height)), - x_identity(width, std::vector(height)), - y_identity(width, std::vector(height)), - rad_identity(width, std::vector(height)), - theta_identity(width, std::vector(height)) + +PerPixelMesh::PerPixelMesh(int width, int height) : width(width), height(height), size (width * height), + p(width * height, Point(0,0)), + p_original(width * height, Point(0,0)), + identity(width * height, PerPixelContext(0,0,0,0,0,0)) { - for (int i=0;i < width; i++ ) - for (int j=0;j < height; j++ ) - { + for (int j=0;j +struct Point +{ + float x; + float y; + + Point(float x, float y); +}; + +struct PerPixelContext +{ + float x; + float y; + float rad; + float theta; + + int i; + int j; + + PerPixelContext(float x, float y, float rad, float theta, int i, int j); +}; + class PerPixelMesh { public: int width; int height; + int size; - std::vector< std::vector > x; - std::vector< std::vector > y; - std::vector< std::vector > x_tex; - std::vector< std::vector > y_tex; - - std::vector< std::vector > x_identity; - std::vector< std::vector > y_identity; - std::vector< std::vector > rad_identity; - std::vector< std::vector > theta_identity; + std::vector p; + std::vector p_original; + std::vector identity; PerPixelMesh(int width, int height); void Reset(); }; + + #endif diff --git a/src/projectM-engine/Pipeline.cpp b/src/projectM-engine/Pipeline.cpp index 8b0d97732..d9e5bd4f7 100644 --- a/src/projectM-engine/Pipeline.cpp +++ b/src/projectM-engine/Pipeline.cpp @@ -6,5 +6,7 @@ */ #include "Pipeline.hpp" -Pipeline::Pipeline(int mesh_x, int mesh_y): mesh_x(mesh_x), mesh_y(mesh_y) {} +Pipeline::Pipeline() {} void Pipeline::Render(){} +Point Pipeline::PerPixel(Point p, PerPixelContext context) +{return p;} diff --git a/src/projectM-engine/Pipeline.hpp b/src/projectM-engine/Pipeline.hpp index b890be457..54bbbd4dc 100644 --- a/src/projectM-engine/Pipeline.hpp +++ b/src/projectM-engine/Pipeline.hpp @@ -2,7 +2,7 @@ #define Pipeline_HPP #include -#include "Transformation.hpp" +#include "PerPixelMesh.hpp" #include "Renderable.hpp" #include "Filters.hpp" @@ -12,9 +12,6 @@ public: int fps; - int mesh_x; - int mesh_y; - float time; float bass; float mid; @@ -32,12 +29,12 @@ public: float videoEchoZoom; float videoEchoOrientation; - std::vector perPixelTransforms; std::vector drawables; std::vector compositeDrawables; - Pipeline(int mesh_x, int mesh_y); + Pipeline(); virtual void Render(); + virtual Point PerPixel(Point p, PerPixelContext context); }; #endif diff --git a/src/projectM-engine/Renderer.cpp b/src/projectM-engine/Renderer.cpp index 642d07750..4acfd3b9c 100644 --- a/src/projectM-engine/Renderer.cpp +++ b/src/projectM-engine/Renderer.cpp @@ -7,6 +7,7 @@ #include "KeyHandler.hpp" #include "TextureManager.hpp" #include +#include #include using namespace std; @@ -30,7 +31,7 @@ Renderer::Renderer(int width, int height, int gx, int gy, int texsize, BeatDetec this->drawtitle=0; - this->title = "Unknown"; + //this->title = "Unknown"; /** Other stuff... */ this->correction = true; @@ -113,7 +114,7 @@ void Renderer::ResetTextures() void Renderer::RenderFrame(Pipeline* pipeline) { - + currentPipe = pipeline; glMatrixMode(GL_PROJECTION); glPushMatrix(); glMatrixMode(GL_MODELVIEW); @@ -439,39 +440,42 @@ void Renderer::Interpolation(Pipeline *pipeline) glEnable(GL_TEXTURE_2D); - int size = mesh.height; - - float p[size*2][2]; - float t[size*2][2]; + int size = mesh.width * 2; glEnableClientState(GL_VERTEX_ARRAY); glEnableClientState(GL_TEXTURE_COORD_ARRAY); glDisableClientState(GL_COLOR_ARRAY); + + float p[size][2]; + float t[size][2]; + glVertexPointer(2,GL_FLOAT,0,p); glTexCoordPointer(2,GL_FLOAT,0,t); mesh.Reset(); + std::transform(mesh.p.begin(), mesh.p.end(), mesh.identity.begin(), mesh.p.begin(), &Renderer::PerPixel); + /* for (vector::iterator pos = pipeline->perPixelTransforms.begin(); pos != pipeline->perPixelTransforms.end(); ++pos) (*pos)->Calculate(&mesh); - - for (int x=0;xPerPixel(p,context); +} Renderer::~Renderer() { @@ -765,7 +774,7 @@ void Renderer::draw_shapes(PresetOutputs *presetOutputs) { - float radius; + float xval, yval; float t; @@ -780,7 +789,7 @@ void Renderer::draw_shapes(PresetOutputs *presetOutputs) // printf("drawing shape %f\n", (*pos)->ang); (*pos)->y=-(( (*pos)->y)-1); - radius=.5; + (*pos)->radius= (*pos)->radius*(.707*.707*.707*1.04); //Additive Drawing or Overwrite if ( (*pos)->additive==0) glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); diff --git a/src/projectM-engine/Renderer.hpp b/src/projectM-engine/Renderer.hpp index 8da7da35b..0a0434e43 100644 --- a/src/projectM-engine/Renderer.hpp +++ b/src/projectM-engine/Renderer.hpp @@ -55,12 +55,14 @@ public: int totalframes; float realfps; + std::string title; int drawtitle; int texsize; PerPixelMesh mesh; + Renderer( int width, int height, int gx, int gy, int texsize, BeatDetect *beatDetect, std::string presetURL, std::string title_fontURL, std::string menu_fontURL); ~Renderer(); void RenderFrame(PresetOutputs *presetOutputs, PresetInputs *presetInputs); @@ -87,7 +89,7 @@ private: RenderTarget *renderTarget; BeatDetect *beatDetect; TextureManager *textureManager; - + static Pipeline* currentPipe; //per pixel equation variables std::string m_presetName; @@ -118,6 +120,7 @@ private: void CompositeOutput(Pipeline* pipeline); void Interpolation(Pipeline* pipeline); + static Point PerPixel(Point p, PerPixelContext context); void Interpolation(PresetOutputs *presetOutputs, PresetInputs *presetInputs); diff --git a/src/projectM-engine/RovastarDriftingChaos.hpp b/src/projectM-engine/RovastarDriftingChaos.hpp index 19d0c667e..fafe0bbf4 100644 --- a/src/projectM-engine/RovastarDriftingChaos.hpp +++ b/src/projectM-engine/RovastarDriftingChaos.hpp @@ -8,6 +8,7 @@ #include "Pipeline.hpp" #include "math.h" #include "MilkdropCompatability.hpp" +#include "Transformation.hpp" #include @@ -15,15 +16,9 @@ class RovastarDriftingChaos : public Pipeline { public: - Delta delta; - PerPixelZoom zoom; - Rotation rotate; Shape shape1, shape2, shape3; - RovastarDriftingChaos(int mesh_x, int mesh_y) : Pipeline(mesh_x, mesh_y), - delta(mesh_x,mesh_y,0,0), - rotate(mesh_x,mesh_y,0.5,0.5,0), - zoom(mesh_x, mesh_y, 1, 1) + RovastarDriftingChaos() : Pipeline() { screenDecay = 1.0; textureWrap = 0; @@ -36,11 +31,6 @@ public: drawables.push_back(&shape2); drawables.push_back(&shape3); - perPixelTransforms.push_back(&zoom); - perPixelTransforms.push_back(&delta); - perPixelTransforms.push_back(&rotate); - - shape1.sides = 3; shape1.radius=0.550000; shape1.a = 0.1; @@ -71,6 +61,7 @@ public: } float xamptarg, q8, oldq8, q7, xpos, ypos,xdir, xspeed, xamp, yamp, yamptarg,yspeed,ydir; + float dx, dy, angle; virtual void Render() { @@ -84,7 +75,7 @@ public: float xaccel = xdir*xamp - xpos - xspeed*0.055*below(abs(xpos),xamp); xspeed += xdir*xamp - xpos - xspeed*0.055*below(abs(xpos),xamp); xpos = xpos + 0.001*xspeed; - delta.dx = xpos*0.005; + dx = xpos*0.005; yamptarg = if_milk(equal(frame%15,0),min(0.3*volume*treb_att,0.5),yamptarg); yamp += 0.5*(yamptarg-yamp); ydir = if_milk(above(abs(ypos),yamp),-sign(ypos),if_milk(below(abs(yspeed),0.1),2*above(ypos,0)-1,ydir)); @@ -93,8 +84,8 @@ public: yspeed += ydir*yamp - ypos - yspeed*0.055*below(abs(ypos),yamp); ypos = ypos + 0.001*yspeed; - delta.dy = ypos*0.005; - rotate.angle = 10*(delta.dx-delta.dy); + dy = ypos*0.005; + angle = 10*(dx-dy); q8 =oldq8+ 0.0003*(powf(1+1.2*bass+0.4*bass_att+0.1*treb+0.1*treb_att+0.1*mid+0.1*mid_att,6)/fps); oldq8 = q8; @@ -130,16 +121,14 @@ public: shape3.g2 = 0.5 + 0.5*cos(q8*0.556+ 1); shape3.b2 = 0.5 + 0.5*sin(q8*0.638 + 3); - - for (int x = 0; x < mesh_x; x++) - for (int y = 0; y < mesh_y; y++) - { - float xval=x/(float)(mesh_x-1); - float yval=-((y/(float)(mesh_y-1))-1); - - float rad=hypot ( ( xval-.5 ) *2, ( yval-.5 ) *2 ) * .7071067; - zoom.zoom[x][y] = 1+0.05*rad; - } } + virtual Point PerPixel(Point p, PerPixelContext context) + { + Transforms::Zoom(p,context,1+0.05*context.rad,1); + Transforms::Transform(p,context,dx,dy); + Transforms::Rotate(p,context,angle,0.5,0.5); + return p; + + } }; diff --git a/src/projectM-engine/RovastarFractopiaFrantic.hpp b/src/projectM-engine/RovastarFractopiaFrantic.hpp index 27ea2c3b7..ac52b6582 100644 --- a/src/projectM-engine/RovastarFractopiaFrantic.hpp +++ b/src/projectM-engine/RovastarFractopiaFrantic.hpp @@ -7,6 +7,7 @@ #include "Pipeline.hpp" #include "math.h" +#include "Transformation.hpp" #include @@ -14,25 +15,19 @@ class RovastarFranticFractopia : public Pipeline { public: - PerPixelDelta delta; - Zoom zoom; - Border border; MotionVectors vectors; + float dx, dy; float q4, q5, q6; float movement; - RovastarFranticFractopia(int mesh_x, int mesh_y) : Pipeline(mesh_x, mesh_y), - delta(mesh_x,mesh_y,0,0), - zoom(mesh_x, mesh_y, 0.98, 1.503744) + RovastarFranticFractopia() : Pipeline() { drawables.push_back(&vectors); drawables.push_back(&border); - perPixelTransforms.push_back(&zoom); - perPixelTransforms.push_back(&delta); screenDecay = 1.0; @@ -67,7 +62,6 @@ public: virtual void Render() { - movement += 0.5*(((bass+bass_att + 0.075*pow((bass+0.6*bass_att+0.2*treb_att),3)))/(float)fps); if (movement > 10000.0) movement = 0.0; @@ -82,20 +76,21 @@ public: vectors.y_offset = 0.03*sin(movement*0.34); vectors.x_offset = 0.035*(sin(movement*0.217)+cos(movement*0.413)+sin(movement*0.311)); - float dx =0.01*sin(movement*5); - float dy =0.0005*(bass+bass_att); + dx =0.01*sin(movement*5); + dy =0.0005*(bass+bass_att); - for (int x = 0; x < mesh_x; x++) - for (int y = 0; y < mesh_y; y++) - { - float xval=x/(float)(mesh_x-1); - float yval=-((y/(float)(mesh_y-1))-1); + } - float myy = yval-(0.250025); - float myx = xval-0.5; - delta.dx[x][y] = dx + 2*(2*myx*myy); - delta.dy[x][y] = dy + 2*((myy*myy) - (myx*myx)); - } + virtual Point PerPixel(Point p, PerPixelContext context) + { + float myy = context.y-(0.250025); + float myx = context.x-0.5; + + Transforms::Zoom(p,context,0.98,1.503744); + + p.x = p.x - (dx + 2*(2*myx*myy)); + p.y = p.y - (dy + 2*((myy*myy) - (myx*myx))); + return p; } }; diff --git a/src/projectM-engine/Transformation.cpp b/src/projectM-engine/Transformation.cpp deleted file mode 100644 index c2bec0977..000000000 --- a/src/projectM-engine/Transformation.cpp +++ /dev/null @@ -1,220 +0,0 @@ -#include "Transformation.hpp" -#include -#include -#include - -using namespace std; - -PerPixelTransform::PerPixelTransform(int width, int height) : - width(width), height(height) {} - - -Warp::Warp(int width, int height, float warp, float speed, float scale) : - PerPixelTransform(width, height), - speed(speed),scale(scale), warp(warp){} - -PerPixelWarp::PerPixelWarp(int width, int height, float warp, float speed, float scale) : - PerPixelTransform(width, height), - speed(speed),scale(scale), - warp(width,vector(height,warp)){} - -Scale::Scale(int width, int height, float cx, float cy, float sx, float sy) : - PerPixelTransform(width, height), - cx(cx), cy(cy), sx(sx), sy(sy){} - -PerPixelScale::PerPixelScale(int width, int height, float cx, float cy, float sx, float sy) : - PerPixelTransform(width, height), - cx(width,vector(height,cx)), - cy(width,vector(height,cy)), - sx(width,vector(height,sx)), - sy(width,vector(height,sy)){} - -Rotation::Rotation(int width, int height, float cx, float cy, float angle) : - PerPixelTransform(width, height), - cx(cx), cy(cy), angle(angle){} - - -PerPixelRotation::PerPixelRotation(int width, int height, float cx, float cy, float angle) : - PerPixelTransform(width, height), - cx(width,vector(height,cx)), cy(width,vector(height,cy)), angle(width,vector(height,angle)){} - -Delta::Delta(int width, int height, float dx, float dy) : - PerPixelTransform(width, height), - dx(dx), dy(dy){} - void Calculate (PerPixelMesh* mesh); - -PerPixelDelta::PerPixelDelta(int width, int height, float dx, float dy) : - PerPixelTransform(width, height), - dx(width,vector(height,dx)), dy(width,vector(height,dy)){} - void Calculate (PerPixelMesh* mesh); - -Zoom::Zoom(int width, int height, float zoom, float zoomExponent) : - PerPixelTransform(width, height), - zoom(zoom), zoomExponent(zoomExponent){} - -PerPixelZoom::PerPixelZoom(int width, int height, float zoom, float zoomExponent) : - PerPixelTransform(width, height), - zoom(width,vector(height,zoom)), zoomExponent(width,vector(height,zoomExponent)){} - - -void Warp::Calculate(PerPixelMesh* mesh) -{ - float fWarpTime = time * speed; - float fWarpScaleInv = 1.0f / scale; - float f[4]; - f[0] = 11.68f + 4.0f*cosf(fWarpTime*1.413f + 10); - f[1] = 8.77f + 3.0f*cosf(fWarpTime*1.113f + 7); - f[2] = 10.54f + 3.0f*cosf(fWarpTime*1.233f + 3); - f[3] = 11.49f + 4.0f*cosf(fWarpTime*0.933f + 5); - - for (int i=0;ix[i][j] += warp*0.0035f*sinf(fWarpTime*0.333f + fWarpScaleInv*(mesh->x_identity[i][j]*f[0] - mesh->y_identity[i][j]*f[3])); - mesh->y[i][j] += warp*0.0035f*cosf(fWarpTime*0.375f - fWarpScaleInv*(mesh->x_identity[i][j]*f[2] + mesh->y_identity[i][j]*f[1])); - mesh->x[i][j] += warp*0.0035f*cosf(fWarpTime*0.753f - fWarpScaleInv*(mesh->x_identity[i][j]*f[1] - mesh->y_identity[i][j]*f[2])); - mesh->y[i][j] += warp*0.0035f*sinf(fWarpTime*0.825f + fWarpScaleInv*(mesh->x_identity[i][j]*f[0] + mesh->y_identity[i][j]*f[3])); - } - } -} - - - -void PerPixelWarp::Calculate(PerPixelMesh* mesh) -{ - float fWarpTime = time * speed; - float fWarpScaleInv = 1.0f / scale; - float f[4]; - f[0] = 11.68f + 4.0f*cosf(fWarpTime*1.413f + 10); - f[1] = 8.77f + 3.0f*cosf(fWarpTime*1.113f + 7); - f[2] = 10.54f + 3.0f*cosf(fWarpTime*1.233f + 3); - f[3] = 11.49f + 4.0f*cosf(fWarpTime*0.933f + 5); - - for (int i=0;ix[i][j] += warp[i][j]*0.0035f*sinf(fWarpTime*0.333f + fWarpScaleInv*(mesh->x_identity[i][j]*f[0] - mesh->y_identity[i][j]*f[3])); - mesh->y[i][j] += warp[i][j]*0.0035f*cosf(fWarpTime*0.375f - fWarpScaleInv*(mesh->x_identity[i][j]*f[2] + mesh->y_identity[i][j]*f[1])); - mesh->x[i][j] += warp[i][j]*0.0035f*cosf(fWarpTime*0.753f - fWarpScaleInv*(mesh->x_identity[i][j]*f[1] - mesh->y_identity[i][j]*f[2])); - mesh->y[i][j] += warp[i][j]*0.0035f*sinf(fWarpTime*0.825f + fWarpScaleInv*(mesh->x_identity[i][j]*f[0] + mesh->y_identity[i][j]*f[3])); - } - } -} - -void PerPixelScale::Calculate(PerPixelMesh* mesh) -{ - for (int i=0;ix[i][j] = ( mesh->x[i][j] - cx[i][j])/sx[i][j] + cx[i][j]; - mesh->y[i][j] = ( mesh->y[i][j] - cy[i][j])/sy[i][j] + cy[i][j]; - } - } -} - -void Scale::Calculate(PerPixelMesh* mesh) -{ - for (int i=0;ix[i][j] = ( mesh->x[i][j] - cx)/sx + cx; - mesh->y[i][j] = ( mesh->y[i][j] - cy)/sy + cy; - } - } -} - - -void Zoom::Calculate(PerPixelMesh* mesh) -{ - for (int i=0;irad_identity[i][j]*2.0f - 1.0f)); - float fZoom2Inv = 1.0f/fZoom2; - mesh->x[i][j]= mesh->x[i][j]*0.5f*fZoom2Inv + 0.5f; - mesh->y[i][j]= mesh->y[i][j]*0.5f*fZoom2Inv + 0.5f; - } - } -} - -void PerPixelZoom::Calculate(PerPixelMesh* mesh) -{ - for (int i=0;irad_identity[i][j]*2.0f - 1.0f)); - float fZoom2Inv = 1.0f/fZoom2; - mesh->x[i][j]= mesh->x[i][j]*0.5f*fZoom2Inv + 0.5f; - mesh->y[i][j]= mesh->y[i][j]*0.5f*fZoom2Inv + 0.5f; - } - } -} - -void Rotation::Calculate(PerPixelMesh* mesh) -{ -for (int i=0;ix[i][j] - cx; - float v2 = mesh->y[i][j] - cy; - - float cos_rot = cosf(angle); - float sin_rot = sinf(angle); - - mesh->x[i][j] = u2*cos_rot - v2*sin_rot + cx; - mesh->y[i][j] = u2*sin_rot + v2*cos_rot + cy; - - } - } -} - -void PerPixelRotation::Calculate(PerPixelMesh* mesh) -{ -for (int i=0;i < width;i++) - { - for(int j=0;jx[i][j] - cx[i][j]; - float v2 = mesh->y[i][j] - cy[i][j]; - - float cos_rot = cosf(angle[i][j]); - float sin_rot = sinf(angle[i][j]); - - mesh->x[i][j] = u2*cos_rot - v2*sin_rot + cx[i][j]; - mesh->y[i][j] = u2*sin_rot + v2*cos_rot + cy[i][j]; - - } - } -} - -void Delta::Calculate(PerPixelMesh* mesh) -{ -for (int i=0;i < width;i++) - { - for(int j=0;jx[i][j] -= dx; - mesh->y[i][j] -= dy; - } - } -} - -void PerPixelDelta::Calculate(PerPixelMesh* mesh) -{ - -for (int i=0;i < width;i++) - { - for(int j=0;jx[i][j] -= dx[i][j]; - mesh->y[i][j] -= dy[i][j]; - } - } -} diff --git a/src/projectM-engine/Transformation.hpp b/src/projectM-engine/Transformation.hpp index 55fe28ec0..15b204fe0 100644 --- a/src/projectM-engine/Transformation.hpp +++ b/src/projectM-engine/Transformation.hpp @@ -2,126 +2,65 @@ #define Transformation_HPP #include "PerPixelMesh.hpp" -#include +#include -class PerPixelTransform + +class Transforms { public: - int width; - int height; - PerPixelTransform(int width, int height); - virtual void Calculate(PerPixelMesh* mesh) = 0; -}; + inline static void Zoom(Point &p, PerPixelContext &context, float zoom, float zoomExponent) + { + float fZoom2 = powf( zoom, powf( zoomExponent, context.rad*2.0f - 1.0f)); + float fZoom2Inv = 1.0f/fZoom2; + p.x -= 0.5; + p.y -= 0.5; + p.x *= fZoom2Inv; + p.y *= fZoom2Inv; + p.x += 0.5; + p.y += 0.5; + } -class Warp : public PerPixelTransform -{ -public: - float warp; - float speed; - float scale; - float time; + inline static void Transform(Point &p, PerPixelContext &context, float dx, float dy) + { + p.x -= dx; + p.y -= dy; + } - Warp(int width, int height, float warp, float speed, float scale); - void Calculate(PerPixelMesh* mesh); -}; + inline static void Scale(Point &p, PerPixelContext &context, float sy, float sx, float cx, float cy) + { + p.x = (p.x - cx)/sx + cx; + p.y = (p.y - cy)/sy + cy; + } -class PerPixelWarp : public PerPixelTransform -{ -public: - std::vector< std::vector > warp; - float speed; - float scale; - float time; + inline static void Rotate(Point &p, PerPixelContext &context, float angle, float cx, float cy) + { + float u2 = p.x - cx; + float v2 = p.y - cy; - PerPixelWarp(int width, int height, float warp, float speed, float scale); - void Calculate(PerPixelMesh* mesh); -}; + float cos_rot = cosf(angle); + float sin_rot = sinf(angle); -class Scale : public PerPixelTransform -{ -public: - float cx; - float cy; - float sx; - float sy; + p.x = u2*cos_rot - v2*sin_rot + cx; + p.y = u2*sin_rot + v2*cos_rot + cy; + } - Scale(int width, int height, float cx, float cy, float sx, float sy); - void Calculate(PerPixelMesh* mesh); -}; + inline static void Warp(Point &p, PerPixelContext &context, float time, float speed, float scale, float warp) + { + float fWarpTime = time * speed; + float fWarpScaleInv = 1.0f / scale; + float f[4]; + f[0] = 11.68f + 4.0f*cosf(fWarpTime*1.413f + 10); + f[1] = 8.77f + 3.0f*cosf(fWarpTime*1.113f + 7); + f[2] = 10.54f + 3.0f*cosf(fWarpTime*1.233f + 3); + f[3] = 11.49f + 4.0f*cosf(fWarpTime*0.933f + 5); -class PerPixelScale : public PerPixelTransform -{ -public: - std::vector< std::vector > cx; - std::vector< std::vector > cy; - std::vector< std::vector > sx; - std::vector< std::vector > sy; + p.x += warp*0.0035f*sinf(fWarpTime*0.333f + fWarpScaleInv*(context.x*f[0] - context.y*f[3])); + p.y += warp*0.0035f*cosf(fWarpTime*0.375f - fWarpScaleInv*(context.x*f[2] + context.y*f[1])); + p.x += warp*0.0035f*cosf(fWarpTime*0.753f - fWarpScaleInv*(context.x*f[1] - context.y*f[2])); + p.y += warp*0.0035f*sinf(fWarpTime*0.825f + fWarpScaleInv*(context.x*f[0] + context.y*f[3])); + } - PerPixelScale(int width, int height, float cx, float cy, float sx, float sy); - void Calculate(PerPixelMesh* mesh); -}; - -class Rotation : public PerPixelTransform -{ -public: - float cx; - float cy; - float angle; - - Rotation(int width, int height, float cx, float cy, float angle); - void Calculate(PerPixelMesh* mesh); -}; - -class PerPixelRotation : public PerPixelTransform -{ -public: - std::vector< std::vector > cx; - std::vector< std::vector > cy; - std::vector< std::vector > angle; - - PerPixelRotation(int width, int height, float cx, float cy, float angle); - void Calculate(PerPixelMesh* mesh); -}; - -class Delta : public PerPixelTransform -{ -public: - float dx; - float dy; - - Delta(int width, int height, float dx, float dy); - void Calculate (PerPixelMesh* mesh); -}; - -class PerPixelDelta : public PerPixelTransform -{ -public: - std::vector< std::vector > dx; - std::vector< std::vector > dy; - - PerPixelDelta(int width, int height, float dx, float dy); - virtual void Calculate (PerPixelMesh* mesh); -}; - -class Zoom : public PerPixelTransform -{ -public: - float zoom; - float zoomExponent; - - Zoom(int width, int height, float zoom, float zoomExponent); - void Calculate (PerPixelMesh* mesh); -}; - -class PerPixelZoom : public PerPixelTransform -{ -public: - std::vector< std::vector > zoom; - std::vector< std::vector > zoomExponent; - - PerPixelZoom(int width, int height, float zoom, float zoomExponent); - void Calculate (PerPixelMesh* mesh); }; #endif