void ShadowMapRenderer::Init() { createEffect(); createGaussianBlurQuadVB(); createRendertargetDepthStencil(); createTextures(); }
void Detection::createTexturesAndShowResultsGUI() { // 1. facial points // show gui cv::namedWindow("Resulting facial components"); cv::imshow("Resulting facial components", m_FacialPointsGUI); // show until any key cv::waitKey(); cv::destroyWindow("Resulting facial components"); // 2. textures // show gui m_FaceGeometryBackup = m_FaceGeometry; static int topValue = 70; static int bottomValue = 50; m_AddTextureTop = topValue/100.0; m_AddTextureBottom = bottomValue/100.0; createTextures(); cv::namedWindow("Resulting textures"); cv::createTrackbar("Top size", "Resulting textures", &topValue, 100, onTextureAdjustmentTrackbarTop, this); cv::imshow("Resulting textures", combineVertically(m_Textures[frontImgNr], m_Textures[sideImgNr])); cv::createTrackbar("Bottom size", "Resulting textures", &bottomValue, 100, onTextureAdjustmentTrackbarBottom, this); cv::imshow("Resulting textures", combineVertically(m_Textures[frontImgNr], m_Textures[sideImgNr])); // show until any key cv::waitKey(); cv::destroyWindow("Resulting textures"); }
// Initialization routine. void setup(void) { //LIGHTING //The lighting seems to pulse because the rotation //causes the spotlight to change intensity, based off //of intensity // Turn on OpenGL lighting. glColor3f(1,1,1); glEnable(GL_LIGHTING); glEnable(GL_COLOR_MATERIAL); glColorMaterial(GL_FRONT, GL_AMBIENT_AND_DIFFUSE); // Light property vectors. float lightAmb[] = { 0.0, 0.0, 0.0, 1.0 }; // ambient light float lightDiffusion[] = { 1.0, 1.0, 1.0, 1.0 }; float lightSpec[] = { 1.0, 1.0, 1.0, 1.0 }; float globAmb[] = { 0.2, 0.2, 0.2, 1.0 }; // Light0 properties. glLightfv(GL_LIGHT0, GL_AMBIENT, lightAmb); glLightfv(GL_LIGHT0, GL_DIFFUSE, lightDiffusion); glLightfv(GL_LIGHT0, GL_SPECULAR, lightSpec); glLightModelfv(GL_LIGHT_MODEL_AMBIENT, globAmb); // Global ambient light. glLightModeli(GL_LIGHT_MODEL_LOCAL_VIEWER, GL_TRUE); // Enable local viewpoint glEnable(GL_LIGHT0); // Enable particular light source. // Material property vectors. float matSpec[] = {1.0, 1.0, 1.0, 1.0}; float matShine[] = {50.0}; float matAmb[] = {1.0, 1.0, 1.0, 1.0}; float matDiff[] = {1.0, 1.0, 1.0, 1.0}; // Material properties. glMaterialfv(GL_FRONT, GL_SPECULAR, matSpec); glMaterialfv(GL_FRONT, GL_SHININESS, matShine); //TEXTURES glEnable(GL_DEPTH_TEST); // Create texture ids. glGenTextures(6, internalTextures); glGenTextures(2, externalTextures); // Generate procedural texture. createTextures(); // Load procedural texture. loadInternalTextures(); loadExternalTextures(); // Specify how texture values combine with current surface color values. glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); // Turn on OpenGL texturing. glEnable(GL_TEXTURE_2D); }
//////////////////////////////////////////////////////////////////////////////// // SoftShadowsRenderer::initRendering() //////////////////////////////////////////////////////////////////////////////// void SoftShadowsRenderer::initRendering() { GLint depthBits; glGetIntegerv(GL_DEPTH_BITS, &depthBits); LOGI("depth bits = %d\n", depthBits); // Setup the eye's view parameters initCamera( NvCameraXformType::MAIN, nv::vec3f(-0.644995f, 0.614183f, 0.660632f) * 1.5f, // position nv::vec3f(0.0f, 0.0f, 0.0f)); // look at point // Setup the light's view parameters initCamera( NvCameraXformType::SECONDARY, nv::vec3f(3.57088f, 6.989f, 5.19698f) * 1.5f, // position nv::vec3f(0.0f, 0.0f, 0.0f)); // look at point // Generate the samplers glGenSamplers(5, m_samplers); CHECK_GL_ERROR(); for (GLuint unit = 0; unit < NumTextureUnits; ++unit) { glBindSampler(unit, m_samplers[unit]); } // Create resources createShadowMap(); createGeometry(); createTextures(); createShaders(); // Set states that don't change glEnable(GL_DEPTH_TEST); glEnable(GL_CULL_FACE); glDepthFunc(GL_LESS); glCullFace(GL_BACK); glDisable(GL_BLEND); glClearColor( m_backgroundColor.x, m_backgroundColor.y, m_backgroundColor.z, m_backgroundColor.w); glClearDepthf(1.0f); for (GLuint unit = 0; unit < NumTextureUnits; ++unit) { glBindSampler(unit, 0); } }
void ShadowMapRenderer::OnResetDevice() { if(mShadowMapEffect) mShadowMapEffect->OnResetDevice(); if(mShadowTexEffect) mShadowTexEffect->OnResetDevice(); if(mGaussianBlurEffect) mGaussianBlurEffect->OnResetDevice(); createGaussianBlurQuadVB(); createRendertargetDepthStencil(); createTextures(); }
int main(int argc, char **argv) { glutInit(&argc, argv); glutInitWindowPosition(10, 10); glutInitWindowSize(800+GAP*3, 400+GAP*2); glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB | GLUT_DEPTH); if ((estado.mainWindow=glutCreateWindow("Labirinto")) == GL_FALSE) exit(1); imprime_ajuda(); // Registar callbacks do GLUT da janela principal init(); glutReshapeFunc(reshapeMainWindow); glutDisplayFunc(displayMainWindow); glutTimerFunc(estado.timer,Timer,0); glutKeyboardFunc(Key); glutKeyboardUpFunc(KeyUp); glutSpecialFunc(SpecialKey); glutSpecialUpFunc(SpecialKeyUp); // criar a sub window topSubwindow estado.topSubwindow=glutCreateSubWindow(estado.mainWindow, GAP, GAP, 400, 400); init(); setLight(); setMaterial(); createTextures(modelo.texID[JANELA_TOP]); createDisplayLists(JANELA_TOP); mdlviewer_init("gordon.mdl", gordon.stdModel[JANELA_TOP] ); for(int i=0;i<3;i++) mdlviewer_init("headcrab.mdl", headCrabs[i].stdModel[JANELA_TOP] ); glutReshapeFunc(redisplayTopSubwindow); glutDisplayFunc(displayTopSubwindow); glutTimerFunc(estado.timer,Timer,0); glutKeyboardFunc(Key); glutSpecialFunc(SpecialKey); glutSpecialUpFunc(SpecialKeyUp); // criar a sub window navigateSubwindow estado.navigateSubwindow=glutCreateSubWindow(estado.mainWindow, 400+GAP, GAP, 400, 800); init(); setLight(); setMaterial(); createTextures(modelo.texID[JANELA_NAVIGATE]); createDisplayLists(JANELA_NAVIGATE); mdlviewer_init("gordon.mdl", gordon.stdModel[JANELA_NAVIGATE] ); for(int i=0;i<3;i++) mdlviewer_init("headcrab.mdl", headCrabs[i].stdModel[JANELA_NAVIGATE] ); glutReshapeFunc(reshapeNavigateSubwindow); glutDisplayFunc(displayNavigateSubwindow); glutMouseFunc(mouseNavigateSubwindow); glutTimerFunc(estado.timer,Timer,0); glutKeyboardFunc(Key); glutSpecialFunc(SpecialKey); glutSpecialUpFunc(SpecialKeyUp); glutMainLoop(); return 0; }
void convert3ds(FILE *outputM2, Lib3dsFile *f) { load3ds(f); createTextures(); printf("Writing M2 File\n"); initFile(outputM2,"TEMP"); printf("Writing Model Data\n"); writeModelData(outputM2, dVertices, nVertices, dTriangles, nTriangles, dSubmeshes, nSubmeshes, dTextureUnits, nTextureUnits); printf("Writing Material Data\n"); writeMaterialData(outputM2, textureNames, dTextures, nTextures, nMaterials, colorData, colorTransData, transData, renderFlags); printf("Finalizing Model Data\n"); rewriteHeader(outputM2); /*int i,j,k; char *inputData; unsigned int fileLength; fseek(inputM2,0,SEEK_END); fileLength=ftell(inputM2); inputData=new char[fileLength]; fseek(inputM2,0,SEEK_SET); fread(inputData,fileLength,1,inputM2); fwrite(inputData,fileLength,1,outputM2); header=(ModelHeader *)inputData; views=(ModelView *)(inputData+header->ofsViews); oldSubmesh=(ModelGeoset *)(inputData+views->ofsSub); load3ds(f); header->ofsVertices=ftell(outputM2); header->nVertices=nVertices*4; fwrite(dVertices,sizeof(ModelVertex),nVertices,outputM2); fwrite(dVertices,sizeof(ModelVertex),nVertices,outputM2); fwrite(dVertices,sizeof(ModelVertex),nVertices,outputM2); fwrite(dVertices,sizeof(ModelVertex),nVertices,outputM2); fillLine(outputM2); header->ofsTexLookup=ftell(outputM2); header->nTexLookup=textureNames.size(); for(i=0;i<textureNames.size();i++) fwrite(&i,sizeof(uint16),1,outputM2); fillLine(outputM2); //Write out texture data createTextures(); for(i=0;i<nTextures;i++) { dTextures[i].nameOfs=ftell(outputM2); fwrite(textureNames[i].c_str(),textureNames[i].length()+1,1,outputM2); fillLine(outputM2); } header->nTextures=nTextures; header->ofsTextures=ftell(outputM2); fwrite(dTextures,sizeof(ModelTextureDef),nTextures,outputM2); fillLine(outputM2); //Output Color data header->nColors=nMaterials; header->ofsColors=ftell(outputM2); AnimationBlock *colorBlocks; colorBlocks=new AnimationBlock[2*nMaterials]; fwrite(colorBlocks,sizeof(AnimationBlock),2*nMaterials,outputM2); fillLine(outputM2); j=0; for(i=0;i<nMaterials;i++) { writeAnimationBlockData(&colorBlocks[i*2], outputM2, 0, 0, &j, 1, &colorData[3*i], 1, 3*sizeof(float)); writeAnimationBlockData(&colorBlocks[i*2+1], outputM2, 0, 0, &j, 1, &colorTransData[i], 1, sizeof(short)); } fseek(outputM2,header->ofsColors,SEEK_SET); fwrite(colorBlocks,sizeof(AnimationBlock),2*nMaterials,outputM2); delete colorBlocks; fseek(outputM2,0,SEEK_END); //Output Transparency AnimationBlock *transBlocks; header->nTransparency=nMaterials; header->ofsTransparency=ftell(outputM2); transBlocks=new AnimationBlock[nMaterials]; fwrite(transBlocks,sizeof(AnimationBlock),nMaterials,outputM2); fillLine(outputM2); for(i=0;i<nMaterials;i++) writeAnimationBlockData(&transBlocks[i], outputM2, 0, 0, &j, 1, &transData[i], 1, sizeof(short)); fseek(outputM2,header->ofsTransparency,SEEK_SET); fwrite(transBlocks,sizeof(AnimationBlock),nMaterials,outputM2); delete transBlocks; fseek(outputM2,0,SEEK_END); header->nTransparencyLookup=nMaterials; header->ofsTransparencyLookup=ftell(outputM2); for(i=0;i<textureNames.size();i++) fwrite(&i,sizeof(uint16),1,outputM2); fillLine(outputM2); //Output Render Flags header->nTexFlags=nMaterials; header->ofsTexFlags=ftell(outputM2); fwrite(renderFlags,sizeof(uint32),nMaterials,outputM2); fillLine(outputM2); //Redo View Data for(i=0;i<header->nViews;i++) { views[i].ofsIndex=ftell(outputM2); views[i].nIndex=nVertices; for(j=0;j<nVertices;j++) { k=j+i*nVertices; fwrite(&k,sizeof(uint16),1,outputM2); } fillLine(outputM2); views[i].ofsTris=ftell(outputM2); views[i].nTris=nTriangles*3; fwrite(dTriangles,sizeof(uint16)*3,nTriangles,outputM2); fillLine(outputM2); views[i].ofsProps=ftell(outputM2); views[i].nProps=nVertices; k=0; for(j=0;j<nVertices;j++) fwrite(&k,sizeof(int),1,outputM2); fillLine(outputM2); views[i].ofsSub=ftell(outputM2); views[i].nSub=nSubmeshes; fwrite(dSubmeshes,sizeof(ModelGeoset),nSubmeshes,outputM2); fillLine(outputM2); views[i].ofsTex=ftell(outputM2); views[i].nTex=nTextureUnits; fwrite(dTextureUnits,sizeof(ModelTexUnit),nTextureUnits,outputM2); fillLine(outputM2); } fseek(outputM2,0,SEEK_SET); fwrite(header,sizeof(ModelHeader),1,outputM2); fseek(outputM2,header->ofsViews,SEEK_SET); fwrite(views,sizeof(ModelView),header->nViews,outputM2);*/ }