//-------------------------------------------------------------- void SceneNode::renderAll(imp::Uint32 passID){ if(!renderActivated)return; SceneNode::nbDisplayed++; Matrix4 modelMat = getModelMatrix(); Matrix4 normalMat = getNormalMatrix(); render(passID); for(SceneNodeIt it = subSceneNodes.begin(); it != subSceneNodes.end(); it++) { SceneNode* sub = *it; sub->setParentModelMatrices(modelMat, normalMat); sub->renderAll(passID); } }
uint32_t rSimpleMesh::getMatrix( rMat3f **_mat, rObjectBase::MATRIX_TYPES _type ) { switch ( _type ) { case NORMAL_MATRIX: *_mat = getNormalMatrix(); return 0; default: return INDEX_OUT_OF_RANGE; } }
//Comparison speed: 10.96 //Bounding Boxes: 5.89 //Ordering: 4.99 double RayGroup::intersect(Ray3D ray,RayIntersectionInfo& iInfo,double mx){ //printf("This runs\n"); bool ignoreMX = false; if (mx == -1) ignoreMX = true; Ray3D rayCopy = Ray3D(); rayCopy.position = ray.position; rayCopy.direction = ray.direction; double min_t = -1; RayShape* min_shape = NULL; RayIntersectionInfo tempInfo = RayIntersectionInfo(); double boxOut = bBox.intersect(ray); if (boxOut < mx || ignoreMX){ if(boxOut > -1){ Matrix4D matrix = getMatrix(); ray.position = getInverseMatrix().multPosition(ray.position); ray.direction = getInverseMatrix().multDirection(ray.direction); double scaler = ray.direction.length(); ray.direction = ray.direction.unit(); int count = 0; for (int i = 0; i < sNum; i++) { RayShape* temp = shapes[i]; double dist = temp->bBox.intersect(ray); if(dist < mx || ignoreMX) { if (dist > -1) { //Means we have a hit of the inner volume hits[count].shape = temp; hits[count].t = dist; count++; } } } qsort(hits,count,sizeof(RayShapeHit),RayShapeHit::Compare); //if (bBox.intersect(ray) > -1){ for (int i = 0; i < count; i++) { //printf("something got hit!\n"); //printf("i = %i\n",i); RayShape* temp = hits[i].shape; double t = -1; t = temp->intersect(ray, tempInfo, mx); if (t > 0) { t = t / scaler; if (min_t == -1 || t < min_t) { min_t = t; min_shape = temp; iInfo.iCoordinate = tempInfo.iCoordinate; iInfo.normal = tempInfo.normal; iInfo.material = tempInfo.material; break; } } //Checks if its a Static Ray Group with its own transform information /*StaticRayGroup* temp2 = dynamic_cast<StaticRayGroup*>(temp); if(temp2 != 0) { t = temp->intersect(rayCopy, tempInfo, mx); if (t > 0) { if (min_t == -1 || t < min_t) { iInfo.iCoordinate = tempInfo.iCoordinate; iInfo.normal = tempInfo.normal; iInfo.material = tempInfo.material; min_t = t; min_shape = temp; } } } else { ray.position = getInverseMatrix().multPosition(rayCopy.position); ray.direction = getInverseMatrix().multDirection(rayCopy.direction).unit(); t = temp->intersect(ray, tempInfo, mx); if (t > 0) { if (min_t == -1 || t < min_t) { iInfo.iCoordinate = matrix.multPosition(tempInfo.iCoordinate); iInfo.normal = getNormalMatrix().multNormal(tempInfo.normal); iInfo.material = tempInfo.material; min_t = t; min_shape = temp; } } }*/ } iInfo.iCoordinate = matrix.multPosition(iInfo.iCoordinate); iInfo.normal = getNormalMatrix().multDirection(iInfo.normal).unit(); //iInfo.material = iInfo.material; } } return min_t; }