Exemplo n.º 1
0
bool ModelInstance::intersectRay(const G3D::Ray& pRay, float& pMaxDist,
		bool pStopAtFirstHit) const {
	if (!iModel) {
		//std::cout << "<object not loaded>\n";
		return false;
	}
	float time = pRay.intersectionTime(iBound);
	if (time == G3D::inf()) {
//            std::cout << "Ray does not hit '" << name << "'\n";

		return false;
	}
//        std::cout << "Ray crosses bound of '" << name << "'\n";
	/*        std::cout << "ray from:" << pRay.origin().x << ", " << pRay.origin().y << ", " << pRay.origin().z
	 << " dir:" << pRay.direction().x << ", " << pRay.direction().y << ", " << pRay.direction().z
	 << " t/tmax:" << time << "/" << pMaxDist;
	 std::cout << "\nBound lo:" << iBound.low().x << ", " << iBound.low().y << ", " << iBound.low().z << " hi: "
	 << iBound.high().x << ", " << iBound.high().y << ", " << iBound.high().z << std::endl; */
	// child bounds are defined in object space:
	Vector3 p = iInvRot * (pRay.origin() - iPos) * iInvScale;
	Ray modRay(p, iInvRot * pRay.direction());
	float distance = pMaxDist * iInvScale;
	bool hit = iModel->IntersectRay(modRay, distance, pStopAtFirstHit);
	if (hit) {
		distance *= iScale;
		pMaxDist = distance;
	}
	return hit;
}
Exemplo n.º 2
0
    bool ModelInstance::intersectRay(const G3D::Ray& pRay, float& pMaxDist, bool pStopAtFirstHit) const
    {
        if (!iModel)
        {
#ifdef VMAP_DEBUG
            DEBUG_LOG("<object not loaded>");
#endif
            return false;
        }
        float time = pRay.intersectionTime(iBound);
        if (time == G3D::inf())
        {
#ifdef VMAP_DEBUG
            DEBUG_LOG("Ray does not hit '%s'", name.c_str());
#endif
            return false;
        }
        // child bounds are defined in object space:
        Vector3 p = iInvRot * (pRay.origin() - iPos) * iInvScale;
        Ray modRay(p, iInvRot * pRay.direction());
        float distance = pMaxDist * iInvScale;
        bool hit = iModel->IntersectRay(modRay, distance, pStopAtFirstHit);
        if(hit)
        {
            distance *= iScale;
            pMaxDist = distance;
        }
        return hit;
    }
Exemplo n.º 3
0
bool GameObjectModel::intersectRay(const G3D::Ray& ray, float& MaxDist, bool StopAtFirstHit, uint32 ph_mask) const
{
    if (!(phasemask & ph_mask))
        { return false; }

    float time = ray.intersectionTime(iBound);
    if (time == G3D::inf())
        { return false; }

    // child bounds are defined in object space:
    Vector3 p = iInvRot * (ray.origin() - iPos) * iInvScale;
    Ray modRay(p, iInvRot * ray.direction());
    float distance = MaxDist * iInvScale;
    bool hit = iModel->IntersectRay(modRay, distance, StopAtFirstHit);
    if (hit)
    {
        distance *= iScale;
        MaxDist = distance;
    }
    return hit;
}
Exemplo n.º 4
0
bool ModelInstance::intersectRay(const G3D::Ray& pRay, float& pMaxDist, bool pStopAtFirstHit) const
{
    if (!iModel)
        return false;

    float time = pRay.intersectionTime(iBound);
    if (time == G3D::inf())
        return false;

    // child bounds are defined in object space:
    Vector3 p = iInvRot * (pRay.origin() - iPos) * iInvScale;
    Ray modRay(p, iInvRot * pRay.direction());
    float distance = pMaxDist * iInvScale;
    bool hit = iModel->IntersectRay(modRay, distance, pStopAtFirstHit);
    if (hit)
    {
        distance *= iScale;
        pMaxDist = distance;
    }
    return hit;
}