void Heightmap::loadRAW(int rows, int colums, string filename, float heightScale, float heightOffset) { // Set values. mHeightScale = heightScale; mHeightOffset = heightOffset; mRows = rows; mColums = colums; // Resize the vector. mHeightmap.resize(rows*colums); // A height for each vertex std::vector<unsigned char> in(rows*colums); // Open the file. std::ifstream inFile; inFile.open(filename.c_str(), ios_base::binary); // Read the RAW bytes. inFile.read((char*)&in[0], (streamsize)in.size()); for(int i = 0; i < mHeightmap.size(); i++) mHeightmap[i] = (float)in[i] * mHeightScale + mHeightOffset; // Done with file. inFile.close(); filter3x3(); }
//-------------------------------------------------------------- void testApp::update(){ ofBackground(100,100,100); vidGrabber.grabFrame(); if (vidGrabber.isFrameNew()){ unsigned char * pixels = vidGrabber.getPixels(); get2DVector(vector2D, pixels); for(int i=0;i<2;i++) filter3x3(vector2D, LP); filter3x3(vector2D, HP); tHold(vector2D); for(int i=0;i<3;i++) shrink(vector2D); for(int i=0;i<4;i++) expand(vector2D); for(int i=0;i<3;i++) shrink(vector2D); getRGBVector(grayPixels, vector2D); } videoTexture.loadData(grayPixels, camWidth,camHeight, GL_RGB); }
void Heightmap::addHeight(int i, int j, float height) { mHeightmap[i*mColums + j] += height; filter3x3(); }