//------------------------------------------- ofTexture ofxAssimpModelLoader::getTextureForMesh(int num){ if((int)modelMeshes.size()<=num){ ofLog(OF_LOG_ERROR,"couldn't find mesh " + ofToString(num) + " there's only " + ofToString(scene->mNumMeshes)); return ofTexture(); } return modelMeshes[num].texture; }
//------------------------------------------- ofTexture ofxAssimpModelLoader::getTextureForMesh(int i){ if(i < modelMeshes.size()){ if(modelMeshes[i].hasTexture()) { return modelMeshes[i].getTextureRef(); } } ofLogError("ofxAssimpModelLoader") << "getTextureForMesh(): mesh id: " << i << "out of range for total num meshes: " << scene->mNumMeshes; return ofTexture(); }
//------------------------------------------- ofTexture ofxAssimpModelLoader::getTextureForMesh(string name){ for(int i=0; i<(int)modelMeshes.size(); i++){ if(string(modelMeshes[i].mesh->mName.data)==name){ return modelMeshes[i].texture; } } ofLog(OF_LOG_ERROR,"couldn't find mesh " + name); return ofTexture(); }
//------------------------------------------- ofTexture ofxAssimpModelLoader::getTextureForMesh(string name){ for(int i=0; i<(int)modelMeshes.size(); i++){ if(string(modelMeshes[i].mesh->mName.data)==name){ if(modelMeshes[i].hasTexture()) { return modelMeshes[i].getTextureRef(); } } } ofLogError("ofxAssimpModelLoader") << "getTextureForMesh(): couldn't find mesh: \"" + name << "\""; return ofTexture(); }
//-------------------------------------------------------------- void testApp::setup() { mSession = PXCUPipeline_Init((PXCUPipeline)(PXCU_PIPELINE_GESTURE|PXCU_PIPELINE_COLOR_VGA)); if(!mSession) return; if(PXCUPipeline_QueryLabelMapSize(mSession, &mlw, &mlh)) { mLabelMap = new unsigned char[mlw*mlh]; mLabelTex = ofTexture(); mLabelTex.allocate(mlw,mlh,GL_LUMINANCE); } if(PXCUPipeline_QueryRGBSize(mSession, &mcw, &mch)) { mRgbMap = new unsigned char[mcw*mch*4]; mRgbTex = ofTexture(); mRgbTex.allocate(mcw,mch,GL_RGBA); } ofSetWindowShape(mcw*2,mch); mDraw = false; }
/* ====================================================================== setup() load images, set initial player pos and direction ====================================================================== */ void ofApp::setup() { width = ofGetWidth(); height = ofGetHeight(); pos.set(2, 2); FOV = 60; rot = PI; useTextures = true; keys = new bool[512]; for(int i = 0; i < 512; i++) { keys[i] = false; } tex = ofTexture(); tex.allocate(width, height, GL_RGB8); screenBuffer = new unsigned char[width * height * 8]; colorBuffer = new unsigned char[width * height * 3]; images = new ofImage[5]; images[0].loadImage("bricks.gif"); images[1].loadImage("bricks1.png"); images[2].loadImage("wall_plain.gif"); images[3].loadImage("bricks1.gif"); images[4].loadImage("bricks.gif"); textureData = new unsigned char[64 * 64 * 3]; textureData2 = new unsigned char[64 * 64 * 3]; textureData3 = new unsigned char[64 * 64 * 3]; for(int c = 0; c < 64 * 64 * 3; c++) { textureData[c] = images[0].getPixels()[c]; textureData2[c] = images[1].getPixels()[c]; textureData3[c] = images[2].getPixels()[c]; } }
//-------------------------------------------------------------------- bool ofVideoGrabber::setup(int w, int h, bool setUseTexture) { #ifndef OF_VID_GRABBER_TYPE #error OF_VID_GRABBER_TYPE is not #defined! #endif if(!grabber) { setGrabber( shared_ptr<OF_VID_GRABBER_TYPE>(new OF_VID_GRABBER_TYPE) ); } bUseTexture = setUseTexture; if( requestedDeviceID >= 0 ) { grabber->setDeviceID(requestedDeviceID); } setPixelFormat(internalPixelFormat); //this safely handles checks for supported format if( desiredFramerate!=-1 ) { grabber->setDesiredFrameRate(desiredFramerate); } grabber->setup(w, h); width = (int)grabber->getWidth(); height = (int)grabber->getHeight(); if( grabber->isInitialized() && bUseTexture ) { if(!grabber->getTexturePtr()) { for(int i=0; i<grabber->getPixels().getNumPlanes(); i++) { ofPixels plane = grabber->getPixels().getPlane(i); tex.push_back(ofTexture()); tex[i].allocate(plane); if(ofIsGLProgrammableRenderer() && plane.getPixelFormat() == OF_PIXELS_GRAY) { tex[i].setRGToRGBASwizzles(true); } } } } return grabber->isInitialized(); }
void ofxSwipeable::load(vector<ofPixels> pix, float w, float h, float f){ width = w; height = h; ofFbo::allocate(width,height,GL_RGBA32F_ARB); tex.assign(pix.size(),ofTexture()); for(int i=0;i<pix.size();i++){ tex[i].loadData(pix[i]); texWidth = tex[i].getWidth(); texHeight = tex[i].getHeight(); tex[i].setAnchorPercent(0.5,0.5); } indicators.assign(tex.size(),0); for(int i=0;i<indicators.size();i++){ indicators[i]=(i-0.5*indicators.size())*(width*indicatorGap); } indicatorPos=indicators[current]; if(indicators.size()<=1) indicator=false; fadeSize = f; ofFloatPixels fadePixels; fadePixels.allocate(fadeSize,height,OF_PIXELS_RGBA); int i=0; for(int y=0;y<(int)height;y++) { for(int x=0;x<(int)fadeSize;x++){ fadePixels[i+0]=0.; fadePixels[i+1]=0.; fadePixels[i+2]=0.; fadePixels[i+3]=1.-(x*x)/(fadeSize*fadeSize); //QUADRATIC_EASE_IN i+=4; } } fade.loadData(fadePixels); }