color rayTrace(ray R, int depth) { sphere s = {200,200,25,100}; color r = {1.0,0,0}; color w = {1.0,1.0,1.0}; bool b = intersectSphere(R,s); if(b) return r; return w; }
bool Ray::intersectObject(MeshObject *obj, Fragment &inter) const { if(obj->type == MESH) { if (intersectSphere(obj->boundingSphere)) { if (intersectMesh(obj->mesh, inter)) { return true; } } } else if(obj->type == SPHERE) { if (intersectSphere(obj->boundingSphere, &inter)) { inter.id = obj; return true; } } return false; }
/// Sphere/Sphere intersection test bool intersectSphere( const QVector3D & centerB, const float & radiusB, QVector3D * normal, float * depth ) const { return intersectSphere( mCenter, mRadius, centerB, radiusB, normal, depth ); }