Ejemplo n.º 1
0
void Scene::intersect(Ray &ray)
{
	Point3 hitPoint;
	bool isHit;
	int hitObject[numofObject];
	int index =0;
	for(int k = 0;k<numofObject;k++)
	{
		if(intersectMesh(ray,m_objects[k]))
			hitObject[index++] = k;
	}
	printf("the hit objects without using the kdtree:(no sorting)\n");
	for(int i=0;i<index;i++)
	{
		printf("object sequence(%d):%d\n",i,hitObject[i]);
	}
}
Ejemplo n.º 2
0
bool Ray::intersectObject(MeshObject *obj, Fragment &inter) const
{
	if(obj->type == MESH)
	{
		if (intersectSphere(obj->boundingSphere))
		{
			if (intersectMesh(obj->mesh, inter))
			{
				return true;
			}
		}
	}
	else if(obj->type == SPHERE)
	{
		if (intersectSphere(obj->boundingSphere, &inter))
		{
			inter.id = obj;
			return true;
		}
	}
	
	
	return false;
}