本文整理汇总了C++中Sphere::getPos方法的典型用法代码示例。如果您正苦于以下问题:C++ Sphere::getPos方法的具体用法?C++ Sphere::getPos怎么用?C++ Sphere::getPos使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Sphere
的用法示例。
在下文中一共展示了Sphere::getPos方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: setupScene
void MyApp::setupScene()
{
int N_SPHERES = 8;
float SKY_HEIGHT = 175.0f;
float MIN_RAD = 5;
float MAX_RAD = 15;
int MIN_TESSFACTOR = 2;
int MAX_TESSFACTOR = 7;
float spheres_area = GRID_WIDTH;
for (int i=0; i<N_SPHERES; i++)
{
Sphere s;
s.setPos( rand() % (unsigned int)spheres_area - spheres_area / 2.0f,
SKY_HEIGHT,
rand() % (unsigned int)spheres_area - spheres_area / 2.0f
);
s.setTargetPos(s.getPos().x, 25.0f, s.getPos().z);
float rnd = rand() / (float)RAND_MAX;
s.radius = MIN_RAD + rnd * (MAX_RAD - MIN_RAD);
s.tessFactor = rand() % (MAX_TESSFACTOR - MIN_TESSFACTOR + 1) + MIN_TESSFACTOR;
m_spheres.push_back(s);
}
// tess objects parameters
for (int i=0; i<4; i++) {
tessObjects[i].bWireframe = false;
tessObjects[i].iEdgeFactor = 10;
tessObjects[i].iInsideFactor = 10;
tessObjects[i].partitioning = TessPartitioning::INTEGER;
}
}
示例2: sphereAABBIntersection
//static
bool Intersections::sphereAABBIntersection(Sphere s, AABB a){
Vector3 sphere_pos = s.getPos();
double sphere_radius = s.getRadius();
Vector3 aabb_bmin = a.getBmin();
Vector3 aabb_bmax = a.getBmax();
double r2 = sphere_radius * sphere_radius;
double dmin = 0.0;
//3 dimensions
for( int i = 0; i < 3; i++ ) {
if( sphere_pos[i] < aabb_bmin[i] ) {
dmin += square( sphere_pos[i] - aabb_bmin[i] );
}
else if( sphere_pos[i] > aabb_bmax[i] ) {
dmin += square( sphere_pos[i] - aabb_bmax[i] );
}
}
return dmin <= r2;
}
示例3: pointInSphere
bool Intersections::pointInSphere(Vector3 point , Sphere s){
Vector3 sphere_pos = s.getPos();
double sphere_radius = s.getRadius();
return (sphere_pos - point).length() <= sphere_radius;
}