/* * Ray++ - Object-oriented ray tracing library * Copyright (C) 1998-2001 Martin Reinecke and others. * See the AUTHORS file for more information. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public * License as published by the Free Software Foundation; either * version 2 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Library General Public License for more details. * * You should have received a copy of the GNU Library General Public * License along with this library; if not, write to the Free * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * * See the README file for more information. */ /*! \file fuzprojector.cxx \brief Implementation of the FUZPROJECTOR class */ /* THIS FILE is copyright (c) 1999 by Ugo Varetto - varetto@computer.org */ #include "lights/fuzprojector.h" #include "utils/math.h" namespace RAYPP { extern HANDLE World; FUZPROJECTOR::FUZPROJECTOR () : PROJECTOR(), DeltaAngle(0.0),Samples(1) {} FUZPROJECTOR::FUZPROJECTOR(const VECTOR &Loc,const VECTOR &to, const COLOUR &Col,const float8 &e, const float8 &c) : PROJECTOR(Loc,to,Col,e,c), DeltaAngle(0.0),Samples(1) {} //virtual void FUZPROJECTOR::Cast_Light (const VECTOR &Pos, LIGHT_ARRAY &Arr) const { ci(); VECTOR v = (Pos - Location); float8 d1 = v.Length(); float8 d2 = d1*d1; VECTOR L = v.Norm(); float8 cosangle = Dot(L,Dir); float8 maxval= max(cosangle-CutOff,0.0); float8 att = pow(maxval,Exp)/ (d2*Attenuation[2]+d1*Attenuation[1]+Attenuation[0]); COLOUR Col = Colour*att; VECTOR dir; bool isect=false; if (Pixels) { COLOUR c2(0,0,0); for (int4 i=0;i=0.0) { VECTOR P = t*dir+Location; P = P - O; float8 ucomp = Dot(P,X); if (abs(ucomp) <= Xs/2.0 ) { float8 vcomp = Dot(P,Y); if (abs(vcomp) <= Ys/2.0 ) { isect=true; ucomp += Xs/2.0; vcomp += Ys/2.0; int4 j = Height-1-int4((vcomp/Ys)*(float8 (Height)-1.0)+.5); int4 i = int4((ucomp/Xs)*(float8 (Width)-1.0)+.5); int4 idx=3*(j*Width+i); COLOUR c=COLOUR(Pixels[idx+2],Pixels[idx+1],Pixels[idx]); c2+=c; } } } } if (isect) { c2=c2/Samples; if ((c2.r != Transparent.r && c2.g != Transparent.g && c2.b != Transparent.b) || !Transparency) { c2 = INV_255*c2; Col = Mix*c2*Col+(1-Mix)*c2; } } } if (!Col.TooSmall()) Arr.push_back (LIGHT_ENTRY (Col, Location, MyVolume)); } } // namespace RAYPP