Changeset 541
- Timestamp:
- 03/01/10 22:54:45 (5 months ago)
- Location:
- branches/cpp-ode/src
- Files:
-
- 11 modified
-
libmmpong/netgame_ode.cc (modified) (1 diff)
-
libmmpong/netgame_ode.h (modified) (1 diff)
-
libmmpong/netgame_ode_pong.cc (modified) (2 diffs)
-
libmmpong/netgame_ode_pong.h (modified) (1 diff)
-
libmmpong/netmsg.h (modified) (2 diffs)
-
libmmpong/ode_box.cc (modified) (1 diff)
-
libmmpong/ode_box.h (modified) (1 diff)
-
libmmpong/ode_obj.h (modified) (5 diffs)
-
libmmpong/ode_sphere.cc (modified) (1 diff)
-
libmmpong/ode_sphere.h (modified) (1 diff)
-
mmpong-gl/client_gl.cc (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
branches/cpp-ode/src/libmmpong/netgame_ode.cc
r540 r541 30 30 for (unsigned int i=0; i<step_count; i++) { 31 31 collide(); 32 step(STEPSIZE);32 quickStep(STEPSIZE); 33 33 } 34 34 world_time=endtime; -
branches/cpp-ode/src/libmmpong/netgame_ode.h
r540 r541 49 49 unsigned int n_collide = dCollide(o1, o2, MAX_CONTACTS, &contact[0].geom, sizeof(dContact)); 50 50 for (unsigned int i=0; i< n_collide; i++){ 51 contact[i].surface.mode = dContactBounce; 51 contact[i].surface.mode = dContactBounce;// | dContactSoftCFM; 52 52 contact[i].surface.mu=dInfinity; 53 contact[i].surface. mu2=0;54 contact[i].surface.bounce =0.9;55 contact[i].surface.bounce_vel=0.1;53 contact[i].surface.bounce=1.0; // \in [0,1] 54 contact[i].surface.bounce_vel=0.01; 55 //contact[i].surface.soft_cfm = 0.1; 56 56 dBodyID b1 = dGeomGetBody(o1), b2 = dGeomGetBody(o2); 57 57 dJointID c = dJointCreateContact(id(), 0, contact+i); -
branches/cpp-ode/src/libmmpong/netgame_ode_pong.cc
r540 r541 23 23 boost::shared_ptr<ODEBox> playerpad=srv_ent_create<ODEBox>(); 24 24 playerpad->geom.setLengths(0.05,0.5,0.05); 25 playerpad->set_immovable(); 25 26 double ang=M_PI*(1.0+2.0*newteamid/srv_teamid_cur); 26 playerpad-> geom.setPosition(cos(ang)*1.05, sin(ang)*1.05, 0.0);27 playerpad->setPosition(cos(ang)*1.05, sin(ang)*1.05, 0.0); 27 28 uint16_t newpadid=playerpad->get_entid(); 28 29 player2pad[newplayerid]=newpadid; … … 274 275 boost::shared_ptr<ODEBox> pad=get_ent<ODEBox>(mypadid); 275 276 double ang=M_PI*(1.0+2.0*myteamid/srv_teamid_cur); 276 pad-> geom.setPosition(cos(ang)*1.05, -1.0 + 2.0 * mypadpos, 0.0);277 pad->setPosition(cos(ang)*1.05, -1.0 + 2.0 * mypadpos, 0.0); 277 278 NetMsg::pointer msg=NetMsg::create(NetMsg::CmdGameCustom); 278 279 msg->pack_begin(); -
branches/cpp-ode/src/libmmpong/netgame_ode_pong.h
r540 r541 55 55 barbot=srv_ent_create<ODEBox>(); 56 56 bartop->geom.setLengths(2.0,0.05,0.05); 57 bartop->geom.setPosition(0.0, 1.05, 0.0); 57 bartop->setPosition(0.0, 1.05, 0.0); 58 bartop->set_immovable(); 59 58 60 barbot->geom.setLengths(2.0,0.05,0.05); 59 barbot->geom.setPosition(0.0, -1.05, 0.0); 61 barbot->setPosition(0.0, -1.05, 0.0); 62 barbot->set_immovable(); 60 63 61 64 boost::shared_ptr<ODESphere> 62 65 ball=srv_ent_create<ODESphere>(); 63 66 ball->geom.setRadius(0.025); 64 ball->setLinearVel( -0.1, 0.0, 0.0);67 ball->setLinearVel(0.0, 1.0, 0.0); 65 68 }; 66 69 virtual void srv_con_start(NetCon::pointer con); -
branches/cpp-ode/src/libmmpong/netmsg.h
r528 r541 108 108 pack_raw<uint32_t>(&conv); 109 109 }; 110 111 void pack(bool b) { 112 uint16_t i=b; 113 pack(i); 114 }; 110 115 111 116 void pack(double f) { … … 173 178 }; 174 179 180 void unpack(bool &ret) { 181 uint16_t i; 182 unpack(i); 183 ret=(bool)i; 184 }; 185 175 186 void unpack(double &f) { 176 187 //TODO: assure double has 64 bit -
branches/cpp-ode/src/libmmpong/ode_box.cc
r540 r541 3 3 using namespace mmp; 4 4 5 ODEBox::ODEBox(NetGame::pointer game, uint16_t entid ) :5 ODEBox::ODEBox(NetGame::pointer game, uint16_t entid, bool _movable) : 6 6 ODEObj<NetEnt::ODEBox, dBox>(game, entid) 7 7 { 8 8 geom.create(get_space(), 1.0, 1.0, 1.0); 9 //geom.setBody(*this);10 9 classname="ODEBox"; 10 if (_movable) 11 set_movable(); 11 12 } 12 13 -
branches/cpp-ode/src/libmmpong/ode_box.h
r528 r541 10 10 class ODEBox : public ODEObj<NetEnt::ODEBox, dBox>, public NetEntCreator<ODEBox> { 11 11 public: 12 ODEBox(NetGame::pointer game, uint16_t entid );12 ODEBox(NetGame::pointer game, uint16_t entid, bool _movable=true); 13 13 private: 14 14 virtual void update(NetMsg::pointer msg) { -
branches/cpp-ode/src/libmmpong/ode_obj.h
r540 r541 17 17 boost::shared_ptr<NetGameODE> game; 18 18 public: 19 //TODO: should the GEOM be protected? (andre thinks so...) 19 20 GEOM geom; 20 21 protected: … … 33 34 //we could also use: this->classname="ODEObj"; 34 35 NetEntHelper<CLASSID>::classname="ODEObj"; 36 movable=false; 35 37 }; 36 38 39 bool movable; 40 public: 41 //links geom to body => physics do not influence object 42 //note that the object can still be moved by user input 43 void set_immovable() { 44 movable=false; 45 geom.setBody(0); 46 }; 47 48 //links geom to body => physics influence object 49 void set_movable() { 50 movable=true; 51 const dReal *vals=getPosition(); 52 dBody::setPosition(vals); 53 vals=getRotation(); 54 dBody::setRotation(vals); 55 geom.setBody(*this); 56 }; 57 58 //we need these wrapper functions (do NOT use dBody or dGeom 59 //functions directly for positioning) 60 const dReal* getPosition() { 61 return geom.getPosition(); 62 }; 63 64 const dReal* getRotation() { 65 return geom.getRotation(); 66 }; 67 68 void setPosition(const dReal vals[3]) { 69 geom.setPosition(vals[0], vals[1], vals[2]); 70 if (!movable) 71 dBody::setPosition(vals); 72 }; 73 //convenience wrapper 74 void setPosition(dReal x, dReal y, dReal z) { 75 dReal vals[3]={x,y,z}; 76 setPosition(vals); 77 }; 78 79 80 void setRotation(const dMatrix3 rot) { 81 geom.setRotation(rot); 82 if (!movable) 83 dBody::setRotation(rot); 84 }; 85 protected: 37 86 virtual void update(NetMsg::pointer msg) { 38 87 if (msg->get_state()==NetMsg::StatPacking) { 39 const dReal *vals=geom.getPosition(); 88 msg->pack(movable); 89 const dReal *vals=getPosition(); 40 90 LOGDBG("Position==["<<vals[0]<<","<<vals[1]<<","<<vals[2]<<"]"); 41 91 for(unsigned int i=0; i<3; i++) … … 48 98 49 99 //check ODE alignment in dMatrix3 50 vals=ge om.getRotation();100 vals=getRotation(); 51 101 LOGDBG("Rotation==["<<vals[0]<<","<<vals[1]<<","<<vals[2]<<";"<<vals[4]<<","<<vals[5]<<","<<vals[6]<<";"<<vals[8]<<","<<vals[9]<<","<<vals[10]<<"]"); 52 102 for(unsigned int i=0; i<3; i++) … … 62 112 msg->pack_ode(vals[i]); 63 113 } else if (msg->get_state()==NetMsg::StatUnpacking) { 114 bool _movable; 115 msg->unpack(_movable); 116 if (movable && !_movable) 117 set_immovable(); 118 if (!movable && _movable) 119 set_movable(); 64 120 dReal vals[12]; 65 121 for(unsigned int i=0; i<3; i++) 66 122 msg->unpack_ode(vals[i]); 67 123 LOGDBG("Position==["<<vals[0]<<","<<vals[1]<<","<<vals[2]<<"]"); 68 geom.setPosition(vals[0], vals[1], vals[2]);124 setPosition(vals[0], vals[1], vals[2]); 69 125 70 126 for(unsigned int i=0; i<3; i++) … … 80 136 msg->unpack_ode(vals[i]); 81 137 LOGDBG("Rotation==["<<vals[0]<<","<<vals[1]<<","<<vals[2]<<";"<<vals[4]<<","<<vals[5]<<","<<vals[6]<<";"<<vals[8]<<","<<vals[9]<<","<<vals[10]<<"]"); 82 geom.setRotation(vals);138 setRotation(vals); 83 139 84 140 for(unsigned int i=0; i<3; i++) -
branches/cpp-ode/src/libmmpong/ode_sphere.cc
r532 r541 3 3 using namespace mmp; 4 4 5 ODESphere::ODESphere(NetGame::pointer game, uint16_t entid, dReal r) :5 ODESphere::ODESphere(NetGame::pointer game, uint16_t entid, bool _movable) : 6 6 ODEObj<NetEnt::ODESphere, dSphere>(game, entid) 7 7 { 8 geom.create(get_space(), r);8 geom.create(get_space(), 1.0); 9 9 geom.setBody(*this); 10 10 classname="ODESphere"; 11 if (_movable) 12 set_movable(); 11 13 } 12 14 -
branches/cpp-ode/src/libmmpong/ode_sphere.h
r529 r541 9 9 class ODESphere : public ODEObj<NetEnt::ODESphere, dSphere>, public NetEntCreator<ODESphere> { 10 10 public: 11 ODESphere(NetGame::pointer game, uint16_t entid, dReal r=1.0);11 ODESphere(NetGame::pointer game, uint16_t entid, bool _movable=true); 12 12 private: 13 13 virtual void update(NetMsg::pointer msg) { -
branches/cpp-ode/src/mmpong-gl/client_gl.cc
r540 r541 120 120 boost::posix_time::time_duration renderdur=renderend-renderbegin, waitdur=framedur-renderdur; 121 121 LOG("Rendering: " << renderdur << " => Waiting " << waitdur); 122 boost::this_thread::sleep(waitdur); 122 if (!waitdur.is_negative()) 123 boost::this_thread::sleep(waitdur); 123 124 } 124 125 }
