Environment::Environment(Ogre::SceneManager* sceneManager, btDynamicsWorld& world, std::istream& level) : _sceneManager(sceneManager), _world(world), _DebugDrawers(), DebugAI(-1) { for(int i = 0; i < 5; ++i) { _DebugDrawers.push_back(std::unique_ptr<DebugDrawer>(new DebugDrawer(sceneManager, 0.5))); } boost::posix_time::ptime t1 = boost::posix_time::microsec_clock::universal_time(); while (!level.eof()) { std::string MeshName; std::string Orientation; float x, y, z; level >> MeshName >> x >> y >> z >> Orientation; if (MeshName.compare("") && (MeshName[0] != '#')) { std::cout << "mesh " << MeshName << " at (" << x << "," << y << "," << z << "), " << Orientation << std::endl; orientation_t o; if (!Orientation.compare("N")) o = North; else if (!Orientation.compare("S")) o = South; else if (!Orientation.compare("E")) o = East; else if (!Orientation.compare("W")) o = West; else { std::stringstream str; str << "Invalid orientation (" << Orientation << ")"; throw std::invalid_argument(str.str()); } Ogre::Entity * Entity = _sceneManager->createEntity(MeshName); Entity->setCastShadows(false); _blocks.push_back(Block(Entity, o, Ogre::Vector3(x,y,z))); } } boost::posix_time::ptime t2 = boost::posix_time::microsec_clock::universal_time(); Ogre::StaticGeometry *sg = _sceneManager->createStaticGeometry("environment"); boost::posix_time::ptime t3 = boost::posix_time::microsec_clock::universal_time(); _NavMesh.AgentHeight = 1.8; _NavMesh.AgentRadius = 0.8; _NavMesh.AgentMaxSlope = M_PI / 4; _NavMesh.AgentMaxClimb = 0.5; _NavMesh.CellHeight = 0.2; _NavMesh.CellSize = 0.2; _NavMesh.QueryExtent = Ogre::Vector3(10, 10, 10); //for(auto const & block : _blocks) BOOST_FOREACH(auto const & block, _blocks) { sg->addEntity(block._entity, block._position, getQuaternion(block._orientation)); OgreConverter converter(*block._entity); Ogre::Matrix4 transform = getMatrix4(block._orientation, block._position); converter.AddToTriMesh(transform, _TriMesh); converter.AddToHeightField(transform, _NavMesh); }
void RotationMatrix::rotate(const Quaternion& rotate) { setFromMatrix4( getMatrix4().getPremultipliedBy(Matrix4::getRotationQuantised(rotate)) ); }