00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 #include "uv.h"
00025 #include "error.h"
00026
00027 using namespace lux;
00028
00029
00030 Texture<float> * UVTexture::CreateFloatTexture(const Transform &tex2world,
00031 const TextureParams &tp) {
00032 return NULL;
00033 }
00034
00035 Texture<Spectrum> * UVTexture::CreateSpectrumTexture(const Transform &tex2world,
00036 const TextureParams &tp) {
00037
00038 TextureMapping2D *map = NULL;
00039 string type = tp.FindString("mapping");
00040 if (type == "" || type == "uv") {
00041 float su = tp.FindFloat("uscale", 1.);
00042 float sv = tp.FindFloat("vscale", 1.);
00043 float du = tp.FindFloat("udelta", 0.);
00044 float dv = tp.FindFloat("vdelta", 0.);
00045 map = new UVMapping2D(su, sv, du, dv);
00046 }
00047 else if (type == "spherical") map = new SphericalMapping2D(tex2world.GetInverse());
00048 else if (type == "cylindrical") map = new CylindricalMapping2D(tex2world.GetInverse());
00049 else if (type == "planar")
00050 map = new PlanarMapping2D(tp.FindVector("v1", Vector(1,0,0)),
00051 tp.FindVector("v2", Vector(0,1,0)),
00052 tp.FindFloat("udelta", 0.f), tp.FindFloat("vdelta", 0.f));
00053 else {
00054
00055 std::stringstream ss;
00056 ss<<"2D texture mapping '"<<type<<"' unknown";
00057 luxError(LUX_BADTOKEN,LUX_ERROR,ss.str().c_str());
00058 map = new UVMapping2D;
00059 }
00060 return new UVTexture(map);
00061 }