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 #include "dynload.h"
00027
00028 using namespace lux;
00029
00030
00031 Texture<float> * UVTexture::CreateFloatTexture(const Transform &tex2world,
00032 const TextureParams &tp) {
00033 return NULL;
00034 }
00035
00036 Texture<SWCSpectrum> * UVTexture::CreateSWCSpectrumTexture(const Transform &tex2world,
00037 const TextureParams &tp) {
00038
00039 TextureMapping2D *map = NULL;
00040 string type = tp.FindString("mapping");
00041 if (type == "" || type == "uv") {
00042 float su = tp.FindFloat("uscale", 1.);
00043 float sv = tp.FindFloat("vscale", 1.);
00044 float du = tp.FindFloat("udelta", 0.);
00045 float dv = tp.FindFloat("vdelta", 0.);
00046 map = new UVMapping2D(su, sv, du, dv);
00047 }
00048 else if (type == "spherical") map = new SphericalMapping2D(tex2world.GetInverse());
00049 else if (type == "cylindrical") map = new CylindricalMapping2D(tex2world.GetInverse());
00050 else if (type == "planar")
00051 map = new PlanarMapping2D(tp.FindVector("v1", Vector(1,0,0)),
00052 tp.FindVector("v2", Vector(0,1,0)),
00053 tp.FindFloat("udelta", 0.f), tp.FindFloat("vdelta", 0.f));
00054 else {
00055
00056 std::stringstream ss;
00057 ss<<"2D texture mapping '"<<type<<"' unknown";
00058 luxError(LUX_BADTOKEN,LUX_ERROR,ss.str().c_str());
00059 map = new UVMapping2D;
00060 }
00061 return new UVTexture(map);
00062 }
00063
00064 static DynamicLoader::RegisterFloatTexture<UVTexture> r1("uv");
00065 static DynamicLoader::RegisterSWCSpectrumTexture<UVTexture> r2("uv");