void YafFile::loadFile(char* filename) { TiXmlDocument* doc=new TiXmlDocument( filename ); bool loadOkay = doc->LoadFile(); if ( !loadOkay ) { printf( "Could not load file '%s'. Error='%s'. Exiting.\n", filename, doc->ErrorDesc() ); exit( 1 ); } TiXmlElement* yafElement= doc->FirstChildElement( "yaf" ); if (yafElement == NULL) { printf("Main yaf block element not found! Exiting!\n"); exit(1); } TiXmlElement* globalsElement = yafElement->FirstChildElement( "globals" ); processGlobals(globalsElement); TiXmlElement* lightingElement = yafElement->FirstChildElement("lighting"); processGlobalLight(lightingElement); processLights(lightingElement); TiXmlElement* camerasElement = yafElement->FirstChildElement("cameras"); processCameras(camerasElement); TiXmlElement* texturesElement = yafElement->FirstChildElement("textures"); processTextures(texturesElement); TiXmlElement* appearanceElement = yafElement->FirstChildElement("appearances"); processAppearances(appearanceElement); TiXmlElement* animationsElement = yafElement->FirstChildElement("animations"); if(animationsElement!=NULL) { processAnimations(animationsElement); map<string,Animation*>::iterator it = animations.begin(); for(;it!=animations.end();it++) { (*it->second).print(); } } TiXmlElement* graphElement = yafElement->FirstChildElement("graph"); processGraph(graphElement); }
void XMLScene::loadFile() { TiXmlDocument* doc=new TiXmlDocument( filename ); bool loadOkay = doc->LoadFile(); if ( !loadOkay ) { printf( "Could not load file '%s'. Error='%s'. Exiting.\n", filename, doc->ErrorDesc() ); exit( 1 ); } TiXmlElement* anfElement= doc->FirstChildElement( "anf" ); if (anfElement == NULL) { printf("Main anf block element not found! Exiting!\n"); exit(1); } TiXmlElement* globalsElement = anfElement->FirstChildElement( "globals" ); processGlobals(globalsElement); TiXmlElement* camerasElement = anfElement->FirstChildElement("cameras"); processCameras(camerasElement); TiXmlElement* lightingElement = anfElement->FirstChildElement("lights"); defineGlobalVariables(); processLights(lightingElement); defineGlobalVariables(); TiXmlElement* texturesElement = anfElement->FirstChildElement("textures"); processTextures(texturesElement); TiXmlElement* appearanceElement = anfElement->FirstChildElement("appearances"); processAppearances(appearanceElement); TiXmlElement* graphElement = anfElement->FirstChildElement("graph"); processGraph(graphElement); //sets the children to the correct bool sceneGraph->setChildDisplay(); }
void ShadowMapping::populateRenderGraph(RenderingContext& ctx) { ANKI_TRACE_SCOPED_EVENT(R_SM); // First process the lights U32 threadCountForScratchPass = 0; processLights(ctx, threadCountForScratchPass); // Build the render graph RenderGraphDescription& rgraph = ctx.m_renderGraphDescr; if(m_scratchWorkItems.getSize()) { // Will have to create render passes // Scratch pass { // Compute render area const U32 minx = 0, miny = 0; const U32 height = m_scratchMaxViewportHeight; const U32 width = m_scratchMaxViewportWidth; GraphicsRenderPassDescription& pass = rgraph.newGraphicsRenderPass("SM scratch"); m_scratchRt = rgraph.newRenderTarget(m_scratchRtDescr); pass.setFramebufferInfo(m_scratchFbDescr, {}, m_scratchRt, minx, miny, width, height); ANKI_ASSERT( threadCountForScratchPass && threadCountForScratchPass <= m_r->getThreadHive().getThreadCount()); pass.setWork( [](RenderPassWorkContext& rgraphCtx) { static_cast<ShadowMapping*>(rgraphCtx.m_userData)->runShadowMapping(rgraphCtx); }, this, threadCountForScratchPass); TextureSubresourceInfo subresource = TextureSubresourceInfo(DepthStencilAspectBit::DEPTH); pass.newDependency({m_scratchRt, TextureUsageBit::FRAMEBUFFER_ATTACHMENT_READ_WRITE, subresource}); } // ESM pass { GraphicsRenderPassDescription& pass = rgraph.newGraphicsRenderPass("ESM"); m_esmRt = rgraph.importRenderTarget(m_esmAtlas, TextureUsageBit::SAMPLED_FRAGMENT); pass.setFramebufferInfo(m_esmFbDescr, {{m_esmRt}}, {}); pass.setWork( [](RenderPassWorkContext& rgraphCtx) { static_cast<ShadowMapping*>(rgraphCtx.m_userData)->runEsm(rgraphCtx); }, this, 0); pass.newDependency( {m_scratchRt, TextureUsageBit::SAMPLED_FRAGMENT, TextureSubresourceInfo(DepthStencilAspectBit::DEPTH)}); pass.newDependency({m_esmRt, TextureUsageBit::FRAMEBUFFER_ATTACHMENT_WRITE}); } } else { // No need for shadowmapping passes, just import the ESM atlas m_esmRt = rgraph.importRenderTarget(m_esmAtlas, TextureUsageBit::SAMPLED_FRAGMENT); } }
void MissionLighting::processInteriors() { // walk though the interiors and light each one for( int i = 0; i < m_interiors.size(); i++ ) { m_currentInterior = i; // check if skipping this one if( missionLightLockOnly && !m_interiors[i]->isLocked() ) { String name; getInteriorBaseFilename( m_interiors[i], name ); print( V_LOW, "Skipping unlocked interior ( %s )\n", name.c_str() ); continue; } ITRInstance * instance = getInteriorInstance( m_interiors[i] ); // check if the shape exists if( !instance || !instance->getShape() ) { String name; getInteriorBaseFilename( m_interiors[i], name ); print( V_HIGH, " *****************************************************\n" ); print( V_HIGH, " ***** Failed to get interior: %s\n", name.c_str() ); print( V_HIGH, " *****************************************************\n" ); continue; } ITRShape & src = *( instance->getShape() ); // test if an interior or not if( instance->isLinked() ) { String name; getInteriorBaseFilename( m_interiors[i], name ); print( V_MEDIUM, "Skipping linked interior ( %s )\n", name.c_str() ); continue; } // check for cloud mapping if( missionUseCloudMap ) print( V_MEDIUM, "Using cloud map: %s\n", cloudMapFile.c_str() ); // create our new shape ITRShape dest = src; dest.m_nameBuffer.clear(); // go through all the states in this one for( UInt32 j = 0; j < src.getNumStates(); j++ ) { ITRShape::State srcState = src.getState( j ); ITRShape::State & destState = dest.getState( j ); // add the name to the name index destState.nameIndex = dest.addFileName( src.getFileName( srcState.nameIndex ) ); // determine the number of details for( UInt32 k = 0; k < srcState.numLODs; k++ ) { ITRShape::LOD srcLod = src.m_lodVector[ srcState.lodIndex + k ]; ITRShape::LOD & destLod = dest.m_lodVector[ destState.lodIndex + k ]; // add the name to the name index destLod.geometryFileOffset = dest.addFileName( src.getFileName( srcLod.geometryFileOffset ) ); // get the geometry for this detail ITRGeometry * geometry = instance->getGeometry( srcState.lodIndex + k ); // go through the number of light sets for( UInt32 l = 0; l < src.getNumLightStates(); l++ ) { ITRShape::LODLightState srcLightState = src.m_lodLightStates[ srcLod.lightStateIndex + l ]; ITRShape::LODLightState & destLightState = dest.m_lodLightStates[ destLod.lightStateIndex + l ]; // set the lightstate to grab instance->setInteriorLightState( resManager, l ); // get the lighting for this lightset/geometry ITRLighting lighting = *instance->getLighting( k ); // process ITRBasicLighting::MaterialPropList matProps; // add one thing for now ITRBasicLighting::LightList lightList; // process the lights ( move them into the interior's space processLights( lightList, *m_interiors[i] ); // convert the lightmap file String fileName = src.getFileName( srcLightState.lightFileOffset ); char ext[64]; sprintf( ext, "-%d.dil", interior_instance[i] ); reextendFile( fileName, ext ); // add the name to the alt dis file destLightState.lightFileOffset = dest.addFileName( fileName.c_str() ); print( V_MEDIUM, "lighting-> %s - %s\n", dest.getFileName( destLightState.lightFileOffset ), dest.getFileName( destLod.geometryFileOffset ) ); // light it ITRBasicLighting::g_useNormal = true; // ITRBasicLighting::g_useLightMaps = true; // ITRBasicLighting::g_missionLighting = true; ITRBasicLighting::filterScale = 0.5f; // fill in the callback info ITRBasicLighting::CallbackInfo callback; callback.obj = this; callback.collide = collide; // set the flag to indicate that this is not the terrain we are lighting ( for the callback ) lightingTerrain = false; // do the lighting // ITRBasicLighting::light( *geometry, lightList, matProps, // &lighting, missionInteriorLOSCheck ? &callback : NULL ); ITRMissionLighting missionLighting; ITRBasicLighting::light( *geometry, lightList, &lighting, &missionLighting, missionInteriorLOSCheck ? &callback : NULL ); missionLighting.fileStore( fileName.c_str() ); // restore the lightmap list size // lighting.fileStore( fileName.c_str() ); dumpFileToVolumeAndRemove( volumeFile, fileName ); } } // add the materiallist filename dest.m_materialListOffset = dest.addFileName( src.getMaterialListFileName() ); // copy the light state names in for( UInt32 m = 0; m < src.getNumLightStates(); m++ ) { dest.m_lightStateNames[m] = dest.addFileName( src.getFileName( src.m_lightStateNames[m] ) ); } // get the new dis file name String disFile; getInteriorBaseFilename( m_interiors[i], disFile ); char ext[64]; sprintf( ext, ".%d.dis", interior_instance[i] ); reextendFile( disFile, ext ); // set the filename for this SimInterior setInteriorFilename( m_interiors[i], disFile.c_str() ); // write out the file FileRWStream Stream; Stream.open( disFile.c_str() ); dest.store( Stream ); Stream.close(); // add to the volume dumpFileToVolumeAndRemove( volumeFile, disFile ); } } }