本文整理汇总了C++中SampleGenerator::AddObstacle方法的典型用法代码示例。如果您正苦于以下问题:C++ SampleGenerator::AddObstacle方法的具体用法?C++ SampleGenerator::AddObstacle怎么用?C++ SampleGenerator::AddObstacle使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SampleGenerator
的用法示例。
在下文中一共展示了SampleGenerator::AddObstacle方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: CreateObstacle
void WorldParserObj::CreateObstacle(const std::string& line)
{
if(line.find("c ") == 0)
{
char r[255],g[255],b[255],t[255];
sscanf(line.c_str(),"c %s %s %s %s",r,g,b,t);
//manager_.SetNextColor(strtod (r, NULL), strtod(g, NULL), strtod(b, NULL));
//manager_.SetNextTransparency(strtod (t, NULL));
return;
}
vector<long int> indices;
vector<long int> normalindices;
T_Point points;
for(int i =0; i<1; ++i)
{
string ligne = doubleSlash(line);
ligne=remplacerSlash(ligne); //On remplace les '/' par des espaces, ex : pour "f 1/2/3 4/5/6 7/8/9" on obtiendra "f 1 2 3 4 5 6 7 8 9"
vector<string> termes=splitSpace(ligne.substr(2)); //On éclate la chaîne en ses espaces (le substr permet d'enlever "f ")
int ndonnees=(int)termes.size()/3;
for(int i=0; i <ndonnees;i++) //On aurait très bien pu mettre i<ndonnees mais je veux vraiment limiter à 3 ou 4
{
long int idx = (strtol(termes[i*3].c_str(),NULL, 10)) - 1;
long int idn = (strtol(termes[i*3+2].c_str(),NULL, 10)) - 1;
std::vector<long int>::iterator it = indices.begin();
it = find (indices.begin(), indices.end(), idx);
if(it == indices.end())
{
indices.push_back(idx);
points.push_back(points_[(int)idx]);
}
it = find (normalindices.begin(), normalindices.end(), idn);
if(it == normalindices.end())
{
normalindices.push_back(idn);
}
}
}
Vector3d p1(points[0]);
Vector3d p2(points[1]);
Vector3d p3(points[2]);
Vector3d u_(p3-p1);
Vector3d v_(p2-p1);
if(abs( u_.dot(v_)) > 0.001) { v_ = u_; u_ = p2-p1;}
//we need convex hull of this crap
Vector3d normal (u_.cross(v_));
normals_[(int)normalindices[0]];
SampleGenerator * generator = SampleGenerator::GetInstance();
Obstacle * obstacle;
if(normal.dot(normals_[(int)normalindices[0]]) > 0 )
{
generator->AddObstacle(new Obstacle(p1, p2, p3));
}
else
{
generator->AddObstacle(new Obstacle(p3, p2, p1));
}
}