Exemplo n.º 1
0
	vec3 Point::computeNormal(const vec3& point) const
	{
		vec3 normal(point - getTransformedPosition());
		normalizeOrRandomize(normal);

		return normal;
	}
Exemplo n.º 2
0
Arquivo: SPK_Line.cpp Projeto: 4ian/GD
	Vector3D Line::computeNormal(const Vector3D& point) const
	{
		float d = -dotProduct(tDist,point);
		float sqrNorm = tDist.getSqrNorm();
		float t = 0.0f;
		if (sqrNorm > 0.0f)
		{
			t = -(dotProduct(tDist,tBounds[0]) + d) / sqrNorm;
			// t is clamped to the segment
			if (t < 0.0f) t = 0.0f;
			else if (t > 1.0f) t = 1.0f;
		}

		Vector3D normal = point;
		normal -= tBounds[0] + t * tDist;

		normalizeOrRandomize(normal);
		return normal;
	}
Exemplo n.º 3
0
	Vector3D Sphere::computeNormal(const Vector3D& point) const
	{
		Vector3D normal(point - getTransformedPosition());
		normalizeOrRandomize(normal);
		return normal;
	}