Example #1
0
//--------------------------------------------------------------------------------------------------
/// 
//--------------------------------------------------------------------------------------------------
bool DrawableGeo::rayIntersectCreateDetail(const Ray& ray, Vec3d* intersectionPoint, ref<HitDetail>* hitDetail) const
{
    uint faceIdx = 0;
    if (rayIntersect(ray, intersectionPoint, &faceIdx))
    {
        if (hitDetail)
        {
            *hitDetail = new HitDetailDrawableGeo(faceIdx);
        }
        return true;
    }
    else
    {
        return false;
    }
}
Example #2
0
color rayTrace(Ray &ray, int times)
{
	float t = (float)(~(1<<31));
    int iObjectIndex = 0;
    color c, cRefl;
    vect point;
	
    if(times < MAX_REFLECTION_TIMES_LIMIT)
    {
        if(rayIntersect(ray, iObjectIndex, t))
        {
            point = ray.d * t + ray.p0;
            Ray newRay= Ray(point, g_papoObjects[iObjectIndex]->getReflection((-1.0)*ray.d,point));
            cRefl = rayTrace(newRay, times + 1);
            c = getLighting(ray, point,iObjectIndex) *(1 - g_papoObjects[iObjectIndex]->reflPerc)  + g_papoObjects[iObjectIndex]->reflPerc * cRefl;
	    }
    }
	return c;
}