本文整理汇总了C++中RenderObject::getPosition方法的典型用法代码示例。如果您正苦于以下问题:C++ RenderObject::getPosition方法的具体用法?C++ RenderObject::getPosition怎么用?C++ RenderObject::getPosition使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类RenderObject
的用法示例。
在下文中一共展示了RenderObject::getPosition方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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);
}
}