From c91847d549cc1c30eb15504a15ea9a6d5aa48165 Mon Sep 17 00:00:00 2001 From: "chirs241097@gmail.com" Date: Sun, 12 Jan 2014 14:43:14 +0000 Subject: --- hgehelp/hgedistort.cpp | 242 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 242 insertions(+) create mode 100644 hgehelp/hgedistort.cpp (limited to 'hgehelp/hgedistort.cpp') diff --git a/hgehelp/hgedistort.cpp b/hgehelp/hgedistort.cpp new file mode 100644 index 0000000..276ca05 --- /dev/null +++ b/hgehelp/hgedistort.cpp @@ -0,0 +1,242 @@ +/* +** Haaf's Game Engine 1.7 +** Copyright (C) 2003-2007, Relish Games +** hge.relishgames.com +** +** hgeDistortionMesh helper class implementation +*/ + +#include "../../include/hgedistort.h" + + +HGE *hgeDistortionMesh::hge=0; + + +hgeDistortionMesh::hgeDistortionMesh(int cols, int rows) +{ + int i; + + hge=hgeCreate(HGE_VERSION); + + nRows=rows; + nCols=cols; + cellw=cellh=0; + quad.tex=0; + quad.blend=BLEND_COLORMUL | BLEND_ALPHABLEND | BLEND_ZWRITE; + disp_array=new hgeVertex[rows*cols]; + + for(i=0;iRelease(); +} + +hgeDistortionMesh& hgeDistortionMesh::operator= (const hgeDistortionMesh &dm) +{ + if(this!=&dm) + { + nRows=dm.nRows; + nCols=dm.nCols; + cellw=dm.cellw; + cellh=dm.cellh; + tx=dm.tx; + ty=dm.ty; + width=dm.width; + height=dm.height; + quad=dm.quad; + + delete[] disp_array; + disp_array=new hgeVertex[nRows*nCols]; + memcpy(disp_array, dm.disp_array, sizeof(hgeVertex)*nRows*nCols); + } + + return *this; + +} + +void hgeDistortionMesh::SetTexture(HTEXTURE tex) +{ + quad.tex=tex; +} + +void hgeDistortionMesh::SetTextureRect(float x, float y, float w, float h) +{ + int i,j; + float tw,th; + + tx=x; ty=y; width=w; height=h; + + if (quad.tex) + { + tw=(float)hge->Texture_GetWidth(quad.tex); + th=(float)hge->Texture_GetHeight(quad.tex); + } + else + { + tw = w; + th = h; + } + + cellw=w/(nCols-1); + cellh=h/(nRows-1); + + for(j=0; jGfx_RenderQuad(&quad); + } +} + +void hgeDistortionMesh::SetZ(int col, int row, float z) +{ + if(row