00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026 #include "stdafx.h"
00027 #include "textures/dots.h"
00028
00029
00030 DotsTexture<float> *CreateDotsFloatTexture(const Transform &tex2world,
00031 const TextureParams &tp) {
00032
00033 TextureMapping2D *map = NULL;
00034 string type = tp.FindString("mapping", "uv");
00035 if (type == "uv") {
00036 float su = tp.FindFloat("uscale", 1.);
00037 float sv = tp.FindFloat("vscale", 1.);
00038 float du = tp.FindFloat("udelta", 0.);
00039 float dv = tp.FindFloat("vdelta", 0.);
00040 map = new UVMapping2D(su, sv, du, dv);
00041 }
00042 else if (type == "spherical") map = new SphericalMapping2D(Inverse(tex2world));
00043 else if (type == "cylindrical") map = new CylindricalMapping2D(Inverse(tex2world));
00044 else if (type == "planar")
00045 map = new PlanarMapping2D(tp.FindVector("v1", Vector(1,0,0)),
00046 tp.FindVector("v2", Vector(0,1,0)),
00047 tp.FindFloat("udelta", 0.f), tp.FindFloat("vdelta", 0.f));
00048 else {
00049 Error("2D texture mapping \"%s\" unknown", type.c_str());
00050 map = new UVMapping2D;
00051 }
00052 return new DotsTexture<float>(map,
00053 tp.GetFloatTexture("inside", 1.f),
00054 tp.GetFloatTexture("outside", 0.f));
00055 }
00056
00057
00058
00059 DotsTexture<Spectrum> *CreateDotsSpectrumTexture(const Transform &tex2world,
00060 const TextureParams &tp) {
00061
00062 TextureMapping2D *map = NULL;
00063 string type = tp.FindString("mapping", "uv");
00064 if (type == "uv") {
00065 float su = tp.FindFloat("uscale", 1.);
00066 float sv = tp.FindFloat("vscale", 1.);
00067 float du = tp.FindFloat("udelta", 0.);
00068 float dv = tp.FindFloat("vdelta", 0.);
00069 map = new UVMapping2D(su, sv, du, dv);
00070 }
00071 else if (type == "spherical") map = new SphericalMapping2D(Inverse(tex2world));
00072 else if (type == "cylindrical") map = new CylindricalMapping2D(Inverse(tex2world));
00073 else if (type == "planar")
00074 map = new PlanarMapping2D(tp.FindVector("v1", Vector(1,0,0)),
00075 tp.FindVector("v2", Vector(0,1,0)),
00076 tp.FindFloat("udelta", 0.f), tp.FindFloat("vdelta", 0.f));
00077 else {
00078 Error("2D texture mapping \"%s\" unknown", type.c_str());
00079 map = new UVMapping2D;
00080 }
00081 return new DotsTexture<Spectrum>(map,
00082 tp.GetSpectrumTexture("inside", 1.f),
00083 tp.GetSpectrumTexture("outside", 0.f));
00084 }
00085
00086