00001 /**************************************************************************** 00002 * 00003 * surface.h: Surface sampling representation and api 00004 * This is part of the yafray package 00005 * Copyright (C) 2002 Alejandro Conty Estevez 00006 * 00007 * This library is free software; you can redistribute it and/or 00008 * modify it under the terms of the GNU Lesser General Public 00009 * License as published by the Free Software Foundation; either 00010 * version 2.1 of the License, or (at your option) any later version. 00011 * 00012 * This library is distributed in the hope that it will be useful, 00013 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00014 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00015 * Lesser General Public License for more details. 00016 * 00017 * You should have received a copy of the GNU Lesser General Public 00018 * License along with this library; if not, write to the Free Software 00019 * Foundation,Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 00020 * 00021 */ 00022 #ifndef Y_SURFACE_H 00023 #define Y_SURFACE_H 00024 #include "vector3d.h" 00025 //#include <yafray/core/extern/vector2d.h> 00026 #include "color.h" 00027 00028 #include<yafray_config.h> 00029 00030 __BEGIN_YAFRAY 00031 class material_t; 00032 class light_t; 00033 class object3d_t; 00034 class diffRay_t; 00035 00036 /* 00037 struct YAFRAYCORE_EXPORT surfacePoint_t 00038 { 00039 surfacePoint_t(const point3d_t &p, const point3d_t &orc, 00040 const vector3d_t &n,const vector3d_t &g, 00041 GFLOAT u, GFLOAT v, color_t vcol, 00042 PFLOAT d,const shader_t *sha=NULL, 00043 bool uv=false, bool hvcol=false,bool horco=false) 00044 { P=p; N=n; Ng=g; 00045 U=u; V=v; vertex_col=vcol; 00046 Z=d; object=-1; shader=sha; hasUV=uv; hasVertexCol=hvcol; 00047 hasOrco=horco; 00048 orcoP=orc; 00049 createCS(N,NU,NV); 00050 dudNU=dudNV=dvdNU=dvdNV=0; 00051 origin=NULL; 00052 } 00053 00054 surfacePoint_t() { hasOrco=false;hasUV=false; hasVertexCol=false; shader=NULL; origin=NULL; } 00055 00056 vector3d_t N; /// the normal. 00057 vector3d_t Ng; /// the geometric normal. 00058 point3d_t P; /// the position. 00059 point3d_t orcoP; 00060 GFLOAT U; /// the u texture coord. 00061 GFLOAT V; /// the v texture coord. 00062 bool hasUV; /// whatever it has valid UV or not 00063 bool hasVertexCol; /// if the point has a valid vertex color 00064 bool hasOrco; 00065 color_t vertex_col; 00066 PFLOAT Z; 00067 int object; /// the object owner of the point. 00068 const shader_t *shader; /// the surface shader 00069 vector3d_t NU; 00070 vector3d_t NV; 00071 GFLOAT dudNU; 00072 GFLOAT dudNV; 00073 GFLOAT dvdNU; 00074 GFLOAT dvdNV; 00075 void setUvGradient(GFLOAT uu, GFLOAT uv, GFLOAT vu, GFLOAT vv) 00076 { dudNU=uu; dudNV=uv; dvdNU=vu; dvdNV=vv; } 00077 00078 point2d_t screenpos; // only used with 'win' texture coord. mode 00079 void *origin; 00080 }; 00081 00082 */ 00083 00089 struct YAFRAYCORE_EXPORT surfacePoint_t 00090 { 00091 //int object; //!< the object owner of the point. 00092 const material_t *material; 00093 const light_t *light; 00094 const object3d_t *object; 00095 // point2d_t screenpos; // only used with 'win' texture coord. mode 00096 void *origin; 00097 00098 // Geometry related 00099 mutable vector3d_t N; 00100 vector3d_t Ng; 00101 vector3d_t orcoNg; 00102 point3d_t P; 00103 point3d_t orcoP; 00104 // color_t vertex_col; 00105 bool hasUV; 00106 bool hasOrco; 00107 bool available; 00108 int primNum; 00109 00110 GFLOAT U; 00111 GFLOAT V; 00112 mutable vector3d_t NU; 00113 mutable vector3d_t NV; 00114 vector3d_t dPdU; 00115 vector3d_t dPdV; 00116 vector3d_t dSdU; 00117 vector3d_t dSdV; 00118 GFLOAT sU; 00119 GFLOAT sV; 00120 //GFLOAT dudNU; 00121 //GFLOAT dudNV; 00122 //GFLOAT dvdNU; 00123 //GFLOAT dvdNV; 00124 }; 00125 00128 class YAFRAYCORE_EXPORT spDifferentials_t 00129 { 00130 public: 00131 spDifferentials_t(const surfacePoint_t &spoint, const diffRay_t &ray); 00133 void reflectedRay(const diffRay_t &in, diffRay_t &out) const; 00135 void refractedRay(const diffRay_t &in, diffRay_t &out, PFLOAT IOR) const; 00136 PFLOAT projectedPixelArea(); 00137 vector3d_t dPdx; 00138 vector3d_t dPdy; 00139 const surfacePoint_t &sp; 00140 }; 00141 00142 __END_YAFRAY 00143 00144 #endif
1.6.1