Ejemplo n.º 1
0
	GLuint TexCoordinates(std::vector<T>& dest) const
	{
		unsigned k = 0, n = _vertex_count();
		dest.resize(n * 2);


		T uc, vc = T(0);
		T ustep = T(1) / _udiv;
		T vstep = T(1) / _vdiv;

		unsigned leap = _udiv+1;


		for(unsigned j=0; j!=(_vdiv+1); ++j)
		{
			uc = T(0);
			for(unsigned i=0; i!=leap; ++i)
			{
				dest[k++] = T(uc);
				dest[k++] = T(vc);
				uc += ustep;
			}
			vc += vstep;
		}
		assert(k == dest.size());
		// 2 values per vertex
		return 2;
	}
Ejemplo n.º 2
0
	GLuint Positions(std::vector<T>& dest) const
	{
		unsigned k = 0, n = _vertex_count();
		dest.resize(n * 3);


		Vec3f pos(_point - _u - _v);
		Vec3f ustep(_u * (2.0 / _udiv));
		Vec3f vstep(_v * (2.0 / _vdiv));

		unsigned leap = _udiv+1;

		for(unsigned j=0; j!=(_vdiv+1); ++j)
		{
			Vec3f tmp = pos;
			for(unsigned i=0; i!=leap; ++i)
			{
				dest[k++] = T(tmp.x());
				dest[k++] = T(tmp.y());
				dest[k++] = T(tmp.z());
				tmp += ustep;
			}
			pos += vstep;
		}
		assert(k == dest.size());
		return 3;
	}
Ejemplo n.º 3
0
	GLuint TexCoordinates(std::vector<T>& dest) const
	{
		unsigned k = 0, n = _vertex_count();
		dest.resize(n * 2);


		T ustep = T(1) / _udiv;
		T vstep = T(1) / _vdiv;


		for(unsigned i=0; i<(_udiv+1); ++i)
		{
			dest[k++] = T(ustep*i);
			dest[k++] = T(0);

			dest[k++] = T(ustep*i);
			dest[k++] = T(1);
		}

		for(unsigned j=1; j<(_vdiv); ++j)
		{
			dest[k++] = T(0);
			dest[k++] = T(vstep*j);

			dest[k++] = T(1);
			dest[k++] = T(vstep*j);
		}
		assert(k == dest.size());
		// 2 values per vertex
		return 2;
	}
Ejemplo n.º 4
0
	GLuint Bitangents(std::vector<T>& dest) const
	{
		unsigned k = 0, n = _vertex_count();
		dest.resize(n * 3);
		Vec3f bitangent(Normalized(_v));

		for(unsigned i=0; i!=n; ++i)
		{
			dest[k++] = T(bitangent.x());
			dest[k++] = T(bitangent.y());
			dest[k++] = T(bitangent.z());
		}
		//
		assert(k == dest.size());
		// 3 values per vertex
		return 3;
	}
Ejemplo n.º 5
0
	GLuint Normals(std::vector<T>& dest) const
	{
		unsigned k = 0, n = _vertex_count();
		dest.resize(n * 3);
		Vec3f normal = Normal();

		for(unsigned i=0; i!=n; ++i)
		{
			dest[k++] = T(normal.x());
			dest[k++] = T(normal.y());
			dest[k++] = T(normal.z());
		}
		//
		assert(k == dest.size());
		// 3 values per vertex
		return 3;
	}
Ejemplo n.º 6
0
	GLuint Positions(std::vector<T>& dest) const
	{
		unsigned k = 0, n = _vertex_count();
		dest.resize(n * 3);

		const Vec3f pos(_point - _u - _v);
		const Vec3f ustep(_u * (2.0 / _udiv));
		const Vec3f vstep(_v * (2.0 / _vdiv));

		for(unsigned i=0; i<(_udiv+1); ++i)
		{
			Vec3f tmp = pos+ustep*i;
			dest[k++] = T(tmp.x());
			dest[k++] = T(tmp.y());
			dest[k++] = T(tmp.z());

			tmp += 2.0*_v;
			dest[k++] = T(tmp.x());
			dest[k++] = T(tmp.y());
			dest[k++] = T(tmp.z());
		}

		for(unsigned j=1; j<(_vdiv); ++j)
		{
			Vec3f tmp = pos+vstep*j;
			dest[k++] = T(tmp.x());
			dest[k++] = T(tmp.y());
			dest[k++] = T(tmp.z());

			tmp += 2.0*_u;
			dest[k++] = T(tmp.x());
			dest[k++] = T(tmp.y());
			dest[k++] = T(tmp.z());
		}
		assert(k == dest.size());
		return 3;
	}