int main(int argc, char* argv[]) { // Create a ChronoENGINE physical system ChSystem mphysicalSystem; // Create the Irrlicht visualization (open the Irrlicht device, // bind a simple user interface, etc. etc.) ChIrrApp application(&mphysicalSystem, L"Critical cases for solver convergence",core::dimension2d<u32>(800,600),false,true); // Easy shortcuts to add camera, lights, logo and sky in Irrlicht scene: ChIrrWizard::add_typical_Logo(application.GetDevice()); ChIrrWizard::add_typical_Sky(application.GetDevice()); ChIrrWizard::add_typical_Lights(application.GetDevice()); ChIrrWizard::add_typical_Camera(application.GetDevice(), core::vector3df(0,1.5,-3)); // Create all the rigid bodies. create_items(application); class MyContactCallback : public ChSystem::ChCustomCollisionPointCallback { public: virtual void ContactCallback( const collision::ChCollisionInfo& mcontactinfo, ///< get info about contact (cannot change it) ChMaterialCouple& material ) ///< you can modify this! { // Set compliance (normal and tangential at once) material.compliance = STATIC_COMPLIANCE; material.complianceT = material.compliance ; material.dampingf = 0.2f; }; ChSystem* msystem; }; MyContactCallback mycontact_callback; // create the callback object mycontact_callback.msystem = &mphysicalSystem; // will be used by callback // Tell the system to use the callback above, per each created contact! mphysicalSystem.SetCustomCollisionPointCallback(&mycontact_callback); // Use this function for adding a ChIrrNodeAsset to all already created items (ex. a floor, a wall, etc.) // Otherwise use application.AssetBind(myitem); on a per-item basis. application.AssetBindAll(); application.AssetUpdateAll(); // Modify some setting of the physical system for the simulation, if you want mphysicalSystem.SetLcpSolverType(ChSystem::LCP_ITERATIVE_BARZILAIBORWEIN); //mphysicalSystem.SetLcpSolverType(ChSystem::LCP_ITERATIVE_SOR); mphysicalSystem.SetIterLCPmaxItersSpeed(60); mphysicalSystem.SetIterLCPmaxItersStab(5); mphysicalSystem.SetParallelThreadNumber(1); //mphysicalSystem.SetUseSleeping(true); application.SetStepManage(true); application.SetTimestep(0.01); application.SetPaused(true); // // THE SOFT-REAL-TIME CYCLE // while(application.GetDevice()->run()) { application.GetVideoDriver()->beginScene(true, true, SColor(255,140,161,192)); application.DrawAll(); align_spheres(application); // just to simplify test, on y axis only application.DoStep(); application.GetVideoDriver()->endScene(); } return 0; }
int main(int argc, char* argv[]) { // In CHRONO engine, The DLL_CreateGlobals() - DLL_DeleteGlobals(); pair is needed if // global functions are needed. DLL_CreateGlobals(); // Create a ChronoENGINE physical system ChSystem mphysicalSystem; // Create the Irrlicht visualization (open the Irrlicht device, // bind a simple user interface, etc. etc.) ChIrrApp application(&mphysicalSystem, L"Bricks test",core::dimension2d<u32>(800,600),false, true); // Easy shortcuts to add camera, lights, logo and sky in Irrlicht scene: ChIrrWizard::add_typical_Logo (application.GetDevice()); ChIrrWizard::add_typical_Sky (application.GetDevice()); ChIrrWizard::add_typical_Lights(application.GetDevice(), core::vector3df(70.f, 120.f, -90.f), core::vector3df(30.f, 80.f, 60.f), 290, 190); ChIrrWizard::add_typical_Camera(application.GetDevice(), core::vector3df(-15,14,-30), core::vector3df(0,5,0)); // // HERE YOU POPULATE THE MECHANICAL SYSTEM OF CHRONO... // // Create all the rigid bodies. create_wall_bodies (mphysicalSystem); //create_jengatower_bodies (mphysicalSystem); // Use this function for adding a ChIrrNodeAsset to all items // If you need a finer control on which item really needs a visualization proxy in // Irrlicht, just use application.AssetBind(myitem); on a per-item basis. application.AssetBindAll(); // Use this function for 'converting' into Irrlicht meshes the assets // into Irrlicht-visualizable meshes application.AssetUpdateAll(); // Prepare the physical system for the simulation mphysicalSystem.SetLcpSolverType(ChSystem::LCP_ITERATIVE_SOR_MULTITHREAD); mphysicalSystem.SetUseSleeping(false); mphysicalSystem.SetMaxPenetrationRecoverySpeed(1.6); // used by Anitescu stepper only mphysicalSystem.SetIterLCPmaxItersSpeed(40); mphysicalSystem.SetIterLCPmaxItersStab(20); // unuseful for Anitescu, only Tasora uses this mphysicalSystem.SetIterLCPwarmStarting(true); mphysicalSystem.SetParallelThreadNumber(4); // // THE SOFT-REAL-TIME CYCLE // application.SetStepManage(true); application.SetTimestep(0.02); while(application.GetDevice()->run()) { application.GetVideoDriver()->beginScene(true, true, SColor(255,140,161,192)); ChIrrTools::drawGrid(application.GetVideoDriver(), 5,5, 20,20, ChCoordsys<>(ChVector<>(0,0.2,0),Q_from_AngAxis(CH_C_PI/2,VECT_X)), video::SColor(50,90,90,150),true); application.DrawAll(); application.DoStep(); application.GetVideoDriver()->endScene(); } // Remember this at the end of the program, if you started // with DLL_CreateGlobals(); DLL_DeleteGlobals(); return 0; }