Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Namespace Members | Class Members | File Members | Related Pages

scene.inl

Go to the documentation of this file.
00001 /*
00002     toxic - A Global Illumination Renderer
00003     Copyright (C) 2003-2004 Francois Beaune
00004     Contact: http://toxicengine.sourceforge.net/
00005 
00006     This file is part of toxic.
00007 
00008     toxic is free software; you can redistribute it and/or modify
00009     it under the terms of the GNU General Public License as published by
00010     the Free Software Foundation; either version 2 of the License, or
00011     (at your option) any later version.
00012 
00013     toxic is distributed in the hope that it will be useful,
00014     but WITHOUT ANY WARRANTY; without even the implied warranty of
00015     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00016     GNU General Public License for more details.
00017 
00018     You should have received a copy of the GNU General Public License
00019     along with toxic; if not, write to the Free Software
00020     Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
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 /*= 0*/) const {
00056     assert(m_root_object);
00057 
00058     const bool result = m_root_object->Intersect(context, ray, hit);
00059 
00060     // Make sure that if there is an intersection, it is a true intersection.
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 /*= Ray::VISIBILITY_RAY*/) const
00072 {
00073     assert(m_root_object);
00074     assert(origin_normal.IsUnitLength());
00075 
00076     // Visibility evaluation rays will try to reach a point that is slighty shifted
00077     // along the geometric normal to the surface at the point of origin. This is
00078     // necessary to avoid false intersections.
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         // Make sure this is a true intersection.
00086         assert(hit.m_abscissa > 1.0e-8);
00087 
00088         return hit.m_abscissa > 1.0 - 1.0e-8;
00089     } else return true;
00090 }

Generated on Tue May 11 01:31:52 2004 for toxic by doxygen 1.3.6