Changeset 44
- Timestamp:
- 01/02/10 20:38:11 (2 years ago)
- Location:
- trunk
- Files:
-
- 12 modified
-
SConstruct (modified) (2 diffs)
-
include/freequest/GameBasicPhysicCallback.hh (modified) (2 diffs)
-
include/freequest/objects/Avatar.hh (modified) (1 diff)
-
include/freequest/objects/StaticObject.hh (modified) (3 diffs)
-
src/GameAvatarManager.cc (modified) (1 diff)
-
src/GameBasicPhysicCallback.cc (modified) (2 diffs)
-
src/GamePhysicManager.cc (modified) (3 diffs)
-
src/GamePlayerCallback.cc (modified) (2 diffs)
-
src/MainGameState.cc (modified) (3 diffs)
-
src/SConscript (modified) (3 diffs)
-
src/objects/Avatar.cc (modified) (9 diffs)
-
src/objects/StaticObject.cc (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/SConstruct
r43 r44 186 186 # 187 187 # Do not display deprecated messsage 188 env.Append(CXXFLAGS = ['-Wno-deprecated']) 188 if sys.platform == 'linux2': 189 env.Append(CXXFLAGS = ['-Wno-deprecated']) 190 189 191 #------------------------------------ 190 192 # Platform … … 326 328 # TODO : Checking OgreNewt cause several "undefined reference to" Newton. 327 329 #for lib in ['Newton', lib_ogrenewt]: 328 lib = 'Newton'330 lib = 'Newton' 329 331 if not conf.CheckLib(lib, language="C++"): 330 332 print "Not found Newton library : %s..."%lib -
trunk/include/freequest/GameBasicPhysicCallback.hh
r38 r44 22 22 #include <OgreNewt.h> 23 23 24 //#include "freequest/GamePrerequisites.hh"24 #include "freequest/objects/Object.hh" 25 25 26 26 namespace freequest … … 34 34 private: 35 35 }; 36 37 36 } 38 37 #endif -
trunk/include/freequest/objects/Avatar.hh
r41 r44 31 31 { 32 32 public: 33 Ogre::Vector3 pos;33 Ogre::Vector3 mPos; 34 34 35 35 // CREATORS -
trunk/include/freequest/objects/StaticObject.hh
r42 r44 47 47 void setMass(Ogre::Real mass); 48 48 void setMaterialID(const OgreNewt::MaterialID* matID); 49 void addForce( const Ogre::Vector3& force ); 49 50 50 51 // ACCESSORS … … 55 56 OgreNewt::Body* getBody( void ) const; 56 57 57 static void applyForceAndTorqueCallback( OgreNewt::Body* body);58 void applyForceAndTorqueCallback( void ); 58 59 59 60 void update( void ); … … 67 68 PhyscicType mGeomType; 68 69 Ogre::Vector3 mGravity; 69 70 //The force to apply at the body 71 Ogre::Vector3 mForce; 70 72 }; 71 73 -
trunk/src/GameAvatarManager.cc
r42 r44 81 81 LOG_INFO( Logger::getLogger("freequest.game"), " ==== creating object Avatar ===="); 82 82 83 CPhysicManager::getInstance()->createPhysicBody(GEOM_ELLIPS, mPlayerAvatar );83 CPhysicManager::getInstance()->createPhysicBody(GEOM_ELLIPS, mPlayerAvatar, 0.0001); 84 84 mPlayerAvatar->getPhysicObject()->setMaterialID(CPhysicManager::getInstance()->getMaterialIDByName("player")); 85 85 -
trunk/src/GameBasicPhysicCallback.cc
r43 r44 22 22 #include "freequest/log/Logger.hh" 23 23 #include "freequest/GameBasicPhysicCallback.hh" 24 #include "freequest/objects/Object.hh" 24 25 25 26 26 using namespace freequest; 27 27 using namespace freequest::log; 28 28 29 29 30 //------------------------------------------------------------------------------------------------ … … 74 75 /* 75 76 obj0.reset(static_cast<CGameObject*>(m_body1->getUserData())); 76 // *obj = *((CGameObject*)m_body0->getUserData());77 //*obj = *((CGameObject*)m_body0->getUserData()); 77 78 obj1.reset((CGameObject*)m_body0->getUserData()); 78 79 */ -
trunk/src/GamePhysicManager.cc
r42 r44 16 16 */ 17 17 18 18 19 #ifdef HAVE_CONFIG_HH 19 20 # include "config.h" … … 217 218 { 218 219 //LOG_INFO( Logger::getLogger("freequest.game"), "*** NEWTON PHYSIC CALLBACK"); 219 ObjectPtr objet;220 /*ObjectPtr objet; 220 221 objet.reset((CGameObject*)body->getUserData()); 221 222 if (objet.use_count()) 222 223 { 223 //LOG_INFO( Logger::getLogger("freequest.game"), "*** NEWTON PHYSIC CALLBACK APPLY FORCE"); 224 //objet->getPhysicObject()->applyForceAndTorqueCallback(); 225 } 224 LOG_INFO( Logger::getLogger("freequest.game"), "*** NEWTON PHYSIC CALLBACK APPLY FORCE for " << objet->getObjectName()); 225 objet->getPhysicObject()->applyForceAndTorqueCallback(); 226 }*/ 227 ((CGameObject*)body->getUserData())->getPhysicObject()->applyForceAndTorqueCallback(); 226 228 } 227 229 … … 320 322 obj->getPhysicObject()->createBody(mWorld, geomType, obj, col, mass, inertia); 321 323 //obj->getPhysicObject()->setMaterialID(this->getMaterialIDByName("default")); 322 //obj->getPhysicObject()->getBody()->setCustomForceAndTorqueCallback(applyForceAndTorqueCallback); 324 //obj->getPhysicObject()->getBody()->removeForceAndTorqueCallback(); 325 //obj->getPhysicObject()->getBody()->removeAutoactiveCallback(); 326 obj->getPhysicObject()->getBody()->setCustomForceAndTorqueCallback(applyForceAndTorqueCallback); 323 327 324 328 delete col; -
trunk/src/GamePlayerCallback.cc
r42 r44 16 16 */ 17 17 18 18 19 #ifdef HAVE_CONFIG_HH 19 20 # include "config.h" … … 39 40 getContactPositionAndNormal(point, normal); 40 41 41 LOG_INFO( Logger::getLogger("freequest.game"), "====== PHYSIC CONTACT << USERPROCESS >> " << point.x << " - " << point.y << " - " << point.z << " ====="); 42 //LOG_INFO( Logger::getLogger("freequest.game"), "====== PHYSIC CONTACT << USERPROCESS >> " << point.x << " - " << point.y << " - " << point.z << " ====="); 43 /* 44 CGameObject* mObjet = 0; 45 46 if (((CGameObject*)m_body0->getUserData())->getObjectType() == "PC") 47 { 48 mObjet = ((CGameObject*)m_body0->getUserData()); 49 } 50 51 if (((CGameObject*)m_body1->getUserData())->getObjectType() == "PC") 52 { 53 mObjet = ((CGameObject*)m_body1->getUserData()); 54 } 55 56 57 // determine if this contact is with the floor. 58 // Meaning the contact normal has an angle to UNIT_Y of 20 or less. 59 Ogre::Degree angle = Ogre::Math::ACos(normal.dotProduct(Ogre::Vector3::UNIT_Y)); 60 61 Ogre::Vector3 charPos; 62 Ogre::Quaternion charOri; 63 mObjet->getPhysicObject()->getBody()->getPositionOrientation(charPos, charOri); 64 bool isFloorCollision(false); 65 66 Ogre::AxisAlignedBox CharAab = mObjet->getPhysicObject()->getBody()->getCollision()->getAABB(); 67 Ogre::Real charHeight = CharAab.getMaximum().y - CharAab.getMinimum().y; 68 Ogre::Real stepHeight = point.y - charPos.y; 69 70 if( stepHeight < charHeight/2 ) 71 { 72 isFloorCollision = true; 73 } 74 75 if( stepHeight < 0.4 ) 76 { 77 if(stepHeight > 0.01f) 78 { 79 //rotateTangentDirections(charOri + Ogre::Vector3::UNIT_Y); 80 setContactTangentAcceleration(5,0); 81 setContactFrictionState(1,0); 82 setContactFrictionState(1,1); 83 } 84 else 85 { 86 setContactFrictionState(1,0); 87 setContactFrictionState(1,1); 88 } 89 } 90 else 91 { 92 Ogre::Vector3 vel; 93 vel = mObjet->getPhysicObject()->getVelocity(); 94 if( vel.y >= 0 ) 95 { 96 setContactFrictionState(1,0); 97 setContactFrictionState(1,1); 98 } 99 else 100 { 101 setContactFrictionState(0,0); 102 setContactFrictionState(0,1); 103 } 104 } 105 106 setContactSoftness(0.8f); 107 setContactElasticity(0.0f); 108 */ 42 109 return 1; 43 110 } -
trunk/src/MainGameState.cc
r43 r44 236 236 floornode->showBoundingBox(true); 237 237 */ 238 238 /* 239 239 // CYLINDER test 240 240 ObjectPtr cylindObj = CObjectFactory::getInstance()->createObject("BLD"); … … 248 248 CObjectManager::getInstance()->addObject(cylindObj); 249 249 LOG_INFO( Logger::getLogger("freequest.game"), " ==== creating object CYLINDER ===="); 250 250 251 // Create the physic body by the physicManager 252 CPhysicManager::getInstance()->createPhysicBody(GEOM_CYLINDER, cylindObj, 200.0); 253 cylindObj->getPhysicObject()->setMaterialID(CPhysicManager::getInstance()->getMaterialIDByName("default")); 254 */ 251 255 // CUBE test 252 256 ObjectPtr cubObj = CObjectFactory::getInstance()->createObject("BLD"); … … 262 266 263 267 // Create the physic body by the physicManager 264 CPhysicManager::getInstance()->createPhysicBody(GEOM_CYLINDER, cylindObj, 200.0);265 268 CPhysicManager::getInstance()->createPhysicBody(GEOM_BOX, cubObj, 200.0); 266 cylindObj->getPhysicObject()->setMaterialID(CPhysicManager::getInstance()->getMaterialIDByName("default"));267 269 cubObj->getPhysicObject()->setMaterialID(CPhysicManager::getInstance()->getMaterialIDByName("default")); 268 270 269 271 LOG_INFO( Logger::getLogger("freequest.game"), "MAINGameState end enter()"); 270 272 -
trunk/src/SConscript
r43 r44 39 39 'objects/AnimeObject.cc', 40 40 'objects/Object.cc', 41 'GameVideoManager.cc', 41 42 'GameAvatarManager.cc', 42 43 'GameResource.cc', … … 69 70 'GameEngine.cc', 70 71 'freequest.cc' 71 ] 72 # 'GameVideoManager.cc', 72 ] 73 73 74 74 # … … 85 85 # 86 86 if sys.platform == 'win32': 87 bin_game_env.AppendUnique(LIBS=["libDFLog", "freequest_main", " Plugin_TheoraVideoSystem"])87 bin_game_env.AppendUnique(LIBS=["libDFLog", "freequest_main", "OgreNewt_Main", "Plugin_TheoraVideoSystem"]) 88 88 else: 89 89 bin_game_env.AppendUnique(LIBS=["libDFLog", "freequest_main", "OgreNewt"]) -
trunk/src/objects/Avatar.cc
r41 r44 30 30 using namespace freequest; 31 31 32 33 32 //------------------------------------------------------------------------------------------------ 34 33 CAvatar::CAvatar( void ) … … 38 37 setObjectType("PC"); 39 38 40 pos = Ogre::Vector3::ZERO;39 mPos = Ogre::Vector3::ZERO; 41 40 } 42 41 … … 75 74 } 76 75 77 mObjectNode->translate( pos, Ogre::Node::TS_LOCAL );76 mObjectNode->translate( mPos, Ogre::Node::TS_LOCAL ); 78 77 79 78 mPhysicObj->update(); … … 86 85 mAnimation->setAnimLoop(true); 87 86 88 pos.z -= mStats->getMoveSpeed(); 87 mPos.z -= mStats->getMoveSpeed(); 88 mPhysicObj->addForce(mPos); 89 89 } 90 90 … … 95 95 mAnimation->setAnimLoop(true); 96 96 97 pos.z += mStats->getMoveSpeed(); 97 mPos.z += mStats->getMoveSpeed(); 98 mPhysicObj->addForce(mPos); 98 99 } 99 100 … … 104 105 mAnimation->setAnimLoop(true); 105 106 106 pos.x = -mStats->getMoveSpeed(); 107 mPos.x = -mStats->getMoveSpeed(); 108 mPhysicObj->addForce(mPos); 107 109 } 108 110 … … 113 115 mAnimation->setAnimLoop(true); 114 116 115 pos.x = mStats->getMoveSpeed(); 117 mPos.x = mStats->getMoveSpeed(); 118 mPhysicObj->addForce(mPos); 116 119 } 117 120 … … 129 132 this->setQuickAnimationChange("wait"); 130 133 mAnimation->setAnimLoop(false); 131 pos = Ogre::Vector3::ZERO; 134 mPos = Ogre::Vector3::ZERO; 135 mPhysicObj->addForce(mPos); 132 136 } 133 137 … … 137 141 this->setQuickAnimationChange("arme_shield_attack"); 138 142 mAnimation->setAnimLoop(false); 139 pos = Ogre::Vector3::ZERO;143 mPos = Ogre::Vector3::ZERO; 140 144 } 141 145 -
trunk/src/objects/StaticObject.cc
r42 r44 20 20 #endif 21 21 22 23 22 // Includes 24 23 #include "freequest/log/Logger.hh" … … 36 35 mGeomType = GEOM_NONE; 37 36 mGravity = Ogre::Vector3::ZERO; 37 mForce = Ogre::Vector3::ZERO; 38 38 LOG_INFO( Logger::getLogger("freequest.game"), " xxxx constructor ~CStaticObject xxxx" ); 39 39 } … … 48 48 49 49 //------------------------------------------------------------------------------------------------ 50 void CStaticObject::applyForceAndTorqueCallback( OgreNewt::Body* body)51 { 52 Ogre::Real mass;50 void CStaticObject::applyForceAndTorqueCallback( void ) 51 { 52 /*Ogre::Real mass; 53 53 Ogre::Vector3 inertia; 54 body->getMassMatrix(mass, inertia);54 mBody->getMassMatrix(mass, inertia);*/ 55 55 Ogre::Vector3 force(0,-10,0); 56 force *= mass; 57 //LOG_INFO( Logger::getLogger("freequest.game"), " AAAAAAAAAAAADDDDDDDDDDDDD FFFOOOOORRRRCCCCEEE " << force.x << "--" << force.y << "--" << force.z << " MASS " << mass ); 58 body->addForce(force); 56 force *= mMass; 57 force += mForce; 58 mBody->addForce( force ); 59 LOG_INFO( Logger::getLogger("freequest.game"), " AAAAAAAAAAAADDDDDDDDDDDDD FFFOOOOORRRRCCCCEEE " << mForce.x << "--" << mForce.y << "--" << mForce.z << " for " << ((CGameObject*)mBody->getUserData())->getObjectName()); 60 mForce = Ogre::Vector3::ZERO; 59 61 } 60 62 … … 68 70 mBody = new OgreNewt::Body( world, col, geomType); 69 71 mBody->attachToNode( actor->getSceneNode() ); 70 mBody->setMassMatrix( m ass, inertia );72 mBody->setMassMatrix( mMass, inertia ); 71 73 mBody->setStandardForceCallback(); 72 74 mBody->setUserData(mActor.get()); 73 75 74 mBody->setCustomForceAndTorqueCallback(applyForceAndTorqueCallback);76 //mBody->setCustomForceAndTorqueCallback(applyForceAndTorqueCallback); 75 77 //mBody->setCustomForceAndTorqueCallback<CPhysicManager>(&freequest::CPhysicManager::doForceCallback, CPhysicManager::getInstance().get()); 76 78 //mBody->setCustomForceAndTorqueCallback(&freequest::CPhysicManager::doForceCallback); … … 160 162 } 161 163 164 void CStaticObject::addForce(const Ogre::Vector3& force) 165 { 166 mBody->unFreeze(); 167 mForce += force; 168 } 169 170 //------------------------------------------------------------------------------------------------ 162 171 //------------------------------------------------------------------------------------------------ 163 172 void CStaticObject::update( void ) … … 165 174 if (mBody && mActor.use_count()) 166 175 { 167 mBody->setPositionOrientation( 168 mActor->getSceneNode()->_getDerivedPosition(), 169 mActor->getSceneNode()->_getDerivedOrientation()); 170 //mActor->update(0); 176 mBody->setPositionOrientation( mActor->getSceneNode()->_getDerivedPosition(), mActor->getSceneNode()->_getDerivedOrientation()); 171 177 //LOG_INFO( Logger::getLogger("freequest.game"), "*** PHYSIC UPDATE ****"); 172 178 }
