00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023 inline
00024 const Color3 &Scene::GetBackgroundColor() const {
00025 return m_background_color;
00026 }
00027
00028 inline
00029 const IObject *Scene::GetRootObject() const {
00030 return m_root_object;
00031 }
00032
00033 inline
00034 void Scene::SetAmbientIllumination(const Color3 &ambient) {
00035 m_ambient = ambient;
00036 }
00037
00038 inline
00039 const Color3 &Scene::GetAmbientIllumination() const {
00040 return m_ambient;
00041 }
00042
00043 inline
00044 int Scene::GetLightCount() const {
00045 return static_cast<int>(m_lights.size());
00046 }
00047
00048 inline
00049 const ILight *Scene::GetLight(int i) const {
00050 assert(i >= 0 && i < GetLightCount());
00051 return m_lights[i];
00052 }
00053
00054 inline
00055 bool Scene::Trace(const Context &context, const Ray &ray, Hit *hit ) const {
00056 assert(m_root_object);
00057
00058 const bool result = m_root_object->Intersect(context, ray, hit);
00059
00060
00061 assert(!result || (result && hit->m_abscissa > 1.0e-8));
00062
00063 return result;
00064 }
00065
00066 inline
00067 bool Scene::ArePointsMutuallyVisible(const Context &context,
00068 const sheep::Point3 &origin,
00069 const sheep::Vector3 &origin_normal,
00070 const sheep::Point3 &goal,
00071 Ray::Type ray_type ) const
00072 {
00073 assert(m_root_object);
00074 assert(origin_normal.IsUnitLength());
00075
00076
00077
00078
00079 const sheep::Point3 shifted_origin = origin + 1.0e-8 * origin_normal;
00080
00081 const Ray ray(ray_type, shifted_origin, goal - shifted_origin);
00082 Hit hit;
00083
00084 if(m_root_object->Intersect(context, ray, &hit)) {
00085
00086 assert(hit.m_abscissa > 1.0e-8);
00087
00088 return hit.m_abscissa > 1.0 - 1.0e-8;
00089 } else return true;
00090 }