void test_logging(logger_type& lg, std::string const& channel_name) { BOOST_LOG_CHANNEL_SEV(lg, channel_name, normal) << "A normal severity level message"; BOOST_LOG_CHANNEL_SEV(lg, channel_name, notification) << "A notification severity level message"; BOOST_LOG_CHANNEL_SEV(lg, channel_name, warning) << "A warning severity level message"; BOOST_LOG_CHANNEL_SEV(lg, channel_name, error) << "An error severity level message"; BOOST_LOG_CHANNEL_SEV(lg, channel_name, critical) << "A critical severity level message"; }
void phx::core::actor::rigidactor::base::release() { BOOST_LOG_CHANNEL_SEV(lg, "phx core actor", debug) << __PRETTY_FUNCTION__; neb::core::actor::rigidactor::base::release(); phx::core::actor::actor::base::release(); }
phx::core::scene::local::local(sp::shared_ptr<neb::core::scene::util::parent> parent): neb::core::scene::base(parent), neb::core::scene::local(parent), phx::core::scene::base(parent) { BOOST_LOG_CHANNEL_SEV(lg, "phx core scene", debug) << __PRETTY_FUNCTION__; }
void neb::gfx::context::base::step(neb::core::TimeStep const & ts) { BOOST_LOG_CHANNEL_SEV(lg, "neb gfx context", debug) << __PRETTY_FUNCTION__; if(environ_) environ_->step(ts); }
void neb::gfx::Viewport::resize(int w, int h) { BOOST_LOG_CHANNEL_SEV(lg, "neb gfx", debug) << __PRETTY_FUNCTION__; w_ = w; h_ = h; aspect_ = (real)w_ / (real)h_; }
void phx::core::scene::base::init() { BOOST_LOG_CHANNEL_SEV(lg, "phx core scene", debug) << __PRETTY_FUNCTION__; neb::core::scene::base::init(); create_physics(); }
void neb::app::__net::sendClient(sp::shared_ptr< gal::net::omessage > msg) { //NEBULA_DEBUG_1_FUNCTION; if(client_) { client_->write(msg); } else { BOOST_LOG_CHANNEL_SEV(lg, "neb", debug) << "no client"; } }
void neb::app::__net::sendServer(sp::shared_ptr< gal::net::omessage > msg) { //NEBULA_DEBUG_1_FUNCTION; if(server_) { server_->write(msg); } else { BOOST_LOG_CHANNEL_SEV(lg, "neb", debug) << "no server"; } }
void test_logging(logger_type& lg, std::string const& channel_name) { BOOST_LOG_CHANNEL_SEV(lg, channel_name, normal) << "A normal severity level message"; BOOST_LOG_CHANNEL_SEV(lg, channel_name, notification) << "A notification severity level message"; BOOST_LOG_CHANNEL_SEV(lg, channel_name, warning) << "A warning severity level message"; BOOST_LOG_CHANNEL_SEV(lg, channel_name, error) << "An error severity level message"; BOOST_LOG_CHANNEL_SEV(lg, channel_name, critical) << "A critical severity level message"; BOOST_LOG_CHANNEL_SEV(lg, channel_name, critical) << boost::format("writing %1%, x=%2% : %3%-th try") % "toto" % 40.23 % 50; }
int phx::game::weapon::SimpleProjectile::key_fun(sp::shared_ptr<neb::gfx::window::base> window, int key, int , int action, int mods) { BOOST_LOG_CHANNEL_SEV(lg, "phx game weapon", debug) << __PRETTY_FUNCTION__;; int key_fire = GLFW_KEY_SPACE; switch(action) { case GLFW_PRESS: if(key == key_fire) { fire(); return 1; } break; } return 0; }
void neb::gfx::context::base::render() { BOOST_LOG_CHANNEL_SEV(lg, "neb gfx context", debug) << __PRETTY_FUNCTION__; /** * prepare rendering environment and then call the drawable */ GLUTPP_DEBUG_1_FUNCTION; if(!environ_) return; auto self = sp::dynamic_pointer_cast<neb::gfx::context::base>(shared_from_this()); assert(self); environ_->render(self); }
void phx::game::weapon::SimpleProjectile::fire() { BOOST_LOG_CHANNEL_SEV(lg, "phx game weapon", debug) << __PRETTY_FUNCTION__;; // create projectile actor auto actor(actor_.lock()); assert(actor); auto scene = actor->getPxParent()->getScene(); auto proj(sp::make_shared<phx::core::actor::rigiddynamic::local>(scene)); scene->insert(proj); proj->simulation_.word0 = phx::filter::filter::type::DYNAMIC | phx::filter::filter::type::PROJECTILE; proj->simulation_.word1 = phx::filter::filter::RIGID_AGAINST; // initialize position and velocity // relative values vec3 pos_relative(0,0,-2); vec3 vel_relative(0,0,-1); vel_relative *= velocity_; // rotate relative values to actor's space pos_relative = actor->pose_.rot_ * pos_relative; vel_relative = actor->pose_.rot_ * vel_relative; // center on actor proj->pose_ = actor->pose_; // translate proj->pose_.pos_ += vec4(pos_relative,0); // velocity proj->velocity_ = vel_relative; auto rigidbody(actor->isPxActorRigidBodyBase()); if(rigidbody) { proj->velocity_ += rigidbody->velocity_; } proj->init(); // shape auto shape = sp::make_shared<phx::core::shape::box>(proj); proj->neb::core::shape::util::parent::insert(shape); shape->s_ = vec3(size_); shape->init(); proj->setupFiltering(); // release timer std::shared_ptr<neb::Timer::actor::base> t( new neb::Timer::actor::Release(proj, scene->last_ + 5.0) ); }
void neb::gfx::context::base::release() { BOOST_LOG_CHANNEL_SEV(lg, "neb gfx context", debug) << __PRETTY_FUNCTION__; }
neb::gfx::context::base& neb::gfx::context::base::operator=(neb::gfx::context::base const & r){ BOOST_LOG_CHANNEL_SEV(lg, "neb gfx context", debug) << __PRETTY_FUNCTION__; return *this; }
neb::gfx::context::base::base(sp::shared_ptr<neb::gfx::context::util::parent> parent): parent_(parent) { BOOST_LOG_CHANNEL_SEV(lg, "neb gfx context", debug) << __PRETTY_FUNCTION__; }
int phx::core::actor::control::rigidbody::base::key_fun(sp::shared_ptr<neb::gfx::window::base> window, int key, int scancode, int action, int mods) { //NEBULA_DEBUG_0_FUNCTION; BOOST_LOG_CHANNEL_SEV(lg, "phx core actor", debug) << __PRETTY_FUNCTION__; /* long unsigned int f = flag_.val_ & ( neb::gfx::camera::view::util::flag::NORTH | neb::gfx::camera::view::util::flag::SOUTH | neb::gfx::camera::view::util::flag::EAST | neb::gfx::camera::view::util::flag::WEST | neb::gfx::camera::view::util::flag::UP | neb::gfx::camera::view::util::flag::DOWN);*/ BOOST_LOG_CHANNEL_SEV(lg, "phx core actor", debug) << "key = " << key << " scancode = " << scancode << " action = " << action << " mods = " << mods << " flag = "; vec4 x(1.0,0.0,0.0,0); vec4 y(0.0,1.0,0.0,0); vec4 z(0.0,0.0,1.0,0); switch(action) { case GLFW_PRESS: switch(key) { case GLFW_KEY_D: f_ += x; return 1; case GLFW_KEY_A: f_ -= x; return 1; case GLFW_KEY_E: f_ += y; return 1; case GLFW_KEY_Q: f_ -= y; return 1; case GLFW_KEY_W: f_ -= z; return 1; case GLFW_KEY_S: f_ += z; return 1; case GLFW_KEY_I: t_ += x; return 1; case GLFW_KEY_K: t_ -= x; return 1; case GLFW_KEY_L: t_ -= y; return 1; case GLFW_KEY_J: t_ += y; return 1; case GLFW_KEY_O: t_ -= z; return 1; case GLFW_KEY_U: t_ += z; return 1; default: return 0; } case GLFW_RELEASE: switch(key) { case GLFW_KEY_D: f_ -= x; return 1; case GLFW_KEY_A: f_ += x; return 1; case GLFW_KEY_E: f_ -= y; return 1; case GLFW_KEY_Q: f_ += y; return 1; case GLFW_KEY_W: f_ += z; return 1; case GLFW_KEY_S: f_ -= z; return 1; case GLFW_KEY_I: t_ -= x; return 1; case GLFW_KEY_K: t_ += x; return 1; case GLFW_KEY_L: t_ += y; return 1; case GLFW_KEY_J: t_ -= y; return 1; case GLFW_KEY_O: t_ += z; return 1; case GLFW_KEY_U: t_ -= z; return 1; default: return 0; } } return 0; }
void phx::core::scene::base::create_physics() { BOOST_LOG_CHANNEL_SEV(lg, "phx core scene", debug) << __PRETTY_FUNCTION__; if(px_scene_ != NULL) { BOOST_LOG_CHANNEL_SEV(lg, "phx core scene", debug) << "been here!"; return; } auto pxphysics = phx::app::base::global()->px_physics_; physx::PxSceneDesc scene_desc(pxphysics->getTolerancesScale()); scene_desc.gravity = phx::util::convert(gravity_); scene_desc.flags |= physx::PxSceneFlag::eENABLE_ACTIVETRANSFORMS; int m_nbThreads = 1; // cpu dispatcher printf("cpu dispatcher\n"); if( !scene_desc.cpuDispatcher ) { physx::PxDefaultCpuDispatcher* cpuDispatcher = ::physx::PxDefaultCpuDispatcherCreate( m_nbThreads ); assert( cpuDispatcher ); scene_desc.cpuDispatcher = cpuDispatcher; } // filter shader printf("filter shader\n"); if(!scene_desc.filterShader) { if(px_filter_shader_) { scene_desc.filterShader = px_filter_shader_; } else { scene_desc.filterShader = DefaultFilterShader; } } // gpu dispatcher printf("gpu dispatcher\n"); #ifdef PX_WINDOWS if( !scene_desc.gpuDispatcher && m_cudaContextManager ) { sceneDesc.gpuDispatcher = m_cudaContextManager->getGpuDispatcher(); } #endif assert( scene_desc.isValid() ); px_scene_ = pxphysics->createScene(scene_desc); assert(px_scene_); // simulation callback phx::simulation_callback* sec = new phx::simulation_callback; simulation_callback_ = sec; px_scene_->setSimulationEventCallback(sec); }
void phx::core::scene::base::release() { BOOST_LOG_CHANNEL_SEV(lg, "phx core scene", debug) << __PRETTY_FUNCTION__; }
void phx::core::scene::local::step(neb::core::TimeStep const & ts) { BOOST_LOG_CHANNEL_SEV(lg, "phx core scene", debug) << __PRETTY_FUNCTION__ << " dt = " << ts.dt; neb::core::scene::local::step(ts); phx::core::scene::base::step(ts); auto app = neb::app::base::global(); // timer //timer_set_.step(time); //physx::PxU32 nbPxactor = px_scene_->getNbActors(physx::PxActorTypeSelectionFlag::eRIGID_DYNAMIC); // PxScene assert(px_scene_ != NULL); px_scene_->simulate(ts.dt); px_scene_->fetchResults(true); // retrieve array of actors that moved physx::PxU32 nb_active_transforms; const physx::PxActiveTransform* active_transforms = px_scene_->getActiveTransforms(nb_active_transforms); BOOST_LOG_CHANNEL_SEV(lg, "phx core scene", debug) << "active transforms: " << nb_active_transforms; //physx::PxTransform pose; physx::PxTransform pose; // update each render object with the new transform for(physx::PxU32 i = 0; i < nb_active_transforms; ++i) { //physx::PxActor* px_actor = active_transforms[i].actor; //printf( "actor type = %i\n", px_actor->getType() ); physx::PxActor* pxactor = active_transforms[i].actor; assert(pxactor); void* ud = active_transforms[i].userData; assert(ud); physx::PxRigidBody* pxrigidbody = pxactor->isRigidBody(); neb::core::actor::base* pactor = static_cast<neb::core::actor::base*>(ud); auto actor = pactor->isActorBase(); assert(actor); if(actor) { pose = active_transforms[i].actor2World; actor->setPose(neb::core::pose( phx::util::convert(pose.p), phx::util::convert(pose.q) )); BOOST_LOG_CHANNEL_SEV(lg, "phx core scene", debug) << std::setw(8) << "p" << std::setw(8) << pose.p.x << std::setw(8) << pose.p.y << std::setw(8) << pose.p.z; if(pxrigidbody != NULL) { auto rigidbody = actor->isActorRigidBody(); if(!rigidbody) { std::cout << typeid(*actor).name() << std::endl; abort(); } physx::PxVec3 v(pxrigidbody->getLinearVelocity()); rigidbody->velocity_ = phx::util::convert(v); //v.print(); } actor->flag_.set(neb::core::actor::util::Flag::E::SHOULD_UPDATE); } } // vehicle //physx::PxVec3 g(0,-0.25,0); //vehicle_manager_.vehicle_suspension_raycasts(px_scene_); //vehicle_manager_.update((float)dt, g); send_actor_update(); }
phx::core::scene::base::base(sp::shared_ptr< ::neb::core::scene::util::parent > parent): neb::core::scene::base(parent), px_scene_(NULL) { BOOST_LOG_CHANNEL_SEV(lg, "phx core scene", debug) << __PRETTY_FUNCTION__; }
void phx::core::actor::rigidactor::base::step(neb::core::TimeStep const & ts) { BOOST_LOG_CHANNEL_SEV(lg, "phx core actor", debug) << __PRETTY_FUNCTION__; neb::core::actor::rigidactor::base::step(ts); phx::core::actor::actor::base::step(ts); }