void AELoadedResourcesTreeView::LoadResources() { LoadModels(); LoadMaterials(); LoadTextures(); // LoadMeshes(); // LoadModelInstances(); // LoadMeshInstances(); }
//----------------------------------------------------------------------------- // The application main loop //----------------------------------------------------------------------------- int CIHVTestApp::Main() { SpewOutputFunc( IHVTestSpewFunc ); if ( !SetupStudioRender() ) { return 0; } if ( !InitMaterialSystem( m_hWnd ) ) { return 0; } #if !defined( _X360 ) // X360TBD: extern void Sys_InitFloatTime( void ); //garymcthack Sys_InitFloatTime(); #endif LoadModels(); #if USE_VTUNE VTResume(); #endif #ifdef USE_VPROF g_VProfCurrentProfile.Start(); #endif bool m_bExitMainLoop = false; while (!m_bExitMainLoop && !g_BenchFinished) { AppPumpMessages(); RenderFrame(); } #ifdef USE_VPROF g_VProfCurrentProfile.Stop(); #endif g_IHVTestFP = fopen( "ihvtest_vprof.txt", "w" ); #ifdef USE_VPROF SpewOutputFunc( IHVTestVProfSpewFunc ); g_VProfCurrentProfile.OutputReport( VPRT_SUMMARY ); g_VProfCurrentProfile.OutputReport( VPRT_HIERARCHY_TIME_PER_FRAME_AND_COUNT_ONLY ); fclose( g_IHVTestFP ); SpewOutputFunc( IHVTestSpewFunc ); #endif #if USE_VTUNE VTPause(); #endif return 0; }
bool CThesaurus::ReadThesaurusFromDisk() { //ErrorMessage ("Cannot Load models " +m_Directory+"/StatThes/FreqCollocTypes.txt"); if (m_bDontLoad) return true; if (!m_pMainGramTab) return false; if (!m_pEngGramTab) return false; if (m_MainLanguage == morphUnknown) return false; if (!LoadModels (m_Directory+"/StatThes/FreqCollocTypes.txt")) { ErrorMessage ("Cannot Load models " +m_Directory+"/StatThes/FreqCollocTypes.txt"); return false; }; string OborotsFileName = (m_MainLanguage == morphGerman) ? m_Directory+"/StatThes/GerOborots.txt" : m_Directory+"/StatThes/RusOborots.txt"; if (!LoadOborots (OborotsFileName)) { ErrorMessage ("Cannot Load oborots " + OborotsFileName); return false; }; if (!LoadTermins (m_Directory+"/StatThes/TextEntr.txt")) { ErrorMessage ("Cannot Load text entries " +m_Directory+"/StatThes/TextEntr.txt"); return false; }; if (!LoadSynItems (m_Directory+"/StatThes/Lemmas.txt")) { ErrorMessage ("Cannot Load lemmas " +m_Directory+"/StatThes/Lemmas.txt"); return false; }; if (!LoadSynonyms (m_Directory+"/StatThes/Synonyms.txt")) { ErrorMessage ("Cannot Load text entries " +m_Directory+"/StatThes/Synonyms.txt"); return false; }; return true; }
MOboolean mo3dModelManagerRef::Init(moConfig * cfg, MOuint param, mo3dModelManager *M) { moText text; nModels = cfg->GetValuesCount(param); text = moText("nModels: "); text += IntToStr(nModels); MODebug2->Push(text); Models = new mo3dModel* [nModels]; for(MOuint i=0;i<nModels;i++) Models[i] = NULL; MODebug2->Push(moText("Espacio asignado: cargando modelos... 8o|")); LoadModels(cfg,param,M); MODebug2->Push(moText("Models cargados 8oD")); return true; }
/* ================ idMoveable::Spawn ================ */ void idMoveable::Spawn( void ) { idTraceModel trm; float density, friction, bouncyness, mass, air_friction_linear, air_friction_angular; int clipShrink; idStr clipModelName; idVec3 maxForce, maxTorque; // check if a clip model is set spawnArgs.GetString( "clipmodel", "", clipModelName ); if( !clipModelName[0] ) { clipModelName = spawnArgs.GetString( "model" ); // use the visual model } // tels: support "model" "" with "noclipmodel" "0" - do not attempt to load // the clipmodel from the non-existing model name in this case: if( clipModelName.Length() ) { if( !collisionModelManager->TrmFromModel( clipModelName, trm ) ) { gameLocal.Error( "idMoveable '%s': cannot load collision model %s", name.c_str(), clipModelName.c_str() ); return; } // angua: check if the cm is valid if( idMath::Fabs( trm.bounds[0].x ) == idMath::INFINITY ) { gameLocal.Error( "idMoveable '%s': invalid collision model %s", name.c_str(), clipModelName.c_str() ); } // if the model should be shrunk clipShrink = spawnArgs.GetInt( "clipshrink" ); if( clipShrink != 0 ) { trm.Shrink( clipShrink * CM_CLIP_EPSILON ); } } // get rigid body properties spawnArgs.GetFloat( "density", "0.5", density ); density = idMath::ClampFloat( 0.001f, 1000.0f, density ); spawnArgs.GetFloat( "bouncyness", "0.6", bouncyness ); bouncyness = idMath::ClampFloat( 0.0f, 1.0f, bouncyness ); explode = spawnArgs.GetBool( "explode" ); unbindOnDeath = spawnArgs.GetBool( "unbindondeath" ); spawnArgs.GetFloat( "friction", "0.05", friction ); // reverse compatibility, new contact_friction key replaces friction only if present if( spawnArgs.FindKey( "contact_friction" ) ) { spawnArgs.GetFloat( "contact_friction", "0.05", friction ); } spawnArgs.GetFloat( "linear_friction", "0.6", air_friction_linear ); spawnArgs.GetFloat( "angular_friction", "0.6", air_friction_angular ); fxCollide = spawnArgs.GetString( "fx_collide" ); nextCollideFxTime = 0; // tels: m_scriptCollide = spawnArgs.GetString( "script_collide" ); m_nextCollideScriptTime = 0; m_collideScriptCounter = spawnArgs.GetInt( "collide_script_counter", "1" ); // override the default of 1 with 0 if no script is defined if( m_scriptCollide == "" ) { m_collideScriptCounter = 0; } m_minScriptVelocity = spawnArgs.GetFloat( "min_script_velocity", "5.0" ); damage = spawnArgs.GetString( "def_damage", "" ); canDamage = spawnArgs.GetBool( "damageWhenActive" ) ? false : true; minDamageVelocity = spawnArgs.GetFloat( "minDamageVelocity", "-1" ); if( minDamageVelocity == -1 ) { // grayman #2816 minDamageVelocity = MIN_DAMAGE_VELOCITY; } maxDamageVelocity = spawnArgs.GetFloat( "maxDamageVelocity", "-1" ); if( maxDamageVelocity == -1 ) { // grayman #2816 maxDamageVelocity = MAX_DAMAGE_VELOCITY; } nextDamageTime = 0; nextSoundTime = 0; health = spawnArgs.GetInt( "health", "0" ); // tels: load a visual model, as well as an optional brokenModel LoadModels(); // setup the physics physicsObj.SetSelf( this ); physicsObj.SetClipModel( new idClipModel( trm ), density ); physicsObj.GetClipModel()->SetMaterial( GetRenderModelMaterial() ); physicsObj.SetOrigin( GetPhysics()->GetOrigin() ); physicsObj.SetAxis( GetPhysics()->GetAxis() ); physicsObj.SetBouncyness( bouncyness ); physicsObj.SetFriction( air_friction_linear, air_friction_angular, friction ); physicsObj.SetGravity( gameLocal.GetGravity() ); int contents = CONTENTS_SOLID | CONTENTS_OPAQUE; // ishtvan: overwrite with custom contents, if present if( m_CustomContents != -1 ) { contents = m_CustomContents; } // greebo: Set the frobable contents flag if the spawnarg says so if( spawnArgs.GetBool( "frobable", "0" ) ) { contents |= CONTENTS_FROBABLE; } physicsObj.SetContents( contents ); physicsObj.SetClipMask( MASK_SOLID | CONTENTS_BODY | CONTENTS_CORPSE | CONTENTS_MOVEABLECLIP ); SetPhysics( &physicsObj ); if( spawnArgs.GetFloat( "mass", "10", mass ) ) { physicsObj.SetMass( mass ); } // tels if( spawnArgs.GetVector( "max_force", "", maxForce ) ) { physicsObj.SetMaxForce( maxForce ); } if( spawnArgs.GetVector( "max_torque", "", maxTorque ) ) { physicsObj.SetMaxTorque( maxTorque ); } if( spawnArgs.GetBool( "nodrop" ) ) { physicsObj.PutToRest(); } else { physicsObj.DropToFloor(); } if( spawnArgs.GetBool( "noimpact" ) || spawnArgs.GetBool( "notpushable" ) ) { physicsObj.DisableImpact(); } if( !spawnArgs.GetBool( "solid" ) ) { BecomeNonSolid(); } // SR CONTENTS_RESPONSE FIX if( m_StimResponseColl->HasResponse() ) { physicsObj.SetContents( physicsObj.GetContents() | CONTENTS_RESPONSE ); } m_preHideContents = physicsObj.GetContents(); m_preHideClipMask = physicsObj.GetClipMask(); allowStep = spawnArgs.GetBool( "allowStep", "1" ); // parse LOD spawnargs if( ParseLODSpawnargs( &spawnArgs, gameLocal.random.RandomFloat() ) ) { // Have to start thinking if we're distance dependent BecomeActive( TH_THINK ); } // grayman #2820 - don't queue EV_SetOwnerFromSpawnArgs if it's going to // end up doing nothing. Queuing this for every moveable causes a lot // of event posting during frame 0. If extra work is added to // EV_SetOwnerFromSpawnArgs, then that must be accounted for here, to // make sure it has a chance of getting done. idStr owner; if( spawnArgs.GetString( "owner", "", owner ) ) { PostEventMS( &EV_SetOwnerFromSpawnArgs, 0 ); } }
// - main ---------------------------------------------------------------------- int main(int argc, char* argv[]) { // Create viewer osgViewer::Viewer viewer; viewer.setUpViewInWindow(0, 0, 1024, 768); // Construct the scene graph, set it as the data to be viewed osg::ref_ptr<osg::Group> sgRoot = LoadModels(); sgRoot->addChild(CreateHUD(1024, 768)); viewer.setSceneData(sgRoot); // Create the OSGUIsh event handler osg::ref_ptr<OSGUIsh::EventHandler> guishEH( new OSGUIsh::EventHandler( 0.0, OSGUIsh::FocusPolicyFactoryMason<OSGUIsh::MouseOverFocusPolicy>(), OSGUIsh::FocusPolicyFactoryMason<OSGUIsh::MouseDownFocusPolicy>())); viewer.addEventHandler(guishEH); // Add an event handler for changing the policies osg::ref_ptr<ChangePolicyEventHandler> focusPolicyEH( new ChangePolicyEventHandler(guishEH)); viewer.addEventHandler(focusPolicyEH); // Adds the node to the event handler, so that it can get events guishEH->addNode(TreeNode); guishEH->addNode(StrawberryNode); guishEH->addNode(FishNode); // Register event handlers guishEH->getSignal(TreeNode, OSGUIsh::EVENT_MOUSE_ENTER) ->connect(&HandleMouseEnter); guishEH->getSignal(StrawberryNode, OSGUIsh::EVENT_MOUSE_ENTER) ->connect(&HandleMouseEnter); guishEH->getSignal(FishNode, OSGUIsh::EVENT_MOUSE_ENTER) ->connect(&HandleMouseEnter); guishEH->getSignal(TreeNode, OSGUIsh::EVENT_MOUSE_LEAVE) ->connect(&HandleMouseLeave); guishEH->getSignal(StrawberryNode, OSGUIsh::EVENT_MOUSE_LEAVE) ->connect(&HandleMouseLeave); guishEH->getSignal(FishNode, OSGUIsh::EVENT_MOUSE_LEAVE) ->connect(&HandleMouseLeave); guishEH->getSignal(TreeNode, OSGUIsh::EVENT_MOUSE_WHEEL_UP) ->connect(&HandleMouseWheelUp); guishEH->getSignal(StrawberryNode, OSGUIsh::EVENT_MOUSE_WHEEL_UP) ->connect(&HandleMouseWheelUp); guishEH->getSignal(FishNode, OSGUIsh::EVENT_MOUSE_WHEEL_UP) ->connect(&HandleMouseWheelUp); guishEH->getSignal(TreeNode, OSGUIsh::EVENT_MOUSE_WHEEL_DOWN) ->connect(&HandleMouseWheelDown); guishEH->getSignal(StrawberryNode, OSGUIsh::EVENT_MOUSE_WHEEL_DOWN) ->connect(&HandleMouseWheelDown); guishEH->getSignal(FishNode, OSGUIsh::EVENT_MOUSE_WHEEL_DOWN) ->connect(&HandleMouseWheelDown); guishEH->getSignal(TreeNode, OSGUIsh::EVENT_KEY_DOWN) ->connect(&HandleKeyDown); guishEH->getSignal(StrawberryNode, OSGUIsh::EVENT_KEY_DOWN) ->connect(&HandleKeyDown); guishEH->getSignal(FishNode, OSGUIsh::EVENT_KEY_DOWN) ->connect(&HandleKeyDown); // Enter rendering loop viewer.run(); }
//----------------------------------------------------------------------------- // Name: WinMain() // Desc: The application's entry point //----------------------------------------------------------------------------- int WINAPI WinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow ) { WNDCLASSEX winClass; MSG uMsg; bool deviceReset = FALSE; memset(&uMsg,0,sizeof(uMsg)); winClass.lpszClassName = "MY_WINDOWS_CLASS"; winClass.cbSize = sizeof(WNDCLASSEX); winClass.style = CS_HREDRAW | CS_VREDRAW; winClass.lpfnWndProc = WindowProc; winClass.hInstance = hInstance; winClass.hIcon = LoadIcon(hInstance, (LPCTSTR)IDI_DIRECTX_ICON); winClass.hIconSm = LoadIcon(hInstance, (LPCTSTR)IDI_DIRECTX_ICON); winClass.hCursor = LoadCursor(NULL, IDC_ARROW); winClass.hbrBackground = (HBRUSH)GetStockObject(BLACK_BRUSH); winClass.lpszMenuName = NULL; winClass.cbClsExtra = 0; winClass.cbWndExtra = 0; if(!RegisterClassEx( &winClass) ) return E_FAIL; // // Create window #0... // g_hWnd_0 = CreateWindowEx( NULL, "MY_WINDOWS_CLASS", "Direct3D (DX9) - Multiple Devices (Window #0)", WS_EX_TOPMOST | WS_POPUP, // fullscreen values /* WS_OVERLAPPEDWINDOW | WS_VISIBLE,*/ 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT, NULL, NULL, hInstance, NULL ); if( g_hWnd_0 == NULL ) return E_FAIL; ShowWindow( g_hWnd_0, nCmdShow ); UpdateWindow( g_hWnd_0 ); #ifdef TWO // // Create window #1... // g_hWnd_1 = CreateWindowEx( NULL, "MY_WINDOWS_CLASS", "Direct3D (DX9) - Multiple Devices (Window #1)", WS_EX_TOPMOST | WS_POPUP, // fullscreen values /* WS_OVERLAPPEDWINDOW | WS_VISIBLE,*/ 1920, 0, SCREEN_WIDTH, SCREEN_HEIGHT, NULL, NULL, hInstance, NULL ); if( g_hWnd_1 == NULL ) return E_FAIL; ShowWindow( g_hWnd_1, nCmdShow ); UpdateWindow( g_hWnd_1 ); #endif // // Init Direct3D usage on both windows... // init_0(); #ifdef TWO init_1(); #endif ResetDevice(); // Important !!! LoadModels(); while( uMsg.message != WM_QUIT ) { if( PeekMessage( &uMsg, NULL, 0, 0, PM_REMOVE ) ) { TranslateMessage( &uMsg ); DispatchMessage( &uMsg ); } else { g_dCurrentTime = timeGetTime(); g_dElpasedFrameTime = g_dCurrentTime - g_dLastTime; // How much time has passed since the last frame? g_dElpasedAppTime += g_dElpasedFrameTime; // How much time has passed overall for the application? g_dLastTime = g_dCurrentTime; render_0(); #ifdef TWO render_1(); #endif } } // // Cleanup Direct3D usage on both windows... // #ifdef TWO shutDown_1(); #endif shutDown_0(); UnregisterClass( "MY_WINDOWS_CLASS", winClass.hInstance ); return uMsg.wParam; }
/*************************************************** ** Main program entry point. ** ***************************************************/ int main(int argc, char* argv[]) { /* Do all the general purpose startup stuff...*/ glutInit(&argc, argv); /* we got a RGBA buffer and we're double buffering! */ glutInitDisplayMode( GLUT_RGBA | GLUT_DOUBLE | GLUT_DEPTH | GLUT_ALPHA ); /* set some size for the window. */ glutInitWindowSize( screenSize, screenSize ); /* arbitrarily set an initial window position... */ glutInitWindowPosition( 100, 100 ); /* make the window. give it a cool title */ glutCreateWindow("Reducing Noise in Image-Space Caustics With Variable-Sized Splatting (DEMO)"); /* load glew */ glewInit(); /* set the callback functions */ glutDisplayFunc( display ); glutReshapeFunc( reshape ); glutIdleFunc( idle ); glutMouseFunc( button ); glutMotionFunc( motion ); glutKeyboardFunc( keys ); glutSpecialFunc( special_keys ); /* Print out basic info about the demo on the command line */ DemoInformationToStdout(); AllocateTrackballs( TOTAL_TRACKBALLS ); if( argc > 0 && argv[1] ) ParseGeometrySettingsFile( argv[1] ); else UseDefaultSettings(); /* load models/textures/other data */ printf("(+) Loading and allocating textures...\n" ); SetupAndAllocateTextures(); LoadModels(); SetupModelMenu( ); glEnable( GL_LIGHTING ); glEnable( GL_LIGHT0 ); initLookAtMatrices(); glPushMatrix(); glLoadIdentity(); glRotatef( -90, 1, 0, 0 ); glGetDoublev( GL_MODELVIEW_MATRIX, initialMatrix ); glPopMatrix(); printf("(+) Loading vertex and fragment shaders...\n" ); InitCGPrograms(); printf("(+) Starting Main Loop...\n" ); makeMovie = new MovieMaker(); glutMainLoop(); return 0; }