本文整理汇总了C++中RenderObject::getChildren方法的典型用法代码示例。如果您正苦于以下问题:C++ RenderObject::getChildren方法的具体用法?C++ RenderObject::getChildren怎么用?C++ RenderObject::getChildren使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类RenderObject
的用法示例。
在下文中一共展示了RenderObject::getChildren方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: activateGrab
void Cross::activateGrab() {
if(isGrabActive) return;
isGrabActive = true;
float minDistance = 1000;
RenderObject * minBody = NULL;
// TODO children hack
const vec3 crossPos = this->getPosition();
std::vector<RenderObject *> allSceneObjects;
for(unsigned int i = 0; i < sceneObjects->size(); i++){
RenderObject * body = (*sceneObjects)[i];
allSceneObjects.push_back(body);
const std::vector<RenderObject *>& children = body->getChildren();
for(unsigned int j = 0; j < children.size(); j++){
allSceneObjects.push_back(children[j]);
}
}
for(unsigned int i = 0; i < allSceneObjects.size(); i++){
RenderObject * body = (allSceneObjects)[i];
if(!body->isGrabable()) continue;
const vec3& bodyPos = body->getPosition();
float dx = crossPos.x - bodyPos.x;
dx *= dx;
float dy = crossPos.y - bodyPos.y;
dy *= dy;
float dz = crossPos.z - bodyPos.z;
dz *= dz;
float distance = sqrt(dx + dy + dz);
if(distance < grabRadius){
if(distance < minDistance){
minDistance = distance;
minBody = body;
}
}
}
if(minBody != NULL){
grabedMap.clear();
grabedMap[minBody] = BodyInfo(minDistance, *minBody->getColor());
minBody->setColor(grabedColor);
minBody->setSelected(true);
}
}
示例2: sqrt
std::vector<RenderObject*> Cross::getClosestObjectVector(const RayCast& ray,
int width, int height,
int distTol) const{
std::vector<RenderObject*> closestObjects;
float error_tol = 0.10;
float x = ray.currentX;
float y = ray.currentY;
float vX = 2.0 / (float) width;
int rayX = (x + 1.0f) / vX;
float vY = 2.0 / (float) height;
int rayY = (y + 1.0f) / vY;
for(unsigned int i = 1; i < sceneObjects->size(); i++){
RenderObject * body = (*sceneObjects)[i];
// ---------------------
// TODO children
const std::vector<RenderObject *>& curr_children = body->getChildren();
for(unsigned int i = 0 ; i < curr_children.size(); i++){
RenderObject * child = curr_children[i];
const vec3& bodyProjectedPosition = child->getProjectedPosition();
float bodyX = bodyProjectedPosition.x;
float bodyY = bodyProjectedPosition.y;
if(child->NDC_W < error_tol) continue;
int bodypX = (bodyX + 1.0f) / vX;
int bodypY = (bodyY + 1.0f) / vY;
int dx = rayX - bodypX;
int dy = rayY - bodypY;
int dist = sqrt(dx*dx + dy*dy);
if(dist < distTol){
closestObjects.push_back(child);
return closestObjects;
}
}
// ---------------------
if(!body->isGrabable()) continue;
const vec3& bodyProjectedPosition = body->getProjectedPosition();
float bodyX = bodyProjectedPosition.x;
float bodyY = bodyProjectedPosition.y;
if(body->NDC_W < error_tol) continue;
int bodypX = (bodyX + 1.0f) / vX;
int bodypY = (bodyY + 1.0f) / vY;
int dx = rayX - bodypX;
int dy = rayY - bodypY;
int dist = sqrt(dx*dx + dy*dy);
if(dist < distTol){
closestObjects.push_back(body);
}
}
return closestObjects;
}