Ejemplo n.º 1
0
TriangleMesh* DebugGeometryBuilder::createBoxHeadedArrow( float size, const Vector& start, const Vector& end )
{
   FastFloat simdSize; simdSize.setFromFloat( size );

   Vector dir;
   dir.setSub( end, start );
   dir.normalize();

   Vector perpVec1, perpVec2;
   VectorUtil::calculatePerpendicularVector( dir, perpVec1 );
   perpVec1.normalize();
   perpVec2.setCross( dir, perpVec1 );

   perpVec1.mul( simdSize );
   perpVec2.mul( simdSize );


   // the line
   std::vector<LitVertex> vertices;
   std::vector<Face> faces;
   addCuboid( simdSize, start, end, vertices, faces );
   
   // and the box-shaped tip
   FastFloat tipSize; tipSize.setFromFloat( 6 * size );
   Vector tipEnd;
   tipEnd.setMulAdd( dir, tipSize, end );
   addCuboid( tipSize, end, tipEnd, vertices, faces );
   
   TriangleMesh* mesh = new TriangleMesh( FilePath(), vertices, faces );
   return mesh;
}
Ejemplo n.º 2
0
void Level::loadMapFromFile(const std::string &mapfile)
{
    // load XML document
    rapidxml::file<> mf(mapfile.c_str());
    rapidxml::xml_document<> xml_doc;
    xml_doc.parse<0>(mf.data());
    
    // parse XML document
    for(rapidxml::node_iterator<char> it(xml_doc.first_node()); it.dereference() != NULL; ++it)
    {
        if(strcmp(it->name(), "cuboid") == 0)
            addCuboid(*it);
        else if(strcmp(it->name(), "tunnel") == 0)
            addTunnel(*it);
		else
            throw std::runtime_error("Error: Unrecognized element in level file!");
    }    
}