SceneRenderer::SceneRenderer(bool isES2) { initTimers(); // Call this early to give it time to multi-thread init. m_particles = new ParticleRenderer(isES2); m_texStorage["floor"] = NvImage::UploadTextureFromDDSFile("images/tex1.dds"); m_texStorage["white_dummy"] = NvImage::UploadTextureFromDDSFile("images/white_dummy.dds"); m_modelStorage["T34-85"] = loadModelFromFile("models/T34-85.obj", 30.0f); m_modelStorage["cow"] = loadModelFromFile("models/cow.obj", 10.0f); const float treeOffset = 20; NvImage::VerticalFlip(false); m_texStorage["palm"] = NvImage::UploadTextureFromDDSFile("images/palm.dds"); NvImage::VerticalFlip(true); m_modelStorage["palm"] = loadModelFromFile("models/palm_tree.obj", 50.0f); // create terrain nv::vec3f scale(1000.0f, 100.0, 1000.0f); nv::vec3f translate(0.0f, -45.0, 0.0f); nv::matrix4f scaleMat, translateMat; scaleMat.set_scale(scale); translateMat.set_translate(translate); TerrainInput input; input.heightmap = "images/terrain_heightmap.dds"; input.colormap = "images/terrain_colormap.dds"; input.transform = translateMat*scaleMat; input.subdivsX = 128; input.subdivsY = 128; m_pTerrain = new Terrain(input); CreateRandomObjectsOnLandScape(m_models, m_modelStorage, m_texStorage, treeOffset); std::sort(m_models.begin(), m_models.end(), ObjectSorter()); m_opaqueColorProg = new OpaqueColorProgram(isES2); m_opaqueSolidDepthProg = new OpaqueDepthProgram("shaders/unshaded_solid.frag"); m_opaqueAlphaDepthProg = new OpaqueDepthProgram("shaders/unshaded_alpha.frag"); m_fbos = new SceneFBOs(); m_upsampler = new Upsampler(m_fbos); // Disable particle self-shadowing and render all particles in one draw call (slice). getParticleParams()->numSlices = 1; m_scene.setLightVector(vec3f(-0.70710683f, 0.50000000f, 0.49999994f)); m_scene.setLightDistance(6.f); m_scene.m_fbos = m_fbos; m_scene.m_lightAmbient = 0.15f; m_scene.m_lightDiffuse = 0.85f; m_statsCountdown = STATS_FRAMES; }
// Initialization: load and compile shaders, initialize camera(s), load models. void init() { // Get handles to the Scene and the Screen. Scene *rootScene = Engine::instance()->rootScene(); Screen *primScreen = Engine::instance()->mainScreen(); // Load shaders and use the resulting shader program. GLuint gShader = Angel::InitShader( "shaders/vmorph.glsl", "shaders/fmorph.glsl" ); // Let the other objects know which shader to use by default. rootScene->Shader( gShader ); primScreen->_camList.Shader( gShader ); // We start with no cameras, by default. Add one and set it "active" by using next(). primScreen->_camList.addCamera( "Camera1" ); primScreen->_camList.next(); // Create an object and add it to the scene with the name "bottle". Object *bottle = rootScene->AddObject( "bottle" ); // Use the object loader to actually fill out the vertices and-so-on of the bottle. loadModelFromFile( bottle, "../models/bottle-a.obj" ); // Scale the bottle down! bottle->trans.scale.Set( 0.01 ); // Buffer the object onto the GPU. This does not happen by default, // To allow you to make many changes and buffer only once, // or to buffer changes selectively. bottle->Buffer(); // Object class has-a pointer to an object which is the morph target. // they are created and buffered as follows: // this makes a new object and links it to the source object. it returns the addr of the new obj.. bottle->genMorphTarget( gShader ) ; // we can get the addr of the morph object like this, also. Object *bottleMorphTarget = bottle->getMorphTargetPtr() ; // with this model, we can use all the preexisting Object class functionality loadModelFromFile( bottleMorphTarget, "../models/bottle-b.obj" ); bottleMorphTarget->trans.scale.Set( 0.01 ); // YES THIS IS THE REAL OBJECT, NOT THE TARGET. // IT SENDS THE MORPH VERTICES TO THE SHADER, NOT TO THE DRAW LIST TO BE DRAWN! bottle->BufferMorphOnly(); // Generic OpenGL setup: Enable the depth buffer and set a nice background color. glEnable( GL_DEPTH_TEST ); glClearColor( 0.3, 0.5, 0.9, 1.0 ); }
StaticMesh::StaticMesh(const std::string& filename, bool flipUVs) : m_IsLoaded(false), m_NumMeshEntries(0), m_FilePath(filename) { m_FlipUVs = flipUVs; if (!loadModelFromFile(filename)) { std::cout << "failed to load assimp mesh: " << filename << std::endl; Log::Instance()->OutputError("failed to load assimp mesh: %s", filename.c_str()); return; } }
bool PostProcessing::loadModelFromFile(std::string filename){ std::fstream file; file.open(filename.c_str(), std::ios::in); if( !loadModelFromFile( file ) ){ return false; } //Close the file file.close(); return true; }
bool MovementIndex::loadModelFromFile(string filename) { std::fstream file; file.open(filename.c_str(), std::ios::in); if( !loadModelFromFile( file ) ) { return false; } //Close the file file.close(); return true; }
bool TimeDomainFeatures::loadModelFromFile(const string filename){ std::fstream file; file.open(filename.c_str(), std::ios::in); if( !loadModelFromFile( file ) ){ return false; } //Close the file file.close(); return true; }
void ImageViewer::detect() { loadModelFromFile(); QImage img(pathImage); reader.setInstancesNumber(0); for (int x0 = 0; x0 < img.width() - X_PIXEL; x0 += STEP_X_DETECTING) { reader.processInstance(x0, 0, x0 + X_PIXEL, Y_PIXEL, img); reader.incInstancesNumber(); } classify(img); }
bool KMeansQuantizer::loadModelFromFile(string filename){ std::fstream file; file.open(filename.c_str(), std::ios::in); if( !loadModelFromFile( file ) ){ return false; } //Close the file file.close(); return true; }
bool MinDist::loadModelFromFile(string filename){ std::fstream file; file.open(filename.c_str(), std::ios::in); if( !loadModelFromFile( file ) ){ return false; } file.close(); return true; }
bool ThresholdDetection::loadModelFromFile(string filename){ std::fstream file; file.open(filename.c_str(), std::ios::in); if( !loadModelFromFile( file ) ){ return false; } //Close the file file.close(); return true; }
bool DTW::loadModelFromFile( string fileName ){ std::fstream file; file.open(fileName.c_str(), std::ios::in); if( !loadModelFromFile( file ) ){ return false; } file.close(); return trained; }
bool Derivative::loadModelFromFile(string filename){ std::fstream file; file.open(filename.c_str(), std::ios::in); if( !loadModelFromFile( file ) ){ file.close(); initialized = false; return false; } file.close(); return true; }
bool ClassLabelTimeoutFilter::loadModelFromFile(string filename){ std::fstream file; file.open(filename.c_str(), std::ios::in); if( !loadModelFromFile( file ) ){ file.close(); initialized = false; return false; } file.close(); return true; }
bool DoubleMovingAverageFilter::loadModelFromFile( std::string filename ){ std::fstream file; file.open(filename.c_str(), std::ios::in); if( !loadModelFromFile( file ) ){ file.close(); initialized = false; return false; } file.close(); return true; }
bool SavitzkyGolayFilter::loadModelFromFile( std::string filename ){ std::fstream file; file.open(filename.c_str(), std::ios::in); if( !loadModelFromFile( file ) ){ file.close(); initialized = false; return false; } file.close(); return true; }
bool KNN::loadModelFromFile(string filename){ std::fstream file; file.open(filename.c_str(), std::ios::in); //Clear any previous models or data clear(); if( !loadModelFromFile( file ) ){ return false; } file.close(); return true; }
void InstancingApp::initRendering(void) { m_transformer->setTranslationVec(isMobilePlatform() ? nv::vec3f(0.0f, 0.0f, -40.0f) : nv::vec3f(-20.0f, 0.0f, -100.0f)); if( requireMinAPIVersion(NvGLAPIVersionES3(), false) ) { m_hwInstancing = true; glDrawElementsInstancedInternal = (PFNDrawElementsInstanced)getGLContext()->getGLProcAddress("glDrawElementsInstanced"); glVertexAttribDivisorInternal = (PFNVertexAttribDivisor)getGLContext()->getGLProcAddress("glVertexAttribDivisor"); } else { // We need at least _one_ of these two extensions if (!requireExtension("GL_ARB_instanced_arrays", false) && !requireExtension("GL_NV_draw_instanced", false)) { m_hwInstancing = false; m_instancingOptions = SHADER_INSTANCING; } else { m_hwInstancing = true; if (requireExtension("GL_ARB_instanced_arrays", false) ) { glDrawElementsInstancedInternal = (PFNDrawElementsInstanced)getGLContext()->getGLProcAddress("glDrawElementsInstancedARB"); glVertexAttribDivisorInternal = (PFNVertexAttribDivisor)getGLContext()->getGLProcAddress("glVertexAttribDivisorARB"); } else { glDrawElementsInstancedInternal = (PFNDrawElementsInstanced)getGLContext()->getGLProcAddress("glDrawElementsInstancedNV"); glVertexAttribDivisorInternal = (PFNVertexAttribDivisor)getGLContext()->getGLProcAddress("glVertexAttribDivisorNV"); } } } if( m_hwInstancing == false ) { m_instancingOptions = SHADER_INSTANCING; } NvAssetLoaderAddSearchPath("es2-aurora/InstancingApp"); LOGI("Hardware Instancing %s\n", m_hwInstancing ? "Available" : "Not available" ); if (getGLContext()->getConfiguration().apiVer.api == NvGLAPI::GL) { NvGLSLProgram::setGlobalShaderHeader("#version 130\n"); } else { NvGLSLProgram::setGlobalShaderHeader("#version 300 es\n"); } //init the shaders m_shaders[0] = NvGLSLProgram::createFromFiles("shaders/boxes.vert", "shaders/boxes.frag"); m_shaders[1] = NvGLSLProgram::createFromFiles("shaders/grass.vert", "shaders/grass.frag"); m_shaders[2] = NvGLSLProgram::createFromFiles("shaders/boxes_instanced.vert", "shaders/boxes.frag"); m_shaders[3] = NvGLSLProgram::createFromFiles("shaders/grass_instanced.vert", "shaders/grass.frag"); NvGLSLProgram::setGlobalShaderHeader(NULL); initShaders(); CHECK_GL_ERROR(); //load g_pModel loadModelFromFile("models/cube.obj", 0); loadModelFromFile("models/grass.obj", 1); CHECK_GL_ERROR(); GLuint texID; NvImage::VerticalFlip(false); CHECK_GL_ERROR(); texID = NvImageGL::UploadTextureFromDDSFile("images/rock.dds"); if( texID > 0) { configTexture( texID, 0 ); configTexture( texID, 2 ); } CHECK_GL_ERROR(); texID = NvImageGL::UploadTextureFromDDSFile( "images/grass.dds" ); if( texID > 0) { configTexture( texID, 1 ); configTexture( texID, 3 ); } CHECK_GL_ERROR(); texID = NvImageGL::UploadTextureFromDDSFile( "images/rock.dds" ); if( texID > 0) configTexture( texID, 2 ); CHECK_GL_ERROR(); texID = NvImageGL::UploadTextureFromDDSFile( "images/grass.dds" ); if( texID > 0) configTexture( texID, 3 ); CHECK_GL_ERROR(); NvImage::VerticalFlip(false); glClearColor(0.0, 0.0, 0.0, 1.0); CHECK_GL_ERROR(); }
UpdatingFileModel::UpdatingFileModel(const QString& _fileName, const QUrl& _url, QObject *parent) : UpdatingModel(_url, parent) , fileName(_fileName) { loadModelFromFile(); }
Model ResourceManager::LoadModel(std::string file, std::string name) { Models[name] = loadModelFromFile(file); return Models[name]; }
bool MLBase::load(const std::string filename){ return loadModelFromFile(filename); }